Switch from lua_ls to emmylua_ls

This commit is contained in:
orip
2026-10-06 00:47:39 +03:00
parent 8e35dbedb7
commit 2e8d67c328
+21 -20
View File
@@ -747,33 +747,34 @@ do
stylua = {}, -- Used to format Lua code
-- Special Lua Config, as recommended by neovim help docs
lua_ls = {
emmylua_ls = {
on_init = function(client)
client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
-- If the workspace has its own emmylua_ls/lua_ls config file, defer to it.
if client.workspace_folders then
local path = client.workspace_folders[1].name
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
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.emmyrc.json') or vim.uv.fs_stat(path .. '/.luarc.json')) then
client.config.settings = {}
end
end
local current_settings = client.config.settings --[[@as lspconfig.settings.lua_ls]]
client.config.settings.Lua = vim.tbl_deep_extend('force', current_settings.Lua, {
runtime = {
version = 'LuaJIT',
path = { 'lua/?.lua', 'lua/?/init.lua' },
},
workspace = {
checkThirdParty = false,
-- NOTE: this is a lot slower and will cause issues when working on your own configuration.
-- See https://github.com/neovim/nvim-lspconfig/issues/3189
library = vim.api.nvim_get_runtime_file('', true),
},
})
end,
---@type lspconfig.settings.lua_ls
---@type lspconfig.settings.emmylua_ls
settings = {
Lua = {
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
emmylua = {
-- Tell the server which Lua you're using (usually LuaJIT, for Neovim).
runtime = { version = 'LuaJIT' },
diagnostics = {
globals = {
'vim',
-- You can add globals here to make emmylua aware of them
'MiniIcons',
},
},
-- Make the server aware of Neovim runtime files.
workspace = {
library = vim.api.nvim_get_runtime_file('', true),
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
},
},
},
},