separate find ctag and find definition into different keys

Sometimes the tags file contain symbols that collide with the actual
definition of the keyword under the cursor. So now I use different
shortcuts for ctags and lsp-based definition.
This commit is contained in:
Ivar Fatland
2025-04-11 10:59:13 +02:00
parent 75d3604278
commit 846acbc899
+3 -12
View File
@@ -335,19 +335,13 @@ require'lazy'.setup{ --{{{1
end,
})
-- Honors tags file
local function jump_to_definition()
local word = vim.fn.expand("<cword>")
local success = pcall(vim.cmd --[[@as function]], "tag " .. word)
if success then
print("tag found in tags file")
else
print("using lsp")
vim.lsp.buf.definition()
end
vim.cmd("tag " .. word)
end
vim.keymap.set( 'n', ',fd', jump_to_definition, { noremap = true, silent = true})
vim.keymap.set( 'n', ',fc', jump_to_definition, { noremap = true, silent = true})
vim.keymap.set( 'n', ',fd', vim.lsp.buf.definition, { noremap = true, silent = true})
vim.cmd [[
noremap ,rn :lua vim.lsp.buf.rename()<CR>
@@ -529,9 +523,6 @@ require'lazy'.setup{ --{{{1
noremap ,fm :lua require'telescope.builtin'.marks()<CR>
noremap ,fb :lua require'telescope.builtin'.buffers()<CR>
noremap ,fcm :lua require'telescope.builtin'.commands()<CR>
noremap ,fct :lua require'telescope.builtin'.tags()<CR>
noremap ,fea :lua require'telescope.builtin'.diagnostics()<CR>
noremap ,fee :lua require'telescope.builtin'.diagnostics{severity="ERROR"}<CR>
noremap ,few :lua require'telescope.builtin'.diagnostics{severity="WARN"}<CR>