@@ -157,57 +157,66 @@ return { -- LSP Configuration & Plugins
157
157
-- - settings (table): Override the default settings passed when initializing the server.
158
158
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
159
159
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'} },
163
165
164
- bashls = {},
166
+ bashls = {},
165
167
166
- ts_ls = {},
168
+ ts_ls = {},
167
169
168
- tailwindcss = {},
170
+ tailwindcss = {},
169
171
170
- dockerls = {},
172
+ dockerls = {},
171
173
172
- jsonls = {},
174
+ jsonls = {},
173
175
174
- emmet_language_server = {},
176
+ emmet_language_server = {},
175
177
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
+ },
184
187
},
185
188
},
186
189
},
187
- },
188
190
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
+ },
205
208
},
206
- },
207
- }
208
- },
209
+ }
210
+ },
209
211
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
+ },
211
220
}
212
221
213
222
--- @param command string ?
@@ -217,16 +226,23 @@ return { -- LSP Configuration & Plugins
217
226
218
227
-- Configure Servers
219
228
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
226
237
vim .lsp .config (server , config )
227
238
end
228
239
end
229
240
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
+
230
246
-- add workspace-diagnostics to all LSPs
231
247
vim .lsp .config (' *' , {
232
248
on_attach = function (client , bufnr )
@@ -235,7 +251,7 @@ return { -- LSP Configuration & Plugins
235
251
})
236
252
237
253
-- 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 {})
239
255
local tools = require (' kickstart.mason-tools' )
240
256
vim .list_extend (ensure_installed , tools )
241
257
require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
0 commit comments