mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-07 17:43:21 +00:00
diagnostics/nvim-lint: rough initial implementation
This commit is contained in:
parent
7d8e2f7669
commit
6b98217df8
2 changed files with 34 additions and 5 deletions
|
@ -12,9 +12,31 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lint"];
|
||||
pluginRC.nvim-lint = entryAnywhere ''
|
||||
require("lint").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
pluginRC.nvim-lint = let
|
||||
mappedLinters =
|
||||
lib.concatMapAttrsStringSep "\n" (name: value: ''
|
||||
local linter_${name} = lint.linters.${name}
|
||||
linter_${name}.args = ${toLuaObject value}
|
||||
'')
|
||||
cfg.configuredLinters;
|
||||
in
|
||||
entryAnywhere ''
|
||||
local lint = require("lint")
|
||||
${mappedLinters}
|
||||
lint.linters_by_ft = ${toLuaObject cfg.setupOpts.linters_by_ft};
|
||||
|
||||
-- TODO: one way of doing this dynamically is to use take required
|
||||
-- parameters like fts, commands, arguments and everything expected
|
||||
-- by nvim-lint to simply construct multiple autocommands. nvim-lint
|
||||
-- doesn't seem to be able to handle that by itself.
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
callback = function()
|
||||
-- try_lint without arguments runs the linters defined in `linters_by_ft`
|
||||
-- for the current filetype
|
||||
require("lint").try_lint()
|
||||
end,
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf listOf str;
|
||||
inherit (lib.types) attrsOf listOf str anything;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.diagnostics.nvim-lint = {
|
||||
enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]";
|
||||
|
||||
configuredLinters = mkOption {
|
||||
type = attrsOf anything;
|
||||
default = {};
|
||||
description = "";
|
||||
};
|
||||
|
||||
setupOpts = mkPluginSetupOption "nvim-lint" {
|
||||
linters_by_ft = mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = {};
|
||||
default = {markdown = ["value"];};
|
||||
example = {
|
||||
text = ["vale"];
|
||||
markdown = ["vale"];
|
||||
|
|
Loading…
Add table
Reference in a new issue