44 lines
1.2 KiB
Lua
44 lines
1.2 KiB
Lua
return {
|
|
"mfussenegger/nvim-lint",
|
|
config = function()
|
|
local lint = require("lint")
|
|
|
|
lint.linters_by_ft = {
|
|
javascript = { "eslint_d" },
|
|
javascriptreact = { "eslint_d" },
|
|
typescript = { "eslint_d" },
|
|
typescriptreact = { "eslint_d" },
|
|
sh = { "shellcheck" },
|
|
nix = { "nix" },
|
|
}
|
|
|
|
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePre", "InsertLeave" }, {
|
|
callback = function()
|
|
-- check if eslint config exists
|
|
if
|
|
vim.bo.filetype == "javascript"
|
|
or vim.bo.filetype == "typescript"
|
|
or vim.bo.filetype == "typescriptreact"
|
|
or vim.bo.filetype == "javascriptreact"
|
|
then
|
|
local eslintConfigFilenames = {
|
|
"eslint.config.js",
|
|
"eslint.config.mjs",
|
|
"eslint.config.cjs",
|
|
"eslint.config.ts",
|
|
"eslint.config.mts",
|
|
"eslint.config.cts",
|
|
".eslintrc.js",
|
|
".eslintrc.json",
|
|
".eslintrc.cjs",
|
|
}
|
|
if vim.fs.root(0, eslintConfigFilenames) == nil then
|
|
return
|
|
end
|
|
end
|
|
|
|
lint.try_lint()
|
|
end,
|
|
})
|
|
end,
|
|
}
|