mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
* feat: Add Zig zlint linter and handler for ALE * docs: Add zlint documentation to ALE Zig integration guide * docs: Updating docs for zlint support * tests: Adding tests for checking zlint executable and command * refactor: Move zlint configuration test to separate test file
35 lines
1.1 KiB
VimL
35 lines
1.1 KiB
VimL
" Author: Don Isaac
|
|
" Description: A linter for the Zig programming language
|
|
|
|
call ale#Set('zig_zlint_executable', 'zlint')
|
|
|
|
function! ale_linters#zig#zlint#Handle(buffer, lines) abort
|
|
" GitHub Actions format: ::severity file=file,line=line,col=col,title=code::message
|
|
let l:pattern = '::\([a-z]\+\) file=\([^,]\+\),line=\(\d\+\),col=\(\d\+\),title=\([^:]\+\)::\(.*\)'
|
|
let l:output = []
|
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
call add(l:output, {
|
|
\ 'filename': l:match[2],
|
|
\ 'lnum': str2nr(l:match[3]),
|
|
\ 'col': str2nr(l:match[4]),
|
|
\ 'text': l:match[6],
|
|
\ 'type': l:match[1] =~? 'error\|fail' ? 'E' : 'W',
|
|
\ 'code': l:match[5],
|
|
\})
|
|
endfor
|
|
|
|
return l:output
|
|
endfunction
|
|
|
|
function! ale_linters#zig#zlint#GetCommand(buffer) abort
|
|
return ale#Escape(ale#Var(a:buffer, 'zig_zlint_executable')) . ' %s -f gh'
|
|
endfunction
|
|
|
|
call ale#linter#Define('zig', {
|
|
\ 'name': 'zlint',
|
|
\ 'executable': {b -> ale#Var(b, "zig_zlint_executable")},
|
|
\ 'command': function('ale_linters#zig#zlint#GetCommand'),
|
|
\ 'callback': 'ale_linters#zig#zlint#Handle',
|
|
\})
|