diff options
author | David Houston <houstdav000@gmail.com> | 2021-11-18 17:41:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 07:41:05 +0900 |
commit | ea643b97ab08e571a543f4bd89cd3170f3f288e2 (patch) | |
tree | f701724bf0911b445107fc5caa23d6d1503de260 /autoload | |
parent | aee0cc45bea7f190c27f0fc06f98a465ecff56fa (diff) | |
download | ale-ea643b97ab08e571a543f4bd89cd3170f3f288e2.zip |
Add cspell Linter (#3981)
* Add cspell linter
Add cspell linter, with the languages it supports.
Signed-off-by: David Houston <houstdav000@gmail.com>
* Add cspell Global Variables Documentation
Add documentation to /doc/ale.txt with cspell configuration options.
Signed-off-by: David Houston <houstdav000@gmail.com>
* Add cspell to docs, Minor Cleanup
Add cspell for each supported language, adding some spaces and removing
others when caught navigating the file.
Signed-off-by: David Houston <houstdav000@gmail.com>
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/handlers/cspell.vim | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/autoload/ale/handlers/cspell.vim b/autoload/ale/handlers/cspell.vim new file mode 100644 index 00000000..2cd02d5c --- /dev/null +++ b/autoload/ale/handlers/cspell.vim @@ -0,0 +1,54 @@ +scriptencoding utf-8 +" Author: David Houston <houstdav000> +" Description: Define a handler function for cspell's output + +function! ale#handlers#cspell#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, + \ 'cspell', [ + \ 'node_modules/.bin/cspell', + \ 'node_modules/cspell/bin.js', + \ ] + \) +endfunction + +function! ale#handlers#cspell#GetCommand(buffer) abort + let l:executable = ale#handlers#cspell#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'cspell_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . ' lint --no-color --no-progress --no-summary' + \ . ale#Pad(l:options) + \ . ' -- stdin' +endfunction + +function! ale#handlers#cspell#Handle(buffer, lines) abort + " Look for lines like the following: + " + " /home/user/repos/ale/README.md:723:48 - Unknown word (stylelint) + let l:pattern = '\v^.*:(\d+):(\d+) - (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#cspell#DefineLinter(filetype) abort + call ale#Set('cspell_executable', 'cspell') + call ale#Set('cspell_options', '') + call ale#Set('cspell_use_global', get(g:, 'ale_use_global_executables', 0)) + + call ale#linter#Define(a:filetype, { + \ 'name': 'cspell', + \ 'executable': function('ale#handlers#cspell#GetExecutable'), + \ 'command': function('ale#handlers#cspell#GetCommand'), + \ 'callback': 'ale#handlers#cspell#Handle', + \}) +endfunction |