summaryrefslogtreecommitdiff
path: root/ale_linters/qml
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-08-02 23:44:12 +0100
committerw0rp <devw0rp@gmail.com>2018-08-02 23:44:12 +0100
commit217284360d35711b751859ed27a7a3c3da300e85 (patch)
tree4b26a84b397e3ac15a8b13a572b1f9a50312dbab /ale_linters/qml
parent9ef266d050d698c3ed3be3456ce6a5da5755d5ef (diff)
downloadale-217284360d35711b751859ed27a7a3c3da300e85.zip
Simplify the code for most linters and tests with closures
Diffstat (limited to 'ale_linters/qml')
-rw-r--r--ale_linters/qml/qmlfmt.vim33
1 files changed, 9 insertions, 24 deletions
diff --git a/ale_linters/qml/qmlfmt.vim b/ale_linters/qml/qmlfmt.vim
index 85b131fd..12f3e97b 100644
--- a/ale_linters/qml/qmlfmt.vim
+++ b/ale_linters/qml/qmlfmt.vim
@@ -1,40 +1,25 @@
" 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
+call ale#Set('qml_qmlfmt_executable', 'qmlfmt')
" 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
+ return map(ale#util#GetMatches(a:lines, l:pattern), "{
+ \ 'lnum': v:val[2] + 0,
+ \ 'col': v:val[3] + 0,
+ \ 'text': v:val[4],
+ \ 'type': v:val[1] is# 'Warning' ? 'W' : 'E',
+ \}")
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',
+\ 'executable_callback': ale#VarFunc('qml_qmlfmt_executable'),
+\ 'command': '%e -e',
\ 'callback': 'ale_linters#qml#qmlfmt#Handle',
\})