Improve handling of leader init keymaps

This commit is contained in:
Thomas Gideon 2024-08-09 08:27:28 -04:00
parent 22acd8bb5b
commit 372846fa2f

View file

@ -10,7 +10,7 @@ vim.opt.completeopt = "menuone,noinsert,noselect"
vim.opt.shortmess:append('c') vim.opt.shortmess:append('c')
-- extend timeout to allow time for three character shortcuts -- extend timeout to allow time for three character shortcuts
vim.opt.timeoutlen = 1400 vim.opt.timeoutlen = 2500
local bufnr = vim.api.nvim_get_current_buf() local bufnr = vim.api.nvim_get_current_buf()
local opts = { buffer = bufnr, noremap = true, silent = true } local opts = { buffer = bufnr, noremap = true, silent = true }
@ -32,38 +32,38 @@ vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
-- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) -- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
-- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) -- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function() vim.keymap.set('n', '<Leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts) end, opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts) vim.keymap.set('n', '<Leader>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts) vim.keymap.set('n', '<Leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, opts) vim.keymap.set('n', '<Leader>gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<Leader>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts) vim.keymap.set('n', '<Leader>q', vim.diagnostic.setloclist, opts)
vim.keymap.set('n', '<leader>xx', vim.cmd.TroubleToggle, opts) vim.keymap.set('n', '<Leader>xx', vim.cmd.TroubleToggle, opts)
vim.keymap.set('n', '<leader>xw', function() vim.keymap.set('n', '<Leader>xw', function()
vim.cmd("TroubleToggle workspace_diagnostics") vim.cmd("TroubleToggle workspace_diagnostics")
end, opts) end, opts)
vim.keymap.set('n', '<leader>xd', function() vim.keymap.set('n', '<Leader>xd', function()
vim.cmd("TroubleToggle workspace_diagnostics") vim.cmd("TroubleToggle workspace_diagnostics")
end, opts) end, opts)
vim.keymap.set('n', '<leader>xq', function() vim.keymap.set('n', '<Leader>xq', function()
vim.cmd("TroubleToggle quickfix") vim.cmd("TroubleToggle quickfix")
end, opts) end, opts)
vim.keymap.set('n', '<leader>xl', function() vim.keymap.set('n', '<Leader>xl', function()
vim.cmd("TroubleToggle loclist") vim.cmd("TroubleToggle loclist")
end, opts) end, opts)
-- work with Trouble to view lists of diagnostic warnings/errors -- work with Trouble to view lists of diagnostic warnings/errors
vim.keymap.set('n', '<leader>t', function() vim.keymap.set('n', '<Leader>wt', function()
vim.cmd("e ~/Documents/Wiki/tags.md") vim.cmd("e ~/Documents/Wiki/tags.md")
end, opts) end, opts)
vim.keymap.set('n', '<leader>tr', vim.cmd.VimwikiRebuildTags, opts) vim.keymap.set('n', '<Leader>tr', vim.cmd.VimwikiRebuildTags, opts)
vim.keymap.set('n', '<leader>tg', vim.cmd.VimwikiGenerateTagLinks, opts) vim.keymap.set('n', '<Leader>tg', vim.cmd.VimwikiGenerateTagLinks, opts)
-- TODO translate to lua -- TODO translate to lua
--function! VimwikiFindAllIncompleteTasks() --function! VimwikiFindAllIncompleteTasks()