refactor: address emmylua diagnostics

This commit is contained in:
2026-04-20 22:11:18 +02:00
parent 516b9ea749
commit c7dd083083
29 changed files with 542 additions and 532 deletions
+42 -12
View File
@@ -1,5 +1,3 @@
local lsp = require("lsp")
local lua_library_paths = { vim.env.VIMRUNTIME }
vim.list_extend(lua_library_paths, require("pack").get_paths())
@@ -7,17 +5,17 @@ vim.list_extend(lua_library_paths, require("pack").get_paths())
return {
settings = {
emmylua = {
format = {
useDiff = true,
externalTool = {
program = "luafmt",
args = {
"--stdin",
"--level=lua-jit",
"--config=.luafmt.toml",
}
diagnostics = {
disable = {
"unnecessary-if",
"preferred-local-alias",
"redefined-local",
},
},
format = {
-- Re-enable once luafmt is integrated in server
-- useDiff = true,
},
runtime = {
version = "LuaJIT",
requirePattern = {
@@ -33,5 +31,37 @@ return {
},
}
},
on_attach = lsp.on_attach,
on_attach = function(_, bufnr)
local util = require("util")
vim.keymap.set("n", "<leader>lf", function()
util.format({
buf = bufnr,
cmd = {
"stylua",
"--stdin-filepath",
"%file%",
"-",
},
output = "stdout",
})
end, { buffer = bufnr })
vim.keymap.set("x", "<leader>lf", function()
util.format({
buf = bufnr,
cmd = {
"stylua",
"--range-start",
"%byte_start%",
"--range-end",
"%byte_end%",
"--stdin-filepath",
"%file%",
"-",
},
output = "stdout",
})
end, { buffer = bufnr })
end,
}