File tree Expand file tree Collapse file tree
lua/guard-collection/linter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7878- [ ] [ shellcheck] ( https://github.com/koalaman/shellcheck )
7979- [ ] [ stylelint] ( https://stylelint.io/ )
8080- [x] [ ruff] ( https://github.com/astral-sh/ruff )
81+ - [ ] [ typos] ( https://github.com/crate-ci/typos )
8182- [ ] [ mypy] ( https://mypy.readthedocs.io/en/stable/index.html )
8283- [ ] [ mypyc] ( https://mypyc.readthedocs.io/en/latest/index.html )
8384- [ ] [ dmypy] ( https://mypy.readthedocs.io/en/stable/mypy_daemon.html )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ return {
1717 shellcheck = require (' guard-collection.linter.shellcheck' ),
1818 stylelint = require (' guard-collection.linter.stylelint' ),
1919 ruff = require (' guard-collection.linter.ruff' ),
20+ typos = require (' guard-collection.linter.typos' ),
2021 mypy = require (' guard-collection.linter.mypy' ).mypy ,
2122 mypyc = require (' guard-collection.linter.mypy' ).mypyc ,
2223 dmypy = require (' guard-collection.linter.mypy' ).dmypy ,
Original file line number Diff line number Diff line change 1+ local lint = require (' guard.lint' )
2+ return {
3+ cmd = ' typos' ,
4+ stdin = false ,
5+ fname = true ,
6+ args = { ' --format=json' , ' --force-exclude' },
7+ parse = function (result , bufnr )
8+ if result == ' ' then
9+ return {}
10+ end
11+
12+ local diagnostics = {}
13+
14+ for json in string.gmatch (result , ' [%S]+' ) do
15+ local item = vim .json .decode (json )
16+
17+ if item ~= nil and item .line_num ~= nil then
18+ local line_num = item .line_num - 1
19+ local corrections = table.concat (item .corrections , ' / ' )
20+
21+ table.insert (
22+ diagnostics ,
23+ lint .diag_fmt (
24+ bufnr ,
25+ line_num ,
26+ item .byte_offset ,
27+ string.format (' `%s` should be `%s`' , item .typo , corrections ),
28+ vim .diagnostic .severity .WARN ,
29+ ' [typos] ' .. item .type ,
30+ line_num ,
31+ item .byte_offset + item .type :len ()
32+ )
33+ )
34+ end
35+ end
36+
37+ return diagnostics
38+ end ,
39+ }
You can’t perform that action at this time.
0 commit comments