From 6a43247c4c5cc2d0afd8638f0a0404b597f38215 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Fri, 27 Jun 2025 17:40:24 +0200 Subject: [PATCH] nvim: patch built-in LSP functions instead of wrapping them This causes the behavior to be what I expect anytime I call one of these functions globally. --- .../nvim/lua/fschauen/plugins/lspconfig.lua | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/config/nvim/lua/fschauen/plugins/lspconfig.lua b/config/nvim/lua/fschauen/plugins/lspconfig.lua index 404c09d..2886d32 100644 --- a/config/nvim/lua/fschauen/plugins/lspconfig.lua +++ b/config/nvim/lua/fschauen/plugins/lspconfig.lua @@ -31,9 +31,18 @@ return { vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end - local rounded = function(action) - return function() action { border = "rounded" } end - end + -- Patch some built-in LSP functions so they use custom borders. + (function(names) + for _, name in ipairs(names) do + local builtin = vim.lsp.buf[name] + vim.lsp.buf[name] = function(opts) + builtin(vim.tbl_deep_extend("force", opts or {}, { border = "rounded" })) + end + end + end) { + "signature_help", + "hover", + } -- stylua: ignore start vim.keymap.set("n", "sh", toggle_inlay_hints, { buffer = 0 }) @@ -44,9 +53,9 @@ return { vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = 0 } ) vim.keymap.set("n", "grr", vim.lsp.buf.rename, { buffer = 0 } ) vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, { buffer = 0 } ) - vim.keymap.set("n", "gs", rounded(vim.lsp.buf.signature_help), { buffer = 0 } ) - vim.keymap.set("i", "", rounded(vim.lsp.buf.signature_help), { buffer = 0 } ) - vim.keymap.set("n", "K", rounded(vim.lsp.buf.hover), { buffer = 0 } ) + vim.keymap.set("n", "gs", vim.lsp.buf.signature_help, { buffer = 0 } ) + vim.keymap.set("i", "", vim.lsp.buf.signature_help, { buffer = 0 } ) + vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 } ) -- stylua: ignore end -- Opt out of semantic highlighting because it has been causing issues