Support for 'separable:' comment in shaders
Adding '// separable: yes' in a shader's source will cause it to be checked as a separable shader.
This commit is contained in:
parent
cf1a1619fe
commit
ce57d85007
1 changed files with 19 additions and 20 deletions
|
@ -3,20 +3,10 @@ if exists("g:loaded_syntastic_glsl_driver_checker")
|
||||||
endif
|
endif
|
||||||
let g:loaded_syntastic_glsl_driver_checker = 1
|
let g:loaded_syntastic_glsl_driver_checker = 1
|
||||||
|
|
||||||
let s:glsl_extensions = {
|
|
||||||
\ 'glslf': 'f',
|
|
||||||
\ 'glslv': 'v',
|
|
||||||
\ 'frag': 'f',
|
|
||||||
\ 'vert': 'v',
|
|
||||||
\ 'geom': 'g',
|
|
||||||
\ 'fp': 'f',
|
|
||||||
\ 'vp': 'v'
|
|
||||||
\ }
|
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! SyntaxCheckers_glsl_driver_GetLocList() dict " {{{1
|
function! SyntaxCheckers_glsl_driver_GetLocList() dict
|
||||||
let makeprg = self.makeprgBuild({
|
let makeprg = self.makeprgBuild({
|
||||||
\ 'args_before': s:GetShaderType() })
|
\ 'args_before': s:GetShaderType() })
|
||||||
|
|
||||||
|
@ -29,9 +19,9 @@ function! SyntaxCheckers_glsl_driver_GetLocList() dict " {{{1
|
||||||
return SyntasticMake({
|
return SyntasticMake({
|
||||||
\ 'makeprg': makeprg,
|
\ 'makeprg': makeprg,
|
||||||
\ 'errorformat': errorformat })
|
\ 'errorformat': errorformat })
|
||||||
endfunction " }}}1
|
endfunction
|
||||||
|
|
||||||
function! s:GetShaderType() " {{{2
|
function! s:GetShaderType()
|
||||||
let save_view = winsaveview()
|
let save_view = winsaveview()
|
||||||
let old_foldenable = &foldenable
|
let old_foldenable = &foldenable
|
||||||
let old_lazyredraw = &lazyredraw
|
let old_lazyredraw = &lazyredraw
|
||||||
|
@ -40,21 +30,30 @@ function! s:GetShaderType() " {{{2
|
||||||
let &foldenable = 0
|
let &foldenable = 0
|
||||||
call cursor(1, 1)
|
call cursor(1, 1)
|
||||||
|
|
||||||
let magic = '\m\C^// type:\s*'
|
let type_magic = '\m\C^// type:\s*'
|
||||||
let line = search(magic, 'c')
|
let sep_magic = '\m\C^// separable:\s*'
|
||||||
|
let type_line = search(type_magic, 'c')
|
||||||
|
let sep_line = search(sep_magic, 'c')
|
||||||
|
|
||||||
call winrestview(save_view)
|
call winrestview(save_view)
|
||||||
let &foldenable = old_foldenable
|
let &foldenable = old_foldenable
|
||||||
let &lazyredraw = old_lazyredraw
|
let &lazyredraw = old_lazyredraw
|
||||||
|
|
||||||
if line
|
if type_line
|
||||||
let profile = matchstr(getline(line), magic . '\zs.*')
|
let profile = matchstr(getline(type_line), type_magic . '\zs.*')
|
||||||
else
|
else
|
||||||
let profile = get(s:extensions, tolower(expand('%:e', 1)), 'v')
|
let profile = 'v'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return profile
|
if sep_line
|
||||||
endfunction " }}}2
|
let separable = matchstr( getline( sep_line ) , sep_magic . '\zs.*' )
|
||||||
|
else
|
||||||
|
let separable = 'no'
|
||||||
|
endif
|
||||||
|
let separable = ( separable ==? 'yes' ) ? '/ ' : ''
|
||||||
|
|
||||||
|
return separable . profile
|
||||||
|
endfunction
|
||||||
|
|
||||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||||
\'filetype': 'glsl',
|
\'filetype': 'glsl',
|
||||||
|
|
Reference in a new issue