Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ Table format for custom tool:

#### Linter

- `clang-tidy`
- `Pylint`
- `rubocop`
- [clang-tidy](https://clang.llvm.org/extra/clang-tidy/)
- [pylint](https://github.com/PyCQA/pylint)
- [rubocop](https://github.com/rubocop/rubocop)
- [shellcheck](https://github.com/koalaman/shellcheck)

## Troubleshooting

Expand Down
37 changes: 37 additions & 0 deletions lua/guard/tools/linter/shellcheck.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local diag_fmt = require('guard.lint').diag_fmt
return {
cmd = 'shellcheck',
args = { '--format', 'json1', '--external-sources' },
stdin = true,
output_fmt = function(result, buf)
local comments = vim.json.decode(result).comments

if #comments < 1 then
return {}
end

-- https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md
-- "Valid values in order of severity are error, warning, info and style."
local severities = {
error = 1,
warning = 2,
info = 3,
style = 4
}

local diags = {}

vim.tbl_map(function(mes)
diags[#diags + 1] = diag_fmt(
buf,
tonumber(mes.line) - 1,
tonumber(mes.column) - 1,
mes.message .. ' [' .. mes.code .. ']',
severities[mes.level] or 4,
'shellcheck'
)
end, comments)

return diags
end
}