-- Non-plugin and global helper keymaps -- -- NOTE: LSP keymaps are primarily handled in lua/plugins/lsp.lua via LspAttach. -- Buffer-local keymaps set there take precedence over these global fallbacks. -- -- These global keymaps provide fallback behavior for buffers without LSP attached, -- ensuring that common navigation keys still work with built-in Vim functionality -- (e.g., ctags, included files, man pages). local map = vim.keymap.set -- Fallback navigation keymaps for non-LSP buffers -- When LSP attaches, buffer-local keymaps in lsp.lua override these map('n', 'gd', function() -- Built-in: jump to definition via tags or included files vim.cmd("normal! gd") end, { desc = 'Go to definition (built-in fallback)', silent = true }) map('n', 'gD', function() -- Built-in: jump to declaration (global) vim.cmd("normal! gD") end, { desc = 'Go to declaration (built-in fallback)', silent = true }) -- LSP-only keymaps (no useful fallback for these in non-LSP contexts) map('n', 'gr', '', { desc = 'References (requires LSP)', silent = true }) map('n', 'gI', '', { desc = 'Implementation (requires LSP)', silent = true }) -- K: Hover/Help with sensible fallback map('n', 'K', function() -- Built-in K uses 'keywordprg' (defaults to 'man' for shell scripts, etc.) -- LSP buffers override this with vim.lsp.buf.hover() in lsp.lua if vim.bo.keywordprg ~= '' then vim.cmd("normal! K") end end, { desc = 'Hover/Help (LSP or keywordprg fallback)', silent = true })