mason + lsp config working
This commit is contained in:
parent
81fbb4ec14
commit
319c66bc0a
9 changed files with 142 additions and 26 deletions
|
|
@ -1,8 +1,42 @@
|
|||
-- Non-plugin keymaps (kept intentionally minimal for bootstrap)
|
||||
-- Non-plugin and global helper keymaps
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- Add non-plugin keymaps during Phase 3 when porting settings
|
||||
-- LSP-aware helpers with graceful fallback to built-ins
|
||||
local function lsp_has(bufnr, capability)
|
||||
for _, client in pairs(vim.lsp.get_clients({ bufnr = bufnr })) do
|
||||
if client.server_capabilities[capability] then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function lsp_or_builtin(bufnr, capability, lsp_fn, builtin_normal)
|
||||
if lsp_has(bufnr, capability) then
|
||||
lsp_fn()
|
||||
else
|
||||
vim.cmd("normal! " .. builtin_normal)
|
||||
end
|
||||
end
|
||||
|
||||
-- Global LSP-keymaps with fallback so they work reliably
|
||||
map('n', 'gd', function()
|
||||
lsp_or_builtin(0, 'definitionProvider', vim.lsp.buf.definition, 'gd')
|
||||
end, { desc = 'Go to definition (LSP or built-in)' })
|
||||
|
||||
map('n', 'gr', function()
|
||||
if lsp_has(0, 'referencesProvider') then vim.lsp.buf.references() end
|
||||
end, { desc = 'References (LSP)', silent = true })
|
||||
|
||||
map('n', 'gD', function()
|
||||
lsp_or_builtin(0, 'declarationProvider', vim.lsp.buf.declaration, 'gD')
|
||||
end, { desc = 'Go to declaration (LSP or built-in)' })
|
||||
|
||||
map('n', 'gI', function()
|
||||
if lsp_has(0, 'implementationProvider') then vim.lsp.buf.implementation() end
|
||||
end, { desc = 'Go to implementation (LSP)', silent = true })
|
||||
|
||||
map('n', 'K', function()
|
||||
if lsp_has(0, 'hoverProvider') then vim.lsp.buf.hover() end
|
||||
end, { desc = 'Hover (LSP)', silent = true })
|
||||
|
||||
return {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue