summaryrefslogtreecommitdiff
path: root/ale_linters/vala
diff options
context:
space:
mode:
authorAtsuya Takagi <asoftonight@gmail.com>2021-01-02 15:42:38 +0900
committerAtsuya Takagi <asoftonight@gmail.com>2021-01-23 00:08:01 +0900
commit4ed520a2192cfee9b93f329e46a0a57c2bd2e771 (patch)
tree5dfa11d44b60f175dcedb833e3ae847953b1c181 /ale_linters/vala
parenta1e6df987c28dd3e0efb7422f4ad85ee3bb3bebc (diff)
downloadale-4ed520a2192cfee9b93f329e46a0a57c2bd2e771.zip
add initial files
Diffstat (limited to 'ale_linters/vala')
-rw-r--r--ale_linters/vala/vala_lint.vim44
1 files changed, 44 insertions, 0 deletions
diff --git a/ale_linters/vala/vala_lint.vim b/ale_linters/vala/vala_lint.vim
new file mode 100644
index 00000000..4aad4dcd
--- /dev/null
+++ b/ale_linters/vala/vala_lint.vim
@@ -0,0 +1,44 @@
+" Author: Atsuya Takagi <asoftonight@gmail.com>
+" Description: A linter for Vala using Vala-Lint.
+
+function! ale_linters#vala#vala_lint#GetCommand(buffer) abort
+ return 'io.elementary.vala-lint'
+endfunction
+
+function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort
+ let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(\w\+\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if len(l:match) == 0
+ continue
+ endif
+
+ let l:line = l:match[1] + 0
+ let l:column = l:match[2] + 0
+ let l:type = 'E'
+ let l:text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '')
+ let l:code = l:match[5]
+
+ call add(l:output, {
+ \ 'lnum': l:line,
+ \ 'col': l:column,
+ \ 'text': l:text,
+ \ 'type': l:type,
+ \ 'code': l:code,
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('vala', {
+\ 'name': 'vala-lint',
+\ 'output_stream': 'both',
+\ 'executable': 'io.elementary.vala-lint',
+\ 'command': function('ale_linters#vala#vala_lint#GetCommand'),
+\ 'callback': 'ale_linters#vala#vala_lint#Handle',
+\ 'lint_file': 1,
+\})