mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-13 16:18:36 +00:00
Merge a436aca603
into ed31499ad6
This commit is contained in:
commit
83516d51b2
6 changed files with 71 additions and 68 deletions
|
@ -290,6 +290,7 @@
|
|||
|
||||
- `eslint_d` now checks for configuration files to load.
|
||||
- Fixed an error where `eslint_d` fails to load.
|
||||
- Added required files support for linters under `vim.diagnostics.nvim-lint.linters.*.required_files`.
|
||||
|
||||
[Sc3l3t0n](https://github.com/Sc3l3t0n):
|
||||
|
||||
|
|
|
@ -38,8 +38,29 @@ in {
|
|||
{
|
||||
event = ["BufWritePost"];
|
||||
callback = mkLuaInline ''
|
||||
function()
|
||||
require("lint").try_lint()
|
||||
function(args)
|
||||
local ft = vim.api.nvim_get_option_value("filetype", { buf = args.buf })
|
||||
local linters = require("lint").linters
|
||||
local linters_from_ft = require("lint").linters_by_ft[ft]
|
||||
|
||||
-- if no linter is configured for this filetype, stops linting
|
||||
if linters_from_ft == nil then return end
|
||||
|
||||
for _, name in ipairs(linters_from_ft) do
|
||||
local cwd = linters[name].required_files
|
||||
|
||||
-- if no configuration files are configured, lint
|
||||
if cwd == nil then
|
||||
require("lint").try_lint(name)
|
||||
else
|
||||
-- if configuration files are configured and present in the project, lint
|
||||
for _, fn in ipairs(cwd) do
|
||||
if vim.uv.fs_stat(fn) then
|
||||
require("lint").try_lint(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -69,6 +69,13 @@
|
|||
default = null;
|
||||
description = "Parser function";
|
||||
};
|
||||
|
||||
required_files = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
description = "Required files to lint";
|
||||
example = ["eslint.config.js"];
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
|
|
|
@ -53,24 +53,20 @@
|
|||
# TODO: specify packages
|
||||
defaultDiagnosticsProvider = ["eslint_d"];
|
||||
diagnosticsProviders = {
|
||||
eslint_d = {
|
||||
package = pkgs.eslint_d;
|
||||
eslint_d = let
|
||||
pkg = pkgs.eslint_d;
|
||||
in {
|
||||
package = pkg;
|
||||
config = {
|
||||
# HACK: change if nvim-lint gets a dynamic enable thing
|
||||
parser = mkLuaInline ''
|
||||
function(output, bufnr, cwd)
|
||||
local markers = { "eslint.config.js", "eslint.config.mjs",
|
||||
".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.yml", }
|
||||
for _, filename in ipairs(markers) do
|
||||
local path = vim.fs.joinpath(cwd, filename)
|
||||
if vim.loop.fs_stat(path) then
|
||||
return require("lint.linters.eslint_d").parser(output, bufnr, cwd)
|
||||
end
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
'';
|
||||
cmd = getExe pkg;
|
||||
required_files = [
|
||||
"eslint.config.js"
|
||||
"eslint.config.mjs"
|
||||
".eslintrc"
|
||||
".eslintrc.json"
|
||||
".eslintrc.js"
|
||||
".eslintrc.yml"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -153,16 +149,9 @@ in {
|
|||
vim.diagnostics.nvim-lint = {
|
||||
enable = true;
|
||||
linters_by_ft.astro = cfg.extraDiagnostics.types;
|
||||
linters = mkMerge (map (
|
||||
name: {
|
||||
${name} =
|
||||
diagnosticsProviders.${name}.config
|
||||
// {
|
||||
cmd = getExe diagnosticsProviders.${name}.package;
|
||||
};
|
||||
}
|
||||
)
|
||||
cfg.extraDiagnostics.types);
|
||||
linters =
|
||||
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
|
||||
cfg.extraDiagnostics.types);
|
||||
};
|
||||
})
|
||||
]);
|
||||
|
|
|
@ -55,21 +55,14 @@
|
|||
package = pkg;
|
||||
config = {
|
||||
cmd = getExe pkg;
|
||||
# HACK: change if nvim-lint gets a dynamic enable thing
|
||||
parser = mkLuaInline ''
|
||||
function(output, bufnr, cwd)
|
||||
local markers = { "eslint.config.js", "eslint.config.mjs",
|
||||
".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.yml", }
|
||||
for _, filename in ipairs(markers) do
|
||||
local path = vim.fs.joinpath(cwd, filename)
|
||||
if vim.loop.fs_stat(path) then
|
||||
return require("lint.linters.eslint_d").parser(output, bufnr, cwd)
|
||||
end
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
'';
|
||||
required_files = [
|
||||
"eslint.config.js"
|
||||
"eslint.config.mjs"
|
||||
".eslintrc"
|
||||
".eslintrc.json"
|
||||
".eslintrc.js"
|
||||
".eslintrc.yml"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -91,27 +91,20 @@
|
|||
# TODO: specify packages
|
||||
defaultDiagnosticsProvider = ["eslint_d"];
|
||||
diagnosticsProviders = {
|
||||
eslint_d = {
|
||||
package = pkgs.eslint_d;
|
||||
config = let
|
||||
pkg = pkgs.eslint_d;
|
||||
in {
|
||||
eslint_d = let
|
||||
pkg = pkgs.eslint_d;
|
||||
in {
|
||||
package = pkg;
|
||||
config = {
|
||||
cmd = getExe pkg;
|
||||
# HACK: change if nvim-lint gets a dynamic enable thing
|
||||
parser = mkLuaInline ''
|
||||
function(output, bufnr, cwd)
|
||||
local markers = { "eslint.config.js", "eslint.config.mjs",
|
||||
".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.yml", }
|
||||
for _, filename in ipairs(markers) do
|
||||
local path = vim.fs.joinpath(cwd, filename)
|
||||
if vim.loop.fs_stat(path) then
|
||||
return require("lint.linters.eslint_d").parser(output, bufnr, cwd)
|
||||
end
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
'';
|
||||
required_files = [
|
||||
"eslint.config.js"
|
||||
"eslint.config.mjs"
|
||||
".eslintrc"
|
||||
".eslintrc.json"
|
||||
".eslintrc.js"
|
||||
".eslintrc.yml"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -221,10 +214,9 @@ in {
|
|||
linters_by_ft.typescript = cfg.extraDiagnostics.types;
|
||||
linters_by_ft.typescriptreact = cfg.extraDiagnostics.types;
|
||||
|
||||
linters = mkMerge (map (name: {
|
||||
${name}.cmd = getExe diagnosticsProviders.${name}.package;
|
||||
})
|
||||
cfg.extraDiagnostics.types);
|
||||
linters =
|
||||
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
|
||||
cfg.extraDiagnostics.types);
|
||||
};
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue