1
1
-- LSP Plugins
2
+ --
2
3
return {
4
+
5
+ -- LSP Plugins
3
6
{
4
7
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
5
8
-- used for completion, annotations and signatures of Neovim apis
@@ -23,10 +26,42 @@ return {
23
26
' mason-org/mason-lspconfig.nvim' ,
24
27
' WhoIsSethDaniel/mason-tool-installer.nvim' ,
25
28
29
+ -- Useful status updates for LSP.
30
+ -- { 'j-hui/fidget.nvim', opts = {} },
31
+
26
32
-- Allows extra capabilities provided by blink.cmp
27
33
' saghen/blink.cmp' ,
28
34
},
29
35
config = function ()
36
+ -- Brief aside: **What is LSP?**
37
+ --
38
+ -- LSP is an initialism you've probably heard, but might not understand what it is.
39
+ --
40
+ -- LSP stands for Language Server Protocol. It's a protocol that helps editors
41
+ -- and language tooling communicate in a standardized fashion.
42
+ --
43
+ -- In general, you have a "server" which is some tool built to understand a particular
44
+ -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
45
+ -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
46
+ -- processes that communicate with some "client" - in this case, Neovim!
47
+ --
48
+ -- LSP provides Neovim with features like:
49
+ -- - Go to definition
50
+ -- - Find references
51
+ -- - Autocompletion
52
+ -- - Symbol Search
53
+ -- - and more!
54
+ --
55
+ -- Thus, Language Servers are external tools that must be installed separately from
56
+ -- Neovim. This is where `mason` and related plugins come into play.
57
+ --
58
+ -- If you're wondering about lsp vs treesitter, you can check out the wonderfully
59
+ -- and elegantly composed help section, `:help lsp-vs-treesitter`
60
+
61
+ -- This function gets run when an LSP attaches to a particular buffer.
62
+ -- That is to say, every time a new file is opened that is associated with
63
+ -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
64
+ -- function will be executed to configure the current buffer
30
65
vim .api .nvim_create_autocmd (' LspAttach' , {
31
66
group = vim .api .nvim_create_augroup (' kickstart-lsp-attach' , { clear = true }),
32
67
callback = function (event )
@@ -160,12 +195,6 @@ return {
160
195
},
161
196
}
162
197
163
- -- LSP servers and clients are able to communicate to each other what features they support.
164
- -- By default, Neovim doesn't support everything that is in the LSP specification.
165
- -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
166
- -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
167
- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
168
-
169
198
-- Enable the following language servers
170
199
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
171
200
--
@@ -176,20 +205,8 @@ return {
176
205
-- - settings (table): Override the default settings passed when initializing the server.
177
206
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
178
207
local servers = {
179
- -- clangd = {},
180
- -- gopls = {},
181
- -- pyright = {},
182
- -- rust_analyzer = {},
183
- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
184
- --
185
- -- Some languages (like typescript) have entire language plugins that can be useful:
186
- -- https://github.com/pmizio/typescript-tools.nvim
187
- --
188
- -- But for many setups, the LSP (`ts_ls`) will work just fine
189
- -- ts_ls = {},
190
- --
191
208
clangd = {
192
- cmd = { -- This doesn't seem to do anything. Look into this later
209
+ cmd = {
193
210
' clangd' ,
194
211
' --offset-encoding=utf-16' ,
195
212
' --clang-tidy' ,
@@ -198,7 +215,6 @@ return {
198
215
' --header-insertion=iwyu' ,
199
216
},
200
217
},
201
- -- gopls = {},
202
218
asm_lsp = {},
203
219
pyright = {},
204
220
rust_analyzer = {
@@ -256,18 +272,27 @@ return {
256
272
},
257
273
258
274
ltex = {
259
- Settings = {
275
+ settings = {
260
276
ltex = {
261
- -- language = 'en-US',
262
- language = ' DE' ,
277
+ language = ' en-US' ,
263
278
checkFrequency = ' save' ,
264
279
-- languageToolHttpServerUri = "https://api.languagetoolplus.com/",
265
280
-- require("creds").languageToolOrg
266
281
},
267
282
},
268
283
},
269
284
270
- svlangserver = {},
285
+ svlangserver = {
286
+ settings = {
287
+ systemverilog = {
288
+ includeIndexing = { ' **/*.{sv,svh}' },
289
+ excludeIndexing = { ' test/**/*.sv*' },
290
+ defines = {},
291
+ launchConfiguration = ' verilator -sv -Wall --lint-only' ,
292
+ formatCommand = ' verible-verilog-format' ,
293
+ },
294
+ },
295
+ },
271
296
-- veridian = {
272
297
-- cmd = { 'veridian' },
273
298
-- filetypes = { 'systemverilog', 'verilog' },
@@ -287,6 +312,11 @@ return {
287
312
},
288
313
},
289
314
}
315
+ --- @type MasonLspconfigSettings
316
+ --- @diagnostic disable-next-line : missing-fields
317
+ require (' mason-lspconfig' ).setup {
318
+ automatic_enable = vim .tbl_keys (servers or {}),
319
+ }
290
320
291
321
-- Ensure the servers and tools above are installed
292
322
--
@@ -307,21 +337,16 @@ return {
307
337
})
308
338
require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
309
339
310
- require (' mason-lspconfig' ).setup {
311
- ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
312
- automatic_installation = false ,
313
- handlers = {
314
- function (server_name )
315
- local server = servers [server_name ] or {}
316
- -- This handles overriding only values explicitly passed
317
- -- by the server configuration above. Useful when disabling
318
- -- certain features of an LSP (for example, turning off formatting for ts_ls)
319
- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
320
- require (' lspconfig' )[server_name ].setup (server )
321
- end ,
322
- },
323
- }
340
+ -- Installed LSPs are configured and enabled automatically with mason-lspconfig
341
+ -- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
342
+ for server_name , config in pairs (servers ) do
343
+ vim .lsp .config (server_name , config )
344
+ end
345
+
346
+ -- NOTE: Some servers may require an old setup until they are updated. For the full list refer here: https://github.com/neovim/nvim-lspconfig/issues/3705
347
+ -- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
324
348
end ,
325
349
},
326
350
}
351
+
327
352
-- vim: ts=2 sts=2 sw=2 et
0 commit comments