From 8375ee2766c4d69462b8c883ddf76d58a86891e4 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 29 Oct 2020 18:27:27 +0100 Subject: 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. --- autoload/ale/handlers/inko.vim | 37 +++++++++++++++++++++++++++++++++++++ autoload/ale/linter.vim | 1 + 2 files changed, 38 insertions(+) create mode 100644 autoload/ale/handlers/inko.vim (limited to 'autoload') 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 +" 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'], -- cgit v1.2.3