This commit is contained in:
Alex Yatskov 2024-10-02 17:33:07 -07:00
parent c18b62f675
commit 45d892e313
2 changed files with 17 additions and 10 deletions

View File

@ -38,11 +38,12 @@ vim.opt.writebackup = false
-- common keymaps -- common keymaps
vim.keymap.set('i', '<c-c>', '<esc>') vim.keymap.set('i', '<c-c>', '<esc>')
vim.keymap.set('n', '<bs>', '<cmd>bp|bd #<cr>') vim.keymap.set('n', '<bs>', '<cmd>bp|bd#<cr>')
vim.keymap.set('n', '<c-c><c-c>', '<cmd>nohlsearch<cr>') vim.keymap.set('n', '<c-c><c-c>', '<cmd>nohlsearch<cr>')
vim.keymap.set('n', '<leader><leader>', '<cmd>b#<cr>') vim.keymap.set('n', '<leader><leader>', '<cmd>b#<cr>')
vim.keymap.set('n', '<leader>w', '<cmd>w<cr>') vim.keymap.set('n', '<leader>w', '<cmd>w<cr>')
vim.keymap.set('n', '<leader>x', '<cmd>x<cr>') vim.keymap.set('n', '<leader>x', '<cmd>x<cr>')
vim.keymap.set('n', '<c-bs>', '<cmd>BuffDeleteAllButCurrent<cr>')
vim.keymap.set('n', 'Y', 'y$') vim.keymap.set('n', 'Y', 'y$')
vim.keymap.set('n', 'j', 'gj') vim.keymap.set('n', 'j', 'gj')
vim.keymap.set('n', 'k', 'gk') vim.keymap.set('n', 'k', 'gk')

View File

@ -7,6 +7,21 @@ vim.api.nvim_create_user_command(
{range = '%'} {range = '%'}
) )
-- BuffDeleteAllButCurrent
vim.api.nvim_create_user_command(
'BuffDeleteAllButCurrent',
function()
local bufs = vim.api.nvim_list_bufs()
local current_buf = vim.api.nvim_get_current_buf()
for _, i in ipairs(bufs) do
if i ~= current_buf then
vim.api.nvim_buf_delete(i, {})
end
end
end,
{}
)
local function invoke(args) local function invoke(args)
local output = vim.fn.system(table.concat(args, ' ')) local output = vim.fn.system(table.concat(args, ' '))
return string.gsub(output, '%s+$', '') return string.gsub(output, '%s+$', '')
@ -46,15 +61,6 @@ local function git_edit_paths(names)
end end
end end
-- GitConflicts
vim.api.nvim_create_user_command(
'GitConflicts',
function()
git_edit_paths(invoke({'git', 'diff', '--name-only', '--diff-filter=U'}))
end,
{}
)
-- GitTopicEdit -- GitTopicEdit
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
'GitTopicEdit', 'GitTopicEdit',