Skip to content

Commit 501c6b5

Browse files
committed
Add require.js support
1 parent 62f843c commit 501c6b5

6 files changed

Lines changed: 146 additions & 2 deletions

File tree

autoload/jslibsyntax.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function! jslibsyntax#load(path)
1111
endif
1212
let b:javascript_libraries_syntax = 1
1313

14-
let s:libs = ['jquery', 'underscore', 'backbone', 'prelude', 'angularjs']
14+
let s:libs = ['jquery', 'underscore', 'backbone', 'prelude', 'angularjs', 'require']
1515
if !exists('g:used_javascript_libs')
1616
let g:used_javascript_libs = join(s:libs, ',')
1717
endif

autoload/syntax/require.coffee.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Vim syntax file
2+
" Language: require.js for coffee
3+
" Maintainer: othree <othree@gmail.com>
4+
" Last Change: 2013/02/24
5+
" Version: 2.1.4
6+
" URL: http://requirejs.org/
7+
8+
9+
syntax keyword coffeeRequire require requirejs containedin=ALLBUT,coffeeComment
10+
syntax match coffeeRequiredot containedin=ALLBUT,coffeeComment /\(\<require\.\|requirejs\.\)\@<=\h\w*/ contains=coffeeRequireMethods
11+
syntax keyword coffeeRequireMethods contained config
12+
13+
syntax keyword coffeeRdefine define containedin=ALLBUT,coffeeComment
14+
syntax match coffeeRdefinedot containedin=ALLBUT,coffeeComment /\(\<define\.\)\@<=\h\w*/ contains=coffeeRdefineMethods
15+
syntax keyword coffeeRdefineMethods contained amd
16+
17+
18+
" Define the default highlighting.
19+
" For version 5.7 and earlier: only when not done already
20+
" For version 5.8 and later: only when an item doesn't have highlighting yet
21+
if version >= 508 || !exists("did_lisp_syntax_inits")
22+
if version < 508
23+
let did_lisp_syntax_inits = 1
24+
command -nargs=+ HiLink hi link <args>
25+
else
26+
command -nargs=+ HiLink hi def link <args>
27+
endif
28+
29+
HiLink coffeeRequire PreProc
30+
HiLink coffeeRequireMethods PreProc
31+
HiLink coffeeRdefine PreProc
32+
HiLink coffeeRdefineMethods PreProc
33+
34+
35+
delcommand HiLink
36+
endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Vim syntax file
2+
" Language: require.js for javascript
3+
" Maintainer: othree <othree@gmail.com>
4+
" Last Change: 2013/02/24
5+
" Version: 2.1.4
6+
" URL: http://requirejs.org/
7+
8+
9+
syntax keyword javascriptRequire require requirejs containedin=ALLBUT,javascriptComment
10+
syntax match javascriptRequiredot containedin=ALLBUT,javascriptComment /\(\<require\.\|requirejs\.\)\@<=\h\w*/ contains=javascriptRequireMethods
11+
syntax keyword javascriptRequireMethods contained config
12+
13+
syntax keyword javascriptRdefine define containedin=ALLBUT,javascriptComment
14+
syntax match javascriptRdefinedot containedin=ALLBUT,javascriptComment /\(\<define\.\)\@<=\h\w*/ contains=javascriptRdefineMethods
15+
syntax keyword javascriptRdefineMethods contained amd
16+
17+
18+
" Define the default highlighting.
19+
" For version 5.7 and earlier: only when not done already
20+
" For version 5.8 and later: only when an item doesn't have highlighting yet
21+
if version >= 508 || !exists("did_lisp_syntax_inits")
22+
if version < 508
23+
let did_lisp_syntax_inits = 1
24+
command -nargs=+ HiLink hi link <args>
25+
else
26+
command -nargs=+ HiLink hi def link <args>
27+
endif
28+
29+
HiLink javascriptRequire PreProc
30+
HiLink javascriptRequireMethods PreProc
31+
HiLink javascriptRdefine PreProc
32+
HiLink javascriptRdefineMethods PreProc
33+
34+
35+
delcommand HiLink
36+
endif

autoload/syntax/require.ls.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Vim syntax file
2+
" Language: require.js for ls
3+
" Maintainer: othree <othree@gmail.com>
4+
" Last Change: 2013/02/24
5+
" Version: 2.1.4
6+
" URL: http://requirejs.org/
7+
8+
9+
syntax keyword lsRequire require requirejs containedin=ALLBUT,lsComment
10+
syntax match lsRequiredot containedin=ALLBUT,lsComment /\(\<require\.\|requirejs\.\)\@<=\h\w*/ contains=lsRequireMethods
11+
syntax keyword lsRequireMethods contained config
12+
13+
syntax keyword lsRdefine define containedin=ALLBUT,lsComment
14+
syntax match lsRdefinedot containedin=ALLBUT,lsComment /\(\<define\.\)\@<=\h\w*/ contains=lsRdefineMethods
15+
syntax keyword lsRdefineMethods contained amd
16+
17+
18+
" Define the default highlighting.
19+
" For version 5.7 and earlier: only when not done already
20+
" For version 5.8 and later: only when an item doesn't have highlighting yet
21+
if version >= 508 || !exists("did_lisp_syntax_inits")
22+
if version < 508
23+
let did_lisp_syntax_inits = 1
24+
command -nargs=+ HiLink hi link <args>
25+
else
26+
command -nargs=+ HiLink hi def link <args>
27+
endif
28+
29+
HiLink lsRequire PreProc
30+
HiLink lsRequireMethods PreProc
31+
HiLink lsRdefine PreProc
32+
HiLink lsRdefineMethods PreProc
33+
34+
35+
delcommand HiLink
36+
endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Vim syntax file
2+
" Language: require.js for typescript
3+
" Maintainer: othree <othree@gmail.com>
4+
" Last Change: 2013/02/24
5+
" Version: 2.1.4
6+
" URL: http://requirejs.org/
7+
8+
9+
syntax keyword typescriptRequire require requirejs containedin=ALLBUT,typescriptComment
10+
syntax match typescriptRequiredot containedin=ALLBUT,typescriptComment /\(\<require\.\|requirejs\.\)\@<=\h\w*/ contains=typescriptRequireMethods
11+
syntax keyword typescriptRequireMethods contained config
12+
13+
syntax keyword typescriptRdefine define containedin=ALLBUT,typescriptComment
14+
syntax match typescriptRdefinedot containedin=ALLBUT,typescriptComment /\(\<define\.\)\@<=\h\w*/ contains=typescriptRdefineMethods
15+
syntax keyword typescriptRdefineMethods contained amd
16+
17+
18+
" Define the default highlighting.
19+
" For version 5.7 and earlier: only when not done already
20+
" For version 5.8 and later: only when an item doesn't have highlighting yet
21+
if version >= 508 || !exists("did_lisp_syntax_inits")
22+
if version < 508
23+
let did_lisp_syntax_inits = 1
24+
command -nargs=+ HiLink hi link <args>
25+
else
26+
command -nargs=+ HiLink hi def link <args>
27+
endif
28+
29+
HiLink typescriptRequire PreProc
30+
HiLink typescriptRequireMethods PreProc
31+
HiLink typescriptRdefine PreProc
32+
HiLink typescriptRdefineMethods PreProc
33+
34+
35+
delcommand HiLink
36+
endif

autoload/syntax/update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
for filetype in 'coffee' 'ls' 'typescript'
33
do
4-
for lib in 'jquery' 'underscore' 'backbone' 'prelude' 'angularjs'
4+
for lib in 'jquery' 'underscore' 'backbone' 'prelude' 'angularjs' 'require'
55
do
66
sed "s/javascript/$filetype/g" $lib.javascript.vim > $lib.$filetype.vim
77
done

0 commit comments

Comments
 (0)