]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/glsl/glslang.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / ale_linters / glsl / glslang.vim
1 " Author: Sven-Hendrik Haase <svenstaro@gmail.com>
2 " Description: glslang-based linter for glsl files
3 "
4 " TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted,
5 " we can use stdin.
6
7 call ale#Set('glsl_glslang_executable', 'glslangValidator')
8 call ale#Set('glsl_glslang_options', '')
9
10 function! ale_linters#glsl#glslang#GetCommand(buffer) abort
11     return '%e'
12     \   . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options'))
13     \   . ' -C %t'
14 endfunction
15
16 function! ale_linters#glsl#glslang#Handle(buffer, lines) abort
17     " Matches patterns like the following:
18     "
19     " ERROR: 0:5: 'foo' : undeclared identifier
20     " or when using options like -V or -G or --target-env
21     " ERROR: filename:5: 'foo' : undeclared identifier
22     let l:pattern = '^\(.\+\): \(.\+\):\(\d\+\): \(.\+\)'
23     let l:output = []
24
25     for l:match in ale#util#GetMatches(a:lines, l:pattern)
26         call add(l:output, {
27         \   'lnum': str2nr(l:match[3]),
28         \   'col' : 0,
29         \   'text': l:match[4],
30         \   'type': l:match[1] is# 'ERROR' ? 'E' : 'W',
31         \})
32     endfor
33
34     return l:output
35 endfunction
36
37 call ale#linter#Define('glsl', {
38 \   'name': 'glslang',
39 \   'executable': {b -> ale#Var(b, 'glsl_glslang_executable')},
40 \   'command': function('ale_linters#glsl#glslang#GetCommand'),
41 \   'callback': 'ale_linters#glsl#glslang#Handle',
42 \})