-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnvim-lspconfig.lua
More file actions
67 lines (60 loc) · 2.51 KB
/
nvim-lspconfig.lua
File metadata and controls
67 lines (60 loc) · 2.51 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
---@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 automatically discovered from `after/lsp`
for _, server in ipairs(util.get_lsp_server_names()) do
vim.lsp.enable(server)
end
-- Additional settings
local lsp_attach_grp =
vim.api.nvim_create_augroup("NvimLspAttach", { clear = true })
vim.api.nvim_create_autocmd("LspAttach", {
group = lsp_attach_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
-- Disable semantic token highlighting for lua_ls
if client and client.name and client.name == "lua_ls" then
client.server_capabilities.semanticTokensProvider = nil
end
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
-- Buffer-local keymaps
util.map_keys(keymaps.nvim_lspconfig, { buffer = ev.buf })
-- Inlay hints policy (buffer overrides global)
if vim.lsp.inlay_hint then
local bufnr = ev.buf
if vim.b[bufnr].inlay_hints_enabled ~= nil then
-- Buffer 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,
}