-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnvim-lspconfig.lua
More file actions
70 lines (64 loc) · 2.56 KB
/
nvim-lspconfig.lua
File metadata and controls
70 lines (64 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---@type LazyPluginSpec
return {
-- Automatic configuration of language servers
"neovim/nvim-lspconfig",
dependencies = { "mason.nvim", "mason-org/mason-lspconfig.nvim" },
event = { "BufReadPre", "BufNewFile" },
config = function()
local keymaps = require("core.keymaps")
local util = require("core.util")
-- Apply enhanced completion capabilities from `blink.cmp` to all servers
vim.lsp.config("*", {
capabilities = require("blink.cmp").get_lsp_capabilities(),
})
-- Enable all servers discovered from `after/lsp`, except those managed
-- elsewhere
local excluded = {
-- Managed by rustaceanvim (see `lua/plugins/rust.lua`)
rust_analyzer = true,
}
for _, server in ipairs(util.get_lsp_server_names()) do
if not excluded[server] then
vim.lsp.enable(server)
end
end
-- Additional settings
local grp = vim.api.nvim_create_augroup("NvimLspAttach", { clear = true })
vim.api.nvim_create_autocmd("LspAttach", {
group = grp,
desc = "Configure nvim-lspconfig",
callback =
---@param ev vim.api.keyset.create_autocmd.callback_args
function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if not client then
return
end
-- Buffer-local keymaps
util.map_keys(keymaps.nvim_lspconfig, { buffer = ev.buf })
-- Disable semantic token highlighting for lua_ls
if client.name and client.name == "lua_ls" then
client.server_capabilities.semanticTokensProvider = nil
end
-- Inlay hints policy (buffer-local overrides global)
if vim.lsp.inlay_hint then
local bufnr = ev.buf
if vim.b[bufnr].inlay_hints_enabled ~= nil then
-- Buffer-local override wins (even if false)
vim.lsp.inlay_hint.enable(
vim.b[bufnr].inlay_hints_enabled,
{ bufnr = bufnr }
)
elseif vim.g.inlay_hints_enabled ~= nil then
-- Apply global only if explicitly set; default stays
-- untouched otherwise
vim.lsp.inlay_hint.enable(
vim.g.inlay_hints_enabled == true,
{ bufnr = bufnr }
)
end
end
end,
})
end,
}