Skip to content

Commit f406e8c

Browse files
committed
highlight native array methods
1 parent 6bea14c commit f406e8c

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
vim-javascript-lib
22
==================
33

4-
This is a companion plugin of [vim-javascript](https://github.com/pangloss/vim-javascript), which provide the keyword highlight of famous js libraries. This plugin will not try to highlight every method of the libs, it only highlight most frequent used __global variables__, such as *_*, *$*, *Backbone*, because __sometimes the more you see the less you get__, we just care the most important stuff here.
4+
This is a companion plugin of [vim-javascript](https://github.com/pangloss/vim-javascript), which provide the keyword highlight of famous js libraries and start to support native methods. This plugin will not try to highlight every method of the libs, it only highlight most frequent used __global variables__, such as *_*, *$*, *Backbone*, because __sometimes the more you see the less you get__, we just care the most important stuff here.
55

66
Install
77
-------
@@ -15,6 +15,11 @@ Dependency
1515

1616
This plugin is designed to work with [vim-javascript](https://github.com/pangloss/vim-javascript), so [vim-javascript](https://github.com/pangloss/vim-javascript) is hard dependency, you must install it to make the plugin works.
1717

18+
JS native highlight
19+
-------------------
20+
21+
* Array methods
22+
1823
Libraries
1924
---------
2025

@@ -25,7 +30,7 @@ Right now the list is:
2530
* Backbone
2631
* angular
2732
* Handlebars / Mustache
28-
* jasmine
33+
* mocha
2934
* AMD
3035
* Q
3136

after/syntax/javascript.vim

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,40 @@
66
" Maintainer: crusoexia
77
" URL: https://github.com/crusoexia/vim-javascript-lib
88

9+
syntax match jsPropertyAccessExpr /\.\<[a-zA-Z_$][0-9a-zA-Z_$]*\>/ contains=jsArrayMethods
10+
11+
" Native: {{{
12+
syntax keyword jsArrayMethods length from isArray observe of concat copyWithin entries every fill filter find findIndex forEach includes indexOf join keys lastIndexOf map pop push reduce reduceRight reverse shift slice some sort splice toLocaleString toSource toString unshift values contained
13+
" }}}
14+
915
" 3rd party libraries: {{{
10-
syntax keyword jsLibrary _ underscore lodash
11-
syntax keyword jsLibrary jQuery Zepto $
12-
syntax keyword jsLibrary Backbone nextgroup=jsBBoneAccessExpr
13-
syntax keyword jsLibrary angular
14-
syntax keyword jsLibrary Handlebars Mustache
15-
syntax keyword jsLibrary jasmine
16-
syntax keyword jsLibrary Q
17-
syntax keyword jsLibrary sinon
18-
19-
syntax match jsBBoneAccessExpr /\./ contained nextgroup=jsBackboneClass
20-
syntax keyword jsBackboneClass Model View Collection Events Router History contained
21-
22-
syntax match jsJQDelimiter /\v<\$/
16+
syntax keyword jsLibrary _ underscore lodash
17+
syntax keyword jsLibrary jQuery Zepto $
18+
syntax keyword jsLibrary Backbone nextgroup=jsBBoneAccessExpr
19+
syntax keyword jsLibrary angular
20+
syntax keyword jsLibrary Handlebars Mustache
21+
syntax keyword jsLibrary jasmine
22+
syntax keyword jsLibrary Q
23+
syntax keyword jsLibrary sinon
24+
25+
syntax match jsBBoneAccessExpr /\./ contained nextgroup=jsBackboneClass
26+
syntax keyword jsBackboneClass Model View Collection Events Router History contained
27+
28+
syntax match jsJQDelimiter /\v<\$/
2329
" }}}
2430

2531
" Module: {{{
26-
syntax keyword jsInclude require
27-
syntax keyword jsDefine define exports module
28-
syntax cluster jsModule contains=jsInclude,jsDefine
32+
syntax keyword jsInclude require
33+
syntax keyword jsDefine define exports module
34+
syntax cluster jsModule contains=jsInclude,jsDefine
2935
" }}}
3036

3137
" Testing: {{{
32-
syntax keyword jsTesting describe it test before after beforeEach afterEach
38+
syntax keyword jsTesting describe it test before after beforeEach afterEach
3339
" }}}
3440

35-
" Add to [vim-javascript](https://github.com/pangloss/vim-javascript) syntax groups.
36-
syntax cluster jsExpression add=jsLibrary,jsJQDelimiter,@jsModule,jsTesting
41+
" Add to [vim-javascript](https://gi thub.com/pangloss/vim-javascript) syntax groups.
42+
syntax cluster jsExpression add=jsLibrary,jsJQDelimiter,@jsModule,jsTesting,@jsNativeMethods,jsPropertyAccessExpr
3743

3844
if version >= 508 || !exists("did_javascript_lib_syn_inits")
3945
if version < 508
@@ -49,6 +55,7 @@ if version >= 508 || !exists("did_javascript_lib_syn_inits")
4955
HiLink jsInclude Include
5056
HiLink jsDefine Define
5157
HiLink jsTesting Statement
58+
HiLink jsArrayMethods Special
5259

5360
delcommand HiLink
5461
endif

0 commit comments

Comments
 (0)