2018-03-31 10:55:20 -04:00
|
|
|
" Author: Sven-Hendrik Haase <svenstaro@gmail.com>
|
|
|
|
" Description: glslang-based linter for glsl files
|
|
|
|
"
|
|
|
|
" TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted,
|
|
|
|
" we can use stdin.
|
|
|
|
|
2018-08-25 12:13:42 -04:00
|
|
|
call ale#Set('glsl_glslang_executable', 'glslangValidator')
|
|
|
|
call ale#Set('glsl_glslang_options', '')
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
function! ale_linters#glsl#glslang#GetCommand(buffer) abort
|
2018-08-25 12:13:42 -04:00
|
|
|
return '%e'
|
2018-07-19 08:52:53 -04:00
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options'))
|
|
|
|
\ . ' -C %t'
|
2018-03-31 10:55:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#glsl#glslang#Handle(buffer, lines) abort
|
|
|
|
" Matches patterns like the following:
|
|
|
|
"
|
|
|
|
" ERROR: 0:5: 'foo' : undeclared identifier
|
2023-08-20 10:33:32 -04:00
|
|
|
" or when using options like -V or -G or --target-env
|
|
|
|
" ERROR: filename:5: 'foo' : undeclared identifier
|
|
|
|
let l:pattern = '^\(.\+\): \(.\+\):\(\d\+\): \(.\+\)'
|
2018-03-31 10:55:20 -04:00
|
|
|
let l:output = []
|
|
|
|
|
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': str2nr(l:match[3]),
|
2023-08-20 10:33:32 -04:00
|
|
|
\ 'col' : 0,
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'text': l:match[4],
|
|
|
|
\ 'type': l:match[1] is# 'ERROR' ? 'E' : 'W',
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('glsl', {
|
|
|
|
\ 'name': 'glslang',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'glsl_glslang_executable')},
|
|
|
|
\ 'command': function('ale_linters#glsl#glslang#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale_linters#glsl#glslang#Handle',
|
|
|
|
\})
|