60 Commits

Author SHA1 Message Date
Jose Elera
7b8e2ee761 Merge pull request #85 from watagashi/avoid-recognizing-slash-in-group-as-end
Regexp: Avoid recognizing slash in group as end character
2020-09-27 12:49:44 -05:00
WADA Takashi
75338eee16 Regexp: Avoid recognizing slash in group as end character 2020-08-16 02:42:26 +09:00
Jose Elera
e65e4f01ba Update and rename README.markdown to README.md 2019-08-21 13:33:37 -05:00
Jose Elera
2af4a1bcf7 Update README 2019-08-21 13:26:27 -05:00
Jose Elera
77f90362a0 Create CODE_OF_CONDUCT.md 2019-07-22 11:25:03 -05:00
Jose Elera
63ed85b226 Create LICENSE 2019-07-22 11:23:44 -05:00
Jose Elera
9c534024e1 add JSON, fetch API and localStorage matching 2019-07-11 11:55:13 -05:00
Jose Elera
1490ec63eb change the all keyword from deprecated 2019-07-11 11:54:39 -05:00
Jose Elera
d0b26c1646 Change my name 2019-07-11 11:53:41 -05:00
Jose Elera
139ec9080f Merge pull request #80 from rachitnigam/master
Function arguments can contain comments.
2017-10-17 16:58:06 -05:00
Rachit Nigam
f054138292 Function arguments can contain comments. 2017-09-24 11:27:13 -04:00
Jose Elera
9453348768 Merge pull request #78 from sabakugaara/patch-1
add new annotation type
2017-08-11 09:27:18 -05:00
Jose Elera
9a8f9ee849 Merge pull request #79 from wpf500/wpf-const
Move const from Reserved to Identifier
2017-08-11 09:26:14 -05:00
Will Franklin
43c653074d Move const from Reserved to Identifier 2017-08-11 11:20:32 +01:00
gaara
3a1bc19fb1 add new annotation type 2017-06-08 14:16:55 +08:00
Jose Elera
490a0fbb7c Merge pull request #76 from julienw/patch-1
Add async/await keywords
2017-03-15 19:35:46 -05:00
Julien Wajsberg
9e7ccf6dbe Add async/await keywords 2017-03-15 17:38:44 +01:00
Jose Elera
6222b85824 Merge pull request #74 from acarl005/master
add `console` to globals and `from` to javaScriptSource
2016-11-14 13:38:38 -06:00
Andy
885939e965 add console to globals and from to javaScriptSource
globals and keywords that arguably could be highlighted
2016-11-14 11:15:48 -08:00
Jose Elera
9e019fccd7 Merge branch 'release/0.8.2' 2016-02-24 03:44:55 -06:00
Jose Elera
e1ac433681 Add instructions for version numbering 2016-02-24 03:42:41 -06:00
Jose Elera
783f31a8ea Bump the date and the version
This convention must be followed in order to have better documentation
and support while debugging and testing.
2016-02-24 03:35:16 -06:00
Jose Elera
747f267214 Add git-flow instructions for new commits 2016-02-24 03:29:18 -06:00
Jose Elera
7064a6e555 Merge pull request #65 from wilhelmtell/hotfix/shebang_test
shebang doesn't have to contain env
2016-02-24 03:05:29 -06:00
Matan Nassau
502218a866 shebang doesn't have to contain env 2016-02-20 18:59:10 -05:00
Jose Elera Campana
e7b2c327d4 Merge pull request #61 from reedcwilson/highlight/templatestrings
Add 'of' keyword and highlight links for template strings
2015-12-09 14:37:38 -06:00
Jose Elera Campana
b93c210c0e Merge pull request #60 from juneidysoo/master
Added @cfg tag from senchalabs/jsduck
2015-12-09 14:36:49 -06:00
Reed Wilson
180e8937f0 add 'of' keyword and highlight links for template strings 2015-12-02 16:34:38 -07:00
juneidy
18579fda9e Added @cfg tag from senchalabs/jsduck 2015-11-18 10:29:44 +08:00
Jose Elera Campana
c907b157ab Merge pull request #53 from mmwtsn/jsdoc-tags
Add complete list of JSDoc tags and synonyms
2015-07-03 11:55:54 -05:00
Jose Elera Campana
e30ebd4a0e Merge pull request #55 from larsbs/master
Added support for object keys syntax highlighting
2015-07-03 11:55:24 -05:00
Lorenzo Ruiz
539dd14378 Fixed typo 2015-07-03 14:15:01 +02:00
Lorenzo Ruiz
ed6a363cd7 Added support for object keys 2015-07-03 14:08:42 +02:00
Lorenzo Ruiz
7f04baf7be Update javascript.vim 2015-07-03 14:00:00 +02:00
M. Maxwell Watson
7614d41df9 Add complete list of alphabetized JSDoc tags 2015-06-16 23:10:51 -04:00
Jose Elera Campana
8066c375aa Merge pull request #51 from averted/es6-interpolation
Adding basic ES6 string interpolation
2015-05-14 14:03:06 -05:00
averted
92117af3bb Adding basic ES6 string interpolation 2015-05-13 16:16:47 -04:00
Jose Elera Campana
82cb62c898 Merge pull request #49 from gabesoft/master
allow multiline strings
2015-01-23 11:14:38 -06:00
Gabriel Adomnicai
9ee13d82e1 allow multiline strings 2015-01-17 18:21:35 -08:00
Jose Elera Campana
386c24a265 Merge pull request #46 from frontierpsycho/multiline-strings
Fix multiline strings.
2014-11-01 11:19:50 -05:00
NamelessOne
46e76c0ba2 Fix multiline strings. 2014-10-23 22:12:50 +02:00
Jose Elera
c4b467d1d8 Merge pull request #45 from bvalosek/master
added @tutorial tag for jsdoc3
2014-10-08 15:59:38 -05:00
Brandon Valosek
99cef7b382 added @tutorial tag 2014-10-08 14:39:06 -05:00
Jose Elera
1c0ea2481d Merge pull request #43 from hendriklammers/update-readme
Replace deprecated Bundle with Plugin in Vundle example
2014-09-02 14:10:47 -05:00
Hendrik Lammers
777312caaf Replace deprecated Bundle with Plugin 2014-09-02 14:23:33 +02:00
Jose Elera
fa7389a56b Merge pull request #42 from bvalosek/master
add support for @readonly JSDoc3 tag
2014-07-31 23:23:51 -05:00
Brandon Valosek
239388b99b add support for @readonly JSDoc3 tag 2014-07-30 15:04:45 -05:00
Jose Elera
4899b2c272 Merge pull request #38 from Fake51/master
Setting iskeyword unconditionally created issues for me
2014-01-14 19:40:34 -08:00
Peter Lind
7ef78f4a2c Explicitly setting $ as part of words for javascript, instead of assuming only php filetype should not have it 2014-01-14 22:09:26 +01:00
Jose Elera
1c08820db8 Merge pull request #36 from bvalosek/master
Added @enum, @const, @mixin, @alias for JSDoc
2013-12-23 14:28:25 -08:00
Brandon Valosek
6de2864feb @event and @fires 2013-12-18 22:19:46 -06:00
Brandon Valosek
6777b611d2 @mixes as well 2013-12-18 21:57:01 -06:00
Brandon Valosek
5be88cba5d Added @enum, @const, @mixin, @alias for JSDoc 2013-12-18 20:44:26 -06:00
Jose Elera
d3855f867a Change "syn" for "syntax", "javascript" for "javaScript"
Change is good for keeping up with uniformity
2013-12-09 13:22:09 -06:00
Jose Elera
7a607a87e2 Update README
highlights 3rd party plugins
2013-12-09 13:03:27 -06:00
Jose Elera
d6b3d6b9f3 Update README
New screenshots, add extra info about other plugins and contributions
2013-12-08 18:40:58 -06:00
Jose Elera
dbbb25a89c Merge pull request #34 from boba1l0s2k9/master
Support more JSDoc tags, inline @example highlighting
2013-12-02 20:49:28 -08:00
boba1l0s2k9
8c6cba0bd2 Added additional JSDoc 3 tags to the list that gets highlighted: @name, @memberof, @exports, @callback, @typedef, and @property. These are all documented here:
http://usejsdoc.org/#JSDoc3_Tag_Dictionary

More importantly, I added special handling for the @example tag to do syntax highlighting for code in example blocks (even though the code is technically inside a comment).
2013-12-02 14:02:37 -08:00
Jose Elera
0aeefd8035 Merge pull request #33 from tommcdo/master
Add word boundaries to "function" keyword
2013-11-13 09:01:43 -08:00
Tom McDonald
c93090a7ab Add word boundaries to "function" keyword
Fixes syntax problems when an identifier contains the word 'function'
(e.g. 'functionName').
2013-11-12 15:16:59 -05:00
6 changed files with 251 additions and 103 deletions

76
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at . All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Jose Elera
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,54 +0,0 @@
#Enhanced Javascript Syntax for Vim
###Credits
- Zhao Yi, Claudio Fleiner, Scott Shattuck (This file is based on their hard work)
- gumnos (From the #vim IRC Channel in Freenode) (Who helped me figured out the crazy Vim Regexes)
###Description
This file is a fork of [this file](http://www.vim.org/scripts/script.php?script_id=1491) and [the stock one](http://fleiner.com/vim/download.html)
This version of this file features the following text highlights:
- Parenthesis, curly and regular brackets.
- The semicolon or comma at the end of line.
- Browser, DOM and "Ajax" keywords like objects, methods, properties and others.
- Operation, comparison and logical symbols (`=`,`==`,`===`,`!=`,etc.).
To enable code folding add the following to your `.vimrc`.
au FileType javascript call JavaScriptFold()
###Note
This is a syntax plugin, not an indentation one. For indentation, this is the [recommended one](https://github.com/vim-scripts/JavaScript-Indent) by Preston Koprivica.
###Installation
- Using [NeoBundle](https://github.com/Shougo/neobundle.vim) **(Which I recommend)**
NeoBundleLazy 'jelera/vim-javascript-syntax', {'autoload':{'filetypes':['javascript']}}
- Using [Vundle](https://github.com/gmarik/vundle)
Bundle 'jelera/vim-javascript-syntax'
- Using [Pathogen](https://github.com/tpope/vim-pathogen)
$ cd ~/.vim/bundle
$ git clone https://github.com/jelera/vim-javascript-syntax.git
###TODO
You can help me improve it too.
- ~~The separate highlight of the arguments~~ Thanks to [Billychan](https://github.com/jelera/vim-javascript-syntax/commit/b03f40ff6ddf605ac146634a651632d6c1e8a50b) for this
- ~~I know this is a syntax file, but having an autocompletion file.~~ So far a better autocompletion can be achieved by [Tern for Vim](https://github.com/marijnh/tern_for_vim)
- ~~Add keywords for the popular third-party libraries like jQuery, YUI, Prototype, etc.~~ This can be done with [this repo](https://github.com/othree/javascript-libraries-syntax.vim)
###Screenshots
This is the stock Javascript syntax file
![Stock Vim Javascript syntax file](http://i.imgur.com/bfQD7.png)
This is with the Enhanced Syntax file
![Enhanced Javascript Vim syntax](http://i.imgur.com/Tezu3.png)
###License
The same as Vim

77
README.md Normal file
View File

@@ -0,0 +1,77 @@
# Enhanced JavaScript Syntax for Vim
## Credits
- Zhao Yi, Claudio Fleiner, Scott Shattuck (This file is based on their hard work)
- gumnos (From the #vim IRC Channel in Freenode) (Who helped me figured out the
crazy Vim Regexes)
## Description
This file is a fork of [this file](http://www.vim.org/scripts/script.php?script_id=1491)
and [the stock one](http://fleiner.com/vim/download.html)
This version of this file features the following text highlights:
- Parenthesis, curly and regular brackets.
- The semicolon or comma at the end of line.
- Browser, DOM and "Ajax" keywords like objects, methods, properties and others.
- Operation, comparison and logical symbols (`=`,`==`,`===`,`!=`,etc.).
- Separate highlight of the arguments. Thanks to [Billychan](https://github.com/jelera/vim-javascript-syntax/commit/b03f40ff6ddf605ac146634a651632d6c1e8a50b).
### Rationale
While there are already a few syntax files in the wild (some even forks from this project), the goal is to have a syntax file that has current keywords for modern ES/JS development and to be fairly lean and quick on loading.
## Screenshots
This is the stock Javascript syntax file
#### Solarized Light
![Stock Vim JavaScript syntax file](http://i.imgur.com/FCVLMgl.png)
This is with the Enhanced Syntax file
![Enhanced JavaScript Vim syntax](http://i.imgur.com/yGY3Cmm.png)
More screenshots [here](http://imgur.com/a/7bnu3).
#### Hybrid
![Stock Vim JavaScript syntax file](http://i.imgur.com/cGb3EjH.png)
This is with the Enhanced Syntax file
![Enhanced JavaScript Vim syntax](http://i.imgur.com/cmgdlO6.png)
## Installation
- Using [Vim-Plug](https://github.com/junegunn/vim-plug) **(Which I recommend)**,
add this line to your `.vimrc`
```vim
Plug 'jelera/vim-javascript-syntax'
```
- Using [Vundle](https://github.com/gmarik/vundle),
add this line to your `.vimrc`
```vim
Plugin 'jelera/vim-javascript-syntax'
```
- Using [Pathogen](https://github.com/tpope/vim-pathogen),
run this command in your shell
```bash
git clone https://github.com/jelera/vim-javascript-syntax.git ~/.vim/bundle/vim-javascript-syntax
```
## Suggested Companion Plugins
- **Indentation**
The recommended way is to use [Prettier](https://prettier.io/docs/en/vim.html) and [ALE](https://github.com/dense-analysis/ale).
~~It can be achieved with [Javascript-Indent](https://github.com/vim-scripts/JavaScript-Indent) by Preston Koprivica. On my testing, it has proved to be the most capable and also indents HTML and JS inside HTML.
The project is unmaintained for now, but you could fork it and improve upon it.~~
- **Autocompletion**
- [Coc.vim](https://github.com/neoclide/coc.nvim), as it supports **Language Server Protocol** as VSCode.
- [Tern for Vim](https://github.com/marijnh/tern_for_vim)
- Popular **third-party libraries support** like jQuery, YUI, Prototype, by [javascript-libraries-syntax](https://github.com/othree/javascript-libraries-syntax.vim)
## Contributions
While all contributions are always welcome, make sure your commit message follow this
[**convention**](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
## License
The same as Vim

View File

@@ -1,5 +1,5 @@
function! s:DetectJS()
if getline(1) =~# '^#!.*/bin/env\s\+node\>'
if getline(1) =~# '^#!.*/bin/\(env\s\+\)\?node\>'
setfiletype javascript
endif
endfunction

View File

@@ -1,13 +1,13 @@
" Vim syntax file
" Language: JavaScript
" Maintainer: Jose Elera Campana <https://github.com/jelera>
" Last Change: September, 17 2013
" Version: 0.8.0
" Changes: Go to https://github.com/jelera/vim-javascript-syntax for
" recent changes.
" Maintainer: Jose Elera <https://github.com/jelera>
" https://jelera.github.io
" Last Modified: Thu 11 Jul 2019 11:53:28 AM CDT
" Version: 0.8.2
" Credits: Zhao Yi, Claudio Fleiner, Scott Shattuck (This file is based
" on their hard work), gumnos (From the #vim IRC Channel in
" Freenode)
" Freenode), all the contributors at this project's github page
" (https://github.com/jelera/vim-javascript-syntax/graphs/contributors)
if !exists("main_syntax")
if version < 600
@@ -23,44 +23,41 @@ if version < 600 && exists("javaScript_fold")
unlet javaScript_fold
endif
"" dollar sign is permitted anywhere in an identifier
setlocal iskeyword+=$
"" Remove dollar sign from identifier when embedded in a PHP file
if &filetype == 'php'
setlocal iskeyword-=$
if &filetype == 'javascript'
setlocal iskeyword+=$
endif
syntax sync fromstart
"" syntax coloring for Node.js shebang line
syn match shebang "^#!.*"
syntax match shebang "^#!.*"
hi link shebang Comment
" Statement Keywords {{{
syntax keyword javaScriptSource import export
syntax keyword javaScriptIdentifier arguments this let var void yield
syntax keyword javaScriptSource import export from
syntax keyword javaScriptIdentifier arguments this let var void yield async await const
syntax keyword javaScriptOperator delete new instanceof typeof
syntax keyword javaScriptBoolean true false
syntax keyword javaScriptNull null undefined
syntax keyword javaScriptMessage alert confirm prompt status
syntax keyword javaScriptGlobal self top parent
syntax keyword javaScriptDeprecated escape unescape all applets alinkColor bgColor fgColor linkColor vlinkColor xmlEncoding
syntax keyword javaScriptDeprecated escape unescape applets alinkColor bgColor fgColor linkColor vlinkColor xmlEncoding
syntax keyword javaScriptConditional if else switch
syntax keyword javaScriptRepeat do while for in
syntax keyword javaScriptRepeat do while for in of
syntax keyword javaScriptBranch break continue
syntax keyword javaScriptLabel case default
syntax keyword javaScriptPrototype prototype
syntax keyword javaScriptStatement return with
syntax keyword javaScriptGlobalObjects Array Boolean Date Function Math Number Object RegExp String
syntax keyword javaScriptExceptions try catch throw finally Error EvalError RangeError ReferenceError SyntaxError TypeError URIError
syntax keyword javaScriptReserved abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public
syntax keyword javaScriptReserved abstract all enum int short boolean export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public
"}}}
" Comments {{{
syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
syntax keyword javaScriptCommentTodo TODO FIXME XXX TBD OPTIMIZE HACK REVIEW contained
syntax match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
syntax match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syntax region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
"}}}
" JSDoc support {{{
if !exists("javascript_ignore_javaScriptdoc")
@@ -69,9 +66,8 @@ if !exists("javascript_ignore_javaScriptdoc")
" syntax coloring for JSDoc comments (HTML)
"unlet b:current_syntax
syntax region javaScriptDocComment matchgroup=javaScriptComment start="/\*\*\s*$" end="\*/" contains=javaScriptDocTags,javaScriptCommentTodo,@javaScriptHtml,@Spell fold
syntax match javaScriptDocTags contained "@\(param\|argument\|returns\=\|requires\|exception\|throws\|type\|class\|extends\|see\|link\|member\|module\|method\|title\|namespace\|optional\|default\|base\|file\)\>" nextgroup=javaScriptDocParam,javaScriptDocSeeTag skipwhite
syntax match javaScriptDocTags contained "@\(beta\|deprecated\|description\|fileoverview\|author\|license\|version\|constructor\|private\|protected\|final\|ignore\|addon\|exec\)\>"
syntax region javaScriptDocComment matchgroup=javaScriptComment start="/\*\*\s*$" end="\*/" contains=javaScriptDocTags,javaScriptCommentTodo,@javaScriptHtml,jsInJsdocExample,@Spell fold
syntax match javaScriptDocTags contained "@\(abstract\|access\|alias\|arg\|argument\|augments\|author\|borrows\|callback\|class\|classdesc\|const\|constant\|constructor\|constructs\|copyright\|default\|defaultvalue\|deprecated\|desc\|description\|emits\|enum\|event\|example\|exception\|exports\|extends\|external\|file\|fileoverview\|fires\|func\|function\|global\|host\|ignore\|implements\|inheritdoc\|inner\|instance\|interface\|kind\|lends\|license\|link\|linkcode\|linkplain\|listens\|member\|memberof\|method\|mixes\|mixin\|module\|name\|namespace\|override\|overview\|param\|private\|prop\|property\|cfg\|protected\|public\|readonly\|requires\|return\|returns\|see\|since\|static\|summary\|this\|throws\|todo\|tutorial\|tutorial\|type\|typedef\|var\|variation\|version\|virtual\)\>" nextgroup=javaScriptDocParam,javaScriptDocSeeTag skipwhite
syntax match javaScriptDocParam contained "\%(#\|\w\|\.\|:\|\/\)\+"
syntax region javaScriptDocSeeTag contained matchgroup=javaScriptDocSeeTag start="{" end="}" contains=javaScriptDocTags
@@ -80,26 +76,37 @@ endif
syntax case match
"}}}
" Strings, Numbers and Regex Highlight {{{
syn match javaScriptSpecial "\\\d\d\d\|\\."
syn region javaScriptString start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
syn region javaScriptString start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
syntax match javaScriptSpecial "\\\d\d\d\|\\."
syntax region javaScriptString start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
syntax region javaScriptString start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
syn match javaScriptSpecialCharacter "'\\.'"
syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gim]\{0,2\}\s*$+ end=+/[gim]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
syntax match javaScriptSpecialCharacter "'\\.'"
syntax match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syntax region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\(\\\|\[[^]]*\)/+ end=+/[gim]\{0,2\}\s*$+ end=+/[gim]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
syntax match javaScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
"}}}
" DOM, Browser and Ajax Support {{{
syntax keyword javaScriptBrowserObjects window navigator screen history location
syntax keyword javaScriptBrowserObjects window navigator screen history location console
syntax keyword javaScriptDOMObjects document event HTMLElement Anchor Area Base Body Button Form Frame Frameset Image Link Meta Option Select Style Table TableCell TableRow Textarea
syntax keyword javaScriptDOMMethods createTextNode createElement insertBefore replaceChild removeChild appendChild hasChildNodes cloneNode normalize isSupported hasAttributes getAttribute setAttribute removeAttribute getAttributeNode setAttributeNode removeAttributeNode getElementsByTagName hasAttribute getElementById adoptNode close compareDocumentPosition createAttribute createCDATASection createComment createDocumentFragment createElementNS createEvent createExpression createNSResolver createProcessingInstruction createRange createTreeWalker elementFromPoint evaluate getBoxObjectFor getElementsByClassName getSelection getUserData hasFocus importNode
syntax keyword javaScriptDOMProperties nodeName nodeValue nodeType parentNode childNodes firstChild lastChild previousSibling nextSibling attributes ownerDocument namespaceURI prefix localName tagName
syntax keyword javaScriptLocalStorageObjects localStorage
syntax keyword javaScriptLocalStorageMethods setItem getItem removeItem
syntax keyword javaScriptAjaxObjects XMLHttpRequest
syntax keyword javaScriptAjaxProperties readyState responseText responseXML statusText
syntax keyword javaScriptAjaxMethods onreadystatechange abort getAllResponseHeaders getResponseHeader open send setRequestHeader
syntax keyword javaScriptFetchAPIObjects Response Promise
syntax keyword javaScriptFetchAPIMethods fetch then response clone redirect arrayBuffer blob formData allSettled race reject resolve
syntax keyword javaScriptFetchAPIProperties headers ok redirected url useFinalURL bodyUsed
syntax keyword javaScriptJSONObject JSON
syntax keyword javaScriptJSONMethods json stringify parse
syntax keyword javaScriptPropietaryObjects ActiveXObject
syntax keyword javaScriptPropietaryMethods attachEvent detachEvent cancelBubble returnValue
@@ -116,7 +123,7 @@ syntax keyword javaScriptEventListenerMethods scrollIntoView addEventListen
syntax keyword javaScriptWebAPI Element ElementTraversal Entity EntityReference Entry EntrySync ErrorEvent Event EventListener EventSource EventTarget Extensions File FileEntry FileEntrySync FileError FileException FileList FileReader FileSystem FileSystemSync Float32Array Float64Array FMRadio FocusEvent FormData GainNode Geolocation History
syntax keyword javaScriptWebAPI HTMLAnchorElement HTMLAreaElement HTMLAudioElement HTMLBaseElement HTMLBaseFontElement HTMLBodyElement HTMLBRElement HTMLButtonElement HTMLCanvasElement HTMLCollection HTMLDataElement HTMLDataListElement HTMLDivElement HTMLDListElement HTMLDocument HTMLElement HTMLEmbedElement HTMLFieldSetElement HTMLFormControlsCollection HTMLFormElement HTMLHeadElement HTMLHeadingElement HTMLHRElement HTMLHtmlElement HTMLIFrameElement HTMLImageElement HTMLInputElement HTMLIsIndexElement HTMLKeygenElement HTMLLabelElement HTMLLegendElement HTMLLIElement HTMLLinkElement HTMLMapElement HTMLMediaElement HTMLMetaElement HTMLMeterElement HTMLModElement HTMLObjectElement HTMLOListElement HTMLOptGroupElement HTMLOptionElement HTMLOptionsCollection HTMLOutputElement HTMLParagraphElement HTMLParamElement HTMLPreElement HTMLProgressElement HTMLQuoteElement HTMLScriptElement HTMLSelectElement HTMLSourceElement HTMLSpanElement HTMLStyleElement HTMLTableCaptionElement HTMLTableCellElement HTMLTableColElement HTMLTableElement HTMLTableRowElement HTMLTableSectionElement HTMLTextAreaElement HTMLTimeElement HTMLTitleElement HTMLTrackElement HTMLUListElement HTMLUnknownElement HTMLVideoElement
syntax keyword javaScriptWebAPI IDBCursor IDBCursorWithValue IDBDatabase IDBDatabaseException IDBEnvironment IDBFactory IDBIndex IDBKeyRange IDBObjectStore IDBOpenDBRequest IDBRequest IDBTransaction IDBVersionChangeEvent ImageData Int16Array Int32Array Int8Array KeyboardEvent LinkStyle LocalFileSystem LocalFileSystemSync Location MediaQueryList MediaQueryListListener MediaSource MediaStream MediaStreamTrack MessageEvent MouseEvent MouseScrollEvent MouseWheelEvent MozActivity MozActivityOptions MozActivityRequestHandler MozAlarmsManager MozContact MozContactChangeEvent MozIccManager MozMmsEvent MozMmsMessage MozMobileCellInfo MozMobileCFInfo MozMobileConnection MozMobileConnectionInfo MozMobileICCInfo MozMobileMessageManager MozMobileMessageThread MozMobileNetworkInfo MozNetworkStats MozNetworkStatsData MozNetworkStatsManager MozSettingsEvent MozSmsEvent MozSmsFilter MozSmsManager MozSmsMessage MozSmsSegmentInfo MozTimeManager MozWifiConnectionInfoEvent MutationObserver
syntax keyword javaScriptWebAPI NamedNodeMap NameList Navigator NavigatorGeolocation NavigatorID NavigatorLanguage NavigatorOnLine NavigatorPlugins NetworkInformation Node NodeFilter NodeIterator NodeList Notation Notification NotifyAudioAvailableEvent OfflineAudioCompletionEvent OfflineAudioContext PannerNode ParentNode Performance PerformanceNavigation PerformanceTiming Plugin PluginArray Position PositionError PositionOptions PowerManager ProcessingInstruction ProgressEvent Promise PromiseResolver PushManager
syntax keyword javaScriptWebAPI NamedNodeMap NameList Navigator NavigatorGeolocation NavigatorID NavigatorLanguage NavigatorOnLine NavigatorPlugins NetworkInformation Node NodeFilter NodeIterator NodeList Notation Notification NotifyAudioAvailableEvent OfflineAudioCompletionEvent OfflineAudioContext PannerNode ParentNode Performance PerformanceNavigation PerformanceTiming Plugin PluginArray Position PositionError PositionOptions PowerManager ProcessingInstruction ProgressEvent PromiseResolver PushManager
syntax keyword javaScriptWebAPI Range ScriptProcessorNode Selection SettingsLock SettingsManager SharedWorker StyleSheet StyleSheetList SVGAElement SVGAngle SVGAnimateColorElement SVGAnimatedAngle SVGAnimatedBoolean SVGAnimatedEnumeration SVGAnimatedInteger SVGAnimatedLengthList SVGAnimatedNumber SVGAnimatedNumberList SVGAnimatedPoints SVGAnimatedPreserveAspectRatio SVGAnimatedRect SVGAnimatedString SVGAnimatedTransformList SVGAnimateElement SVGAnimateMotionElement SVGAnimateTransformElement SVGAnimationElement SVGCircleElement SVGClipPathElement SVGCursorElement SVGDefsElement SVGDescElement SVGElement SVGEllipseElement SVGFilterElement SVGFontElement SVGFontFaceElement SVGFontFaceFormatElement SVGFontFaceNameElement SVGFontFaceSrcElement SVGFontFaceUriElement
syntax keyword javaScriptWebAPI SVGForeignObjectElement SVGGElement SVGGlyphElement SVGGradientElement SVGHKernElement SVGImageElement SVGLength SVGLengthList SVGLinearGradientElement SVGLineElement SVGMaskElement SVGMatrix SVGMissingGlyphElement SVGMPathElement SVGNumber SVGNumberList SVGPathElement SVGPatternElement SVGPolygonElement SVGPolylineElement SVGPreserveAspectRatio SVGRadialGradientElement SVGRect SVGRectElement SVGScriptElement SVGSetElement SVGStopElement SVGStringList SVGStylable SVGStyleElement SVGSVGElement SVGSwitchElement SVGSymbolElement SVGTests SVGTextElement SVGTextPositioningElement SVGTitleElement SVGTransform SVGTransformable SVGTransformList SVGTRefElement SVGTSpanElement SVGUseElement SVGViewElement SVGVKernElement TCPSocket Telephony TelephonyCall Text TextDecoder TextEncoder TextMetrics TimeRanges Touch TouchEvent TouchList Transferable TransitionEvent TreeWalker TypeInfo UIEvent Uint16Array Uint32Array Uint8Array Uint8ClampedArray URL URLUtils URLUtilsReadOnly
" }}}
@@ -172,25 +179,32 @@ endif
"}}}
" Function and arguments highlighting {{{
syntax keyword javaScriptFuncKeyword function contained
syntax region javascriptFuncExp start=/\w\+\s\==\s\=function/ end="\([^)]*\)" contains=javascriptFuncEq,javascriptFuncKeyword,javascriptFuncArg keepend
syntax match javaScriptFuncArg "\(([^()]*)\)" contains=javaScriptParens,javaScriptFuncComma contained
syntax region javaScriptFuncExp start=/\w\+\s\==\s\=function\>/ end="\([^)]*\)" contains=javaScriptFuncEq,javaScriptFuncKeyword,javaScriptFuncArg keepend
syntax match javaScriptFuncArg "\(([^()]*)\)" contains=javaScriptParens,javaScriptFuncComma,javaScriptComment contained
syntax match javaScriptFuncComma /,/ contained
syntax match javascriptFuncEq /=/ contained
syntax region javaScriptFuncDef start="function" end="\([^)]*\)" contains=javaScriptFuncKeyword,javaScriptFuncArg keepend
syntax match javaScriptFuncEq /=/ contained
syntax region javaScriptFuncDef start="\<function\>" end="\([^)]*\)" contains=javaScriptFuncKeyword,javaScriptFuncArg keepend
syntax match javaScriptObjectKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\)\@=/ contains=javaScriptFunctionKey
syntax match javaScriptFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function\s*\)\@=/ contained
"}}}
" Braces, Parens, symbols, colons {{{
syn match javaScriptBraces "[{}\[\]]"
syn match javaScriptParens "[()]"
syn match javaScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-="
syn match javaScriptEndColons "[;,]"
syn match javaScriptLogicSymbols "\(&&\)\|\(||\)"
syntax match javaScriptBraces "[{}\[\]]"
syntax match javaScriptParens "[()]"
syntax match javaScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-="
syntax match javaScriptEndColons "[;,]"
syntax match javaScriptLogicSymbols "\(&&\)\|\(||\)"
"}}}
" ES6 String Interpolation {{{
syntax match javaScriptTemplateDelim "\${\|}" contained
syntax region javaScriptTemplateVar start=+${+ end=+}+ contains=javaScriptTemplateDelim keepend
syntax region javaScriptTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=javaScriptTemplateVar,javaScriptSpecial keepend
"}}}
" JavaScriptFold Function {{{
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
syntax region foldBraces start=/{/ end=/}/ transparent fold keepend extend
endfunction
" }}}
@@ -210,6 +224,7 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink javaScriptLogicSymbols Boolean
HiLink javaScriptBraces Function
HiLink javaScriptParens Operator
HiLink javaScriptTemplateDelim Operator
HiLink javaScriptComment Comment
HiLink javaScriptLineComment Comment
@@ -222,6 +237,7 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink javaScriptString String
HiLink javaScriptRegexpString String
HiLink javaScriptTemplateString String
HiLink javaScriptNumber Number
HiLink javaScriptFloat Number
@@ -266,6 +282,16 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink javaScriptBrowserObjects Constant
HiLink javaScriptLocalStorageObjects Constant
HiLink javaScriptLocalStorageMethods Type
HiLink javaScriptFetchAPIObjects Constant
HiLink javaScriptFetchAPIMethods Type
HiLink javaScriptFetchAPIProperties Label
HiLink javaScriptJSONObject Constant
HiLink javaScriptJSONMethods Type
HiLink javaScriptDOMObjects Constant
HiLink javaScriptDOMMethods Type
HiLink javaScriptDOMProperties Label
@@ -276,10 +302,10 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink javaScriptFuncKeyword Function
HiLink javaScriptFuncDef PreProc
HiLink javascriptFuncExp Title
HiLink javaScriptFuncExp Title
HiLink javaScriptFuncArg Special
HiLink javascriptFuncComma Operator
HiLink javascriptFuncEq Operator
HiLink javaScriptFuncComma Operator
HiLink javaScriptFuncEq Operator
HiLink javaScriptHtmlEvents Constant
HiLink javaScriptHtmlElemProperties Label
@@ -302,3 +328,5 @@ let b:current_syntax = "javascript"
if main_syntax == 'javascript'
unlet main_syntax
endif
syntax region jsInJsdocExample matchgroup=Snip start="^\s*\* @example" end="\(^\s*\* [^[:space:]]\)\@=" containedin=@javaScriptComment contains=@javaScriptAll
hi link Snip SpecialComment