From bcab974cce576fd94d8fa0e07380b563e85ae270 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Wed, 12 Apr 2023 13:57:02 +0100 Subject: [PATCH] fix(vim): cspell linter will now work with newer versions There was a breaking change / bug fix to the cspell that caused the error format to change. --- site-modules/core/files/vim/plugin/lint.lua | 56 +++++++++++---------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/site-modules/core/files/vim/plugin/lint.lua b/site-modules/core/files/vim/plugin/lint.lua index e462870..8a10525 100644 --- a/site-modules/core/files/vim/plugin/lint.lua +++ b/site-modules/core/files/vim/plugin/lint.lua @@ -37,37 +37,39 @@ lint.linters.psalm = { end } -lint.linters.cspell = { - cmd = "cspell", - stdin = true, - args = { - "lint", - "--no-color", - "--no-progress", - "--no-summary", +local get_language_id = function() + local file_type = vim.api.nvim_buf_get_option(0, "filetype") + return "--language-id=" .. file_type +end + +lint.linters.cspell = { + cmd = 'cspell', + stdin = true, + ignore_exitcode = 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, - }), + get_language_id, + '--', + 'stdin' + }, + stream = 'stdout', + parser = require('lint.parser').from_errorformat('%f:%l:%c - %m', { + source = 'cspell', + severity = vim.diagnostic.severity.INFO + }) } - lint.linters_by_ft = { - php = {'phpcs'}, - typescript = {'eslint'}, - javascript = {'eslint'}, - typescriptreact = {'eslint'}, - javascriptreact = {'eslint'}, - lua = {'luacheck'}, + php = {'phpcs'}, + typescript = {'eslint'}, + javascript = {'eslint'}, + typescriptreact = {'eslint'}, + javascriptreact = {'eslint'}, + lua = {'luacheck'}, }