11--[[
2-
32=====================================================================
43==================== READ THIS BEFORE CONTINUING ====================
54=====================================================================
@@ -660,59 +659,74 @@ require('lazy').setup({
660659 -- By default, Neovim doesn't support everything that is in the LSP specification.
661660 -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
662661 -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
663- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
662+ -- NOTE: The following line is now commented as blink.cmp extends capabilites by default from its internal code:
663+ -- https://github.com/Saghen/blink.cmp/blob/102db2f5996a46818661845cf283484870b60450/plugin/blink-cmp.lua
664+ -- It has been left here as a comment for educational purposes (as the predecessor completion plugin required this explicit step).
665+ --
666+ -- local capabilities = require("blink.cmp").get_lsp_capabilities()
664667
665- -- Enable the following language servers
666- -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
668+ -- Language servers can broadly be installed in the following ways:
669+ -- 1) via the mason package manager; or
670+ -- 2) via your system's package manager; or
671+ -- 3) via a release binary from a language server's repo that's accessible somewhere on your system.
667672 --
668- -- Add any additional override configuration in the following tables. Available keys are:
669- -- - cmd (table): Override the default command used to start the server
670- -- - filetypes (table): Override the default list of associated filetypes for the server
671- -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
672- -- - settings (table): Override the default settings passed when initializing the server.
673- -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
674673 local servers = {
675- -- clangd = {},
676- gopls = {},
677- pyright = {},
678- rust_analyzer = {
679- settings = {
680- [' rust-analyzer' ] = {
681- procMacro = { enable = true },
674+ -- Add any additional override configuration in any of the following tables. Available keys are:
675+ -- - cmd (table): Override the default command used to start the server
676+ -- - filetypes (table): Override the default list of associated filetypes for the server
677+ -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
678+ -- - settings (table): Override the default settings passed when initializing the server.
679+ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
680+ --
681+ -- Feel free to add/remove any LSPs here that you want to install via Mason. They will automatically be installed and setup.
682+ mason = {
683+ -- clangd = {},
684+ gopls = {},
685+ pyright = {},
686+ rust_analyzer = {
687+ settings = {
688+ [' rust-analyzer' ] = {
689+ procMacro = { enable = true },
690+ },
682691 },
683692 },
684- },
685- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
686- --
687- -- Some languages (like typescript) have entire language plugins that can be useful:
688- -- https://github.com/pmizio/typescript-tools.nvim
689- --
690- -- But for many setups, the LSP (`ts_ls`) will work just fine
691- ts_ls = {},
692- --
693-
694- -- Open API
695- -- spectral = {},
696- -- vacuum = {},
697-
698- yamlls = {},
693+ -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
694+ --
695+ -- Some languages (like typescript) have entire language plugins that can be useful:
696+ -- https://github.com/pmizio/typescript-tools.nvim
697+ --
698+ -- But for many setups, the LSP (`ts_ls`) will work just fine
699+ ts_ls = {},
700+ --
699701
700- lua_ls = {
701- -- cmd = { ... },
702- -- filetypes = { ... },
703- -- capabilities = {},
704- settings = {
705- Lua = {
706- completion = {
707- callSnippet = ' Replace' ,
702+ -- Open API
703+ -- spectral = {},
704+ -- vacuum = {},
705+
706+ yamlls = {},
707+
708+ lua_ls = {
709+ -- cmd = { ... },
710+ -- filetypes = { ... },
711+ -- capabilities = {},
712+ settings = {
713+ Lua = {
714+ completion = {
715+ callSnippet = ' Replace' ,
716+ },
717+ -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
718+ -- diagnostics = { disable = { 'missing-fields' } },
708719 },
709- -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
710- -- diagnostics = { disable = { 'missing-fields' } },
711720 },
712721 },
722+ -- PHP
723+ intelephense = {},
724+ },
725+ -- This table contains config for all language servers that are *not* installed via Mason.
726+ -- Structure is identical to the mason table from above.
727+ others = {
728+ -- dartls = {},
713729 },
714- -- PHP
715- intelephense = {},
716730 }
717731 vim .filetype .add {
718732 pattern = {
@@ -735,26 +749,31 @@ require('lazy').setup({
735749 --
736750 -- You can add other tools here that you want Mason to install
737751 -- for you, so that they are available from within Neovim.
738- local ensure_installed = vim .tbl_keys (servers or {})
752+ local ensure_installed = vim .tbl_keys (servers . mason or {})
739753 vim .list_extend (ensure_installed , {
740754 ' stylua' , -- Used to format Lua code
741755 })
742756 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
743757
758+ -- Either merge all additional server configs from the `servers.mason` and `servers.others` tables
759+ -- to the default language server configs as provided by nvim-lspconfig or
760+ -- define a custom server config that's unavailable on nvim-lspconfig.
761+ for server , config in pairs (vim .tbl_extend (' keep' , servers .mason , servers .others )) do
762+ if vim .fn .empty (config ) ~= 1 then
763+ vim .lsp .config (server , config )
764+ end
765+ end
766+
767+ -- After configuring our language servers, we now enable them
744768 require (' mason-lspconfig' ).setup {
745769 ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
746- automatic_installation = false ,
747- handlers = {
748- function (server_name )
749- local server = servers [server_name ] or {}
750- -- This handles overriding only values explicitly passed
751- -- by the server configuration above. Useful when disabling
752- -- certain features of an LSP (for example, turning off formatting for ts_ls)
753- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
754- require (' lspconfig' )[server_name ].setup (server )
755- end ,
756- },
770+ automatic_enable = true , -- automatically run vim.lsp.enable() for all servers that are installed via Mason
757771 }
772+
773+ -- Manually run vim.lsp.enable for all language servers that are *not* installed via Mason
774+ if vim .fn .empty (servers .others ) ~= 1 then
775+ vim .lsp .enable (vim .tbl_keys (servers .others ))
776+ end
758777 end ,
759778 },
760779
@@ -959,7 +978,12 @@ require('lazy').setup({
959978 },
960979
961980 -- Highlight todo, notes, etc in comments
962- { ' folke/todo-comments.nvim' , event = ' VimEnter' , dependencies = { ' nvim-lua/plenary.nvim' }, opts = { signs = false } },
981+ {
982+ ' folke/todo-comments.nvim' ,
983+ event = ' VimEnter' ,
984+ dependencies = { ' nvim-lua/plenary.nvim' },
985+ opts = { signs = false },
986+ },
963987
964988 { -- Collection of various small independent plugins/modules
965989 ' echasnovski/mini.nvim' ,
@@ -1004,7 +1028,19 @@ require('lazy').setup({
10041028 main = ' nvim-treesitter.configs' , -- Sets main module to use for opts
10051029 -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
10061030 opts = {
1007- ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' },
1031+ ensure_installed = {
1032+ ' bash' ,
1033+ ' c' ,
1034+ ' diff' ,
1035+ ' html' ,
1036+ ' lua' ,
1037+ ' luadoc' ,
1038+ ' markdown' ,
1039+ ' markdown_inline' ,
1040+ ' query' ,
1041+ ' vim' ,
1042+ ' vimdoc' ,
1043+ },
10081044 -- Autoinstall languages that are not installed
10091045 auto_install = true ,
10101046 highlight = {
0 commit comments