From 96a962a00d3d5dd1365bb0bc96a18b9e42945b26 Mon Sep 17 00:00:00 2001 From: xiaoshihou Date: Mon, 11 Sep 2023 19:11:18 +0800 Subject: [PATCH] chore: port codespell --- 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 bbcd664..193ebc9 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,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, +}