diff options
author | Nick James <verbitan@users.noreply.github.com> | 2017-08-02 23:05:19 +0100 |
---|---|---|
committer | Nick James <verbitan@users.noreply.github.com> | 2017-08-02 23:05:19 +0100 |
commit | a3d2fb568897b3cb26d9c22c8d21660249facd44 (patch) | |
tree | 4da0072cfd631a23c4037bfae64f09ac85b8826f /ale_linters/tcl | |
parent | db531171acd9064f91a4f8d6c31d8037ee01e8c5 (diff) | |
download | ale-a3d2fb568897b3cb26d9c22c8d21660249facd44.zip |
Add Tcl nagelfar linter
Diffstat (limited to 'ale_linters/tcl')
-rw-r--r-- | ale_linters/tcl/nagelfar.vim | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/ale_linters/tcl/nagelfar.vim b/ale_linters/tcl/nagelfar.vim new file mode 100644 index 00000000..8b29f9ee --- /dev/null +++ b/ale_linters/tcl/nagelfar.vim @@ -0,0 +1,46 @@ +" Author: Nick James <github@nsjuk.xyz> +" Description: nagelfar linter for tcl files + +call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl') +call ale#Set('tcl_nagelfar_options', '') + +function! ale_linters#tcl#nagelfar#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'tcl_nagelfar_executable') +endfunction + +function! ale_linters#tcl#nagelfar#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options') + + return ale#Escape(ale_linters#tcl#nagelfar#GetExecutable(a:buffer)) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %s' +endfunction + +function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort + " Matches patterns like the following: + " Line 5: W Found constant "bepa" which is also a variable. + " Line 13: E Wrong number of arguments (3) to "set" + " Line 93: N Close brace not aligned with line 90 (4 0) + + let l:pattern = '^Line\s\+\([0-9]\+\): \([NEW]\) \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] ==# 'N' ? 'W' : l:match[2], + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('tcl', { +\ 'name': 'nagelfar', +\ 'output_stream': 'stdout', +\ 'executable_callback': 'ale_linters#tcl#nagelfar#GetExecutable', +\ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand', +\ 'callback': 'ale_linters#tcl#nagelfar#Handle', +\ 'lint_file': 1, +\}) |