Add shortcuts to LSP get declaration/definition

nvim-lspconfig already has shortcuts to declaration/definition with "gd"
and "gD", but in testing, they did not behave the same as the shortcuts
defined in this commit for some reason.

<leader>d and <leader>D are the shortcuts defined for
definition/declaration (<leader> is by defalt back-slash "\").

Show floating diagnostic changed to <leader>F.
This commit is contained in:
Stephen Seo 2024-04-17 13:02:12 +09:00
parent 221201d9c6
commit 354ed23291

View file

@ -134,12 +134,16 @@ lspconfig.jedi_language_server.setup{
-- apply available fix
vim.api.nvim_set_keymap("n", "<C-A>", "<cmd>lua vim.lsp.buf.code_action()<CR>", {noremap = true})
-- get lsp declaration
vim.api.nvim_set_keymap("n", "<leader>D", "<cmd>lua vim.lsp.buf.declaration()<CR>", {noremap = true})
-- get lsp definition
vim.api.nvim_set_keymap("n", "<leader>d", "<cmd>lua vim.lsp.buf.definition()<CR>", {noremap = true})
-- goto next warning/error
--vim.api.nvim_set_keymap("n", "<C-N>", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", {noremap = true})
vim.api.nvim_set_keymap("n", "<C-N>", "<cmd>lua vim.diagnostic.goto_next()<CR>", {noremap = true})
vim.api.nvim_set_keymap("n", "<C-P>", "<cmd>lua vim.diagnostic.goto_prev()<CR>", {noremap = true})
-- Get diagnostic on currently selected
vim.api.nvim_set_keymap("n", "<leader>d", "<cmd>lua vim.diagnostic.open_float()<CR>", {noremap = true})
vim.api.nvim_set_keymap("n", "<leader>F", "<cmd>lua vim.diagnostic.open_float()<CR>", {noremap = true})
EOF