Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb445ca
commit f7476bd
Showing
16 changed files
with
462 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## vim es6 :dancer: | ||
|
||
> Write JavaScript ES6 easily with vim. | ||
![](https://raw.githubusercontent.com/isRuslan/vim-es6/master/sample.gif) | ||
|
||
## Install | ||
|
||
> You need [SnipMate](https://github.com/garbas/vim-snipmate) installed. | ||
To install using [Vundle](https://github.com/gmarik/vundle): | ||
|
||
" add this line to your .vimrc file | ||
Plugin 'isRuslan/vim-es6' | ||
|
||
To install using pathogen.vim: | ||
|
||
cd ~/.vim/bundle | ||
git clone https://github.com/isRuslan/vim-es6.git | ||
|
||
To manual install [download](https://github.com/isRuslan/vim-es6/releases) zip file: | ||
|
||
cd ~/.vim | ||
unzip vim-es6.zip | ||
|
||
|
||
To checkout the source from repository: | ||
|
||
cd ~/.vim/bundle | ||
git clone https://github.com/isRuslan/vim-es6.git | ||
|
||
## Snippets list | ||
| Trigger | Result | | ||
| -------: | ------- | | ||
| `gfn→` | `function* name (arg) { yield arg; },` | | ||
| `=>→` | `(arg) => { ... },` | | ||
| `class→` | `class name { constructor () { ...} }` | | ||
| `forof→` | `for (let value of arr) { ... }` | | ||
| `im→` | `import lib from 'Library'` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
" this is well known Filename found in snipmate (and the other engines), but | ||
" rewritten and documented :) | ||
" | ||
" optional arg1: string in which to replace '$1' by filename with extension | ||
" and path dropped. Defaults to $1 | ||
" optional arg2: return this value if buffer has no filename | ||
" But why not use the template in this case, too? | ||
" Doesn't make sense to me | ||
fun! vim_snippets#Filename(...) | ||
let template = get(a:000, 0, "$1") | ||
let arg2 = get(a:000, 1, "") | ||
|
||
let basename = expand('%:t:r') | ||
|
||
if basename == '' | ||
return arg2 | ||
else | ||
return substitute(template, '$1', basename, 'g') | ||
endif | ||
endf | ||
|
||
" original code: | ||
" fun! Filename(...) | ||
" let filename = expand('%:t:r') | ||
" if filename == '' | return a:0 == 2 ? a:2 : '' | endif | ||
" return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g') | ||
" endf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import exp, {pi, e} from "lib/mathplusplus"; | ||
|
||
export default class SkinnedMesh extends THREE.Mesh { | ||
constructor(geometry, materials) { | ||
super(geometry, materials); | ||
|
||
this.idMatrix = SkinnedMesh.defaultMatrix(); | ||
} | ||
update(camera) { | ||
//... | ||
super.update(); | ||
} | ||
static defaultMatrix() { | ||
return new THREE.Matrix4(); | ||
} | ||
} | ||
|
||
nums.forEach(v => { | ||
if (v % 5 === 0) | ||
fives.push(v); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
" set all `es6` extensions to javascript | ||
au BufRead,BufNewFile *.{es6,es6.js} filetype=javascript |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Welcome to the Javascript ES6 snippets! | ||
|
||
# Generator function | ||
snippet gfn | ||
function* ${1:name}(${2}) { | ||
yield ${3}; | ||
} | ||
|
||
# Arrow function | ||
snippet => | ||
(${1}) => { | ||
${2} | ||
} | ||
|
||
# Class | ||
snippet class | ||
class ${1:name} { | ||
constructor (${2:arg}) { | ||
${3:// init} | ||
} | ||
${4} | ||
} | ||
|
||
# For of loop | ||
snippet forof | ||
for (let ${1:s} of ${2:sequence}) { | ||
${3} | ||
} | ||
|
||
# Import | ||
snippet im | ||
import ${1:foo} from "${2:bar}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
" Vim syntax file | ||
" Language: JavaScript | ||
" Maintainer: Ruslan Ismagilov <https://github.com/isRuslan> | ||
" Version: 1.0.0 | ||
" Credits: Kao Wei-Ko(othree), Zhao Yi, Claudio Fleiner, Scott Shattuck | ||
" (This file is based on their hard work) | ||
|
||
if !exists("main_syntax") | ||
if version < 600 | ||
syntax clear | ||
elseif exists("b:current_syntax") | ||
finish | ||
endif | ||
let main_syntax = 'javascript' | ||
endif | ||
|
||
" Drop fold if it set but vim doesn't support it. | ||
if version < 600 && exists("javaScript_fold") | ||
unlet javaScript_fold | ||
endif | ||
|
||
syntax sync fromstart | ||
|
||
"" syntax coloring shebang line | ||
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 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 javaScriptConditional if else switch | ||
syntax keyword javaScriptRepeat do while for in | ||
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 | ||
|
||
" Comments | ||
syntax keyword javaScriptCommentTodo TODO FIXME XXX TBD contained | ||
syntax match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo | ||
syntax match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" | ||
syntax region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo | ||
|
||
" Strings, Numbers and Regex Highlight | ||
syntax match javaScriptSpecial "\\\d\d\d\|\\." | ||
syntax region javaScriptString start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc | ||
syntax region javaScriptString start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc | ||
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\+\)\=\>/ | ||
|
||
" Code blocks" | ||
syntax cluster javaScriptAll contains=javaScriptComment,javaScriptLineComment,javaScriptDocComment,javaScriptString,javaScriptRegexpString,javaScriptNumber,javaScriptFloat,javaScriptLabel,javaScriptSource,javaScriptWebAPI,javaScriptOperator,javaScriptBoolean,javaScriptNull,javaScriptFuncKeyword,javaScriptConditional,javaScriptGlobal,javaScriptRepeat,javaScriptBranch,javaScriptStatement,javaScriptGlobalObjects,javaScriptMessage,javaScriptIdentifier,javaScriptExceptions,javaScriptReserved,javaScriptDeprecated,javaScriptDomErrNo,javaScriptDomNodeConsts,javaScriptHtmlEvents,javaScriptDotNotation,javaScriptBrowserObjects,javaScriptDOMObjects,javaScriptAjaxObjects,javaScriptPropietaryObjects,javaScriptDOMMethods,javaScriptHtmlElemProperties,javaScriptDOMProperties,javaScriptEventListenerKeywords,javaScriptEventListenerMethods,javaScriptAjaxProperties,javaScriptAjaxMethods,javaScriptFuncArg | ||
|
||
if main_syntax == "javascript" | ||
syntax sync clear | ||
syntax sync ccomment javaScriptComment minlines=200 | ||
" syntax sync match javaScriptHighlight grouphere javaScriptBlock /{/ | ||
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 match javaScriptFuncComma /,/ contained | ||
syntax match javaScriptFuncEq /=/ contained | ||
syntax region javaScriptFuncDef start="\<function\>" end="\([^)]*\)" contains=javaScriptFuncKeyword,javaScriptFuncArg keepend | ||
|
||
" Braces, Parens, symbols, colons | ||
syntax match javaScriptBraces "[{}\[\]]" | ||
syntax match javaScriptParens "[()]" | ||
syntax match javaScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-=" | ||
syntax match javaScriptEndColons "[;,]" | ||
syntax match javaScriptLogicSymbols "\(&&\)\|\(||\)" | ||
|
||
" include syntax modules | ||
runtime syntax/vim-es6/modules/*.vim | ||
|
||
" JavaScriptFold Function | ||
function! JavaScriptFold() | ||
setl foldmethod=syntax | ||
setl foldlevelstart=1 | ||
syntax region foldBraces start=/{/ end=/}/ transparent fold keepend extend | ||
endfunction | ||
|
||
" Highlight links | ||
" Define the default highlighting. | ||
" For version 5.7 and earlier: only when not done already | ||
" For version 5.8 and later: only when an item doesn't have highlighting yet | ||
if version >= 508 || !exists("did_javascript_syn_inits") | ||
if version < 508 | ||
let did_javascript_syn_inits = 1 | ||
command -nargs=+ HiLink hi link <args> | ||
else | ||
command -nargs=+ HiLink hi def link <args> | ||
endif | ||
HiLink javaScriptEndColons Operator | ||
HiLink javaScriptOpSymbols Operator | ||
HiLink javaScriptLogicSymbols Boolean | ||
HiLink javaScriptBraces Function | ||
HiLink javaScriptParens Operator | ||
|
||
HiLink javaScriptComment Comment | ||
HiLink javaScriptLineComment Comment | ||
HiLink javaScriptDocComment Comment | ||
HiLink javaScriptCommentTodo Todo | ||
|
||
HiLink javaScriptDocTags Special | ||
HiLink javaScriptDocSeeTag Function | ||
HiLink javaScriptDocParam Function | ||
|
||
HiLink javaScriptString String | ||
HiLink javaScriptRegexpString String | ||
|
||
HiLink javaScriptNumber Number | ||
HiLink javaScriptFloat Number | ||
|
||
HiLink javaScriptGlobal Constant | ||
HiLink javaScriptCharacter Character | ||
HiLink javaScriptPrototype Type | ||
HiLink javaScriptConditional Conditional | ||
HiLink javaScriptBranch Conditional | ||
HiLink javaScriptIdentifier Identifier | ||
HiLink javaScriptRepeat Repeat | ||
HiLink javaScriptStatement Statement | ||
HiLink javaScriptMessage Keyword | ||
HiLink javaScriptReserved Keyword | ||
HiLink javaScriptOperator Operator | ||
HiLink javaScriptNull Type | ||
HiLink javaScriptBoolean Boolean | ||
HiLink javaScriptLabel Label | ||
HiLink javaScriptSpecial Special | ||
HiLink javaScriptSource Special | ||
HiLink javaScriptGlobalObjects Special | ||
HiLink javaScriptExceptions Special | ||
|
||
HiLink javaScriptDeprecated Exception | ||
HiLink javaScriptError Error | ||
HiLink javaScriptParensError Error | ||
HiLink javaScriptParensErrA Error | ||
HiLink javaScriptParensErrB Error | ||
HiLink javaScriptParensErrC Error | ||
HiLink javaScriptDomErrNo Error | ||
|
||
HiLink javaScriptDomNodeConsts Constant | ||
HiLink javaScriptDomElemAttrs Label | ||
HiLink javaScriptDomElemFuncs Type | ||
|
||
HiLink javaScriptWebAPI Type | ||
|
||
HiLink javaScriptHtmlElemAttrs Label | ||
HiLink javaScriptHtmlElemFuncs Type | ||
|
||
HiLink javaScriptCssStyles Type | ||
|
||
HiLink javaScriptBrowserObjects Constant | ||
|
||
HiLink javaScriptDOMObjects Constant | ||
HiLink javaScriptDOMMethods Type | ||
HiLink javaScriptDOMProperties Label | ||
|
||
HiLink javaScriptAjaxObjects Constant | ||
HiLink javaScriptAjaxMethods Type | ||
HiLink javaScriptAjaxProperties Label | ||
|
||
HiLink javaScriptFuncKeyword Function | ||
HiLink javaScriptFuncDef PreProc | ||
HiLink javaScriptFuncExp Title | ||
HiLink javaScriptFuncArg Special | ||
HiLink javaScriptFuncComma Operator | ||
HiLink javaScriptFuncEq Operator | ||
|
||
HiLink javaScriptHtmlEvents Constant | ||
HiLink javaScriptHtmlElemProperties Label | ||
|
||
HiLink javaScriptEventListenerKeywords Type | ||
|
||
HiLink javaScriptPropietaryObjects Constant | ||
|
||
delcommand HiLink | ||
endif | ||
|
||
" Define the htmlJavaScript for HTML syntax html.vim | ||
" syntax clear htmlJavaScript | ||
" syntax clear javaScriptExpression | ||
syntax cluster htmlJavaScript contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError | ||
syntax cluster javaScriptExpression contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError,@htmlPreproc | ||
|
||
let b:current_syntax = "javascript" | ||
if main_syntax == 'javascript' | ||
unlet main_syntax | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax keyword javascriptGlobal Promise nextgroup=javascriptGlobalPromiseDot,javascriptFuncCallArg | ||
syntax match javascriptGlobalPromiseDot /\./ contained nextgroup=javascriptPromiseStaticMethod | ||
syntax keyword javascriptPromiseStaticMethod contained resolve reject all race nextgroup=javascriptFuncCallArg | ||
if exists("did_javascript_hilink") | HiLink javascriptPromiseStaticMethod Keyword | ||
endif | ||
syntax keyword javascriptPromiseMethod contained then catch nextgroup=javascriptFuncCallArg | ||
syntax cluster props add=javascriptPromiseMethod | ||
if exists("did_javascript_hilink") | HiLink javascriptPromiseMethod Keyword | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
syntax keyword javascriptGlobal Proxy | ||
syntax keyword javascriptProxyAPI contained getOwnPropertyDescriptor getOwnPropertyNames | ||
syntax keyword javascriptProxyAPI contained defineProperty deleteProperty freeze seal | ||
syntax keyword javascriptProxyAPI contained preventExtensions has hasOwn get set enumerate | ||
syntax keyword javascriptProxyAPI contained iterate ownKeys apply construct | ||
if exists("did_javascript_hilink") | HiLink javascriptProxyAPI Keyword | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax keyword javascriptGlobal RegExp nextgroup=javascriptGlobalRegExpDot,javascriptFuncCallArg | ||
syntax match javascriptGlobalRegExpDot /\./ contained nextgroup=javascriptRegExpStaticProp | ||
syntax keyword javascriptRegExpStaticProp contained lastIndex | ||
if exists("did_javascript_hilink") | HiLink javascriptRegExpStaticProp Keyword | ||
endif | ||
syntax keyword javascriptRegExpProp contained global ignoreCase multiline source sticky | ||
syntax cluster props add=javascriptRegExpProp | ||
if exists("did_javascript_hilink") | HiLink javascriptRegExpProp Keyword | ||
endif | ||
syntax keyword javascriptRegExpMethod contained exec test nextgroup=javascriptFuncCallArg | ||
syntax cluster props add=javascriptRegExpMethod | ||
if exists("did_javascript_hilink") | HiLink javascriptRegExpMethod Keyword | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
syntax keyword javascriptGlobal Set WeakSet | ||
syntax keyword javascriptES6SetProp contained size | ||
syntax cluster props add=javascriptES6SetProp | ||
if exists("did_javascript_hilink") | HiLink javascriptES6SetProp Keyword | ||
endif | ||
syntax keyword javascriptES6SetMethod contained add clear delete entries forEach has nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptES6SetMethod contained values nextgroup=javascriptFuncCallArg | ||
syntax cluster props add=javascriptES6SetMethod | ||
if exists("did_javascript_hilink") | HiLink javascriptES6SetMethod Keyword | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax keyword javascriptGlobal String nextgroup=javascriptGlobalStringDot,javascriptFuncCallArg | ||
syntax match javascriptGlobalStringDot /\./ contained nextgroup=javascriptStringStaticMethod | ||
syntax keyword javascriptStringStaticMethod contained fromCharCode fromCodePoint nextgroup=javascriptFuncCallArg | ||
if exists("did_javascript_hilink") | HiLink javascriptStringStaticMethod Keyword | ||
endif | ||
syntax keyword javascriptStringMethod contained anchor charAt charCodeAt codePointAt nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptStringMethod contained concat endsWith includes indexOf lastIndexOf nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptStringMethod contained link localeCompare match normalize nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptStringMethod contained repeat replace search slice split nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptStringMethod contained startsWith substr substring toLocaleLowerCase nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptStringMethod contained toLocaleUpperCase toLowerCase toString nextgroup=javascriptFuncCallArg | ||
syntax keyword javascriptStringMethod contained toUpperCase trim valueOf nextgroup=javascriptFuncCallArg | ||
syntax cluster props add=javascriptStringMethod | ||
if exists("did_javascript_hilink") | HiLink javascriptStringMethod Keyword | ||
endif |
Oops, something went wrong.