vis-lint

vis plugin for linting code
git clone anongit@rnpnr.xyz:vis-lint.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 40195720d82f2e4ce91a3deab0ed68756815cd20
Author: Randy Palamar
Date:   Thu, 13 Apr 2023 11:40:39 -0600

initial commit

code from a comment I left in https://github.com/martanne/vis/issues/1070

Diffstat:
ALICENSE | 15+++++++++++++++
AREADME.md | 14++++++++++++++
Avis-lint.lua | 19+++++++++++++++++++
3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,15 @@ +ISC License (ISC) + +© 2023 Randy Palamar <palamar@ualberta.ca> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md @@ -0,0 +1,14 @@ +# vis-lint + +Lint the currently open file in [Vis](https://github.com/martanne/vis) +and display the output in the message window. + +# Installation + +See [Plugins](https://github.com/martanne/vis/wiki/Plugins) on the +Vis wiki. + +# Usage +Type the following into the prompt: + + :lint diff --git a/vis-lint.lua b/vis-lint.lua @@ -0,0 +1,19 @@ +vis:command_register("lint", function() + local linters = {} + linters["bash"] = "shellcheck" + + local cmd = linters[vis.win.syntax] + if cmd == nil then + vis:info(vis.win.syntax .. ": linter not defined") + return false + end + + local file = vis.win.file + local _, ostr, estr = vis:pipe(file, {start = 0, finish = 0}, cmd .. " " .. file.name) + if estr then + vis:message(estr) + return false + end + vis:message(ostr) + return true +end, "Lint the current file and display output in the message window")