mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-31 16:15:58 +00:00
Compare commits
No commits in common. "a3051d49aa5f32d9ceab672bad52d591b8a78a8e" and "1f8a44c4320f12c791d5eabaa3d55bff7e838ad0" have entirely different histories.
a3051d49aa
...
1f8a44c432
2 changed files with 33 additions and 39 deletions
|
|
@ -28,41 +28,6 @@ in {
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
function nvf_lint(buf)
|
||||
local ft = vim.api.nvim_get_option_value("filetype", { buf = 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 linter = linters[name]
|
||||
assert(linter, 'Linter with name `' .. name .. '` not available')
|
||||
|
||||
if type(linter) == "function" then
|
||||
linter = linter()
|
||||
end
|
||||
-- for require("lint").lint() to work, linter.name must be set
|
||||
linter.name = linter.name or name
|
||||
local cwd = linter.required_files
|
||||
|
||||
-- if no configuration files are configured, lint
|
||||
if cwd == nil then
|
||||
require("lint").lint(linter)
|
||||
else
|
||||
-- if configuration files are configured and present in the project, lint
|
||||
for _, fn in ipairs(cwd) do
|
||||
local path = vim.fs.joinpath(linter.cwd or vim.fn.getcwd(), fn);
|
||||
if vim.uv.fs_stat(path) then
|
||||
require("lint").lint(linter)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
|
@ -74,7 +39,38 @@ in {
|
|||
event = ["BufWritePost"];
|
||||
callback = mkLuaInline ''
|
||||
function(args)
|
||||
nvf_lint(args.buf)
|
||||
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 linter = linters[name]
|
||||
assert(linter, 'Linter with name `' .. name .. '` not available')
|
||||
|
||||
if type(linter) == "function" then
|
||||
linter = linter()
|
||||
end
|
||||
-- for require("lint").lint() to work, linter.name must be set
|
||||
linter.name = linter.name or name
|
||||
local cwd = linter.required_files
|
||||
|
||||
-- if no configuration files are configured, lint
|
||||
if cwd == nil then
|
||||
require("lint").lint(linter)
|
||||
else
|
||||
-- if configuration files are configured and present in the project, lint
|
||||
for _, fn in ipairs(cwd) do
|
||||
local path = vim.fs.joinpath(linter.cwd or vim.fn.getcwd(), fn);
|
||||
if vim.uv.fs_stat(path) then
|
||||
require("lint").lint(linter)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,9 +98,7 @@ builtins.mapAttrs
|
|||
Channel = getZip;
|
||||
Tarball = getUrl;
|
||||
}
|
||||
.${
|
||||
spec.type
|
||||
}
|
||||
.${spec.type}
|
||||
or (builtins.throw "Unknown source type ${spec.type}");
|
||||
in
|
||||
spec // {outPath = mayOverride (func spec);}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue