From 15c99013aefa74b10db6c5be3cad80446ebd1b64 Mon Sep 17 00:00:00 2001 From: xiaoshihou514 <108414369+xiaoshihou514@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:46:52 +0800 Subject: [PATCH] chore: port codespell (#5) --- README.md | 1 + lua/guard-collection/linter/codespell.lua | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 lua/guard-collection/linter/codespell.lua diff --git a/README.md b/README.md index 6f128ef..b71a578 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ - [x] [black](https://github.com/psf/black) - [x] [cbfmt](https://github.com/lukas-reineke/cbfmt) - [x] [clang-format](https://www.kernel.org/doc/html/latest/process/clang-format.html) +- [ ] [codespell](https://github.com/codespell-project/codespell) - [ ] [djhtml](https://github.com/rtts/djhtml) - [ ] [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) - [ ] [fnlfmt](https://git.sr.ht/~technomancy/fnlfmt) diff --git a/lua/guard-collection/linter/codespell.lua b/lua/guard-collection/linter/codespell.lua new file mode 100644 index 0000000..1ccf916 --- /dev/null +++ b/lua/guard-collection/linter/codespell.lua @@ -0,0 +1,20 @@ +local lint = require('guard.lint') +return { + cmd = 'codespell', + args = { + '-', + }, + stdin = true, + parse = function(result, bufnr) + local diags = {} + local t = vim.split(result, '\n') + for i, e in ipairs(t) do + local lnum = e:match('^%d+') + if lnum then + diags[#diags + 1] = + lint.diag_fmt(bufnr, tonumber(lnum) - 1, 0, t[i + 1]:gsub('\t', ''), 2, 'codespell') + end + end + return diags + end, +}