From e93f9864b523b7be929b174e685b9c9c6e0ac0c0 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Tue, 15 Nov 2022 20:08:40 +0000 Subject: [PATCH] feat(vim): override the cspell linter for better integration This will now use a custom config file `$HOME/.cspell.json` that will use a custom dictionary for my own words. This will have things like my name so cspell stop telling me I spelt my name wrong. Will also add the `--language-id` flag with the current filetype, so it can match language specific words. --- site-modules/core/files/vim/plugin/lint.lua | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/site-modules/core/files/vim/plugin/lint.lua b/site-modules/core/files/vim/plugin/lint.lua index 6e2f20d..e462870 100644 --- a/site-modules/core/files/vim/plugin/lint.lua +++ b/site-modules/core/files/vim/plugin/lint.lua @@ -37,6 +37,30 @@ lint.linters.psalm = { end } +lint.linters.cspell = { + cmd = "cspell", + stdin = true, + args = { + "lint", + "--no-color", + "--no-progress", + "--no-summary", + "--config=" .. os.getenv("HOME") .. "/.cspell.json", + function() + local file_type = vim.api.nvim_buf_get_option(0, "filetype") + return "--language-id=" .. file_type + end, + "--", + "stdin", + }, + stream = "stdout", + parser = require("lint.parser").from_errorformat("/:%l:%c - %m", { + source = "cspell", + severity = vim.diagnostic.severity.INFO, + }), +} + + lint.linters_by_ft = { php = {'phpcs'}, typescript = {'eslint'},