11--[[
2-
32=====================================================================
43==================== READ THIS BEFORE CONTINUING ====================
54=====================================================================
@@ -659,45 +658,59 @@ require('lazy').setup({
659658 -- By default, Neovim doesn't support everything that is in the LSP specification.
660659 -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
661660 -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
662- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
661+ -- NOTE: The following line is now commented as blink.cmp extends capabilites by default from its internal code:
662+ -- https://github.com/Saghen/blink.cmp/blob/102db2f5996a46818661845cf283484870b60450/plugin/blink-cmp.lua
663+ -- It has been left here as a comment for educational purposes (as the predecessor completion plugin required this explicit step).
664+ --
665+ -- local capabilities = require("blink.cmp").get_lsp_capabilities()
663666
664- -- Enable the following language servers
665- -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
667+ -- Language servers can broadly be installed in the following ways:
668+ -- 1) via the mason package manager; or
669+ -- 2) via your system's package manager; or
670+ -- 3) via a release binary from a language server's repo that's accessible somewhere on your system.
666671 --
667- -- Add any additional override configuration in the following tables. Available keys are:
668- -- - cmd (table): Override the default command used to start the server
669- -- - filetypes (table): Override the default list of associated filetypes for the server
670- -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
671- -- - settings (table): Override the default settings passed when initializing the server.
672- -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
673672 local servers = {
674- -- clangd = {},
675- -- gopls = {},
676- -- pyright = {},
677- -- rust_analyzer = {},
678- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
679- --
680- -- Some languages (like typescript) have entire language plugins that can be useful:
681- -- https://github.com/pmizio/typescript-tools.nvim
673+ -- Add any additional override configuration in any of the following tables. Available keys are:
674+ -- - cmd (table): Override the default command used to start the server
675+ -- - filetypes (table): Override the default list of associated filetypes for the server
676+ -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
677+ -- - settings (table): Override the default settings passed when initializing the server.
678+ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
682679 --
683- -- But for many setups, the LSP (`ts_ls`) will work just fine
684- -- ts_ls = {},
685- --
686-
687- lua_ls = {
688- -- cmd = { ... },
689- -- filetypes = { ... },
690- -- capabilities = {},
691- settings = {
692- Lua = {
693- completion = {
694- callSnippet = ' Replace' ,
680+ -- Feel free to add/remove any LSPs here that you want to install via Mason. They will automatically be installed and setup.
681+ mason = {
682+ -- clangd = {},
683+ -- gopls = {},
684+ -- pyright = {},
685+ -- rust_analyzer = {},
686+ -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
687+ --
688+ -- Some languages (like typescript) have entire language plugins that can be useful:
689+ -- https://github.com/pmizio/typescript-tools.nvim
690+ --
691+ -- But for many setups, the LSP (`ts_ls`) will work just fine
692+ -- ts_ls = {},
693+ --
694+ lua_ls = {
695+ -- cmd = { ... },
696+ -- filetypes = { ... },
697+ -- capabilities = {},
698+ settings = {
699+ Lua = {
700+ completion = {
701+ callSnippet = ' Replace' ,
702+ },
703+ -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
704+ -- diagnostics = { disable = { 'missing-fields' } },
695705 },
696- -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
697- -- diagnostics = { disable = { 'missing-fields' } },
698706 },
699707 },
700708 },
709+ -- This table contains config for all language servers that are *not* installed via Mason.
710+ -- Structure is identical to the mason table from above.
711+ others = {
712+ -- dartls = {},
713+ },
701714 }
702715
703716 -- Ensure the servers and tools above are installed
@@ -713,26 +726,31 @@ require('lazy').setup({
713726 --
714727 -- You can add other tools here that you want Mason to install
715728 -- for you, so that they are available from within Neovim.
716- local ensure_installed = vim .tbl_keys (servers or {})
729+ local ensure_installed = vim .tbl_keys (servers . mason or {})
717730 vim .list_extend (ensure_installed , {
718731 ' stylua' , -- Used to format Lua code
719732 })
720733 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
721734
735+ -- Either merge all additional server configs from the `servers.mason` and `servers.others` tables
736+ -- to the default language server configs as provided by nvim-lspconfig or
737+ -- define a custom server config that's unavailable on nvim-lspconfig.
738+ for server , config in pairs (vim .tbl_extend (' keep' , servers .mason , servers .others )) do
739+ if vim .fn .empty (config ) ~= 1 then
740+ vim .lsp .config (server , config )
741+ end
742+ end
743+
744+ -- After configuring our language servers, we now enable them
722745 require (' mason-lspconfig' ).setup {
723746 ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
724- automatic_installation = false ,
725- handlers = {
726- function (server_name )
727- local server = servers [server_name ] or {}
728- -- This handles overriding only values explicitly passed
729- -- by the server configuration above. Useful when disabling
730- -- certain features of an LSP (for example, turning off formatting for ts_ls)
731- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
732- require (' lspconfig' )[server_name ].setup (server )
733- end ,
734- },
747+ automatic_enable = true , -- automatically run vim.lsp.enable() for all servers that are installed via Mason
735748 }
749+
750+ -- Manually run vim.lsp.enable for all language servers that are *not* installed via Mason
751+ if vim .fn .empty (servers .others ) ~= 1 then
752+ vim .lsp .enable (vim .tbl_keys (servers .others ))
753+ end
736754 end ,
737755 },
738756
@@ -899,7 +917,12 @@ require('lazy').setup({
899917 },
900918
901919 -- Highlight todo, notes, etc in comments
902- { ' folke/todo-comments.nvim' , event = ' VimEnter' , dependencies = { ' nvim-lua/plenary.nvim' }, opts = { signs = false } },
920+ {
921+ ' folke/todo-comments.nvim' ,
922+ event = ' VimEnter' ,
923+ dependencies = { ' nvim-lua/plenary.nvim' },
924+ opts = { signs = false },
925+ },
903926
904927 { -- Collection of various small independent plugins/modules
905928 ' echasnovski/mini.nvim' ,
@@ -944,7 +967,19 @@ require('lazy').setup({
944967 main = ' nvim-treesitter.configs' , -- Sets main module to use for opts
945968 -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
946969 opts = {
947- ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' },
970+ ensure_installed = {
971+ ' bash' ,
972+ ' c' ,
973+ ' diff' ,
974+ ' html' ,
975+ ' lua' ,
976+ ' luadoc' ,
977+ ' markdown' ,
978+ ' markdown_inline' ,
979+ ' query' ,
980+ ' vim' ,
981+ ' vimdoc' ,
982+ },
948983 -- Autoinstall languages that are not installed
949984 auto_install = true ,
950985 highlight = {
0 commit comments