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.
1 " Author: Jake Zimmerman <jake@zimmerman.io>
2 " Description: Shared functions for SML linters
4 " The glob to use for finding the .cm file.
6 " See :help ale-sml-smlnj for more information.
7 call ale#Set('sml_smlnj_cm_file', '*.cm')
9 function! ale#handlers#sml#GetCmFile(buffer) abort
10 let l:pattern = ale#Var(a:buffer, 'sml_smlnj_cm_file')
15 for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
16 let l:results = glob(l:path . '/' . l:pattern, 0, l:as_list)
19 " If there is more than one CM file, we take the first one
20 " See :help ale-sml-smlnj for how to configure this.
21 let l:cmfile = l:results[0]
28 " Only one of smlnj or smlnj-cm can be enabled at a time.
29 function! s:GetExecutable(buffer, source) abort
30 if ale#handlers#sml#GetCmFile(a:buffer) is# ''
31 " No CM file found; only allow single-file mode to be enabled
32 if a:source is# 'smlnj-file'
34 elseif a:source is# 'smlnj-cm'
38 " Found a CM file; only allow cm-file mode to be enabled
39 if a:source is# 'smlnj-file'
41 elseif a:source is# 'smlnj-cm'
47 function! ale#handlers#sml#GetExecutableSmlnjCm(buffer) abort
48 return s:GetExecutable(a:buffer, 'smlnj-cm')
51 function! ale#handlers#sml#GetExecutableSmlnjFile(buffer) abort
52 return s:GetExecutable(a:buffer, 'smlnj-file')
55 function! ale#handlers#sml#Handle(buffer, lines) abort
56 " Try to match basic sml errors
57 " TODO(jez) We can get better errorfmt strings from Syntastic
59 let l:pattern = '^\(.*\)\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)'
60 let l:pattern2 = '^\(.*\)\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)'
63 let l:match2 = matchlist(l:line, l:pattern2)
66 if l:match2[1] =~# 'stdIn$'
67 let l:loc = {'bufnr': a:buffer}
69 let l:loc = {'filename': l:match2[1]}
72 call add(l:out, extend(l:loc, {
73 \ 'lnum': l:match2[2] + 0,
74 \ 'col' : l:match2[3] - 1,
75 \ 'text': l:match2[4],
76 \ 'type': l:match2[4] =~# '^Warning' ? 'W' : 'E',
81 let l:match = matchlist(l:line, l:pattern)
84 if l:match[1] =~# 'stdIn$'
85 let l:loc = {'bufnr': a:buffer}
87 let l:loc = {'filename': l:match[1]}
90 call add(l:out, extend(l:loc, {
91 \ 'lnum': l:match[2] + 0,
92 \ 'text': l:match[3] . ': ' . l:match[4],
93 \ 'type': l:match[3] is# 'error' ? 'E' : 'W',
102 " vim:ts=4:sts=4:sw=4