@@ -594,6 +594,7 @@ require('lazy').setup({
594594 -- Enable the following language servers
595595 -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
596596 -- See `:help lsp-config` for information about keys and how to configure
597+ --- @type table<string , vim.lsp.Config>
597598 local servers = {
598599 -- clangd = {},
599600 -- gopls = {},
@@ -605,6 +606,37 @@ require('lazy').setup({
605606 --
606607 -- But for many setups, the LSP (`ts_ls`) will work just fine
607608 -- ts_ls = {},
609+
610+ stylua = {}, -- Used to format Lua code
611+
612+ -- Special Lua Config, as recommended by neovim help docs
613+ lua_ls = {
614+ on_init = function (client )
615+ if client .workspace_folders then
616+ local path = client .workspace_folders [1 ].name
617+ if path ~= vim .fn .stdpath ' config' and (vim .uv .fs_stat (path .. ' /.luarc.json' ) or vim .uv .fs_stat (path .. ' /.luarc.jsonc' )) then return end
618+ end
619+
620+ client .config .settings .Lua = vim .tbl_deep_extend (' force' , client .config .settings .Lua , {
621+ runtime = {
622+ version = ' LuaJIT' ,
623+ path = { ' lua/?.lua' , ' lua/?/init.lua' },
624+ },
625+ workspace = {
626+ checkThirdParty = false ,
627+ -- NOTE: this is a lot slower and will cause issues when working on your own configuration.
628+ -- See https://github.com/neovim/nvim-lspconfig/issues/3189
629+ library = vim .tbl_extend (' force' , vim .api .nvim_get_runtime_file (' ' , true ), {
630+ ' ${3rd}/luv/library' ,
631+ ' ${3rd}/busted/library' ,
632+ }),
633+ },
634+ })
635+ end ,
636+ settings = {
637+ Lua = {},
638+ },
639+ },
608640 }
609641
610642 -- Ensure the servers and tools above are installed
@@ -616,8 +648,6 @@ require('lazy').setup({
616648 -- You can press `g?` for help in this menu.
617649 local ensure_installed = vim .tbl_keys (servers or {})
618650 vim .list_extend (ensure_installed , {
619- ' lua_ls' , -- Lua Language server
620- ' stylua' , -- Used to format Lua code
621651 -- You can add other tools here that you want Mason to install
622652 })
623653
@@ -628,33 +658,6 @@ require('lazy').setup({
628658 vim .lsp .config (name , server )
629659 vim .lsp .enable (name )
630660 end
631-
632- -- Special Lua Config, as recommended by neovim help docs
633- vim .lsp .config (' lua_ls' , {
634- on_init = function (client )
635- if client .workspace_folders then
636- local path = client .workspace_folders [1 ].name
637- if path ~= vim .fn .stdpath ' config' and (vim .uv .fs_stat (path .. ' /.luarc.json' ) or vim .uv .fs_stat (path .. ' /.luarc.jsonc' )) then return end
638- end
639-
640- client .config .settings .Lua = vim .tbl_deep_extend (' force' , client .config .settings .Lua , {
641- runtime = {
642- version = ' LuaJIT' ,
643- path = { ' lua/?.lua' , ' lua/?/init.lua' },
644- },
645- workspace = {
646- checkThirdParty = false ,
647- -- NOTE: this is a lot slower and will cause issues when working on your own configuration.
648- -- See https://github.com/neovim/nvim-lspconfig/issues/3189
649- library = vim .api .nvim_get_runtime_file (' ' , true ),
650- },
651- })
652- end ,
653- settings = {
654- Lua = {},
655- },
656- })
657- vim .lsp .enable ' lua_ls'
658661 end ,
659662 },
660663
0 commit comments