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.
This commit is contained in:
Yorick Peterse
2020-10-29 18:27:27 +01:00
parent 557a1ed5da
commit 8375ee2766
11 changed files with 174 additions and 0 deletions

View File

@@ -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

View File

@@ -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'],