From 62d06a8bdc06506143d1765004b83b5b52e4bb39 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Wed, 8 Apr 2026 15:41:59 -0400 Subject: [PATCH] fixed --- lua/plugins/lsp.lua | 47 ++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index ad0c2a3..b776b5e 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -141,6 +141,23 @@ return { config = function() local lspconfig = require('lspconfig') + -- Neovim 0.12 exposes built-in :lsp commands and skips lspconfig's legacy + -- :Lsp* aliases. Recreate the old names so existing mappings keep working. + if vim.fn.exists(':lsp') == 2 and vim.fn.exists(':LspStart') == 0 then + vim.api.nvim_create_user_command('LspStart', function(info) + vim.cmd('lsp enable ' .. table.concat(info.fargs, ' ')) + end, { nargs = '*' }) + + vim.api.nvim_create_user_command('LspRestart', function(info) + vim.cmd('lsp restart ' .. table.concat(info.fargs, ' ')) + end, { nargs = '*', bang = true }) + + vim.api.nvim_create_user_command('LspStop', function(info) + local suffix = info.bang and '!' or '' + vim.cmd('lsp stop' .. suffix .. ' ' .. table.concat(info.fargs, ' ')) + end, { nargs = '*', bang = true }) + end + -- Diagnostic display configuration vim.diagnostic.config({ virtual_text = { @@ -165,15 +182,20 @@ return { severity_sort = true, }) - -- Add border to hover and signature help windows - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( - vim.lsp.handlers.hover, - { border = 'rounded' } - ) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( - vim.lsp.handlers.signature_help, - { border = 'rounded' } - ) + -- Add border to hover and signature help windows. + local hover_handler = vim.lsp.handlers.hover + vim.lsp.handlers['textDocument/hover'] = function(err, result, ctx, config) + return hover_handler(err, result, ctx, vim.tbl_extend('force', config or {}, { + border = 'rounded', + })) + end + + local signature_help_handler = vim.lsp.handlers.signature_help + vim.lsp.handlers['textDocument/signatureHelp'] = function(err, result, ctx, config) + return signature_help_handler(err, result, ctx, vim.tbl_extend('force', config or {}, { + border = 'rounded', + })) + end -- Get all known server names by scanning lspconfig's lsp directory local function get_all_servers() @@ -246,8 +268,7 @@ return { table.sort(matching) local function start_server(server) - vim.lsp.enable(server) -- Register on-demand - vim.cmd('LspStart ' .. server) + vim.lsp.enable(server) end if #matching == 0 then @@ -270,9 +291,9 @@ return { { "cs", group = "LSP Commands" }, { "cf", function() vim.lsp.buf.format() end, desc = "Code Format" }, { "csi", ":checkhealth vim.lsp", desc = "LSP Info" }, - { "csr", ":LspRestart", desc = "LSP Restart" }, + { "csr", ":lsp restart", desc = "LSP Restart" }, { "css", lsp_start_smart, desc = "LSP Start" }, - { "csx", ":LspStop", desc = "LSP Stop" }, + { "csx", ":lsp stop", desc = "LSP Stop" }, }) end },