All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 " Author: David Houston <houstdav000>
3 " Description: Define a handler function for cspell's output
5 function! ale#handlers#cspell#GetExecutable(buffer) abort
6 return ale#path#FindExecutable(a:buffer,
8 \ 'node_modules/.bin/cspell',
9 \ 'node_modules/cspell/bin.js',
14 function! ale#handlers#cspell#GetLanguageId(buffer) abort
15 let l:filetype = getbufvar(a:buffer, '&filetype')
17 if l:filetype is# 'tex'
18 " Vim's tex corresponds to latex language-id in cspell
20 elseif l:filetype is# 'plaintex'
21 " Vim's plaintex corresponds to tex language-id in cspell
24 " Fallback to filetype for everything else.
29 function! ale#handlers#cspell#GetCommand(buffer) abort
30 let l:executable = ale#handlers#cspell#GetExecutable(a:buffer)
31 let l:options = ale#Var(a:buffer, 'cspell_options')
32 let l:language_id = ale#handlers#cspell#GetLanguageId(a:buffer)
34 let l:language_id_option = empty(l:language_id) ? '' : '--language-id="' . l:language_id . '"'
36 return ale#node#Executable(a:buffer, l:executable)
37 \ . ' lint --no-color --no-progress --no-summary'
38 \ . ale#Pad(l:language_id_option)
39 \ . ale#Pad(l:options)
43 function! ale#handlers#cspell#Handle(buffer, lines) abort
44 " Look for lines like the following:
46 " /home/user/repos/ale/README.md:3:128 - Unknown word (Neovim)
49 " match3: Unknown word (Neovim)
51 let l:pattern = '\v^.*:(\d+):(\d+) - ([^\(]+\(([^\)]+)\).*)$'
54 for l:match in ale#util#GetMatches(a:lines, l:pattern)
56 \ 'lnum': l:match[1] + 0,
57 \ 'col': l:match[2] + 0,
58 \ 'end_col': l:match[2] + len(l:match[4]) - 1,
67 function! ale#handlers#cspell#DefineLinter(filetype) abort
68 call ale#Set('cspell_executable', 'cspell')
69 call ale#Set('cspell_options', '')
70 call ale#Set('cspell_use_global', get(g:, 'ale_use_global_executables', 0))
72 call ale#linter#Define(a:filetype, {
74 \ 'executable': function('ale#handlers#cspell#GetExecutable'),
75 \ 'command': function('ale#handlers#cspell#GetCommand'),
76 \ 'callback': 'ale#handlers#cspell#Handle',