76 lines
2.4 KiB
Lua
76 lines
2.4 KiB
Lua
local toggle_inlay_hints = function()
|
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
|
end
|
|
|
|
local map_local = function(mode, lhs, rhs, opts)
|
|
opts = vim.tbl_deep_extend("force", opts or {}, { buffer = 0 })
|
|
vim.keymap.set(mode, lhs, rhs, opts)
|
|
end
|
|
|
|
local lsp_on_attach = function(args)
|
|
-- stylua: ignore start
|
|
map_local("n", "<leader>sh", toggle_inlay_hints)
|
|
map_local("n", "<localleader>c", vim.lsp.buf.code_action)
|
|
map_local("n", "<localleader>f", vim.lsp.buf.format)
|
|
map_local("n", "gd", vim.lsp.buf.definition)
|
|
map_local("n", "gD", vim.lsp.buf.declaration)
|
|
map_local("n", "gi", vim.lsp.buf.implementation)
|
|
map_local("n", "grr", vim.lsp.buf.rename)
|
|
map_local("n", "gt", vim.lsp.buf.type_definition)
|
|
map_local("n", "gs", vim.lsp.buf.signature_help)
|
|
map_local("i", "<c-s>", vim.lsp.buf.signature_help)
|
|
map_local("n", "K", vim.lsp.buf.hover)
|
|
-- stylua: ignore end
|
|
|
|
-- Opt out of semantic highlighting because it has been causing issues
|
|
-- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
if client and client.server_capabilities then
|
|
client.server_capabilities.semanticTokensProvider = nil
|
|
end
|
|
end
|
|
|
|
local make_lsp_builtins_use_rounded_border = function()
|
|
local patch = function(name)
|
|
local builtin = vim.lsp.buf[name]
|
|
vim.lsp.buf[name] = function(opts)
|
|
builtin(vim.tbl_deep_extend("force", opts or {}, { border = "rounded" }))
|
|
end
|
|
end
|
|
|
|
patch("signature_help")
|
|
patch("hover")
|
|
end
|
|
|
|
return {
|
|
"neovim/nvim-lspconfig",
|
|
|
|
dependencies = {
|
|
"Hoffs/omnisharp-extended-lsp.nvim",
|
|
},
|
|
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
|
|
config = function()
|
|
make_lsp_builtins_use_rounded_border()
|
|
|
|
local capabilities = (function()
|
|
local cmp_nvim_lsp = vim.F.npcall(require, "cmp_nvim_lsp")
|
|
if cmp_nvim_lsp then
|
|
return cmp_nvim_lsp.default_capabilities()
|
|
else
|
|
return vim.lsp.protocol.make_client_capabilities()
|
|
end
|
|
end)()
|
|
|
|
vim.lsp.config("*", { capabilities = capabilities })
|
|
|
|
vim.lsp.enable("clangd")
|
|
vim.lsp.enable("cmake")
|
|
vim.lsp.enable("lua_ls")
|
|
vim.lsp.enable("omnisharp")
|
|
vim.lsp.enable("pyright")
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", { callback = lsp_on_attach })
|
|
end,
|
|
}
|