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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
if vim.g.did_load_lsp_plugin then
return
end
vim.g.did_load_lsp_plugin = true
local lsp_servers = {
astro = {
binary = "astro-ls",
},
bashls = {
binary = "bash-language-server",
},
cssls = {
binary = "vscode-css-language-server",
},
clangd = {},
denols = {
binary = "deno",
},
dprint = {},
eslint = {
binary = "vscode-eslint-language-server",
},
html = {
binary = "vscode-html-language-server",
},
jsonls = {
binary = "vscode-json-language-server"
},
-- TODO: I WANT STYLUA BACK!!
lua_ls = {
binary = "lua-language-server",
extraOptions = {
settings = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = "vim" },
workspace = { checkThirdPaty = false, library = { vim.env.VIMRUNTIME } },
},
},
},
},
nil_ls = {
binary = "nil",
extraOptions = {
settings = {
["nil"] = {
formatting = { command = { "nixfmt" } },
},
},
},
},
nim_langserver = {
binary = "nimlangserver",
},
pyright = {
extraOptions = {
settings = {
-- ruff is used instead
pyright = { disableOrganizeImports = true },
python = { ignore = { "*" } },
},
},
},
ruff_lsp = {
binary = "ruff-lsp",
extraOptions = {
on_attach = function(client, _)
require("lsp-format").on_attach(client)
-- pyright should handle this
client.server_capabilities.hoverProvider = false
end,
},
},
rust_analyzer = {
binary = "rust-analyzer",
extraOptions = {
settings = {
["rust-analyzer"] = {
check = { command = "clippy" },
},
},
},
},
ts_ls = {
binary = "typescript-language-server",
},
typos_lsp = {
binary = "typos-lsp",
},
typst_lsp = {
binary = "typst-lsp",
},
}
local caps = vim.tbl_deep_extend(
"force",
vim.lsp.protocol.make_client_capabilities(),
require("cmp_nvim_lsp").default_capabilities(),
-- for nil_ls
{ workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } }
)
local setup = {
on_attach = function(client, _)
require("lsp-format").on_attach(client)
end,
capabilities = caps,
}
for server, config in pairs(lsp_servers) do
local binary = config.binary or server
local options = (config.extraOptions == nil) and setup or vim.tbl_extend("keep", config.extraOptions, setup)
if vim.fn.executable(binary) == 1 then
require("lspconfig")[server].setup(options)
end
end
|