-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvim-lspconfig.lua
72 lines (64 loc) · 1.93 KB
/
nvim-lspconfig.lua
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
71
72
return {
{
"williamboman/mason.nvim",
cmd = { "Mason", "MasonUpdate" },
build = ":MasonUpdate",
keys = {
{ "<leader>lm", "<cmd>Mason<cr>", desc = "mason" },
},
opts = {
ui = {
border = "rounded",
width = 0.7,
height = 0.8,
},
},
},
{
"neovim/nvim-lspconfig",
event = { "BufReadPost", "BufNewFile" },
cmd = { "LspInfo", "LspInstall", "LspUninstall" },
dependencies = {
"williamboman/mason-lspconfig.nvim",
"saghen/blink.cmp",
},
config = function()
local lsp = require("util.lsp")
local capabilities = require("blink.cmp").get_lsp_capabilities()
local handlers = {
-- default handlers for all lsp server
---@param sname string lsp server name
function(sname)
-- HACK: what if server that installed not part of `servers` list?
lsp.servers[sname] = lsp.servers[sname] or {}
local sconfig = lsp.servers[sname]
require("lspconfig")[sname].setup({
on_init = sconfig.on_init,
settings = sconfig.settings,
capabilities = capabilities,
on_new_config = sconfig.on_new_config, -- nil or callable
})
-- handle additional keymaps
local keymaps_func = sconfig.keymaps
if keymaps_func ~= nil then
vim.api.nvim_create_autocmd("LspAttach", {
desc = "additional keympas for " .. sname,
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then
return
end
keymaps_func(args.buf)
end,
})
end
end,
}
require("mason-lspconfig").setup({
ensure_installed = vim.tbl_keys(lsp.servers),
automatic_installation = true,
handlers = handlers,
})
end,
},
}