@@ -30,21 +30,15 @@ return {
3030 { ' j-hui/fidget.nvim' , opts = {} },
3131
3232 -- Allows extra capabilities provided by blink.cmp
33+ -- Already installed in another file
3334 ' saghen/blink.cmp' ,
3435 },
3536 config = function ()
3637 -- Brief aside: **What is LSP?**
3738 --
38- -- LSP is an initialism you've probably heard, but might not understand what it is.
39- --
4039 -- LSP stands for Language Server Protocol. It's a protocol that helps editors
4140 -- and language tooling communicate in a standardized fashion.
4241 --
43- -- In general, you have a "server" which is some tool built to understand a particular
44- -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
45- -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
46- -- processes that communicate with some "client" - in this case, Neovim!
47- --
4842 -- LSP provides Neovim with features like:
4943 -- - Go to definition
5044 -- - Find references
@@ -65,11 +59,6 @@ return {
6559 vim .api .nvim_create_autocmd (' LspAttach' , {
6660 group = vim .api .nvim_create_augroup (' kickstart-lsp-attach' , { clear = true }),
6761 callback = function (event )
68- -- NOTE: Remember that Lua is a real programming language, and as such it is possible
69- -- to define small helper and utility functions so you don't have to repeat yourself.
70- --
71- -- In this case, we create a function that lets us more easily define mappings specific
72- -- for LSP related items. It sets the mode, buffer and description for us each time.
7362 local map = function (keys , func , desc , mode )
7463 mode = mode or ' n'
7564 vim .keymap .set (mode , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
@@ -84,18 +73,15 @@ return {
8473 map (' gra' , vim .lsp .buf .code_action , ' [G]oto Code [A]ction' , { ' n' , ' x' })
8574
8675 -- Find references for the word under your cursor.
87- -- map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
8876 map (' grr' , require (' fzf-lua' ).lsp_references , ' [G]oto [R]eferences' )
8977
9078 -- Jump to the implementation of the word under your cursor.
9179 -- Useful when your language has ways of declaring types without an actual implementation.
92- -- map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
9380 map (' gri' , require (' fzf-lua' ).lsp_implementations , ' [G]oto [I]mplementation' )
9481
9582 -- Jump to the definition of the word under your cursor.
9683 -- This is where a variable was first declared, or where a function is defined, etc.
9784 -- To jump back, press <C-t>.
98- -- map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
9985 map (' grd' , require (' fzf-lua' ).lsp_definitions , ' [G]oto [D]efinition' )
10086
10187 -- WARN: This is not Goto Definition, this is Goto Declaration.
@@ -104,18 +90,15 @@ return {
10490
10591 -- Fuzzy find all the symbols in your current document.
10692 -- Symbols are things like variables, functions, types, etc.
107- -- map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols')
10893 map (' gO' , require (' fzf-lua' ).lsp_document_symbols , ' Open Document Symbols' )
10994
11095 -- Fuzzy find all the symbols in your current workspace.
11196 -- Similar to document symbols, except searches over your entire project.
112- -- map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols')
11397 map (' gW' , require (' fzf-lua' ).lsp_workspace_symbols , ' Open Workspace Symbols' )
11498
11599 -- Jump to the type of the word under your cursor.
116100 -- Useful when you're not sure what type a variable is and you want to see
117101 -- the definition of its *type*, not where it was *defined*.
118- -- map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
119102 map (' grt' , require (' fzf-lua' ).lsp_typedefs , ' [G]oto [T]ype Definition' )
120103
121104 -- The following two autocommands are used to highlight references of the
@@ -129,7 +112,6 @@ return {
129112 group = highlight_augroup ,
130113 callback = vim .lsp .buf .document_highlight ,
131114 })
132-
133115 -- When you move your cursor, the highlights will be cleared
134116 vim .api .nvim_create_autocmd ({ ' CursorMoved' , ' CursorMovedI' }, {
135117 buffer = event .buf ,
@@ -148,7 +130,6 @@ return {
148130
149131 -- The following code creates a keymap to toggle inlay hints in your
150132 -- code, if the language server you are using supports them
151- --
152133 -- This may be unwanted, since they displace some of your code
153134 if client and client :supports_method (' textDocument/inlayHint' , event .buf ) then
154135 map (' <leader>th' , function ()
@@ -191,51 +172,33 @@ return {
191172 -- By default, Neovim doesn't support everything that is in the LSP specification.
192173 -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
193174 -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
194- -- local capabilities = require('blink.cmp').get_lsp_capabilities()
175+ local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
176+ vim .lsp .config (' *' , { capabilities = capabilities })
195177
196178 -- Add any additional override configuration in the following tables. Available keys are:
197179 -- - cmd (table): Override the default command used to start the server
198180 -- - filetypes (table): Override the default list of associated filetypes for the server
199181 -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
200182 -- - settings (table): Override the default settings passed when initializing the server.
201183 -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
184+ -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
202185 local servers = {
203186 clangd = {},
204187 gopls = {},
205188 pyright = {},
206189 rust_analyzer = {},
207- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
208190 stylua = {},
209191 lua_ls = {
210192 -- cmd = { ... },
211193 -- filetypes = { ... },
212194 -- 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 ,
195+ -- on_init = function(client)
196+ -- end,
237197 settings = {
238198 Lua = {
199+ runtime = {
200+ version = ' LuaJIT' ,
201+ },
239202 completion = {
240203 callSnippet = ' Replace' ,
241204 },
@@ -248,17 +211,13 @@ return {
248211 },
249212 },
250213 ts_ls = {},
251- -- TODO: make biome work as lsp fot ts, js, tsx, jsx files instead of ts_ls
214+ -- TODO: make biome work as lsp for ts, js, tsx, jsx files instead of ts_ls
252215 biome = {
253- -- cmd = { 'biome', 'lsp-proxy' },
254- -- root_dir = require('lspconfig').util.root_pattern('package.json', '.git'),
216+ -- cmd = { 'biome', 'lsp-proxy' },
217+ -- root_dir = require('lspconfig').util.root_pattern('package.json', '.git'),
255218 },
256219 }
257220
258- -- Ensure the servers and tools above are installed
259- -- To check the current status of installed tools and/or manually install
260- -- other tools, you can run
261- -- :Mason
262221 local ensure_installed = vim .tbl_keys (servers or {})
263222 vim .list_extend (ensure_installed , {
264223 -- add any other tools we want from mason
0 commit comments