@@ -118,33 +118,19 @@ return {
118118 -- map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
119119 map (' grt' , require (' fzf-lua' ).lsp_typedefs , ' [G]oto [T]ype Definition' )
120120
121- -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
122- --- @param client vim.lsp.Client
123- --- @param method vim.lsp.protocol.Method
124- --- @param bufnr ? integer some lsp support methods only in specific files
125- --- @return boolean
126- local function client_supports_method (client , method , bufnr )
127- if vim .fn .has ' nvim-0.11' == 1 then
128- return client :supports_method (method , bufnr )
129- else
130- return client .supports_method (method , { bufnr = bufnr })
131- end
132- end
133-
134121 -- The following two autocommands are used to highlight references of the
135122 -- word under your cursor when your cursor rests there for a little while.
136123 -- See `:help CursorHold` for information about when this is executed
137- --
138- -- When you move your cursor, the highlights will be cleared (the second autocommand).
139124 local client = vim .lsp .get_client_by_id (event .data .client_id )
140- if client and client_supports_method ( client , vim . lsp . protocol . Methods . textDocument_documentHighlight , event .buf ) then
125+ if client and client : supports_method ( ' textDocument/documentHighlight ' , event .buf ) then
141126 local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
142127 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
143128 buffer = event .buf ,
144129 group = highlight_augroup ,
145130 callback = vim .lsp .buf .document_highlight ,
146131 })
147132
133+ -- When you move your cursor, the highlights will be cleared
148134 vim .api .nvim_create_autocmd ({ ' CursorMoved' , ' CursorMovedI' }, {
149135 buffer = event .buf ,
150136 group = highlight_augroup ,
@@ -164,7 +150,7 @@ return {
164150 -- code, if the language server you are using supports them
165151 --
166152 -- This may be unwanted, since they displace some of your code
167- if client and client_supports_method ( client , vim . lsp . protocol . Methods . textDocument_inlayHint , event .buf ) then
153+ if client and client : supports_method ( ' textDocument/inlayHint ' , event .buf ) then
168154 map (' <leader>th' , function ()
169155 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
170156 end , ' [T]oggle Inlay [H]ints' )
@@ -205,11 +191,8 @@ return {
205191 -- By default, Neovim doesn't support everything that is in the LSP specification.
206192 -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
207193 -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
208- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
194+ -- local capabilities = require('blink.cmp').get_lsp_capabilities()
209195
210- -- Enable the following language servers
211- -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
212- --
213196 -- Add any additional override configuration in the following tables. Available keys are:
214197 -- - cmd (table): Override the default command used to start the server
215198 -- - filetypes (table): Override the default list of associated filetypes for the server
@@ -222,64 +205,69 @@ return {
222205 pyright = {},
223206 rust_analyzer = {},
224207 -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
225- --
226- -- Some languages (like typescript) have entire language plugins that can be useful:
227- -- https://github.com/pmizio/typescript-tools.nvim
228- --
229- -- But for many setups, the LSP (`ts_ls`) will work just fine
230- -- ts_ls = {},
231- --
232-
208+ stylua = {},
233209 lua_ls = {
234210 -- cmd = { ... },
235211 -- filetypes = { ... },
236212 -- capabilities = {},
213+ on_init = function (client )
214+ if client .workspace_folders then
215+ local path = client .workspace_folders [1 ].name
216+ if path ~= vim .fn .stdpath ' config' and (vim .uv .fs_stat (path .. ' /.luarc.json' ) or vim .uv .fs_stat (path .. ' /.luarc.jsonc' )) then
217+ return
218+ end
219+ end
220+
221+ -- client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
222+ -- runtime = {
223+ -- version = 'LuaJIT',
224+ -- path = { 'lua/?.lua', 'lua/?/init.lua' },
225+ -- },
226+ -- workspace = {
227+ -- checkThirdParty = false,
228+ -- -- NOTE: this is a lot slower and will cause issues when working on your own configuration.
229+ -- -- See https://github.com/neovim/nvim-lspconfig/issues/3189
230+ -- library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), {
231+ -- '${3rd}/luv/library',
232+ -- '${3rd}/busted/library',
233+ -- }),
234+ -- },
235+ -- })
236+ end ,
237237 settings = {
238238 Lua = {
239239 completion = {
240240 callSnippet = ' Replace' ,
241241 },
242242 -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
243243 -- diagnostics = { disable = { 'missing-fields' } },
244+ diagnostics = {
245+ globals = { ' vim' },
246+ },
244247 },
245248 },
246249 },
247- biome = {},
250+ ts_ls = {},
251+ -- TODO: make biome work as lsp fot ts, js, tsx, jsx files instead of ts_ls
252+ biome = {
253+ -- cmd = { 'biome', 'lsp-proxy' },
254+ -- root_dir = require('lspconfig').util.root_pattern('package.json', '.git'),
255+ },
248256 }
249257
250258 -- Ensure the servers and tools above are installed
251- --
252259 -- To check the current status of installed tools and/or manually install
253260 -- other tools, you can run
254261 -- :Mason
255- --
256- -- You can press `g?` for help in this menu.
257- --
258- -- `mason` had to be setup earlier: to configure its options see the
259- -- `dependencies` table for `nvim-lspconfig` above.
260- --
261- -- You can add other tools here that you want Mason to install
262- -- for you, so that they are available from within Neovim.
263262 local ensure_installed = vim .tbl_keys (servers or {})
264263 vim .list_extend (ensure_installed , {
265- ' stylua ' , -- Used to format Lua code
264+ -- add any other tools we want from mason
266265 })
267266 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
268-
269- require (' mason-lspconfig' ).setup {
270- ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
271- automatic_installation = false ,
272- handlers = {
273- function (server_name )
274- local server = servers [server_name ] or {}
275- -- This handles overriding only values explicitly passed
276- -- by the server configuration above. Useful when disabling
277- -- certain features of an LSP (for example, turning off formatting for ts_ls)
278- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
279- require (' lspconfig' )[server_name ].setup (server )
280- end ,
281- },
282- }
267+ for name , server in pairs (servers ) do
268+ vim .lsp .config (name , server )
269+ vim .lsp .enable (name )
270+ end
283271
284272 -- In case you want to install an lsp directly on your system, you;ll need to configure it and enable it manually
285273 -- local system_installed_servers = {
0 commit comments