@@ -17,8 +17,8 @@ return {
1717 ' neovim/nvim-lspconfig' ,
1818 dependencies = {
1919 -- Automatically install LSPs and related tools to stdpath for Neovim
20- { ' williamboman /mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
21- ' williamboman /mason-lspconfig.nvim' ,
20+ { ' mason-org /mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
21+ ' mason-org /mason-lspconfig.nvim' ,
2222 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
2323
2424 -- Useful status updates for LSP.
@@ -61,52 +61,6 @@ return {
6161 -- That is to say, every time a new file is opened that is associated with
6262 -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
6363 -- function will be executed to configure the current buffer
64- local on_attach = function (_ , buffr )
65- local kset = function (key , func , buffer , desc )
66- vim .keymap .set (' n' , key , func , { buffer = buffer , desc = ' LSP: ' .. desc })
67- end
68-
69- -- Jump to the definition of the word under your cursor.
70- -- This is where a variable was first declared, or where a function is defined, etc.
71- -- To jump back, press <C-t>.
72- kset (' gd' , require (' telescope.builtin' ).lsp_definitions , buffr , ' [G]oto [D]efinition' )
73-
74- -- Find references for the word under your cursor.
75- kset (' gr' , require (' telescope.builtin' ).lsp_references , buffr , ' [G]oto [R]eferences' )
76-
77- -- Jump to the implementation of the word under your cursor.
78- -- Useful when your language has ways of declaring types without an actual implementation.
79- kset (' gI' , require (' telescope.builtin' ).lsp_implementations , buffr , ' [G]oto [I]mplementation' )
80-
81- -- Jump to the type of the word under your cursor.
82- -- Useful when you're not sure what type a variable is and you want to see
83- -- the definition of its *type*, not where it was *defined*.
84- kset (' <leader>D' , require (' telescope.builtin' ).lsp_type_definitions , buffr , ' Type [D]efinition' )
85-
86- -- Fuzzy find all the symbols in your current document.
87- -- Symbols are things like variables, functions, types, etc.
88- kset (' <leader>ds' , require (' telescope.builtin' ).lsp_document_symbols , buffr , ' [D]ocument [S]ymbols' )
89-
90- -- Fuzzy find all the symbols in your current workspace.
91- -- Similar to document symbols, except searches over your entire project.
92- kset (' <leader>ws' , require (' telescope.builtin' ).lsp_dynamic_workspace_symbols , buffr , ' [W]orkspace [S]ymbols' )
93-
94- -- Rename the variable under your cursor.
95- -- Most Language Servers support renaming across files, etc.
96- kset (' <leader>rn' , vim .lsp .buf .rename , buffr , ' [R]e[n]ame' )
97-
98- -- Execute a code action, usually your cursor needs to be on top of an error
99- -- or a suggestion from your LSP for this to activate.
100- kset (' <leader>ca' , vim .lsp .buf .code_action , buffr , ' [C]ode [A]ction' )
101-
102- -- Opens a popup that displays documentation about the word under your cursor
103- -- See `:help K` for why this keymap.
104- kset (' K' , vim .lsp .buf .hover , buffr , ' Hover Documentation' )
105-
106- -- WARN: This is not Goto Definition, this is Goto Declaration.
107- -- For example, in C this would take you to the header.
108- kset (' gD' , vim .lsp .buf .declaration , buffr , ' [G]oto [D]eclaration' )
109- end
11064
11165 vim .api .nvim_create_autocmd (' LspAttach' , {
11266 group = vim .api .nvim_create_augroup (' kickstart-lsp-attach' , { clear = true }),
@@ -222,14 +176,16 @@ return {
222176 severity_sort = true ,
223177 float = { border = ' rounded' , source = ' if_many' },
224178 underline = { severity = vim .diagnostic .severity .ERROR },
225- signs = vim .g .have_nerd_font and {
226- text = {
227- [vim .diagnostic .severity .ERROR ] = ' ' ,
228- [vim .diagnostic .severity .WARN ] = ' ' ,
229- [vim .diagnostic .severity .INFO ] = ' ' ,
230- [vim .diagnostic .severity .HINT ] = ' ' ,
231- },
232- } or {},
179+ signs = vim .g .have_nerd_font
180+ and {
181+ text = {
182+ [vim .diagnostic .severity .ERROR ] = ' ' , -- circle with cross
183+ [vim .diagnostic .severity .WARN ] = ' ' , -- triangle warning
184+ [vim .diagnostic .severity .INFO ] = ' ' , -- circle with i
185+ [vim .diagnostic .severity .HINT ] = ' ' , -- lightbulb
186+ },
187+ }
188+ or {},
233189 virtual_text = {
234190 source = ' if_many' ,
235191 spacing = 2 ,
@@ -268,40 +224,28 @@ return {
268224 -- You can add other tools here that you want Mason to install
269225 -- for you, so that they are available from within Neovim.
270226 -- require('mason-tool-installer').setup { ensure_installed = ensure_installed }
227+
271228 -- INFO: Using my own utils function instead of mason-lspconfig as it checks if the stuff is already installed
272229 -- outside of mason. This is useful for NixOS setup where mason version just doesn't work sometimes due to libc issues.
273-
274230 -- We take the languages configured for a given profile
275231 -- Given the profile we take the LSPs configured for the languages
276232 -- Then we guarantee use or install the LSPs
277- local languages = require (' utils.profile' ).Languages ()
278- local languageServers = require ' utils.languages'
279- local tmpTable = {}
280- for _ , lang in ipairs (languages ) do
281- for lsp , config in pairs (languageServers [lang ]) do
282- tmpTable [lsp ] = config
283- end
284- end
285- require (' utils.mason' ).install (tmpTable , true )
286- local lsp = require ' lspconfig'
287- for server , config in pairs (tmpTable ) do
233+ local lsps = require (' utils.profile' ).LanguageServers ()
234+ -- print(vim.inspect(lsps))
235+ local missing_lsps = require (' utils.mason' ).missing (lsps ) -- find missing lsps
236+ -- print(vim.inspect(missing_lsps))
237+ missing_lsps = {} -- TODO: this is only for NixOS to prefer installing via nixpkgs instead of mason
238+
239+ -- install the executables of the language servers that we don't already have installed locally outside of mason
240+ require (' utils.mason' ).install (missing_lsps )
241+
242+ -- configure nvim lsp via lspconfig package for our list of lsps
243+ local lspconfig = require ' lspconfig'
244+ for server , config in pairs (lsps ) do
288245 config .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , config .capabilities or {})
289- config .on_attach = on_attach
290- lsp [server ].setup (config )
246+ -- config.on_attach = on_attach -- we don't need this because of the events
247+ lspconfig [server ].setup (config )
291248 end
292-
293- -- require('mason-lspconfig').setup {
294- -- handlers = {
295- -- function(server_name)
296- -- local server = servers[server_name] or {}
297- -- -- This handles overriding only values explicitly passed
298- -- -- by the server configuration above. Useful when disabling
299- -- -- certain features of an LSP (for example, turning off formatting for tsserver)
300- -- server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
301- -- require('lspconfig')[server_name].setup(server)
302- -- end,
303- -- },
304- -- }
305249 end ,
306250 },
307251 -- Show LSP explorer of functions and classes etc.
0 commit comments