Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit c73855d

Browse files
committed
Cleanup the glsl/cgc checker.
1 parent 81bb669 commit c73855d

2 files changed

Lines changed: 35 additions & 55 deletions

File tree

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ execute their script to find them.
2828
At the time of this writing, syntax checking plugins exist for ActionScript,
2929
Ada, AppleScript, AsciiDoc, Bourne shell, C, C++, C#, Chef, CoffeeScript,
3030
Coco, Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dust, Elixir, Erlang, eRuby,
31-
Fortran, Gentoo metadata, Go, Haml, Haskell, Haxe, Handlebars, HSS, HTML,
31+
Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe, Handlebars, HSS, HTML,
3232
Java, JavaScript, JSON, LESS, Lex, Limbo, LISP, LLVM intermediate language,
3333
Lua, MATLAB, NASM, Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP,
3434
gettext Portable Object, Puppet, Python, Racket, reStructuredText, Ruby, Rust,

syntax_checkers/glsl/cgc.vim

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
"File: glsl.vim
33
"Description: Syntax checker for OpenGL Shading Language
44
"Maintainer: Joshua Rahm <[email protected]>
5-
"Notes: Add the special comment line "// profile: " somewhere in the file
6-
" Followed by what profile to use for the cgc compiler when
7-
" checking the file. The defalt behavior is to pick the profile
8-
" based on the entries of dictionary g:syntastic_glsl_extensions
9-
" or a default dictionary if that variable does not exist
10-
" Use the variable g:syntastic_glsl_extra_args to specify extra
11-
" arguments to pass to the cgc compiler
125
"License: This program is free software. It comes without any warranty,
136
" to the extent permitted by applicable law. You can redistribute
147
" it and/or modify it under the terms of the Do What The Fuck You
@@ -17,62 +10,28 @@
1710
"
1811
"============================================================================
1912

20-
2113
if exists("g:loaded_syntastic_glsl_cgc_checker")
2214
finish
2315
endif
2416

25-
let g:loaded_syntastic_glsl_cgc_checker=1
26-
27-
function! SyntaxCheckers_glsl_cgc_checker_IsAvailable() dict
28-
return executable(self.getExec());
29-
endfunction
30-
31-
function! SyntaxCheckers_glsl_cgc_checker_GetProfile()
32-
let magic = '^// profile: '
33-
let line = search( magic, 'n' )
34-
35-
if line
36-
let profile = substitute( getline(line), magic, '', '' )
37-
return profile
38-
endif
39-
40-
if exists('g:syntastic_glsl_extensions')
41-
let profiles = g:syntastic_glsl_cgc_profiles
42-
else
43-
let profiles = {
44-
\ 'glslf': 'gpu_fp',
45-
\ 'glslv': 'gpu_vp',
46-
\ 'frag': 'gpu_fp',
47-
\ 'vert': 'gpu_vp',
48-
\ 'fp': 'gpu_fp',
49-
\ 'vp': 'gpu_vp' }
50-
endif
51-
17+
let g:loaded_syntastic_glsl_cgc_checker = 1
5218

53-
let ext = expand('%:e')
54-
55-
if has_key(profiles, ext)
56-
return profiles[ext]
57-
else
58-
return 'gpu_vert'
59-
endif
60-
endfunction!
19+
let s:glsl_extensions = {
20+
\ 'glslf': 'gpu_fp',
21+
\ 'glslv': 'gpu_vp',
22+
\ 'frag': 'gpu_fp',
23+
\ 'vert': 'gpu_vp',
24+
\ 'fp': 'gpu_fp',
25+
\ 'vp': 'gpu_vp'
26+
\ }
6127

62-
function! SyntaxCheckers_glsl_cgc_GetExtraArgs()
63-
if exists('g:syntastic_glsl_extra_args')
64-
return g:syntastic_glsl_extra_args
65-
else
66-
return ''
67-
endif
68-
endfunction
28+
let s:save_cpo = &cpo
29+
set cpo&vim
6930

7031
function! SyntaxCheckers_glsl_cgc_GetLocList() dict
71-
let profile = SyntaxCheckers_glsl_cgc_checker_GetProfile()
72-
73-
let args = printf("-oglsl -profile %s %s", profile,SyntaxCheckers_glsl_cgc_GetExtraArgs())
7432
let makeprg = self.makeprgBuild({
75-
\'args': args })
33+
\ 'args': '-oglsl -profile ' . s:GetProfile() .
34+
\ (exists('g:syntastic_glsl_options') ? ' ' . g:syntastic_glsl_options : '') })
7635

7736
let errorformat =
7837
\ "%E%f(%l) : error %m," .
@@ -83,6 +42,27 @@ function! SyntaxCheckers_glsl_cgc_GetLocList() dict
8342
\ 'errorformat': errorformat })
8443
endfunction
8544

45+
function! s:GetProfile()
46+
let save_cursor = getpos('.')
47+
let magic = '\m\C^// profile:\s*'
48+
let line = search(magic, 'c')
49+
call setpos('.', save_cursor)
50+
51+
if line
52+
let profile = matchstr(getline(line), magic . '\zs.*')
53+
else
54+
let extensions = exists('g:syntastic_glsl_extensions') ? g:syntastic_glsl_extensions : s:glsl_extensions
55+
let profile = get(extensions, tolower(expand('%:e')), 'gpu_vert')
56+
endif
57+
58+
return profile
59+
endfunction!
60+
8661
call g:SyntasticRegistry.CreateAndRegisterChecker({
8762
\'filetype': 'glsl',
8863
\'name': 'cgc'})
64+
65+
let &cpo = s:save_cpo
66+
unlet s:save_cpo
67+
68+
" vim: set et sts=4 sw=4:

0 commit comments

Comments
 (0)