@@ -157,57 +157,66 @@ return { -- LSP Configuration & Plugins
157157 -- - settings (table): Override the default settings passed when initializing the server.
158158 -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
159159 local servers = {
160- -- clangd = {},
161- -- rust_analyzer = {},
162- -- html = { filetypes = { 'html', 'twig', 'hbs'} },
160+ -- Feel free to add/remove any LSPs here that you want to install via Mason. They will automatically be installed and setup.
161+ mason = {
162+ -- clangd = {},
163+ -- rust_analyzer = {},
164+ -- html = { filetypes = { 'html', 'twig', 'hbs'} },
163165
164- bashls = {},
166+ bashls = {},
165167
166- ts_ls = {},
168+ ts_ls = {},
167169
168- tailwindcss = {},
170+ tailwindcss = {},
169171
170- dockerls = {},
172+ dockerls = {},
171173
172- jsonls = {},
174+ jsonls = {},
173175
174- emmet_language_server = {},
176+ emmet_language_server = {},
175177
176- lua_ls = {
177- settings = {
178- Lua = {
179- hint = { enable = true },
180- telemetry = { enable = false },
181- diagnostics = { disable = { ' missing-fields' } },
182- completion = {
183- callSnippet = ' Replace' ,
178+ lua_ls = {
179+ settings = {
180+ Lua = {
181+ hint = { enable = true },
182+ telemetry = { enable = false },
183+ diagnostics = { disable = { ' missing-fields' } },
184+ completion = {
185+ callSnippet = ' Replace' ,
186+ },
184187 },
185188 },
186189 },
187- },
188190
189- basedpyright = { command = ' python3' },
190-
191- omnisharp = { command = ' dotnet' },
192-
193- gopls = {
194- command = ' go' ,
195- settings = {
196- gopls = {
197- hints = {
198- assignVariableTypes = true ,
199- compositeLiteralFields = true ,
200- compositeLiteralTypes = true ,
201- constantValues = true ,
202- functionTypeParameters = true ,
203- parameterNames = true ,
204- rangeVariableTypes = true ,
191+ basedpyright = { command = ' python3' },
192+
193+ omnisharp = { command = ' dotnet' },
194+
195+ gopls = {
196+ command = ' go' ,
197+ settings = {
198+ gopls = {
199+ hints = {
200+ assignVariableTypes = true ,
201+ compositeLiteralFields = true ,
202+ compositeLiteralTypes = true ,
203+ constantValues = true ,
204+ functionTypeParameters = true ,
205+ parameterNames = true ,
206+ rangeVariableTypes = true ,
207+ },
205208 },
206- },
207- }
208- },
209+ }
210+ },
209211
210- jdtls = { command = ' java' }
212+ jdtls = { command = ' java' }
213+ },
214+ -- This table contains config for all language servers that are *not* installed via Mason.
215+ -- Structure is identical to the mason table from above.
216+ others = {
217+ -- dartls = {},
218+ fish_lsp = { command = ' fish-lsp' },
219+ },
211220 }
212221
213222 --- @param command string ?
@@ -217,16 +226,23 @@ return { -- LSP Configuration & Plugins
217226
218227 -- Configure Servers
219228 vim .lsp .enable (' ts_ls' , false ) -- typescript-tools is used instead
220- vim .lsp .enable (' fish_lsp' ) -- Is not supported by mason
221- for server , config in pairs (servers ) do
222- if skip_lsp (config .command ) then
223- servers [server ] = nil
224- else
225- config .command = nil
229+ for server , config in pairs (vim .tbl_extend (' keep' , servers .mason , servers .others )) do
230+ local command = config .command
231+ config .command = nil
232+ if skip_lsp (command ) then
233+ for cat , _ in pairs (servers ) do
234+ servers [cat ][server ] = nil
235+ end
236+ elseif not vim .tbl_isempty (config ) then
226237 vim .lsp .config (server , config )
227238 end
228239 end
229240
241+ -- Manually run vim.lsp.enable for all language servers that are *not* installed via Mason
242+ if not vim .tbl_isempty (servers .others ) then
243+ vim .lsp .enable (vim .tbl_keys (servers .others ))
244+ end
245+
230246 -- add workspace-diagnostics to all LSPs
231247 vim .lsp .config (' *' , {
232248 on_attach = function (client , bufnr )
@@ -235,7 +251,7 @@ return { -- LSP Configuration & Plugins
235251 })
236252
237253 -- Grab the list of servers and tools to install and add them to ensure_installed
238- local ensure_installed = vim .tbl_keys (servers or {})
254+ local ensure_installed = vim .tbl_keys (servers . mason or {})
239255 local tools = require (' kickstart.mason-tools' )
240256 vim .list_extend (ensure_installed , tools )
241257 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
0 commit comments