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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- [ ] [shellcheck](https://github.com/koalaman/shellcheck)
- [ ] [stylelint](https://stylelint.io/)
- [x] [ruff](https://github.com/astral-sh/ruff)
- [ ] [typos](https://github.com/crate-ci/typos)
- [ ] [mypy](https://mypy.readthedocs.io/en/stable/index.html)
- [ ] [mypyc](https://mypyc.readthedocs.io/en/latest/index.html)
- [ ] [dmypy](https://mypy.readthedocs.io/en/stable/mypy_daemon.html)
Expand Down
1 change: 1 addition & 0 deletions lua/guard-collection/linter/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return {
shellcheck = require('guard-collection.linter.shellcheck'),
stylelint = require('guard-collection.linter.stylelint'),
ruff = require('guard-collection.linter.ruff'),
typos = require('guard-collection.linter.typos'),
mypy = require('guard-collection.linter.mypy').mypy,
mypyc = require('guard-collection.linter.mypy').mypyc,
dmypy = require('guard-collection.linter.mypy').dmypy,
Expand Down
39 changes: 39 additions & 0 deletions lua/guard-collection/linter/typos.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
local lint = require('guard.lint')
return {
cmd = 'typos',
stdin = false,
fname = true,
args = { '--format=json', '--force-exclude' },
parse = function(result, bufnr)
if result == '' then
return {}
end

local diagnostics = {}

for json in string.gmatch(result, '[%S]+') do
local item = vim.json.decode(json)

if item ~= nil and item.line_num ~= nil then
local line_num = item.line_num - 1
local corrections = table.concat(item.corrections, ' / ')

table.insert(
diagnostics,
lint.diag_fmt(
bufnr,
line_num,
item.byte_offset,
string.format('`%s` should be `%s`', item.typo, corrections),
vim.diagnostic.severity.WARN,
'[typos] ' .. item.type,
line_num,
item.byte_offset + item.type:len()
)
)
end
end

return diagnostics
end,
}
Loading