Skip to content

Commit 6ee68db

Browse files
author
othree_kao
committed
Support lib selection
1 parent 71c5de2 commit 6ee68db

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

plugin/jslsyntax.vim

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
" Vim plugin file
22
" Language: JS Lib syntax loader
33
" Maintainer: othree <othree@gmail.com>
4-
" Last Change: 2013/02/06
5-
" Version: 0.1
4+
" Last Change: 2013/02/20
5+
" Version: 0.2
66
" URL: https://github.com/othree/javascript-libraries-syntax.vim
77

88
autocmd FileType javascript call LoadLibs(expand('<sfile>:p:h'))
99
autocmd FileType coffee call LoadLibs(expand('<sfile>:p:h'))
1010
autocmd FileType ls call LoadLibs(expand('<sfile>:p:h'))
1111

1212
function! LoadLibs(path)
13-
exe('source '.a:path.'/syntax/jquery.vim')
14-
exe('source '.a:path.'/syntax/underscore.vim')
15-
exe('source '.a:path.'/syntax/backbone.vim')
16-
exe('source '.a:path.'/syntax/prelude.vim')
17-
exe('source '.a:path.'/syntax/postprocess.vim')
13+
if exists('b:javascript_libraries_syntax')
14+
return
15+
endif
16+
let b:javascript_libraries_syntax = 1
17+
18+
let libs = ['jquery', 'underscore', 'backbone', 'prelude']
19+
if !exists('g:used_javascript_libs')
20+
let g:used_javascript_libs = join(libs, ',')
21+
endif
22+
23+
let index = 0
24+
while index < len(libs)
25+
let lib = libs[index]
26+
if g:used_javascript_libs =~ lib
27+
exe('source '.a:path.'/syntax/'.lib.'.vim')
28+
endif
29+
let index = index + 1
30+
endwhile
31+
exe('source '.a:path.'/syntax/postprocess.vim')
1832
endfunction
1933

0 commit comments

Comments
 (0)