mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-01 10:41:52 +00:00
nvim-lint: add lint after save autocmd
This commit is contained in:
parent
aed996eb33
commit
6e8b6bf635
2 changed files with 29 additions and 9 deletions
|
@ -3,18 +3,36 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.diagnostics.nvim-lint;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lint"];
|
||||
pluginRC.nvim-lint = entryAnywhere ''
|
||||
require("lint").linters_by_ft = ${toLuaObject cfg.linters_by_ft}
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lint"];
|
||||
pluginRC.nvim-lint = entryAnywhere ''
|
||||
require("lint").linters_by_ft = ${toLuaObject cfg.linters_by_ft}
|
||||
'';
|
||||
};
|
||||
})
|
||||
(mkIf cfg.lint_after_save {
|
||||
vim = {
|
||||
augroups = [{name = "nvf_nvim_lint";}];
|
||||
autocmds = [
|
||||
{
|
||||
event = ["BufWritePost"];
|
||||
callback = mkLuaInline ''
|
||||
function()
|
||||
require("lint").try_lint()
|
||||
end
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,5 +21,7 @@ in {
|
|||
accept.
|
||||
'';
|
||||
};
|
||||
|
||||
lint_after_save = mkEnableOption "autocmd to lint after each save" // {default = true;};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue