summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorYorick Peterse <yorick@yorickpeterse.com>2020-10-29 18:27:27 +0100
committerYorick Peterse <yorick@yorickpeterse.com>2020-12-23 16:50:45 +0100
commit8375ee2766c4d69462b8c883ddf76d58a86891e4 (patch)
tree788aeba36d0c906359dd18a69225b8998bc508ec /autoload
parent557a1ed5da70cb443a8650766f4e8ea95e8c0da3 (diff)
downloadale-8375ee2766c4d69462b8c883ddf76d58a86891e4.zip
Add linter for Inko
This adds a linter for Inko (https://inko-lang.org/). The linter makes use of Inko's own compiler, and a newly introduced --check flag to only check for errors; instead of also compiling source code.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/inko.vim37
-rw-r--r--autoload/ale/linter.vim1
2 files changed, 38 insertions, 0 deletions
diff --git a/autoload/ale/handlers/inko.vim b/autoload/ale/handlers/inko.vim
new file mode 100644
index 00000000..73f06871
--- /dev/null
+++ b/autoload/ale/handlers/inko.vim
@@ -0,0 +1,37 @@
+" Author: Yorick Peterse <yorick@yorickpeterse.com>
+" Description: output handlers for the Inko JSON format
+
+function! ale#handlers#inko#GetType(severity) abort
+ if a:severity is? 'warning'
+ return 'W'
+ endif
+
+ return 'E'
+endfunction
+
+function! ale#handlers#inko#Handle(buffer, lines) abort
+ try
+ let l:errors = json_decode(join(a:lines, ''))
+ catch
+ return []
+ endtry
+
+ if empty(l:errors)
+ return []
+ endif
+
+ let l:output = []
+ let l:dir = expand('#' . a:buffer . ':p:h')
+
+ for l:error in l:errors
+ call add(l:output, {
+ \ 'filename': ale#path#GetAbsPath(l:dir, l:error['file']),
+ \ 'lnum': l:error['line'],
+ \ 'col': l:error['column'],
+ \ 'text': l:error['message'],
+ \ 'type': ale#handlers#inko#GetType(l:error['level']),
+ \})
+ endfor
+
+ return l:output
+endfunction
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 645c25f9..ba11e1eb 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -43,6 +43,7 @@ let s:default_ale_linters = {
\ 'go': ['gofmt', 'golint', 'go vet'],
\ 'hack': ['hack'],
\ 'help': [],
+\ 'inko': ['inko'],
\ 'perl': ['perlcritic'],
\ 'perl6': [],
\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'],