diff options
author | Linda_pp <rhysd@users.noreply.github.com> | 2022-02-04 16:29:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 16:29:28 +0900 |
commit | 0d529d9b948d21065789c5670500cbfba5386f6f (patch) | |
tree | cc5b73feea8a88bc0c8b8a6f7e829b2f464fb29a /autoload/ale/handlers/naga.vim | |
parent | d1e2aaf85dc81bad223065eec474d9f090fec70e (diff) | |
download | ale-0d529d9b948d21065789c5670500cbfba5386f6f.zip |
Add `naga` linter for WGSL support (#4047)
* Add WGSL support using `naga` command
* Add documents for wgsl
* Add test for `naga` linter
* Separate naga handler callback to hanlder/naga.vim
Diffstat (limited to 'autoload/ale/handlers/naga.vim')
-rw-r--r-- | autoload/ale/handlers/naga.vim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/autoload/ale/handlers/naga.vim b/autoload/ale/handlers/naga.vim new file mode 100644 index 00000000..6480aba6 --- /dev/null +++ b/autoload/ale/handlers/naga.vim @@ -0,0 +1,30 @@ +" Author: rhysd <https://github.com/rhysd> +" Description: Handle errors for naga-cli. + +function! ale#handlers#naga#Handle(buffer, lines) abort + let l:errors = [] + let l:current_error = v:null + + for l:line in a:lines + if l:line =~# '^error: ' + let l:text = l:line[7:] + let l:current_error = { 'text': l:text, 'type': 'E' } + continue + endif + + if l:current_error isnot v:null + let l:matches = matchlist(l:line, '\v:(\d+):(\d+)$') + + if !empty(l:matches) + let l:current_error.lnum = str2nr(l:matches[1]) + let l:current_error.col = str2nr(l:matches[2]) + call add(l:errors, l:current_error) + let l:current_error = v:null + continue + endif + endif + endfor + + return l:errors +endfunction + |