neovim-flake/modules/plugins/diagnostics/nvim-lint/config.nix

53 lines
1.3 KiB
Nix
Raw Permalink Normal View History

2025-02-01 07:31:29 +03:00
{
config,
lib,
...
}: let
2025-03-27 16:31:52 +01:00
inherit (lib.modules) mkIf mkMerge;
inherit (lib.generators) mkLuaInline;
2025-02-01 07:31:29 +03:00
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.diagnostics.nvim-lint;
in {
2025-03-27 16:31:52 +01:00
config = mkMerge [
(mkIf cfg.enable {
vim = {
startPlugins = ["nvim-lint"];
pluginRC.nvim-lint = entryAnywhere ''
require("lint").linters_by_ft = ${toLuaObject cfg.linters_by_ft}
2025-03-27 16:32:44 +01:00
local linters = require("lint").linters
local nvf_linters = ${toLuaObject cfg.linters}
for linter, config in pairs(nvf_linters) do
if linters[linter] == nil then
linters[linter] = config
else
for key, val in pairs(config) do
linters[linter][key] = val
end
end
end
nvf_lint = ${toLuaObject cfg.lint_function}
2025-03-27 16:31:52 +01:00
'';
};
})
(mkIf (cfg.enable && cfg.lint_after_save) {
2025-03-27 16:31:52 +01:00
vim = {
augroups = [{name = "nvf_nvim_lint";}];
autocmds = [
{
event = ["BufWritePost"];
callback = mkLuaInline ''
function(args)
nvf_lint(args.buf)
2025-03-27 16:31:52 +01:00
end
'';
}
];
};
})
];
2025-02-01 07:31:29 +03:00
}