diff options
author | P M <10617122+pylipp@users.noreply.github.com> | 2018-04-05 21:09:41 +0200 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2018-04-05 21:09:41 +0200 |
commit | 85a2a008266f69847a3c7a9d38c16b779636ab30 (patch) | |
tree | 19504abe11cf715dadef67e613cbcb00ad604919 /ale_linters/qml | |
parent | 912f632bf591377a69bf688f6a85668d93be8841 (diff) | |
download | ale-85a2a008266f69847a3c7a9d38c16b779636ab30.zip |
Integration of qmlfmt linting tool (#1462)
* Add first qmlfmt support
* Add GetCommand() function
- pass --error/-e option
* Add handle unittest
- fix pattern regex
- store col as integer
* Update docs
* Add command callback unit test
Diffstat (limited to 'ale_linters/qml')
-rw-r--r-- | ale_linters/qml/qmlfmt.vim | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ale_linters/qml/qmlfmt.vim b/ale_linters/qml/qmlfmt.vim new file mode 100644 index 00000000..85b131fd --- /dev/null +++ b/ale_linters/qml/qmlfmt.vim @@ -0,0 +1,40 @@ +" Author: pylipp (www.github.com/pylipp) +" Description: qmlfmt for QML files + +let g:ale_qml_qmlfmt_executable = get(g:, 'ale_qml_qmlfmt_executable', 'qmlfmt') + +function! ale_linters#qml#qmlfmt#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'qml_qmlfmt_executable') +endfunction + +function! ale_linters#qml#qmlfmt#GetCommand(buffer) abort + return ale#Escape(ale_linters#qml#qmlfmt#GetExecutable(a:buffer)) + \ . ' -e' +endfunction + +" Find lines like +" Error:11:1: Expected token `}' +function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort + let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': l:match[1] is# 'Warning' ? 'W' : 'E', + \} + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('qml', { +\ 'name': 'qmlfmt', +\ 'output_stream': 'stderr', +\ 'executable_callback': 'ale_linters#qml#qmlfmt#GetExecutable', +\ 'command_callback': 'ale_linters#qml#qmlfmt#GetCommand', +\ 'callback': 'ale_linters#qml#qmlfmt#Handle', +\}) |