From 6f6d866362c74ec2eb036c32b56fac50b02af669 Mon Sep 17 00:00:00 2001 From: Dante Criscio <91035779+dante0624@users.noreply.github.com> Date: Thu, 22 Feb 2024 05:08:02 -0500 Subject: [PATCH] Add htmlhint (simple html linter) (#491) --- README.md | 2 ++ lua/lint/linters/htmlhint.lua | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lua/lint/linters/htmlhint.lua diff --git a/README.md b/README.md index 73a6799d..c3c3e78a 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ Other dedicated linters that are built-in are: | [DirectX Shader Compiler][dxc] | `dxc` | | [hadolint][28] | `hadolint` | | [hlint][32] | `hlint` | +| [htmlhint][htmlhint] | `htmlhint` | | [HTML Tidy][12] | `tidy` | | [Inko][17] | `inko` | | [janet][janet] | `janet` | @@ -495,3 +496,4 @@ busted tests/ [regal]: https://github.com/StyraInc/regal [vala-lint]: https://github.com/vala-lang/vala-lint [systemdlint]: https://github.com/priv-kweihmann/systemdlint +[htmlhint]: https://htmlhint.com/ diff --git a/lua/lint/linters/htmlhint.lua b/lua/lint/linters/htmlhint.lua new file mode 100644 index 00000000..5d425fe8 --- /dev/null +++ b/lua/lint/linters/htmlhint.lua @@ -0,0 +1,24 @@ +local pattern = '.*: line (%d+), col (%d+), (%a+) %- (.+) %((.+)%)' +local groups = { 'lnum', 'col', 'severity', 'message', 'code' } +local severities = { + error = vim.diagnostic.severity.ERROR, + warning = vim.diagnostic.severity.WARN, +} + +return { + cmd = "htmlhint", + stdin = true, + args = { + "stdin", + "-f", + "compact", + }, + stream = "stdout", + ignore_exitcode = true, + parser = require('lint.parser').from_pattern( + pattern, + groups, + severities, + { source = "htmlhint" } + ) +}