Commit: ac39925d1c7a5f9f4aa2cea35585aca5042b9583
Parent: f8f490f3fe2072eb01fa545a4e9613f099665d7a
Author: Hugo O. Rivera
Date: Sun, 16 Apr 2023 09:32:49 -0600
Add fixers that could modify the file
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/init.lua b/init.lua
@@ -5,6 +5,10 @@ linters["lua"] = {"luacheck --no-color -"}
linters["man"] = {"mandoc -T lint"}
linters["python"] = {"ruff", "mypy --strict"}
+fixers = {}
+fixers["json"] = {"jq -c"}
+fixers["python"] = {"black", "isort", "ruff --fix"}
+
-- Clear vis:message window before running?
run_actions_on_file = function(action, actions, file)
local cmds = actions[vis.win.syntax]
@@ -33,3 +37,7 @@ end
vis:command_register("lint", function(argv, force, win, selection, range)
return run_actions_on_file('linters', linters, win.file)
end, "Lint the current file and display output in the message window")
+
+vis:command_register("fix", function(argv, force, win, selection, range)
+ return run_actions_on_file('fixers', fixers, win.file)
+end, "Fix the current file and display output in the message window. May modify file.")