refactor(emmylua): centralize config in .emmyrc.json
This commit is contained in:
+10
-1
@@ -2,6 +2,15 @@
|
|||||||
"$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json",
|
"$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json",
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"version": "LuaJIT",
|
"version": "LuaJIT",
|
||||||
"requirePattern": ["lua/?.lua", "lua/?/init.lua"]
|
"requirePattern": ["lua/?.lua", "lua/?/init.lua", "test/?.lua"]
|
||||||
|
},
|
||||||
|
"diagnostics": {
|
||||||
|
"disable": ["unnecessary-if", "preferred-local-alias", "redefined-local"]
|
||||||
|
},
|
||||||
|
"workspace": {
|
||||||
|
"library": [
|
||||||
|
"/usr/share/nvim/runtime",
|
||||||
|
"/home/oscar/.local/share/nvim/site/pack/core/opt"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,6 @@
|
|||||||
return {
|
return {
|
||||||
settings = {
|
settings = {
|
||||||
emmylua = {
|
emmylua = {
|
||||||
diagnostics = {
|
|
||||||
disable = {
|
|
||||||
"unnecessary-if",
|
|
||||||
"preferred-local-alias",
|
|
||||||
"redefined-local",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
format = {
|
format = {
|
||||||
-- Re-enable once luafmt is integrated in server
|
-- Re-enable once luafmt is integrated in server
|
||||||
-- useDiff = true,
|
-- useDiff = true,
|
||||||
@@ -18,33 +11,6 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
---@param config vim.lsp.ClientConfig
|
|
||||||
before_init = function(_, config)
|
|
||||||
---@param path string|string[]
|
|
||||||
---@return string?
|
|
||||||
local function realpath(path)
|
|
||||||
---@type string?
|
|
||||||
local p
|
|
||||||
if type(path) == "table" then
|
|
||||||
p = path[1]
|
|
||||||
else
|
|
||||||
p = path
|
|
||||||
end
|
|
||||||
return p and vim.uv.fs_realpath(p) or p
|
|
||||||
end
|
|
||||||
local config_root = realpath(vim.fn.stdpath("config"))
|
|
||||||
local folder = config.workspace_folders and config.workspace_folders[1]
|
|
||||||
local root = config.root_dir or (folder and folder.name)
|
|
||||||
if root and realpath(root) == config_root then
|
|
||||||
local lib = { vim.env.VIMRUNTIME }
|
|
||||||
vim.list_extend(lib, require("pack").get_paths())
|
|
||||||
---@cast config.settings table
|
|
||||||
config.settings.emmylua =
|
|
||||||
vim.tbl_deep_extend("force", config.settings.emmylua or {}, {
|
|
||||||
workspace = { library = lib },
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_attach = function(_, bufnr)
|
on_attach = function(_, bufnr)
|
||||||
local util = require("util")
|
local util = require("util")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user