Add jj/kitty/nvim/opencode/paru/fish/yazi/jjui
This commit is contained in:
82
nvim/files/lsp/eslint.lua
Normal file
82
nvim/files/lsp/eslint.lua
Normal file
@@ -0,0 +1,82 @@
|
||||
return {
|
||||
cmd = { "vscode-eslint-language-server", "--stdio" },
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
"vue",
|
||||
"svelte",
|
||||
"astro",
|
||||
},
|
||||
root_dir = function(bufnr, on_dir)
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
local root = vim.fs.root(fname, {
|
||||
".eslintrc",
|
||||
".eslintrc.js",
|
||||
".eslintrc.cjs",
|
||||
".eslintrc.yaml",
|
||||
".eslintrc.yml",
|
||||
".eslintrc.json",
|
||||
"eslint.config.js",
|
||||
"eslint.config.mjs",
|
||||
"eslint.config.cjs",
|
||||
"eslint.config.ts",
|
||||
"eslint.config.mts",
|
||||
"eslint.config.cts",
|
||||
"package.json",
|
||||
})
|
||||
|
||||
-- Disable ESLint if Biome is detected
|
||||
if root then
|
||||
local biome_json = vim.fs.joinpath(root, "biome.json")
|
||||
local biome_jsonc = vim.fs.joinpath(root, "biome.jsonc")
|
||||
local has_biome = vim.fn.filereadable(biome_json) == 1 or vim.fn.filereadable(biome_jsonc) == 1
|
||||
|
||||
if has_biome then
|
||||
vim.notify("ESLint disabled - Biome detected in " .. root, vim.log.levels.INFO)
|
||||
on_dir(nil)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
on_dir(root)
|
||||
end,
|
||||
settings = {
|
||||
codeAction = {
|
||||
disableRuleComment = {
|
||||
enable = true,
|
||||
location = "separateLine",
|
||||
},
|
||||
showDocumentation = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
codeActionOnSave = {
|
||||
enable = false,
|
||||
mode = "all",
|
||||
},
|
||||
format = true,
|
||||
nodePath = "",
|
||||
onIgnoredFiles = "off",
|
||||
problems = {
|
||||
shortenToSingleLine = false,
|
||||
},
|
||||
quiet = false,
|
||||
rulesCustomizations = {},
|
||||
run = "onType",
|
||||
useESLintClass = false,
|
||||
validate = "on",
|
||||
workingDirectory = {
|
||||
mode = "location",
|
||||
},
|
||||
},
|
||||
on_attach = function(_, bufnr)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
command = "EslintFixAll",
|
||||
})
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user