diff --git a/dotfiles/.vim/plugged/vim-javascript/.gitrepo b/dotfiles/.vim/plugged/vim-javascript/.gitrepo new file mode 100644 index 00000000..d3749314 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = https://github.com/pangloss/vim-javascript.git + branch = master + commit = c470ce1399a544fe587eab950f571c83cccfbbdc + parent = 90619ab253f3904a65182223142015f4b728473d + method = merge + cmdver = 0.4.3 diff --git a/dotfiles/.vim/plugged/vim-javascript/ISSUE_TEMPLATE.md b/dotfiles/.vim/plugged/vim-javascript/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..b1ddccb1 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/ISSUE_TEMPLATE.md @@ -0,0 +1,13 @@ +*Requisite minimal reproducible example, formatted as plain text :* + +
+ +#### Optional: concerning jsx. +PLEASE PLEASE PLEASE make sure you have properly +setup and are sourcing this plugin https://github.com/mxw/vim-jsx + +WE DO NOT support JSX automatically, you need another plugin to add get this +functionality. + +Make sure the bug still exists if you disable all other javascript plugins +except the one noted above, mxw/vim-jsx diff --git a/dotfiles/.vim/plugged/vim-javascript/README.md b/dotfiles/.vim/plugged/vim-javascript/README.md new file mode 100644 index 00000000..06419b2a --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/README.md @@ -0,0 +1,125 @@ +# vim-javascript + +JavaScript bundle for vim, this bundle provides syntax highlighting and +improved indentation. + + +## Installation + +### Install with native package manager + + git clone https://github.com/pangloss/vim-javascript.git ~/.vim/pack/vim-javascript/start/vim-javascript + +since Vim 8. + +### Install with [pathogen](https://github.com/tpope/vim-pathogen) + + git clone https://github.com/pangloss/vim-javascript.git ~/.vim/bundle/vim-javascript + +alternatively, use a package manager like [vim-plug](https://github.com/junegunn/vim-plug) + + +## Configuration Variables + +The following variables control certain syntax highlighting plugins. You can +add them to your `.vimrc` to enable their features. + +----------------- + +``` +let g:javascript_plugin_jsdoc = 1 +``` + +Enables syntax highlighting for [JSDocs](http://usejsdoc.org/). + +Default Value: 0 + +----------------- + +``` +let g:javascript_plugin_ngdoc = 1 +``` + +Enables some additional syntax highlighting for NGDocs. Requires JSDoc plugin +to be enabled as well. + +Default Value: 0 + +----------------- + +``` +let g:javascript_plugin_flow = 1 +``` + +Enables syntax highlighting for [Flow](https://flowtype.org/). + +Default Value: 0 + +----------------- + +```vim +augroup javascript_folding + au! + au FileType javascript setlocal foldmethod=syntax +augroup END +``` + +Enables code folding for javascript based on our syntax file. + +Please note this can have a dramatic effect on performance. + + +## Concealing Characters + +You can customize concealing characters, if your font provides the glyph you want, by defining one or more of the following +variables: + + let g:javascript_conceal_function = "ƒ" + let g:javascript_conceal_null = "ø" + let g:javascript_conceal_this = "@" + let g:javascript_conceal_return = "⇚" + let g:javascript_conceal_undefined = "¿" + let g:javascript_conceal_NaN = "ℕ" + let g:javascript_conceal_prototype = "¶" + let g:javascript_conceal_static = "•" + let g:javascript_conceal_super = "Ω" + let g:javascript_conceal_arrow_function = "⇒" + let g:javascript_conceal_noarg_arrow_function = "🞅" + let g:javascript_conceal_underscore_arrow_function = "🞅" + + +You can enable concealing within VIM with: + + set conceallevel=1 + +OR if you wish to toggle concealing you may wish to bind a command such as the following which will map `l` (leader is usually the `\` key) to toggling conceal mode: + + map l :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1" + + +## Indentation Specific + +* `:h cino-:` +* `:h cino-=` +* `:h cino-star` +* `:h cino-(` +* `:h cino-w` +* `:h cino-W` +* `:h cino-U` +* `:h cino-m` +* `:h cino-M` +* `:h 'indentkeys'` + +## Contributing + +Please follow the general code style +guides (read the code) and in your pull request explain the reason for the +proposed change and how it is valuable. All p.r.'s will be reviewed by a +maintainer(s) then, hopefully, merged. + +Thank you! + + +## License + +Distributed under the same terms as Vim itself. See `:help license`. diff --git a/dotfiles/.vim/plugged/vim-javascript/after/ftplugin/javascript.vim b/dotfiles/.vim/plugged/vim-javascript/after/ftplugin/javascript.vim new file mode 100644 index 00000000..c6c42d60 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/after/ftplugin/javascript.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: JavaScript +" Maintainer: vim-javascript community +" URL: https://github.com/pangloss/vim-javascript + +setlocal iskeyword+=$ suffixesadd+=.js + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<' +else + let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<' +endif diff --git a/dotfiles/.vim/plugged/vim-javascript/compiler/eslint.vim b/dotfiles/.vim/plugged/vim-javascript/compiler/eslint.vim new file mode 100644 index 00000000..7695a072 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/compiler/eslint.vim @@ -0,0 +1,16 @@ +" Vim compiler plugin +" Language: JavaScript +" Maintainer: vim-javascript community +" URL: https://github.com/pangloss/vim-javascript + +if exists("current_compiler") + finish +endif +let current_compiler = "eslint" + +if exists(":CompilerSet") != 2 + command! -nargs=* CompilerSet setlocal +endif + +CompilerSet makeprg=eslint\ -f\ compact\ % +CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m diff --git a/dotfiles/.vim/plugged/vim-javascript/extras/ctags b/dotfiles/.vim/plugged/vim-javascript/extras/ctags new file mode 100644 index 00000000..cdc4edc0 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/extras/ctags @@ -0,0 +1,8 @@ +--langdef=js +--langmap=js:.js +--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/ +--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/ +--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*([^)])/\1/,function/ +--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/ +--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/ +--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/ diff --git a/dotfiles/.vim/plugged/vim-javascript/extras/flow.vim b/dotfiles/.vim/plugged/vim-javascript/extras/flow.vim new file mode 100644 index 00000000..b34d7101 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/extras/flow.vim @@ -0,0 +1,109 @@ +syntax region jsFlowDefinition contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster containedin=jsParen +syntax region jsFlowArgumentDef contained start=/:/ end=/\%(\s*[,)]\|=>\@!\)\@=/ contains=@jsFlowCluster +syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster,jsComment fold +syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster,jsComment fold +syntax region jsFlowExactObject contained matchgroup=jsFlowNoise start=/{|/ end=/|}/ contains=@jsFlowCluster,jsComment fold +syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster nextgroup=jsFlowArrow skipwhite keepend extend fold +syntax match jsFlowNoise contained /[:;,<>]/ +syntax keyword jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class +syntax keyword jsFlowTypeof contained typeof skipempty skipwhite nextgroup=jsFlowTypeCustom,jsFlowType +syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGeneric +syntax region jsFlowGeneric matchgroup=jsFlowNoise start=/\k\@<=/ contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock +syntax region jsFlowGeneric contained matchgroup=jsFlowNoise start=/(\@=/ oneline contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock +syntax region jsFlowObjectGeneric contained matchgroup=jsFlowNoise start=/\k\@<=/ contains=@jsFlowCluster nextgroup=jsFuncArgs +syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens +syntax match jsFlowObjectKey contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ contains=jsFunctionKey,jsFlowMaybe skipwhite skipempty nextgroup=jsObjectValue containedin=jsObject +syntax match jsFlowOrOperator contained /|/ skipwhite skipempty nextgroup=@jsFlowCluster +syntax keyword jsFlowImportType contained type typeof skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup +syntax match jsFlowWildcard contained /*/ + +syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster,jsFlowArrow,jsFlowReturnParens +syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp extend fold +syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold +syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArrow fold +syntax match jsFlowReturnArrow contained /=>/ skipwhite skipempty nextgroup=@jsFlowReturnCluster +syntax match jsFlowReturnKeyword contained /\k\+/ contains=jsFlowType,jsFlowTypeCustom skipwhite skipempty nextgroup=jsFlowReturnGroup,jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArray +syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword,jsFlowReturnObject,jsFlowReturnParens +syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp +syntax match jsFlowReturnOrOp contained /\s*|\s*/ skipwhite skipempty nextgroup=@jsFlowReturnCluster +syntax match jsFlowWildcardReturn contained /*/ skipwhite skipempty nextgroup=jsFuncBlock +syntax keyword jsFlowTypeofReturn contained typeof skipempty skipwhite nextgroup=@jsFlowReturnCluster + +syntax region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs +syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock +syntax region jsFlowClassFunctionGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs +syntax match jsFlowObjectFuncName contained /\<\K\k*<\@=/ skipwhite skipempty nextgroup=jsFlowObjectGeneric containedin=jsObject + +syntax region jsFlowTypeStatement start=/\(opaque\s\+\)\?type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend +syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/\%(;\|\n\%(\s*|\)\@!\)/ contains=@jsFlowCluster,jsFlowGeneric,jsFlowMaybe +syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue +syntax match jsFlowTypeOperator contained /=/ +syntax keyword jsFlowTypeKeyword contained type + +syntax keyword jsFlowDeclare declare skipwhite skipempty nextgroup=jsFlowTypeStatement,jsClassDefinition,jsStorageClass,jsFlowModule,jsFlowInterface +syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlowClassDef containedin=jsClassBlock +syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassValue + +syntax region jsFlowModule contained start=/module/ end=/\%({\|:\)\@=/ skipempty skipwhite nextgroup=jsFlowDeclareBlock contains=jsString +syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipwhite nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster +syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold + +syntax match jsFlowMaybe contained /?/ +syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsFlowObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise,jsFlowParens,jsFlowGeneric keepend fold + +syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster + +syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow,jsFlowTypeofReturn +syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGeneric,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard + +if version >= 508 || !exists("did_javascript_syn_inits") + if version < 508 + let did_javascript_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink jsFlowDefinition PreProc + HiLink jsFlowClassDef jsFlowDefinition + HiLink jsFlowArgumentDef jsFlowDefinition + HiLink jsFlowType Type + HiLink jsFlowTypeCustom PreProc + HiLink jsFlowTypeof PreProc + HiLink jsFlowTypeofReturn PreProc + HiLink jsFlowArray PreProc + HiLink jsFlowObject PreProc + HiLink jsFlowExactObject PreProc + HiLink jsFlowParens PreProc + HiLink jsFlowGeneric PreProc + HiLink jsFlowObjectGeneric jsFlowGeneric + HiLink jsFlowReturn PreProc + HiLink jsFlowParenAnnotation PreProc + HiLink jsFlowReturnObject jsFlowReturn + HiLink jsFlowReturnArray jsFlowArray + HiLink jsFlowReturnParens jsFlowParens + HiLink jsFlowReturnGroup jsFlowGeneric + HiLink jsFlowFunctionGroup PreProc + HiLink jsFlowClassGroup PreProc + HiLink jsFlowClassFunctionGroup PreProc + HiLink jsFlowArrow PreProc + HiLink jsFlowReturnArrow PreProc + HiLink jsFlowTypeStatement PreProc + HiLink jsFlowTypeKeyword PreProc + HiLink jsFlowTypeOperator Operator + HiLink jsFlowMaybe PreProc + HiLink jsFlowReturnMaybe PreProc + HiLink jsFlowClassProperty jsClassProperty + HiLink jsFlowDeclare PreProc + HiLink jsFlowModule PreProc + HiLink jsFlowInterface PreProc + HiLink jsFlowNoise Noise + HiLink jsFlowObjectKey jsObjectKey + HiLink jsFlowOrOperator jsOperator + HiLink jsFlowReturnOrOp jsFlowOrOperator + HiLink jsFlowWildcard PreProc + HiLink jsFlowWildcardReturn PreProc + HiLink jsFlowImportType PreProc + HiLink jsFlowTypeValue PreProc + HiLink jsFlowObjectFuncName jsObjectFuncName + delcommand HiLink +endif diff --git a/dotfiles/.vim/plugged/vim-javascript/extras/jsdoc.vim b/dotfiles/.vim/plugged/vim-javascript/extras/jsdoc.vim new file mode 100644 index 00000000..a7189d1b --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/extras/jsdoc.vim @@ -0,0 +1,40 @@ +"" syntax coloring for javadoc comments (HTML) +syntax region jsComment matchgroup=jsComment start="/\*\s*" end="\*/" contains=jsDocTags,jsCommentTodo,jsCvsTag,@jsHtml,@Spell fold + +" tags containing a param +syntax match jsDocTags contained "@\(alias\|api\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|fires\|kind\|link\|listens\|member\|member[oO]f\|mixes\|module\|name\|namespace\|requires\|template\|throws\|var\|variation\|version\)\>" skipwhite nextgroup=jsDocParam +" tags containing type and param +syntax match jsDocTags contained "@\(arg\|argument\|cfg\|param\|property\|prop\|typedef\)\>" skipwhite nextgroup=jsDocType +" tags containing type but no param +syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|implements\|this\|type\|return\|returns\|yields\)\>" skipwhite nextgroup=jsDocTypeNoParam +" tags containing references +syntax match jsDocTags contained "@\(lends\|see\|tutorial\)\>" skipwhite nextgroup=jsDocSeeTag +" other tags (no extra syntax) +syntax match jsDocTags contained "@\(abstract\|access\|accessor\|async\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|dict\|event\|example\|file\|file[oO]verview\|final\|function\|global\|ignore\|inherit[dD]oc\|inner\|instance\|interface\|license\|localdoc\|method\|mixin\|nosideeffects\|override\|overview\|preserve\|private\|protected\|public\|readonly\|since\|static\|struct\|todo\|summary\|undocumented\|virtual\)\>" + +syntax region jsDocType contained matchgroup=jsDocTypeBrackets start="{" end="}" contains=jsDocTypeRecord oneline skipwhite nextgroup=jsDocParam +syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" skipwhite nextgroup=jsDocParam +syntax region jsDocTypeRecord contained start=/{/ end=/}/ contains=jsDocTypeRecord extend +syntax region jsDocTypeRecord contained start=/\[/ end=/\]/ contains=jsDocTypeRecord extend +syntax region jsDocTypeNoParam contained start="{" end="}" oneline +syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" +syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\~\|\.\|:\|\/\|\[.\{-}]\|=\)\+" + +syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags + +if version >= 508 || !exists("did_javascript_syn_inits") + if version < 508 + let did_javascript_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink jsDocTags Special + HiLink jsDocSeeTag Function + HiLink jsDocType Type + HiLink jsDocTypeBrackets jsDocType + HiLink jsDocTypeRecord jsDocType + HiLink jsDocTypeNoParam Type + HiLink jsDocParam Label + delcommand HiLink +endif diff --git a/dotfiles/.vim/plugged/vim-javascript/extras/ngdoc.vim b/dotfiles/.vim/plugged/vim-javascript/extras/ngdoc.vim new file mode 100644 index 00000000..c513d875 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/extras/ngdoc.vim @@ -0,0 +1,3 @@ +syntax match jsDocTags contained /@\(link\|method[oO]f\|ngdoc\|ng[iI]nject\|restrict\)/ nextgroup=jsDocParam skipwhite +syntax match jsDocType contained "\%(#\|\$\|\w\|\"\|-\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite +syntax match jsDocParam contained "\%(#\|\$\|\w\|\"\|-\|\.\|:\|{\|}\|\/\|\[\|]\|=\)\+" diff --git a/dotfiles/.vim/plugged/vim-javascript/ftdetect/flow.vim b/dotfiles/.vim/plugged/vim-javascript/ftdetect/flow.vim new file mode 100644 index 00000000..3f1ea65b --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/ftdetect/flow.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead *.flow setfiletype flow diff --git a/dotfiles/.vim/plugged/vim-javascript/ftdetect/javascript.vim b/dotfiles/.vim/plugged/vim-javascript/ftdetect/javascript.vim new file mode 100644 index 00000000..00487326 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/ftdetect/javascript.vim @@ -0,0 +1,8 @@ +fun! s:SelectJavascript() + if getline(1) =~# '^#!.*/bin/\%(env\s\+\)\?node\>' + set ft=javascript + endif +endfun + +autocmd BufNewFile,BufRead *.{js,mjs,cjs,jsm,es,es6},Jakefile setfiletype javascript +autocmd BufNewFile,BufRead * call s:SelectJavascript() diff --git a/dotfiles/.vim/plugged/vim-javascript/indent/javascript.vim b/dotfiles/.vim/plugged/vim-javascript/indent/javascript.vim new file mode 100644 index 00000000..b754e282 --- /dev/null +++ b/dotfiles/.vim/plugged/vim-javascript/indent/javascript.vim @@ -0,0 +1,477 @@ +" Vim indent file +" Language: Javascript +" Maintainer: Chris Paul ( https://github.com/bounceme ) +" URL: https://github.com/pangloss/vim-javascript +" Last Change: December 4, 2017 + +" Only load this indent file when no other was loaded. +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +" Now, set up our indentation expression and keys that trigger it. +setlocal indentexpr=GetJavascriptIndent() +setlocal autoindent nolisp nosmartindent +setlocal indentkeys+=0],0) +" Testable with something like: +" vim -eNs "+filetype plugin indent on" "+syntax on" "+set ft=javascript" \ +" "+norm! gg=G" '+%print' '+:q!' testfile.js \ +" | diff -uBZ testfile.js - + +let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys< lisp<' + +" Only define the function once. +if exists('*GetJavascriptIndent') + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" indent correctly if inside