@@ -204,12 +204,19 @@ return {
204
204
},
205
205
}
206
206
207
+ -- NOTE: I have patched this file based on the changes in https://github.com/nvim-lua/kickstart.nvim/pull/1590 to fix compatibility with mason-lspconfig 2.0 and nvim >0.11
208
+
207
209
-- LSP servers and clients are able to communicate to each other what features they support.
208
210
-- By default, Neovim doesn't support everything that is in the LSP specification.
209
211
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
210
212
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
211
- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
213
+ -- NOTE: The following line is now commented as blink.cmp extends capabilities by default from its internal code:
214
+ -- https://github.com/Saghen/blink.cmp/blob/102db2f5996a46818661845cf283484870b60450/plugin/blink-cmp.lua
215
+ -- It has been left here as a comment for educational purposes (as the predecessor completion plugin required this explicit step).
216
+ --
217
+ -- local capabilities = require("blink.cmp").get_lsp_capabilities()
212
218
219
+ -- Filetypes to load with ltex_plus LSP below
213
220
local ltex_plus_filetypes = {
214
221
' bib' ,
215
222
' context' ,
@@ -230,90 +237,111 @@ return {
230
237
' typst' ,
231
238
' xhtml' ,
232
239
}
240
+ -- Language servers can broadly be installed in the following ways:
241
+ -- 1) via the mason package manager; or
242
+ -- 2) via your system's package manager; or
243
+ -- 3) via a release binary from a language server's repo that's accessible somewhere on your system.
233
244
234
- -- Enable the following language servers
235
- -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
236
- --
237
- -- Add any additional override configuration in the following tables. Available keys are:
238
- -- - cmd (table): Override the default command used to start the server
239
- -- - filetypes (table): Override the default list of associated filetypes for the server
240
- -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
241
- -- - settings (table): Override the default settings passed when initializing the server.
242
- -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
245
+ -- The servers table comprises of the following sub-tables:
246
+ -- 1. mason
247
+ -- 2. others
248
+ -- Both these tables have an identical structure of language server names as keys and
249
+ -- a table of language server configuration as values.
250
+ --- @class LspServersConfig
251
+ --- @field mason table<string , vim.lsp.Config>
252
+ --- @field others table<string , vim.lsp.Config>
243
253
local servers = {
244
- -- gopls = {},
245
- -- pyright = {},
246
- -- rust_analyzer = {},
247
- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
254
+ -- Enable the following language servers
255
+ -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
248
256
--
249
- awk_ls = {},
250
- bashls = {},
251
- clangd = {}, -- TODO: setup compile_commands.json generation for any projects that need to use this LSP
252
- -- csharp_ls = {}, -- or use omnisharp or rosyln_ls instead?
253
- omnisharp = {},
254
- css_variables = {},
255
- cssls = {},
256
- docker_compose_language_service = {},
257
- dockerls = {},
258
- eslint = {},
259
- -- gdscript = {}, -- TODO: in docs but causes mason error
260
- -- gdshader_lsp = {}, -- TODO: in docs but causes mason error
261
- gh_actions_ls = {},
262
- gitlab_ci_ls = {},
263
- glsl_analyzer = {},
264
- gradle_ls = {},
265
- graphql = {},
266
- groovyls = {},
267
- html = {},
268
- -- java_language_server = {}, -- Note - for fancier use cases jdtls lsp or nvim-jdtls plugin may be better -- TODO: mason errors during install
269
- jqls = {},
270
- jsonls = {},
271
- kotlin_language_server = {},
272
- ltex_plus = {
273
- filetypes = ltex_plus_filetypes ,
274
- settings = {
275
- ltex = {
276
- enabled = ltex_plus_filetypes ,
257
+ -- Add any additional override configuration in the following tables. Available keys are:
258
+ -- - cmd (table): Override the default command used to start the server
259
+ -- - filetypes (table): Override the default list of associated filetypes for the server
260
+ -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
261
+ -- - settings (table): Override the default settings passed when initializing the server.
262
+ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
263
+ --
264
+ -- Feel free to add/remove any LSPs here that you want to install via Mason. They will automatically be installed and setup.
265
+ mason = {
266
+ -- gopls = {},
267
+ -- pyright = {},
268
+ -- rust_analyzer = {},
269
+ -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
270
+ --
271
+ awk_ls = {},
272
+ bashls = {},
273
+ clangd = {}, -- TODO: setup compile_commands.json generation for any projects that need to use this LSP
274
+ -- csharp_ls = {}, -- or use omnisharp or rosyln_ls instead?
275
+ omnisharp = {},
276
+ css_variables = {},
277
+ cssls = {},
278
+ docker_compose_language_service = {},
279
+ dockerls = {},
280
+ eslint = {},
281
+ -- gdscript = {}, -- TODO: in docs but causes mason error
282
+ -- gdshader_lsp = {}, -- TODO: in docs but causes mason error
283
+ gh_actions_ls = {},
284
+ gitlab_ci_ls = {},
285
+ glsl_analyzer = {},
286
+ gradle_ls = {},
287
+ graphql = {},
288
+ groovyls = {},
289
+ html = {},
290
+ -- java_language_server = {}, -- Note - for fancier use cases jdtls lsp or nvim-jdtls plugin may be better -- TODO: mason errors during install
291
+ jqls = {},
292
+ jsonls = {},
293
+ kotlin_language_server = {},
294
+ ltex_plus = {
295
+ filetypes = ltex_plus_filetypes ,
296
+ settings = {
297
+ ltex = {
298
+ enabled = ltex_plus_filetypes ,
299
+ },
277
300
},
278
- },
279
- }, -- LaTeX, Markdown, etc. LSP
280
-
281
- lua_ls = {
282
- -- cmd = { ... },
283
- -- filetypes = { ... },
284
- -- capabilities = {},
285
- settings = {
286
- Lua = {
287
- completion = {
288
- callSnippet = ' Replace' ,
301
+ }, -- LaTeX, Markdown, etc. LSP
302
+
303
+ lua_ls = {
304
+ -- cmd = { ... },
305
+ -- filetypes = { ... },
306
+ -- capabilities = {},
307
+ settings = {
308
+ Lua = {
309
+ completion = {
310
+ callSnippet = ' Replace' ,
311
+ },
312
+ -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
313
+ -- diagnostics = { disable = { 'missing-fields' } },
289
314
},
290
- -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
291
- -- diagnostics = { disable = { 'missing-fields' } },
292
315
},
293
316
},
294
- },
295
317
296
- -- metals = {}, -- Scala LSP -- TODO: in docs but causes mason error
297
- perlnavigator = {}, -- Other ones that have about the same level of activity are perlls and perlpls
298
- pico8_ls = {},
299
- ruby_lsp = {}, -- or use solargraph? see also standardrb, syntax_tree, and typeprof
300
- spyglassmc_language_server = {}, -- Minecraft datapacks, may require additional configuration
301
- sqls = {}, -- See also the confusingly similarly named sqlls, and sqruff
302
- terraformls = {}, -- This is the official hashicorp one, see also terraform_lsp
303
- tflint = {},
304
- typos_lsp = {}, -- Code spellchecker
305
-
306
- -- Some languages (like typescript) have entire language plugins that can be useful:
307
- -- https://github.com/pmizio/typescript-tools.nvim
308
- --
309
- -- But for many setups, the LSP (`ts_ls`) will work just fine
310
- ts_ls = {}, -- see also ts_query_ls, tsgo
318
+ -- metals = {}, -- Scala LSP -- TODO: in docs but causes mason error
319
+ perlnavigator = {}, -- Other ones that have about the same level of activity are perlls and perlpls
320
+ pico8_ls = {},
321
+ ruby_lsp = {}, -- or use solargraph? see also standardrb, syntax_tree, and typeprof
322
+ spyglassmc_language_server = {}, -- Minecraft datapacks, may require additional configuration
323
+ sqls = {}, -- See also the confusingly similarly named sqlls, and sqruff
324
+ terraformls = {}, -- This is the official hashicorp one, see also terraform_lsp
325
+ tflint = {},
326
+ typos_lsp = {}, -- Code spellchecker
327
+
328
+ -- Some languages (like typescript) have entire language plugins that can be useful:
329
+ -- https://github.com/pmizio/typescript-tools.nvim
330
+ --
331
+ -- But for many setups, the LSP (`ts_ls`) will work just fine
332
+ ts_ls = {}, -- see also ts_query_ls, tsgo
311
333
312
- vacuum = {}, -- OpenAPI/Swagger linter/analyzer, requires filetypes to be registered
313
- vimls = {}, -- Vimscript
314
- yamlls = {},
334
+ vacuum = {}, -- OpenAPI/Swagger linter/analyzer, requires filetypes to be registered
335
+ vimls = {}, -- Vimscript
336
+ yamlls = {},
315
337
316
- -- TODO: There are a shitload of python LSPs - research and pick one
338
+ -- TODO: There are a shitload of python LSPs - research and pick one
339
+ },
340
+ -- This table contains config for all language servers that are *not* installed via Mason.
341
+ -- Structure is identical to the mason table from above.
342
+ others = {
343
+ -- dartls = {},
344
+ },
317
345
}
318
346
319
347
-- Ensure the servers and tools above are installed
@@ -329,26 +357,31 @@ return {
329
357
--
330
358
-- You can add other tools here that you want Mason to install
331
359
-- for you, so that they are available from within Neovim.
332
- local ensure_installed = vim .tbl_keys (servers or {})
360
+ local ensure_installed = vim .tbl_keys (servers . mason or {})
333
361
vim .list_extend (ensure_installed , {
334
362
' stylua' , -- Used to format Lua code
335
363
})
336
364
require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
337
365
366
+ -- Either merge all additional server configs from the `servers.mason` and `servers.others` tables
367
+ -- to the default language server configs as provided by nvim-lspconfig or
368
+ -- define a custom server config that's unavailable on nvim-lspconfig.
369
+ for server , config in pairs (vim .tbl_extend (' keep' , servers .mason , servers .others )) do
370
+ if not vim .tbl_isempty (config ) then
371
+ vim .lsp .config (server , config )
372
+ end
373
+ end
374
+
375
+ -- After configuring our language servers, we now enable them
338
376
require (' mason-lspconfig' ).setup {
339
377
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
340
- automatic_installation = false ,
341
- handlers = {
342
- function (server_name )
343
- local server = servers [server_name ] or {}
344
- -- This handles overriding only values explicitly passed
345
- -- by the server configuration above. Useful when disabling
346
- -- certain features of an LSP (for example, turning off formatting for ts_ls)
347
- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
348
- require (' lspconfig' )[server_name ].setup (server )
349
- end ,
350
- },
378
+ automatic_enable = true , -- automatically run vim.lsp.enable() for all servers that are installed via Mason
351
379
}
380
+
381
+ -- Manually run vim.lsp.enable for all language servers that are *not* installed via Mason
382
+ if not vim .tbl_isempty (servers .others ) then
383
+ vim .lsp .enable (vim .tbl_keys (servers .others ))
384
+ end
352
385
end ,
353
386
},
354
387
}
0 commit comments