Compare commits

..

21 Commits

Author SHA1 Message Date
Adam Stankiewicz
34eb36e6d1 Fix tmux plugin 2019-09-06 14:49:10 +02:00
Adam Stankiewicz
84ec4eedcd Switch typescript provider, closes #428 2019-09-06 14:32:07 +02:00
Adam Stankiewicz
66b769328c Update 2019-09-06 14:25:42 +02:00
Adam Stankiewicz
ae18284e5a Disable jsx when ts or js is disabled, closes #414 2019-09-04 17:39:23 +02:00
Adam Stankiewicz
e3024f21fc Fix build script 2019-09-04 17:01:29 +02:00
Adam Stankiewicz
31d757fc7b Update 2019-09-04 16:50:13 +02:00
Adam Stankiewicz
556c56d185 Add graphql support, closes #298 2019-09-04 16:29:56 +02:00
Adam Stankiewicz
fe84062992 Include missing file from styledcomponents, fixes #418 2019-09-04 16:25:08 +02:00
Adam Stankiewicz
8742443e69 Remove advanced stuff from r plugin, fixes #420 2019-09-04 16:08:22 +02:00
Adam Stankiewicz
832dfece76 Add dhall, closes #426 2019-09-04 16:06:18 +02:00
Adam Stankiewicz
933e42ea1f Change provider for puppet, closes #424 2019-09-04 16:04:21 +02:00
Adam Stankiewicz
cdd6d73e39 Switch fish provider, fixes #408 2019-09-04 15:55:58 +02:00
Adam Stankiewicz
a48874df4c Update elixir filedetect, closes #421 2019-09-04 15:53:42 +02:00
Adam Stankiewicz
21849c2e18 Add helm syntax, closes #422 2019-09-04 15:45:55 +02:00
Adam Stankiewicz
664aa988f6 Update 2019-09-04 15:44:43 +02:00
Adam Stankiewicz
3ddca5da46 Remove rego, fixes #415 2019-07-01 16:26:25 +02:00
Adam Stankiewicz
140430ffb7 Update 2019-07-01 16:25:37 +02:00
Adam Stankiewicz
d527002849 Update 2019-06-16 18:36:23 +02:00
Adam Stankiewicz
15727e7eb0 Add zephir support 2019-06-14 16:11:54 +02:00
Adam Stankiewicz
6b169212f8 Add svelte support, closes #410 2019-06-14 16:07:20 +02:00
Adam Stankiewicz
2edc785a5e Make typescript.tsx default filetype for tsx, fixes #409 2019-06-09 00:08:31 +02:00
163 changed files with 6600 additions and 3041 deletions

View File

@@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them. > One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*. - It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->143<!--/Package Count--> packages it consists of. - It **installs and updates 120+ times faster** than the <!--Package Count-->147<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs. - Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support). - All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`). - No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -68,6 +68,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin) - [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin)
- [cue](https://github.com/mgrabovsky/vim-cuesheet) (syntax) - [cue](https://github.com/mgrabovsky/vim-cuesheet) (syntax)
- [dart](https://github.com/dart-lang/dart-vim-plugin) (syntax, indent, autoload, ftplugin) - [dart](https://github.com/dart-lang/dart-vim-plugin) (syntax, indent, autoload, ftplugin)
- [dhall](https://github.com/vmchale/dhall-vim) (syntax, ftplugin)
- [dlang](https://github.com/JesseKPhillips/d.vim) (syntax, indent) - [dlang](https://github.com/JesseKPhillips/d.vim) (syntax, indent)
- [dockerfile](https://github.com/ekalinin/Dockerfile.vim) (syntax, indent, ftplugin) - [dockerfile](https://github.com/ekalinin/Dockerfile.vim) (syntax, indent, ftplugin)
- [elixir](https://github.com/elixir-lang/vim-elixir) (syntax, indent, compiler, autoload, ftplugin) - [elixir](https://github.com/elixir-lang/vim-elixir) (syntax, indent, compiler, autoload, ftplugin)
@@ -76,7 +77,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [emblem](https://github.com/yalesov/vim-emblem) (syntax, indent, ftplugin) - [emblem](https://github.com/yalesov/vim-emblem) (syntax, indent, ftplugin)
- [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent) - [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent)
- [ferm](https://github.com/vim-scripts/ferm.vim) (syntax) - [ferm](https://github.com/vim-scripts/ferm.vim) (syntax)
- [fish](https://github.com/dag/vim-fish) (syntax, indent, compiler, autoload, ftplugin) - [fish](https://github.com/georgewitteman/vim-fish) (syntax, indent, compiler, autoload, ftplugin)
- [flatbuffers](https://github.com/dcharbon/vim-flatbuffers) (syntax) - [flatbuffers](https://github.com/dcharbon/vim-flatbuffers) (syntax)
- [fsharp](https://github.com/fsharp/vim-fsharp) (syntax, indent) - [fsharp](https://github.com/fsharp/vim-fsharp) (syntax, indent)
- [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin) - [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin)
@@ -85,6 +86,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) (syntax) - [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) (syntax)
- [go](https://github.com/fatih/vim-go) (syntax, compiler, indent) - [go](https://github.com/fatih/vim-go) (syntax, compiler, indent)
- [gradle](https://github.com/tfnico/vim-gradle) (compiler) - [gradle](https://github.com/tfnico/vim-gradle) (compiler)
- [graphql](https://github.com/jparise/vim-graphql) (syntax, indent, autoload, ftplugin, after)
- [groovy-indent](https://github.com/vim-scripts/groovyindent-unix) (indent) - [groovy-indent](https://github.com/vim-scripts/groovyindent-unix) (indent)
- [groovy](https://github.com/vim-scripts/groovy.vim) (syntax) - [groovy](https://github.com/vim-scripts/groovy.vim) (syntax)
- [haml](https://github.com/sheerun/vim-haml) (syntax, indent, compiler, ftplugin) - [haml](https://github.com/sheerun/vim-haml) (syntax, indent, compiler, ftplugin)
@@ -93,6 +95,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin) - [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin)
- [haxe](https://github.com/yaymukund/vim-haxe) (syntax) - [haxe](https://github.com/yaymukund/vim-haxe) (syntax)
- [hcl](https://github.com/b4b4r07/vim-hcl) (syntax, indent, ftplugin) - [hcl](https://github.com/b4b4r07/vim-hcl) (syntax, indent, ftplugin)
- [helm](https://github.com/towolf/vim-helm) (syntax)
- [hive](https://github.com/zebradil/hive.vim) (syntax, ftplugin) - [hive](https://github.com/zebradil/hive.vim) (syntax, ftplugin)
- [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin) - [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin)
- [i3](https://github.com/mboughaba/i3config.vim) (syntax, ftplugin) - [i3](https://github.com/mboughaba/i3config.vim) (syntax, ftplugin)
@@ -136,19 +139,18 @@ If you need full functionality of any plugin, please use it directly with your p
- [powershell](https://github.com/PProvost/vim-ps1) (syntax, indent, ftplugin) - [powershell](https://github.com/PProvost/vim-ps1) (syntax, indent, ftplugin)
- [protobuf](https://github.com/uarun/vim-protobuf) (syntax, indent) - [protobuf](https://github.com/uarun/vim-protobuf) (syntax, indent)
- [pug](https://github.com/digitaltoad/vim-pug) (syntax, indent, ftplugin) - [pug](https://github.com/digitaltoad/vim-pug) (syntax, indent, ftplugin)
- [puppet](https://github.com/voxpupuli/vim-puppet) (syntax, indent, ftplugin) - [puppet](https://github.com/rodjek/vim-puppet) (syntax, indent, autoload, ftplugin)
- [purescript](https://github.com/purescript-contrib/purescript-vim) (syntax, indent, ftplugin) - [purescript](https://github.com/purescript-contrib/purescript-vim) (syntax, indent, ftplugin)
- [python-compiler](https://github.com/aliev/vim-compiler-python) (compiler, autoload) - [python-compiler](https://github.com/aliev/vim-compiler-python) (compiler, autoload)
- [python-indent](https://github.com/Vimjas/vim-python-pep8-indent) (indent) - [python-indent](https://github.com/Vimjas/vim-python-pep8-indent) (indent)
- [python](https://github.com/vim-python/python-syntax) (syntax) - [python](https://github.com/vim-python/python-syntax) (syntax)
- [qmake](https://github.com/artoj/qmake-syntax-vim) (syntax) - [qmake](https://github.com/artoj/qmake-syntax-vim) (syntax)
- [qml](https://github.com/peterhoeg/vim-qml) (syntax, indent, ftplugin) - [qml](https://github.com/peterhoeg/vim-qml) (syntax, indent, ftplugin)
- [r-lang](https://github.com/vim-scripts/R.vim) (syntax, ftplugin) - [r-lang](https://github.com/vim-scripts/R.vim) (syntax)
- [racket](https://github.com/wlangstroth/vim-racket) (syntax, indent, ftplugin) - [racket](https://github.com/wlangstroth/vim-racket) (syntax, indent, ftplugin)
- [ragel](https://github.com/jneen/ragel.vim) (syntax) - [ragel](https://github.com/jneen/ragel.vim) (syntax)
- [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin) - [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin)
- [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent) - [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent)
- [rego](https://github.com/tsandall/vim-rego) (syntax)
- [rspec](https://github.com/sheerun/rspec.vim) (syntax) - [rspec](https://github.com/sheerun/rspec.vim) (syntax)
- [rst](https://github.com/marshallward/vim-restructuredtext) (syntax, autoload, ftplugin) - [rst](https://github.com/marshallward/vim-restructuredtext) (syntax, autoload, ftplugin)
- [ruby](https://github.com/vim-ruby/vim-ruby) (syntax, indent, compiler, autoload, ftplugin) - [ruby](https://github.com/vim-ruby/vim-ruby) (syntax, indent, compiler, autoload, ftplugin)
@@ -160,8 +162,9 @@ If you need full functionality of any plugin, please use it directly with your p
- [slime](https://github.com/slime-lang/vim-slime-syntax) (syntax, indent) - [slime](https://github.com/slime-lang/vim-slime-syntax) (syntax, indent)
- [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin) - [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin)
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin) - [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
- [styled-components](https://github.com/styled-components/vim-styled-components#main) (syntax, indent, ftplugin) - [styled-components](https://github.com/styled-components/vim-styled-components#main) (after)
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin) - [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
- [svelte](https://github.com/evanleck/vim-svelte) (syntax, indent)
- [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent) - [svg-indent](https://github.com/jasonshell/vim-svg-indent) (indent)
- [svg](https://github.com/vim-scripts/svg.vim) (syntax) - [svg](https://github.com/vim-scripts/svg.vim) (syntax)
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin) - [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
@@ -170,12 +173,12 @@ If you need full functionality of any plugin, please use it directly with your p
- [terraform](https://github.com/hashivim/vim-terraform) (syntax, indent, autoload, ftplugin) - [terraform](https://github.com/hashivim/vim-terraform) (syntax, indent, autoload, ftplugin)
- [textile](https://github.com/timcharper/textile.vim) (syntax, ftplugin) - [textile](https://github.com/timcharper/textile.vim) (syntax, ftplugin)
- [thrift](https://github.com/solarnz/thrift.vim) (syntax) - [thrift](https://github.com/solarnz/thrift.vim) (syntax)
- [tmux](https://github.com/ericpruitt/tmux.vim) () - [tmux](https://github.com/ericpruitt/tmux.vim) (syntax, ftplugin)
- [tomdoc](https://github.com/wellbredgrapefruit/tomdoc.vim) (syntax) - [tomdoc](https://github.com/wellbredgrapefruit/tomdoc.vim) (syntax)
- [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin) - [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin)
- [tptp](https://github.com/c-cube/vim-tptp) (syntax) - [tptp](https://github.com/c-cube/vim-tptp) (syntax)
- [twig](https://github.com/lumiliet/vim-twig) (syntax, indent, ftplugin) - [twig](https://github.com/lumiliet/vim-twig) (syntax, indent, ftplugin)
- [typescript](https://github.com/leafgarland/typescript-vim) (syntax, indent, compiler, ftplugin) - [typescript](https://github.com/HerringtonDarkholme/yats.vim) (syntax, indent, compiler, ftplugin)
- [vala](https://github.com/arrufat/vala.vim) (syntax, indent) - [vala](https://github.com/arrufat/vala.vim) (syntax, indent)
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax) - [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)
- [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax) - [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax)
@@ -187,6 +190,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [xml](https://github.com/amadeus/vim-xml) (syntax) - [xml](https://github.com/amadeus/vim-xml) (syntax)
- [yaml](https://github.com/stephpy/vim-yaml) (syntax, ftplugin) - [yaml](https://github.com/stephpy/vim-yaml) (syntax, ftplugin)
- [yard](https://github.com/sheerun/vim-yardoc) (syntax) - [yard](https://github.com/sheerun/vim-yardoc) (syntax)
- [zephir](https://github.com/xwsoul/vim-zephir) (syntax)
- [zig](https://github.com/ziglang/zig.vim) (syntax, autoload, ftplugin) - [zig](https://github.com/ziglang/zig.vim) (syntax, autoload, ftplugin)
<!--/Language Packs--> <!--/Language Packs-->

View File

@@ -0,0 +1,21 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-components') != -1
finish
endif
" Vim completion script
" Language: styled-components (js/ts)
" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com>
" URL: https://github.com/styled-components/vim-styled-components
fun! styledcomplete#CompleteSC(findstart, base)
if IsStyledDefinition(line('.'))
return csscomplete#CompleteCSS(a:findstart, a:base)
endif
" Only trigger original omnifunc if it was set in the first place
if exists('b:prevofu')
" create a funcref to call with the previous omnicomplete function
let s:funcref = function(b:prevofu)
return s:funcref(a:findstart, a:base)
endif
endfun

View File

@@ -1,6 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rspec') == -1
autocmd BufReadPost,BufNewFile *_spec.rb set syntax=rspec
autocmd BufReadPost,BufNewFile *_spec.rb setlocal commentstring=#\ %s
endif

View File

@@ -14,7 +14,7 @@ if exists('b:undo_ftplugin')
else else
let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<' let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<'
endif endif
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -83,6 +83,10 @@ fu! IsStyledDefinition(lnum)
endfu endfu
if exists('&ofu') if exists('&ofu')
let b:prevofu=&ofu if &ofu
" Do not keep track of previous omnifunc if it was not set in the first
" place
let b:prevofu=&ofu
endif
setl omnifunc=styledcomplete#CompleteSC setl omnifunc=styledcomplete#CompleteSC
endif endif

View File

@@ -6,15 +6,6 @@ if !exists('g:puppet_align_hashes')
let g:puppet_align_hashes = 1 let g:puppet_align_hashes = 1
endif endif
if g:puppet_align_hashes && exists(':Tabularize') if g:puppet_align_hashes
inoremap <buffer> <silent> > ><Esc>:call <SID>puppetalign()<CR>a inoremap <buffer> <silent> => =><Esc>:call puppet#align#AlignHashrockets()<CR>$a
function! s:puppetalign()
let p = '^\s*\w+\s*[=+]>.*$'
let column = strlen(substitute(getline('.')[0:col('.')],'\([^=]\|=[^>]\)','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=>\s*\zs.*'))
Tabularize /=>/l1
normal! 0
echo repeat('\([^=]\|=[^>]\)*=>',column).'\s\{-\}'.repeat('.',position)
call search(repeat('\([^=]\|=[^>]\)*=>',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endfunction
endif endif

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -25,3 +25,7 @@ augroup jsx_comment
augroup end augroup end
setlocal suffixesadd+=.tsx setlocal suffixesadd+=.tsx
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-components') != -1
finish
endif

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif

View File

@@ -2,172 +2,4 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-component
finish finish
endif endif
" Vim syntax file runtime! indent/javascript.vim
" Language: styled-components (js/ts)
" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com>
" URL: https://github.com/styled-components/vim-styled-components
" initialize variable to check, if the indentation expression is run
" multiple times in a row, which indicates an infinite recursion
let s:is_recursion = 0
" store current indentexpr for later
let b:js_ts_indent=&indentexpr
" set indentexpr for this filetype (styled-components)
setlocal indentexpr=GetStyledIndent()
" add the following keys to trigger reindenting, when in insert mode
" - *; - Indent and insert on press of ';' key.
" - *<:> - Indent and insert on press of ':' key.
set indentkeys+=*;,*<:>,*<Return>
fu! s:GetSyntaxNames(lnum, cnum)
return map(synstack(a:lnum, a:cnum), 'synIDattr(v:val, "name")')
endfu
" re-implement SynSOL of vim-jsx
" TODO: add dependency to the readme and remove duplicate implementation
fu! s:SynSOL(lnum)
return s:GetSyntaxNames(a:lnum, 1)
endfu
" re-implement SynEOL of vim-jsx
" TODO: add dependency to the readme and remove duplicate implementation
fu! s:SynEOL(lnum, offset)
let l:lnum = prevnonblank(a:lnum)
let l:col = strlen(getline(l:lnum))
return s:GetSyntaxNames(l:lnum, l:col + a:offset)
endfu
"" Return whether the current line is a jsTemplateString
fu! s:IsStyledDefinition(lnum)
" iterate through all syntax items in the given line
for item in s:SynSOL(a:lnum)
" if syntax-item is a jsTemplateString return 1 - true
" `==#` is a match case comparison of the item
if item ==# 'styledDefinition'
return 1
endif
endfor
" fallback to 0 - false
return 0
endfu
"" Count occurences of `str` at the beginning of the given `lnum` line
fu! s:CountOccurencesInSOL(lnum, str)
let l:occurence = 0
" iterate through all items in the given line
for item in s:SynSOL(a:lnum)
" if the syntax-item equals the given str increment the counter
" `==?` is a case isensitive equal operation
if item ==? a:str
let l:occurence += 1
endif
endfor
" return the accumulated count of occurences
return l:occurence
endfu
"" Count occurences of `str` at the end of the given `lnum` line
fu! s:CountOccurencesInEOL(lnum, str, offset)
let l:occurence = 0
" iterate through all items in the given line
for item in s:SynEOL(a:lnum, a:offset)
" if the syntax-item equals the given str increment the counter
" `==?` is a case insensitive equal operation
if item == a:str
let l:occurence += 1
endif
endfor
" return the accumulated count of occurences
return l:occurence
endfu
"" Get the indentation of the current line
fu! GetStyledIndent()
if s:IsStyledDefinition(v:lnum)
let l:baseIndent = 0
" find last non-styled line
let l:cnum = v:lnum
while s:IsStyledDefinition(l:cnum)
let l:cnum -= 1
endwhile
" get indentation of the last non-styled line as base indentation
let l:baseIndent = indent(l:cnum)
" incrementally build indentation based on current indentation
" - one shiftwidth for the styled definition region
" - one shiftwidth per open nested definition region
let l:styledIndent = &sw
let l:styledIndent += min([
\ s:CountOccurencesInSOL(v:lnum, 'styledNestedRegion'),
\ s:CountOccurencesInEOL(v:lnum, 'styledNestedRegion', 0)
\ ]) * &sw
" decrease indentation by one shiftwidth, if the styled definition
" region ends on the current line
" - either directly via styled definition region, or
" - if the very last
if s:CountOccurencesInEOL(v:lnum, 'styledDefinition', 1) == 0
let l:styledIndent -= &sw
endif
" return the base indentation
" (for nested styles inside classes/objects/etc.) plus the actual
" indentation inside the styled definition region
return l:baseIndent + l:styledIndent
elseif len(b:js_ts_indent)
let l:result = 0
let l:offset = 0
" increase indentation by one shiftwidth, if the last line ended on a
" styledXmlRegion and this line does not continue with it
" this is a fix for an incorrectly indented xml prop after a
" glamor-styled styledXmlRegion
if s:CountOccurencesInEOL(v:lnum-1, 'styledXmlRegion', 0) == 1 &&
\ s:CountOccurencesInSOL(v:lnum, 'styledXmlRegion') == 0
let l:offset = &sw
endif
" make sure `GetStyledIndent` and `GetJsxIndent` don't infinitely
" recurse by incrementing a counter variable, before evaluating the
" stored indent expression
if s:is_recursion == 0
let s:is_recursion = 1
let l:result = eval(b:js_ts_indent)
endif
" `is_recursion` being 0 at this point indicates, that
" `eval(b:js_ts_indent)` did itself evaluate it's stored indentexpr
" and thus it can be assumed, that the current line should be
" indented as JS
if s:is_recursion == 0
" use one of `GetJavascriptIndent` or `GetJsIndent` if existing
" fallback to cindent, if not
if exists('*GetJavascriptIndent')
let l:result = GetJavascriptIndent()
elseif exists('*GetJsIndent')
let l:result = GetJsIndent()
else
let l:result = cindent(v:lnum)
endif
endif
" reset `is_recursion` counter and return the indentation value
let s:is_recursion = 0
return l:result + l:offset
endif
" if all else fails indent according to C-syntax
return cindent(v:lnum)
endfu

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -36,172 +36,4 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-component
finish finish
endif endif
" Vim syntax file runtime! indent/javascript.vim
" Language: styled-components (js/ts)
" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com>
" URL: https://github.com/styled-components/vim-styled-components
" initialize variable to check, if the indentation expression is run
" multiple times in a row, which indicates an infinite recursion
let s:is_recursion = 0
" store current indentexpr for later
let b:js_ts_indent=&indentexpr
" set indentexpr for this filetype (styled-components)
setlocal indentexpr=GetStyledIndent()
" add the following keys to trigger reindenting, when in insert mode
" - *; - Indent and insert on press of ';' key.
" - *<:> - Indent and insert on press of ':' key.
set indentkeys+=*;,*<:>,*<Return>
fu! s:GetSyntaxNames(lnum, cnum)
return map(synstack(a:lnum, a:cnum), 'synIDattr(v:val, "name")')
endfu
" re-implement SynSOL of vim-jsx
" TODO: add dependency to the readme and remove duplicate implementation
fu! s:SynSOL(lnum)
return s:GetSyntaxNames(a:lnum, 1)
endfu
" re-implement SynEOL of vim-jsx
" TODO: add dependency to the readme and remove duplicate implementation
fu! s:SynEOL(lnum, offset)
let l:lnum = prevnonblank(a:lnum)
let l:col = strlen(getline(l:lnum))
return s:GetSyntaxNames(l:lnum, l:col + a:offset)
endfu
"" Return whether the current line is a jsTemplateString
fu! s:IsStyledDefinition(lnum)
" iterate through all syntax items in the given line
for item in s:SynSOL(a:lnum)
" if syntax-item is a jsTemplateString return 1 - true
" `==#` is a match case comparison of the item
if item ==# 'styledDefinition'
return 1
endif
endfor
" fallback to 0 - false
return 0
endfu
"" Count occurences of `str` at the beginning of the given `lnum` line
fu! s:CountOccurencesInSOL(lnum, str)
let l:occurence = 0
" iterate through all items in the given line
for item in s:SynSOL(a:lnum)
" if the syntax-item equals the given str increment the counter
" `==?` is a case isensitive equal operation
if item ==? a:str
let l:occurence += 1
endif
endfor
" return the accumulated count of occurences
return l:occurence
endfu
"" Count occurences of `str` at the end of the given `lnum` line
fu! s:CountOccurencesInEOL(lnum, str, offset)
let l:occurence = 0
" iterate through all items in the given line
for item in s:SynEOL(a:lnum, a:offset)
" if the syntax-item equals the given str increment the counter
" `==?` is a case insensitive equal operation
if item == a:str
let l:occurence += 1
endif
endfor
" return the accumulated count of occurences
return l:occurence
endfu
"" Get the indentation of the current line
fu! GetStyledIndent()
if s:IsStyledDefinition(v:lnum)
let l:baseIndent = 0
" find last non-styled line
let l:cnum = v:lnum
while s:IsStyledDefinition(l:cnum)
let l:cnum -= 1
endwhile
" get indentation of the last non-styled line as base indentation
let l:baseIndent = indent(l:cnum)
" incrementally build indentation based on current indentation
" - one shiftwidth for the styled definition region
" - one shiftwidth per open nested definition region
let l:styledIndent = &sw
let l:styledIndent += min([
\ s:CountOccurencesInSOL(v:lnum, 'styledNestedRegion'),
\ s:CountOccurencesInEOL(v:lnum, 'styledNestedRegion', 0)
\ ]) * &sw
" decrease indentation by one shiftwidth, if the styled definition
" region ends on the current line
" - either directly via styled definition region, or
" - if the very last
if s:CountOccurencesInEOL(v:lnum, 'styledDefinition', 1) == 0
let l:styledIndent -= &sw
endif
" return the base indentation
" (for nested styles inside classes/objects/etc.) plus the actual
" indentation inside the styled definition region
return l:baseIndent + l:styledIndent
elseif len(b:js_ts_indent)
let l:result = 0
let l:offset = 0
" increase indentation by one shiftwidth, if the last line ended on a
" styledXmlRegion and this line does not continue with it
" this is a fix for an incorrectly indented xml prop after a
" glamor-styled styledXmlRegion
if s:CountOccurencesInEOL(v:lnum-1, 'styledXmlRegion', 0) == 1 &&
\ s:CountOccurencesInSOL(v:lnum, 'styledXmlRegion') == 0
let l:offset = &sw
endif
" make sure `GetStyledIndent` and `GetJsxIndent` don't infinitely
" recurse by incrementing a counter variable, before evaluating the
" stored indent expression
if s:is_recursion == 0
let s:is_recursion = 1
let l:result = eval(b:js_ts_indent)
endif
" `is_recursion` being 0 at this point indicates, that
" `eval(b:js_ts_indent)` did itself evaluate it's stored indentexpr
" and thus it can be assumed, that the current line should be
" indented as JS
if s:is_recursion == 0
" use one of `GetJavascriptIndent` or `GetJsIndent` if existing
" fallback to cindent, if not
if exists('*GetJavascriptIndent')
let l:result = GetJavascriptIndent()
elseif exists('*GetJsIndent')
let l:result = GetJsIndent()
else
let l:result = cindent(v:lnum)
endif
endif
" reset `is_recursion` counter and return the indentation value
let s:is_recursion = 0
return l:result + l:offset
endif
" if all else fails indent according to C-syntax
return cindent(v:lnum)
endfu

View File

@@ -6,7 +6,7 @@ endif
" Language: C++ Additions " Language: C++ Additions
" Maintainer: Jon Haggblad <jon@haeggblad.com> " Maintainer: Jon Haggblad <jon@haeggblad.com>
" URL: http://www.haeggblad.com " URL: http://www.haeggblad.com
" Last Change: 1 Feb 2018 " Last Change: 29 Jun 2019
" Version: 0.6 " Version: 0.6
" Changelog: " Changelog:
" 0.1 - initial version. " 0.1 - initial version.
@@ -964,6 +964,12 @@ if !exists("cpp_no_cpp11")
syntax keyword cppSTLtype atomic_uintmax_t syntax keyword cppSTLtype atomic_uintmax_t
syntax keyword cppSTLconstant ATOMIC_FLAG_INIT syntax keyword cppSTLconstant ATOMIC_FLAG_INIT
syntax keyword cppSTLenum memory_order syntax keyword cppSTLenum memory_order
syntax keyword cppSTLtype memory_order_relaxed
syntax keyword cppSTLtype memory_order_consume
syntax keyword cppSTLtype memory_order_acquire
syntax keyword cppSTLtype memory_order_release
syntax keyword cppSTLtype memory_order_acq_rel
syntax keyword cppSTLtype memory_order_seq_cst
syntax keyword cppSTLfunction is_lock_free syntax keyword cppSTLfunction is_lock_free
syntax keyword cppSTLfunction compare_exchange_weak syntax keyword cppSTLfunction compare_exchange_weak
syntax keyword cppSTLfunction compare_exchange_strong syntax keyword cppSTLfunction compare_exchange_strong
@@ -1983,6 +1989,9 @@ endif " C++17
if !exists("cpp_no_cpp20") if !exists("cpp_no_cpp20")
" type_traits " type_traits
syntax keyword cppSTLtype remove_cvref remove_cvref_t syntax keyword cppSTLtype remove_cvref remove_cvref_t
syntax keyword cppType char8_t
syntax keyword cppStatement co_yield co_return co_await
syntax keyword cppStorageClass consteval
endif endif

17
after/syntax/haskell.vim Normal file
View File

@@ -0,0 +1,17 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dhall') != -1
finish
endif
" store and remove current syntax value
let old_syntax = b:current_syntax
unlet b:current_syntax
syn include @dhall syntax/dhall.vim
unlet b:current_syntax
syn region dhallBlock matchgroup=quasiQuote start=/\[\$\?staticDhallExpression|/ end=/|\]/ contains=@dhall
hi def link quasiQuote Underlined
" restore current syntax value
let b:current_syntax = old_syntax

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -54,9 +54,7 @@ else " build-in javascript syntax
syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr,javaScript.* syntax region javaScriptEmbed matchgroup=javaScriptEmbedBraces start=+\${+ end=+}+ contained contains=@javaScriptEmbededExpr,javaScript.*
endif endif
" because this is autoloaded, when developing you're going to need to source runtime syntax/jsx_pretty.vim
" the autoload/jsx_pretty/*.vim file manually, or restart vim
call jsx_pretty#syntax#highlight()
let b:current_syntax = 'javascript.jsx' let b:current_syntax = 'javascript.jsx'
@@ -169,55 +167,16 @@ syn match styledPrefix "\<styled\>\.\k\+"
\ transparent fold \ transparent fold
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ contains=cssTagName,javascriptTagRef \ contains=cssTagName,javascriptTagRef
\ containedin=jsFuncBlock \ containedin=jsFuncBlock,jsParen,jsObject,jsObjectValue
syn match styledPrefix "\.\<attrs\>\s*(\%(\n\|\s\|.\)\{-})" syn match styledPrefix "\.\<attrs\>\s*(\%(\n\|\s\|.\)\{-})"
\ transparent fold extend \ transparent fold extend
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ contains=jsObject,jsParen \ contains=jsObject,jsParen
\ containedin=jsFuncBlock \ containedin=jsFuncBlock,jsParen,jsObject,jsObjectValue
syn match styledPrefix "\.\<extend\>" syn match styledPrefix "\.\<extend\>"
\ transparent fold \ transparent fold
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ containedin=jsFuncBlock \ containedin=jsFuncBlock,jsParen,jsObject,jsObjectValue
" define custom API section, that contains typescript annotations
" this is structurally similar to `jsFuncCall`, but allows type
" annotations (delimited by brackets (e.g. "<>")) between `styled` and
" the function call parenthesis
syn match styledTypescriptPrefix
\ "\<styled\><\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>(\%('\k\+'\|\"\k\+\"\|\k\+\))"
\ transparent fold
\ nextgroup=styledDefinition
\ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType,
\ styledTagNameString
syn match styledTypescriptPrefix
\ "\<styled\>\%((\%('\k\+'\|\"\k\+\"\|\k\+\))\|\.\k\+\)<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold
\ nextgroup=styledDefinition
\ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType,
\ styledTagNameString
syn match styledTypescriptPrefix "\.\<attrs\>\s*(\%(\n\|\s\|.\)\{-})<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold extend
\ nextgroup=styledDefinition
\ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType,
\ styledTagNameString
syn match styledTypescriptPrefix "\.\<extend\><\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold extend
\ nextgroup=styledDefinition
\ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType,
\ styledTagNameString
" define emotion css prop " define emotion css prop
" to bypass problems from top-level defined xml/js definitions, this " to bypass problems from top-level defined xml/js definitions, this
@@ -244,19 +203,13 @@ syn match cssError contained "{@<>"
" extend javascript matches to trigger styledDefinition highlighting " extend javascript matches to trigger styledDefinition highlighting
syn match jsTaggedTemplate extend syn match jsTaggedTemplate extend
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>" \ "\<css\>\|\.\<resolve\>\|\.\<global\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>"
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(.\+)" transparent syn match jsFuncCall "\<styled\>\s*(.\+)" transparent
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))" syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))"
\ contains=styledTagNameString \ contains=styledTagNameString
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ contains=typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType,
\ styledTagNameString
\ nextgroup=styledDefinition
syn match jsFuncCall "\.\<withComponent\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))" syn match jsFuncCall "\.\<withComponent\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))"
\ contains=styledTagNameString \ contains=styledTagNameString
syn match jsFuncCall "\<dc\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))\%((\)\@=" syn match jsFuncCall "\<dc\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))\%((\)\@="
@@ -279,8 +232,6 @@ syn region styledDefinition contained transparent fold extend
syn region styledDefinitionArgument contained transparent start=+(+ end=+)+ syn region styledDefinitionArgument contained transparent start=+(+ end=+)+
\ contains=styledDefinition \ contains=styledDefinition
syn cluster typescriptValue add=styledPrefix,jsFuncCall,styledTypescriptPrefix
""" yajs specific extensions """ yajs specific extensions
" define template tag keywords, that trigger styledDefinitions again to be " define template tag keywords, that trigger styledDefinitions again to be
" contained in and also do contain the `javascriptTagRef` region " contained in and also do contain the `javascriptTagRef` region
@@ -295,13 +246,6 @@ syn cluster javascriptExpression
\ add=styledPrefix,jsFuncCall,javascriptTagRefStyledPrefix \ add=styledPrefix,jsFuncCall,javascriptTagRefStyledPrefix
syn cluster javascriptAfterIdentifier add=styledPrefix,jsFuncCall syn cluster javascriptAfterIdentifier add=styledPrefix,jsFuncCall
""" yats specific extensions
" extend typescriptIdentifierName to allow styledDefinitions in their
" tagged templates
syn match typescriptIdentifierName extend
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>"
\ nextgroup=styledDefinition
" color the custom highlight elements " color the custom highlight elements
hi def link cssCustomKeyFrameSelector Constant hi def link cssCustomKeyFrameSelector Constant
hi def link cssCustomPositioningPrefix StorageClass hi def link cssCustomPositioningPrefix StorageClass

View File

@@ -0,0 +1,27 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1
finish
endif
if exists('b:current_syntax')
let s:current_syntax = b:current_syntax
unlet b:current_syntax
endif
syn include @GraphQLSyntax syntax/graphql.vim
if exists('s:current_syntax')
let b:current_syntax = s:current_syntax
endif
let s:tags = '\%(' . join(graphql#javascript_tags(), '\|') . '\)'
exec 'syntax region graphqlTemplateString start=+' . s:tags . '\@20<=`+ skip=+\\`+ end=+`+ contains=@GraphQLSyntax,jsTemplateExpression,jsSpecial extend'
exec 'syntax match graphqlTaggedTemplate +' . s:tags . '\ze`+ nextgroup=graphqlTemplateString'
" Support expression interpolation ((${...})) inside template strings.
syntax region graphqlTemplateExpression start=+${+ end=+}+ contained contains=jsTemplateExpression containedin=graphqlFold keepend
hi def link graphqlTemplateString jsTemplateString
hi def link graphqlTaggedTemplate jsTaggedTemplate
hi def link graphqlTemplateExpression jsTemplateExpression
syn cluster jsExpression add=graphqlTaggedTemplate
syn cluster graphqlTaggedTemplate add=graphqlTemplateString

216
after/syntax/jsx_pretty.vim Normal file
View File

@@ -0,0 +1,216 @@
if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish
endif
let s:highlight_close_tag = get(g:, 'vim_jsx_pretty_highlight_close_tag', 0)
" <tag id="sample">
" ~~~~~~~~~~~~~~~~~
" and self close tag
" <tag id="sample" />
" ~~~~~~~~~~~~~~~~~~~
syntax region jsxTag
\ start=+<+
\ matchgroup=jsxOpenPunct
\ end=+>+
\ matchgroup=NONE
\ end=+\(/\_s*>\)\@=+
\ contained
\ contains=jsxOpenTag,jsxEscapeJs,jsxAttrib,jsComment,@javascriptComments,javaScriptLineComment,javaScriptComment,typescriptLineComment,typescriptComment,jsxSpreadOperator
\ keepend
\ extend
" <tag></tag>
" ~~~~~~~~~~~
" and fragment
" <></>
" ~~~~~
" and self close tag
" <tag />
" ~~~~~~~
syntax region jsxElement
\ start=+<\_s*\(>\|\${\|\z(\<[-:_\.\$0-9A-Za-z]\+\>\)\)+
\ end=+/\_s*>+
\ end=+<\_s*/\_s*\z1\_s*>+
\ contains=jsxElement,jsxEscapeJs,jsxTag,jsxComment,jsxCloseString,jsxCloseTag,@Spell
\ keepend
\ extend
\ contained
\ fold
" detect jsx region
syntax region jsxRegion
\ start=+\(\(\_[([,?:=+\-*/<>{}]\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\(>\|\z(\(script\)\@!\<[_\$A-Za-z][-:_\.\$0-9A-Za-z]*\>\)\(\_s*\([-+*)\]}&|?]\|/\([/*]\|\_s*>\)\@!\)\)\@!\)+
\ end=++
\ contains=jsxElement
" <tag key={this.props.key}>
" ~~~~~~~~~~~~~~~~
syntax region jsxEscapeJs
\ start=+{+
\ end=++
\ extend
\ contained
\ contains=jsBlock,javascriptBlock,javaScriptBlockBuildIn,typescriptBlock
" <tag key={this.props.key}>
" ~~~~
" and fragment start tag
" <>
" ~~
exe 'syntax region jsxOpenTag
\ matchgroup=jsxOpenPunct
\ start=+<+
\ end=+>+
\ matchgroup=NONE
\ end=+\>+
\ contained
\ contains=jsxTagName
\ nextgroup=jsxAttrib
\ skipwhite
\ skipempty ' .(s:highlight_close_tag ? 'transparent' : '')
" <foo.bar>
" ~
syntax match jsxDot +\.+ contained display
" <foo:bar>
" ~
syntax match jsxNamespace +:+ contained display
" <tag id="sample">
" ~
syntax match jsxEqual +=+ contained display nextgroup=jsxString,jsxEscapeJs,jsxRegion skipwhite
" <tag />
" ~~
syntax match jsxCloseString +/\_s*>+ contained
" </tag>
" ~~~~~~
" and fragment close tag
" </>
" ~~~
syntax region jsxCloseTag
\ matchgroup=jsxClosePunct
\ start=+<\_s*/+
\ end=+>+
\ contained
\ contains=jsxTagName
" <tag key={this.props.key}>
" ~~~
syntax match jsxAttrib
\ +\<[-A-Za-z_][-:_\$0-9A-Za-z]*\>+
\ contained
\ nextgroup=jsxEqual
\ skipwhite
\ skipempty
\ contains=jsxAttribKeyword
\ display
" <MyComponent ...>
" ~~~~~~~~~~~
" NOT
" <someCamel ...>
" ~~~~~
exe 'syntax match jsxComponentName
\ +\<[A-Z][\$0-9A-Za-z]\+\>+
\ contained
\ display ' .(s:highlight_close_tag ? 'transparent' : '')
" <tag key={this.props.key}>
" ~~~
exe 'syntax match jsxTagName
\ +\<[-:_\.\$0-9A-Za-z]\+\>+
\ contained
\ contains=jsxComponentName,jsxDot,jsxNamespace
\ nextgroup=jsxAttrib
\ skipempty
\ skipwhite
\ display ' .(s:highlight_close_tag ? 'transparent' : '')
" <tag id="sample">
" ~~~~~~~~
" and
" <tag id='sample'>
" ~~~~~~~~
syntax region jsxString start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ contained contains=@Spell display
let s:tags = get(g:, 'vim_jsx_pretty_template_tags', ['html', 'raw'])
let s:enable_tagged_jsx = !empty(s:tags)
" add support to JSX inside the tagged template string
" https://github.com/developit/htm
if s:enable_tagged_jsx
exe 'syntax region jsxTaggedRegion
\ start=+\%('. join(s:tags, '\|') .'\)\@<=`+ms=s+1
\ end=+`+me=e-1
\ extend
\ contained
\ containedin=jsTemplateString,javascriptTemplate,javaScriptStringT,typescriptStringB
\ contains=jsxElement'
syntax region jsxEscapeJs
\ start=+\${+
\ end=++
\ extend
\ contained
\ contains=jsTemplateExpression,javascriptTemplateSubstitution,javaScriptEmbed,typescriptInterpolation
syntax region jsxOpenTag
\ matchgroup=jsxOpenPunct
\ start=+<\%(\${\)\@=+
\ matchgroup=NONE
\ end=++
\ contained
\ contains=jsxEscapeJs
\ nextgroup=jsxAttrib,jsxSpreadOperator
\ skipwhite
\ skipempty
syntax keyword jsxAttribKeyword class contained display
syntax match jsxSpreadOperator +\.\.\.+ contained display nextgroup=jsxEscapeJs skipwhite
syntax match jsxCloseTag +<//>+ display
syntax match jsxComment +<!--\_.\{-}-->+ display
endif
" Highlight the tag name
highlight def link jsxTag Function
highlight def link jsxTagName Identifier
highlight def link jsxComponentName Function
highlight def link jsxAttrib Type
highlight def link jsxAttribKeyword jsxAttrib
highlight def link jsxEqual Operator
highlight def link jsxString String
highlight def link jsxDot Operator
highlight def link jsxNamespace Operator
if s:highlight_close_tag
highlight def link jsxCloseString Identifier
highlight def link jsxOpenPunct jsxTag
else
" Highlight the jsxCloseString (i.e. />), jsxPunct (i.e. <,>) and jsxCloseTag (i.e. <//>)
highlight def link jsxCloseString Comment
highlight def link jsxOpenPunct jsxPunct
endif
highlight def link jsxPunct jsxCloseString
highlight def link jsxClosePunct jsxPunct
highlight def link jsxCloseTag jsxCloseString
highlight def link jsxComment Comment
highlight def link jsxSpreadOperator Operator
let s:vim_jsx_pretty_colorful_config = get(g:, 'vim_jsx_pretty_colorful_config', 0)
if s:vim_jsx_pretty_colorful_config == 1
highlight def link jsObjectKey Label
highlight def link jsArrowFuncArgs Type
highlight def link jsFuncArgs Type
endif

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -28,21 +28,21 @@ endif
" refine the typescript line comment " refine the typescript line comment
syntax region typescriptLineComment start=+//+ end=/$/ contains=@Spell,typescriptCommentTodo,typescriptRef extend keepend syntax region typescriptLineComment start=+//+ end=/$/ contains=@Spell,typescriptCommentTodo,typescriptRef extend keepend
" add a typescriptBlock group for typescript if !hlexists('typescriptTypeCast')
syntax region typescriptBlock " add a typescriptBlock group for typescript
\ contained syntax region typescriptBlock
\ matchgroup=typescriptBraces \ matchgroup=typescriptBraces
\ start="{" \ start="{"
\ end="}" \ end="}"
\ extend \ contained
\ contains=@typescriptAll,@typescriptExpression,typescriptBlock \ extend
\ fold \ contains=@typescriptExpression,typescriptBlock
\ fold
endif
" because this is autoloaded, when developing you're going to need to source syntax cluster typescriptExpression add=jsxRegion,typescriptParens
" the autoload/jsx_pretty/*.vim file manually, or restart vim
call jsx_pretty#syntax#highlight()
syntax cluster typescriptExpression add=jsxRegion runtime syntax/jsx_pretty.vim
let b:current_syntax = 'typescript.tsx' let b:current_syntax = 'typescript.tsx'
@@ -52,119 +52,7 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'styled-component
finish finish
endif endif
" Vim syntax file runtime! syntax/javascript.vim
" Language: styled-components (js/ts)
" Maintainer: Karl Fleischmann <fleischmann.karl@gmail.com>
" URL: https://github.com/styled-components/vim-styled-components
if exists("b:current_syntax")
let s:current_syntax=b:current_syntax
unlet b:current_syntax
endif
" fix for "-" before cssPositioningProp
" - needs to be above CSS include to not match cssVendor definitions
syn region cssCustomPositioningPrefix contained
\ start='-' end='\%(\s\{-}:\)\@='
\ contains=cssPositioningProp
" introduce CSS cluster from built-in (or single third party syntax file)
syn include @CSS syntax/css.vim
" try to include CSS3 definitions from multiple files
" this is only possible on vim version above 7
if v:version >= 700
try
syn include @CSS3 syntax/css/*.vim
catch
endtry
endif
" TODO: include react-native keywords
" define custom cssAttrRegion
" - add ",", "`" and "{" to the end characters
" - add "cssPseudoClassId" to it's containing elements
" this will incorrectly highlight pseudo elements incorrectly used as
" attributes but correctly highlight actual attributes
syn region cssCustomAttrRegion contained
\ start=":" end="\ze\%(;\|)\|{\|}\|`\)"
\ contains=css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,
\ cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,
\ cssError,cssAttrComma,cssNoise,cssPseudoClassId,
\ jsTemplateExpression,
\ typescriptInterpolation,typescriptTemplateSubstitution
syn region cssCustomAttrRegion contained
\ start="transition\s*:" end="\ze\%(;\|)\|{\|}\|`\)"
\ contains=css.*Prop,css.*Attr,cssColor,cssImportant,cssValue.*,
\ cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,
\ cssVendor,cssError,cssAttrComma,cssNoise,cssPseudoClassId,
\ jsTemplateExpression,
\ typescriptInterpolation,typescriptTemplateSubstitution
" define custom css elements to not utilize cssDefinition
syn region cssCustomMediaBlock contained fold transparent matchgroup=cssBraces
\ start="{" end="}"
\ contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,
\ cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,
\ cssUnicodeEscape,cssVendor,cssTagName,cssClassName,
\ cssIdentifier,cssPseudoClass,cssSelectorOp,cssSelectorOp2,
\ cssAttributeSelector
syn region cssCustomPageWrap contained transparent matchgroup=cssBraces
\ start="{" end="}"
\ contains=cssPageMargin,cssPageProp,cssCustomAttrRegion,css.*Prop,
\ cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,
\ cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,
\ cssHacks
syn match cssCustomPageMargin contained skipwhite skipnl
\ "@\%(\%(top\|left\|right\|bottom\)-\%(left\|center\|right\|middle\|bottom\)\)\%(-corner\)\="
syn match cssCustomKeyFrameSelector "\%(\d*%\|\<from\>\|\<to\>\)" contained
\ skipwhite skipnl
" define css include customly to overwrite nextgroup
syn region cssInclude start="@media\>" end="\ze{" skipwhite skipnl
\ contains=cssMediaProp,cssValueLength,cssMediaKeyword,cssValueInteger,
\ cssMediaMediaAttr,cssVencor,cssMediaType,cssIncludeKeyword,
\ cssMediaComma,cssComment
\ nextgroup=cssCustomMediaBlock
" define all non-contained css definitions
syn cluster CSSTop
\ contains=cssTagName,cssSelectorOp,cssAttributeSelector,cssClassName,
\ cssBraces,cssIdentifier,cssIncludeKeyword,cssPage,cssKeyFrame,
\ cssFontDescriptor,cssAttrComma,cssPseudoClass,cssUnicodeEscape
" custom highlights for styled components
" - "&" inside top level
" - cssTagName inside of jsStrings inside of styledPrefix regions
" TODO: override highlighting of cssTagName with more subtle one
syn match styledAmpersand contained "&"
syn region styledTagNameString matchgroup=jsString contained
\ start=+'+ end=+'+ skip=+\\\%(\'\|$\)+
\ contains=cssTagName
syn region styledTagNameString matchgroup=jsString contained
\ start=+"+ end=+"+ skip=+\\\%(\"\|$\)+
\ contains=cssTagName
syn region styledTagNameString matchgroup=jsString contained
\ start=+`+ end=+`+ skip=+\\\%(\`\|$\)+
\ contains=cssTagName
" define custom API sections that trigger the styledDefinition highlighting
syn match styledPrefix "\<styled\>\.\k\+"
\ transparent fold
\ nextgroup=styledDefinition
\ contains=cssTagName,javascriptTagRef
\ containedin=jsFuncBlock
syn match styledPrefix "\.\<attrs\>\s*(\%(\n\|\s\|.\)\{-})"
\ transparent fold extend
\ nextgroup=styledDefinition
\ contains=jsObject,jsParen
\ containedin=jsFuncBlock
syn match styledPrefix "\.\<extend\>"
\ transparent fold
\ nextgroup=styledDefinition
\ containedin=jsFuncBlock
" define custom API section, that contains typescript annotations " define custom API section, that contains typescript annotations
" this is structurally similar to `jsFuncCall`, but allows type " this is structurally similar to `jsFuncCall`, but allows type
@@ -172,132 +60,57 @@ syn match styledPrefix "\.\<extend\>"
" the function call parenthesis " the function call parenthesis
syn match styledTypescriptPrefix syn match styledTypescriptPrefix
\ "\<styled\><\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>(\%('\k\+'\|\"\k\+\"\|\k\+\))" \ "\<styled\><\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>(\%('\k\+'\|\"\k\+\"\|\k\+\))"
\ transparent fold \ transparent fold extend
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ contains=cssTagName, \ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons, \ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType, \ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType, \ typescriptType,foldBraces,
\ styledTagNameString \ styledTagNameString
\ containedin=foldBraces
syn match styledTypescriptPrefix syn match styledTypescriptPrefix
\ "\<styled\>\%((\%('\k\+'\|\"\k\+\"\|\k\+\))\|\.\k\+\)<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>" \ "\<styled\>\%((\%('\k\+'\|\"\k\+\"\|\k\+\))\|\.\k\+\)<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold \ transparent fold extend
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ contains=cssTagName, \ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons, \ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType, \ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType, \ typescriptType,foldBraces,
\ styledTagNameString \ styledTagNameString
\ containedin=foldBraces
syn match styledTypescriptPrefix "\.\<attrs\>\s*(\%(\n\|\s\|.\)\{-})<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>" syn match styledTypescriptPrefix "\.\<attrs\>\s*(\%(\n\|\s\|.\)\{-})<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold extend \ transparent fold extend
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ contains=cssTagName, \ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons, \ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType, \ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType, \ typescriptType,foldBraces,
\ styledTagNameString \ styledTagNameString
\ containedin=foldBraces
syn match styledTypescriptPrefix "\.\<extend\><\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>" syn match styledTypescriptPrefix "\.\<extend\><\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold extend \ transparent fold extend
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
\ contains=cssTagName, \ contains=cssTagName,
\ typescriptBraces,typescriptOpSymbols,typescriptEndColons, \ typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType, \ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType, \ typescriptType,foldBraces,
\ styledTagNameString \ styledTagNameString
\ containedin=foldBraces
" define emotion css prop
" to bypass problems from top-level defined xml/js definitions, this
" plugin re-defines keywords/noise for highlighting inside of the custom
" xmlAttrib definition
syn keyword styledXmlRegionKeyword css contained
syn match styledXmlRegionNoise "\%(=\|{\|}\)" contained
" only include styledDefinitions inside of xmlAttribs, that are wrapped
" in `css={}` regions, `keepend` is necessary to correctly break on the
" higher-level xmlAttrib region end
syn region styledXmlRegion
\ start="\<css\>={" end="}"
\ keepend fold
\ containedin=xmlAttrib
\ contains=styledXmlRegionKeyword,styledXmlRegionNoise,styledDefinition
" define nested region for indenting
syn region styledNestedRegion contained transparent
\ matchgroup=cssBraces
\ start="{" end="}"
" re-define cssError to be highlighted correctly in styledNestedRegion
syn match cssError contained "{@<>"
" extend javascript matches to trigger styledDefinition highlighting
syn match jsTaggedTemplate extend
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>"
\ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(.\+)" transparent
\ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))"
\ contains=styledTagNameString
\ nextgroup=styledDefinition
syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>" syn match jsFuncCall "\<styled\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))<\%(\[\|\]\|{\|}\||\|&\|:\|;\|,\|?\|'\|\"\|\k\|\s\|\n\)\+>"
\ transparent fold
\ contains=typescriptBraces,typescriptOpSymbols,typescriptEndColons, \ contains=typescriptBraces,typescriptOpSymbols,typescriptEndColons,
\ typescriptParens,typescriptStringS,@typescriptType, \ typescriptParens,typescriptStringS,@typescriptType,
\ typescriptType, \ typescriptType,foldBraces,
\ styledTagNameString \ styledTagNameString
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
syn match jsFuncCall "\.\<withComponent\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))" \ containedin=foldBraces
\ contains=styledTagNameString
syn match jsFuncCall "\<dc\>\s*(\%('\k\+'\|\"\k\+\"\|`\k\+`\))\%((\)\@="
\ contains=styledTagNameString
\ nextgroup=styledDefinitionArgument
" inject css highlighting into custom jsTemplateString region
" - use `extend` to not end all nested jsTemplateExpression on the first
" closing one
syn region styledDefinition contained transparent fold extend
\ start="`" end="`" skip="\\\%(`\|$\)"
\ contains=@CSSTop,
\ css.*Prop,cssValue.*,cssColor,cssUrl,cssImportant,cssError,
\ cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,
\ cssHacks,
\ cssCustom.*,
\ jsComment,jsTemplateExpression,
\ typescriptInterpolation,typescriptTemplateSubstitution,
\ styledAmpersand,styledNestedRegion
syn region styledDefinitionArgument contained transparent start=+(+ end=+)+
\ contains=styledDefinition
syn cluster typescriptValue add=styledPrefix,jsFuncCall,styledTypescriptPrefix syn cluster typescriptValue add=styledPrefix,jsFuncCall,styledTypescriptPrefix
""" yajs specific extensions
" define template tag keywords, that trigger styledDefinitions again to be
" contained in and also do contain the `javascriptTagRef` region
syn match javascriptTagRefStyledPrefix transparent fold
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>"
\ containedin=javascriptTagRef
\ contains=javascriptTagRef
\ nextgroup=styledDefinition
" extend the yajs clusters to include the previously and extraneously defined
" styled-related matches
syn cluster javascriptExpression
\ add=styledPrefix,jsFuncCall,javascriptTagRefStyledPrefix
syn cluster javascriptAfterIdentifier add=styledPrefix,jsFuncCall
""" yats specific extensions """ yats specific extensions
" extend typescriptIdentifierName to allow styledDefinitions in their " extend typescriptIdentifierName to allow styledDefinitions in their
" tagged templates " tagged templates
syn match typescriptIdentifierName extend syn match typescriptIdentifierName extend
\ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>" \ "\<css\>\|\<keyframes\>\|\<injectGlobal\>\|\<fontFace\>\|\<createGlobalStyle\>"
\ nextgroup=styledDefinition \ nextgroup=styledDefinition
" color the custom highlight elements
hi def link cssCustomKeyFrameSelector Constant
hi def link cssCustomPositioningPrefix StorageClass
hi def link styledAmpersand Special
hi def link styledXmlRegionKeyword Type
hi def link styledXmlRegionNoise Noise
hi def link styledXmlRegion String
if exists("s:current_syntax")
let b:current_syntax=s:current_syntax
endif

View File

@@ -0,0 +1,26 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1
finish
endif
if exists('b:current_syntax')
let s:current_syntax = b:current_syntax
unlet b:current_syntax
endif
syn include @GraphQLSyntax syntax/graphql.vim
if exists('s:current_syntax')
let b:current_syntax = s:current_syntax
endif
let s:tags = '\%(' . join(graphql#javascript_tags(), '\|') . '\)'
exec 'syntax region graphqlTemplateString start=+' . s:tags . '\@20<=`+ skip=+\\`+ end=+`+ contains=@GraphQLSyntax,typescriptTemplateSubstitution extend'
exec 'syntax match graphqlTaggedTemplate +' . s:tags . '\ze`+ nextgroup=graphqlTemplateString'
" Support expression interpolation ((${...})) inside template strings.
syntax region graphqlTemplateExpression start=+${+ end=+}+ contained contains=typescriptTemplateSubstitution containedin=graphqlFold keepend
hi def link graphqlTemplateString typescriptTemplate
hi def link graphqlTemplateExpression typescriptTemplateSubstitution
syn cluster typescriptExpression add=graphqlTaggedTemplate
syn cluster graphqlTaggedTemplate add=graphqlTemplateString

View File

@@ -25,6 +25,7 @@ function! elixir#indent#indent(lnum)
let handlers = [ let handlers = [
\'top_of_file', \'top_of_file',
\'starts_with_string_continuation',
\'following_trailing_binary_operator', \'following_trailing_binary_operator',
\'starts_with_pipe', \'starts_with_pipe',
\'starts_with_binary_operator', \'starts_with_binary_operator',
@@ -35,9 +36,14 @@ function! elixir#indent#indent(lnum)
\] \]
for handler in handlers for handler in handlers
call s:debug('testing handler elixir#indent#handle_'.handler) call s:debug('testing handler elixir#indent#handle_'.handler)
let context = {'lnum': lnum, 'text': text, 'prev_nb_lnum': prev_nb_lnum, 'prev_nb_text': prev_nb_text} let context = {'lnum': lnum, 'text': text, 'first_nb_char_idx': match(text, '\w'), 'prev_nb_lnum': prev_nb_lnum, 'prev_nb_text': prev_nb_text}
let indent = function('elixir#indent#handle_'.handler)(context) let indent = function('elixir#indent#handle_'.handler)(context)
if indent != -1 if indent == -2
" Keep indent the same
call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned -2; returning indent of -1')
call cursor(curs_lnum, curs_col)
return -1
elseif indent != -1
call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned '.indent) call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned '.indent)
call cursor(curs_lnum, curs_col) call cursor(curs_lnum, curs_col)
return indent return indent
@@ -102,7 +108,11 @@ endfunction
" Returns 0 or 1 based on whether or not the given line number and column " Returns 0 or 1 based on whether or not the given line number and column
" number pair is a string or comment " number pair is a string or comment
function! s:is_string_or_comment(line, col) function! s:is_string_or_comment(line, col)
return synIDattr(synID(a:line, a:col, 1), "name") =~ '\%(String\|Comment\)' return s:syntax_name(a:line, a:col) =~ '\%(String\|Comment\)'
endfunction
function! s:syntax_name(line, col)
return synIDattr(synID(a:line, a:col, 1), "name")
endfunction endfunction
" Skip expression for searchpair. Returns 0 or 1 based on whether the value " Skip expression for searchpair. Returns 0 or 1 based on whether the value
@@ -158,6 +168,14 @@ function! elixir#indent#handle_top_of_file(context)
end end
endfunction endfunction
function! elixir#indent#handle_starts_with_string_continuation(context)
if s:syntax_name(a:context.lnum, a:context.first_nb_char_idx) =~ '\(String\|Comment\)$'
return -2
else
return -1
end
endfunction
function! elixir#indent#handle_follow_prev_nb(context) function! elixir#indent#handle_follow_prev_nb(context)
return s:get_base_indent(a:context.prev_nb_lnum, a:context.prev_nb_text) return s:get_base_indent(a:context.prev_nb_lnum, a:context.prev_nb_text)
endfunction endfunction

View File

@@ -11,15 +11,15 @@ function! fish#Indent()
let l:indent = 0 let l:indent = 0
let l:prevline = getline(l:prevlnum) let l:prevline = getline(l:prevlnum)
if l:prevline =~# '\v^\s*switch>' if l:prevline =~# '\v^\s*switch>'
let l:indent = l:shiftwidth * 2 return indent(l:prevlnum) + l:shiftwidth
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>' elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
let l:indent = l:shiftwidth let l:indent = l:shiftwidth
endif endif
let l:line = getline(v:lnum) let l:line = getline(v:lnum)
if l:line =~# '\v^\s*end>' if l:line =~# '\v^\s*end>'
return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent) return indent(l:prevlnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent)
elseif l:line =~# '\v^\s*%(case|else)>' elseif l:line =~# '\v^\s*%(case|else)>'
return indent(v:lnum) - l:shiftwidth return indent(l:prevlnum) - l:shiftwidth
endif endif
return indent(l:prevlnum) + l:indent return indent(l:prevlnum) + l:indent
endfunction endfunction

View File

@@ -18,10 +18,6 @@ function! go#config#VersionWarning() abort
return get(g:, 'go_version_warning', 1) return get(g:, 'go_version_warning', 1)
endfunction endfunction
function! go#config#NullModuleWarning() abort
return get(g:, 'go_null_module_warning', 1)
endfunction
function! go#config#BuildTags() abort function! go#config#BuildTags() abort
return get(g:, 'go_build_tags', '') return get(g:, 'go_build_tags', '')
endfunction endfunction
@@ -29,10 +25,12 @@ endfunction
function! go#config#SetBuildTags(value) abort function! go#config#SetBuildTags(value) abort
if a:value is '' if a:value is ''
silent! unlet g:go_build_tags silent! unlet g:go_build_tags
call go#lsp#ResetWorkspaceDirectories()
return return
endif endif
let g:go_build_tags = a:value let g:go_build_tags = a:value
call go#lsp#ResetWorkspaceDirectories()
endfunction endfunction
function! go#config#TestTimeout() abort function! go#config#TestTimeout() abort
@@ -55,6 +53,14 @@ function! go#config#TermMode() abort
return get(g:, 'go_term_mode', 'vsplit') return get(g:, 'go_term_mode', 'vsplit')
endfunction endfunction
function! go#config#TermCloseOnExit() abort
return get(g:, 'go_term_close_on_exit', 1)
endfunction
function! go#config#SetTermCloseOnExit(value) abort
let g:go_term_close_on_exit = a:value
endfunction
function! go#config#TermEnabled() abort function! go#config#TermEnabled() abort
return has('nvim') && get(g:, 'go_term_enabled', 0) return has('nvim') && get(g:, 'go_term_enabled', 0)
endfunction endfunction
@@ -182,6 +188,9 @@ function! go#config#DocUrl() abort
return godoc_url return godoc_url
endfunction endfunction
function! go#config#DocPopupWindow() abort
return get(g:, 'go_doc_popup_window', 0)
endfunction
function! go#config#DefReuseBuffer() abort function! go#config#DefReuseBuffer() abort
return get(g:, 'go_def_reuse_buffer', 0) return get(g:, 'go_def_reuse_buffer', 0)
endfunction endfunction
@@ -276,10 +285,6 @@ function! go#config#MetalinterEnabled() abort
return get(g:, "go_metalinter_enabled", default_enabled) return get(g:, "go_metalinter_enabled", default_enabled)
endfunction endfunction
function! go#config#MetalinterDisabled() abort
return get(g:, "go_metalinter_disabled", [])
endfunction
function! go#config#GolintBin() abort function! go#config#GolintBin() abort
return get(g:, "go_golint_bin", "golint") return get(g:, "go_golint_bin", "golint")
endfunction endfunction

16
autoload/graphql.vim Normal file
View File

@@ -0,0 +1,16 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1
finish
endif
" Vim plugin
" Language: GraphQL
" Maintainer: Jon Parise <jon@indelible.org>
if exists('g:autoloaded_graphql')
finish
endif
let g:autoloaded_graphql = 1
function! graphql#javascript_tags() abort
return get(g:, 'graphql_javascript_tags', ['gql', 'graphql', 'Relay.QL'])
endfunction

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -7,7 +7,7 @@ function! jsx_pretty#comment#update_commentstring(original)
let syn_start = s:syn_name(line('.'), 1) let syn_start = s:syn_name(line('.'), 1)
let save_cursor = getcurpos() let save_cursor = getcurpos()
if syn_start =~ '^jsx' if syn_start =~? '^jsx'
let line = getline(".") let line = getline(".")
let start = len(matchstr(line, '^\s*')) let start = len(matchstr(line, '^\s*'))
let syn_name = s:syn_name(line('.'), start + 1) let syn_name = s:syn_name(line('.'), start + 1)
@@ -16,7 +16,7 @@ function! jsx_pretty#comment#update_commentstring(original)
let &l:commentstring = '// %s' let &l:commentstring = '// %s'
elseif s:syn_contains(line('.'), col('.'), 'jsxTaggedRegion') elseif s:syn_contains(line('.'), col('.'), 'jsxTaggedRegion')
let &l:commentstring = '<!-- %s -->' let &l:commentstring = '<!-- %s -->'
elseif syn_name =~ '^jsxAttrib' elseif syn_name =~? '^jsxAttrib'
let &l:commentstring = '// %s' let &l:commentstring = '// %s'
else else
let &l:commentstring = '{/* %s */}' let &l:commentstring = '{/* %s */}'

View File

@@ -1,4 +1,4 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1 if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish finish
endif endif
@@ -37,7 +37,7 @@ function! s:prev_line(lnum)
endfunction endfunction
function! s:syn_attr_jsx(synattr) function! s:syn_attr_jsx(synattr)
return a:synattr =~ "^jsx" return a:synattr =~? "^jsx"
endfunction endfunction
function! s:syn_xmlish(syns) function! s:syn_xmlish(syns)
@@ -45,21 +45,21 @@ function! s:syn_xmlish(syns)
endfunction endfunction
function! s:syn_jsx_element(syns) function! s:syn_jsx_element(syns)
return get(a:syns, -1) =~ 'jsxElement' return get(a:syns, -1) =~? 'jsxElement'
endfunction endfunction
function! s:syn_js_comment(syns) function! s:syn_js_comment(syns)
return get(a:syns, -1) =~ 'Comment$' return get(a:syns, -1) =~? 'Comment$'
endfunction endfunction
function! s:syn_jsx_escapejs(syns) function! s:syn_jsx_escapejs(syns)
return get(a:syns, -1) =~ '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' && return get(a:syns, -1) =~? '\(\(js\(Template\)\?\|javaScript\(Embed\)\?\|typescript\)Braces\|javascriptTemplateSB\|typescriptInterpolationDelimiter\)' &&
\ (get(a:syns, -2) =~ 'jsxEscapeJs' || \ (get(a:syns, -2) =~? 'jsxEscapeJs' ||
\ get(a:syns, -3) =~ 'jsxEscapeJs') \ get(a:syns, -3) =~? 'jsxEscapeJs')
endfunction endfunction
function! s:syn_jsx_attrib(syns) function! s:syn_jsx_attrib(syns)
return len(filter(copy(a:syns), 'v:val =~ "jsxAttrib"')) return len(filter(copy(a:syns), 'v:val =~? "jsxAttrib"'))
endfunction endfunction
let s:start_tag = '<\s*\([-:_\.\$0-9A-Za-z]\+\|>\)' let s:start_tag = '<\s*\([-:_\.\$0-9A-Za-z]\+\|>\)'
@@ -73,17 +73,30 @@ function! jsx_pretty#indent#get(js_indent)
let line = substitute(getline(lnum), '^\s*\|\s*$', '', 'g') let line = substitute(getline(lnum), '^\s*\|\s*$', '', 'g')
let current_syn = s:syn_sol(lnum) let current_syn = s:syn_sol(lnum)
let current_syn_eol = s:syn_eol(lnum) let current_syn_eol = s:syn_eol(lnum)
let prev_syn_sol = s:syn_sol(lnum - 1) let prev_line_num = prevnonblank(lnum - 1)
let prev_syn_eol = s:syn_eol(lnum - 1) let prev_syn_sol = s:syn_sol(prev_line_num)
let prev_syn_eol = s:syn_eol(prev_line_num)
let prev_line = s:prev_line(lnum) let prev_line = s:prev_line(lnum)
let prev_ind = s:prev_indent(lnum) let prev_ind = s:prev_indent(lnum)
if s:syn_xmlish(current_syn) if s:syn_xmlish(current_syn)
if !s:syn_xmlish(prev_syn_sol)
\ && !s:syn_jsx_escapejs(prev_syn_sol)
\ && !s:syn_jsx_escapejs(prev_syn_eol)
\ && !s:syn_js_comment(prev_syn_sol)
if line =~ '^/\s*>' || line =~ '^<\s*' . s:end_tag
return prev_ind
else
return prev_ind + s:sw()
endif
elseif !s:syn_xmlish(prev_syn_sol) && !s:syn_js_comment(prev_syn_sol) && s:syn_jsx_attrib(current_syn)
" For #79
return prev_ind + s:sw()
" { " {
" <div></div> " <div></div>
" ##} <-- " ##} <--
if s:syn_jsx_element(current_syn) && line =~ '}$' elseif s:syn_jsx_element(current_syn) && line =~ '}$'
let pair_line = searchpair('{', '', '}', 'b') let pair_line = searchpair('{', '', '}', 'b')
return indent(pair_line) return indent(pair_line)
elseif line =~ '^-->$' elseif line =~ '^-->$'
@@ -124,6 +137,8 @@ function! jsx_pretty#indent#get(js_indent)
else else
return prev_ind return prev_ind
endif endif
elseif prev_line =~ '^\<return'
return prev_ind
else else
return prev_ind - s:sw() return prev_ind - s:sw()
endif endif
@@ -141,16 +156,6 @@ function! jsx_pretty#indent#get(js_indent)
else else
return prev_ind return prev_ind
endif endif
elseif !s:syn_xmlish(prev_syn_sol)
if prev_line =~ '^\<\(return\|default\|await\|yield\)'
if line !~ '^/\s*>' || line !~ '^<\s*' . s:end_tag
return prev_ind + s:sw()
else
return prev_ind
endif
else
return prev_ind
endif
else else
return prev_ind return prev_ind
endif endif
@@ -174,7 +179,8 @@ function! jsx_pretty#indent#get(js_indent)
return prev_ind + s:sw() return prev_ind + s:sw()
endif endif
endif endif
elseif s:syn_jsx_escapejs(current_syn_eol) elseif line =~ '^`' && s:syn_jsx_escapejs(current_syn_eol)
" For `} of template syntax
let pair_line = searchpair('{', '', '}', 'bW') let pair_line = searchpair('{', '', '}', 'bW')
return indent(pair_line) return indent(pair_line)
elseif line =~ '^/[/*]' " js comment in jsx tag elseif line =~ '^/[/*]' " js comment in jsx tag
@@ -188,6 +194,14 @@ function! jsx_pretty#indent#get(js_indent)
else else
let ind = a:js_indent() let ind = a:js_indent()
" Issue #68
" return (<div>
" |<div>)
if (line =~ '^/\s*>' || line =~ '^<\s*' . s:end_tag)
\ && !s:syn_xmlish(prev_syn_sol)
return prev_ind
endif
" If current syntax is not a jsx syntax group " If current syntax is not a jsx syntax group
if s:syn_xmlish(prev_syn_eol) && line !~ '^[)\]}]' if s:syn_xmlish(prev_syn_eol) && line !~ '^[)\]}]'
let sol = matchstr(line, s:opfirst) let sol = matchstr(line, s:opfirst)

View File

@@ -1,218 +0,0 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'jsx') != -1
finish
endif
function! jsx_pretty#syntax#highlight()
let s:highlight_close_tag = get(g:, 'vim_jsx_pretty_highlight_close_tag', 0)
" <tag id="sample">
" ~~~~~~~~~~~~~~~~~
" and self close tag
" <tag id="sample" />
" ~~~~~~~~~~~~~~~~~~~
syntax region jsxTag
\ start=+<+
\ matchgroup=jsxOpenPunct
\ end=+>+
\ matchgroup=NONE
\ end=+\(/\_s*>\)\@=+
\ contained
\ contains=jsxOpenTag,jsxEscapeJs,jsxAttrib,jsComment,@javascriptComments,javaScriptLineComment,javaScriptComment,typescriptLineComment,typescriptComment,jsxSpreadOperator
\ keepend
\ extend
" <tag></tag>
" ~~~~~~~~~~~
" and fragment
" <></>
" ~~~~~
" and self close tag
" <tag />
" ~~~~~~~
syntax region jsxElement
\ start=+<\_s*\(>\|\${\|\z(\<[-:_\.\$0-9A-Za-z]\+\>\)\)+
\ end=+/\_s*>+
\ end=+<\_s*/\_s*\z1\_s*>+
\ contains=jsxElement,jsxEscapeJs,jsxTag,jsxComment,jsxCloseString,jsxCloseTag,@Spell
\ keepend
\ extend
\ contained
\ fold
" detect jsx region
syntax region jsxRegion
\ start=+\(\(\_[([,?:=+\-*/<>{}]\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\(>\|\z(\(script\)\@!\<[_\$A-Za-z][-:_\.\$0-9A-Za-z]*\>\)\(\_s*\([-+*)\]}&|?]\|/\([/*]\|\_s*>\)\@!\)\)\@!\)+
\ end=++
\ contains=jsxElement
" <tag key={this.props.key}>
" ~~~~~~~~~~~~~~~~
syntax region jsxEscapeJs
\ start=+{+
\ end=++
\ extend
\ contained
\ contains=jsBlock,javascriptBlock,javaScriptBlockBuildIn,typescriptBlock
" <tag key={this.props.key}>
" ~~~~
" and fragment start tag
" <>
" ~~
exe 'syntax region jsxOpenTag
\ matchgroup=jsxOpenPunct
\ start=+<+
\ end=+>+
\ matchgroup=NONE
\ end=+\>+
\ contained
\ contains=jsxTagName
\ nextgroup=jsxAttrib
\ skipwhite
\ skipempty ' .(s:highlight_close_tag ? 'transparent' : '')
" <foo.bar>
" ~
syntax match jsxDot +\.+ contained display
" <foo:bar>
" ~
syntax match jsxNamespace +:+ contained display
" <tag id="sample">
" ~
syntax match jsxEqual +=+ contained display nextgroup=jsxString,jsxEscapeJs,jsxRegion skipwhite
" <tag />
" ~~
syntax match jsxCloseString +/\_s*>+ contained
" </tag>
" ~~~~~~
" and fragment close tag
" </>
" ~~~
syntax region jsxCloseTag
\ matchgroup=jsxClosePunct
\ start=+<\_s*/+
\ end=+>+
\ contained
\ contains=jsxTagName
" <tag key={this.props.key}>
" ~~~
syntax match jsxAttrib
\ +\<[-A-Za-z_][-:_\$0-9A-Za-z]*\>+
\ contained
\ nextgroup=jsxEqual
\ skipwhite
\ skipempty
\ contains=jsxAttribKeyword
\ display
" <MyComponent ...>
" ~~~~~~~~~~~
" NOT
" <someCamel ...>
" ~~~~~
exe 'syntax match jsxComponentName
\ +\<[A-Z][\$0-9A-Za-z]\+\>+
\ contained
\ display ' .(s:highlight_close_tag ? 'transparent' : '')
" <tag key={this.props.key}>
" ~~~
exe 'syntax match jsxTagName
\ +\<[-:_\.\$0-9A-Za-z]\+\>+
\ contained
\ contains=jsxComponentName,jsxDot,jsxNamespace
\ nextgroup=jsxAttrib
\ skipempty
\ skipwhite
\ display ' .(s:highlight_close_tag ? 'transparent' : '')
" <tag id="sample">
" ~~~~~~~~
" and
" <tag id='sample'>
" ~~~~~~~~
syntax region jsxString start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ contained contains=@Spell display
let s:tags = get(g:, 'vim_jsx_pretty_template_tags', ['html', 'raw'])
let s:enable_tagged_jsx = !empty(s:tags)
" add support to JSX inside the tagged template string
" https://github.com/developit/htm
if s:enable_tagged_jsx
exe 'syntax region jsxTaggedRegion
\ start=+\%('. join(s:tags, '\|') .'\)\@<=`+ms=s+1
\ end=+`+me=e-1
\ extend
\ contained
\ containedin=jsTemplateString,javascriptTemplate,javaScriptStringT,typescriptStringB
\ contains=jsxElement'
syntax region jsxEscapeJs
\ start=+\${+
\ end=++
\ extend
\ contained
\ contains=jsTemplateExpression,javascriptTemplateSubstitution,javaScriptEmbed,typescriptInterpolation
syntax region jsxOpenTag
\ matchgroup=jsxOpenPunct
\ start=+<\%(\${\)\@=+
\ matchgroup=NONE
\ end=++
\ contained
\ contains=jsxEscapeJs
\ nextgroup=jsxAttrib,jsxSpreadOperator
\ skipwhite
\ skipempty
syntax keyword jsxAttribKeyword class contained display
syntax match jsxSpreadOperator +\.\.\.+ contained display nextgroup=jsxEscapeJs skipwhite
syntax match jsxCloseTag +<//>+ display
syntax match jsxComment +<!--\_.\{-}-->+ display
endif
" Highlight the tag name
highlight def link jsxTag Function
highlight def link jsxTagName Identifier
highlight def link jsxComponentName Function
highlight def link jsxAttrib Type
highlight def link jsxAttribKeyword jsxAttrib
highlight def link jsxEqual Operator
highlight def link jsxString String
highlight def link jsxDot Operator
highlight def link jsxNamespace Operator
" Highlight the jsxCloseString (i.e. />), jsxPunct (i.e. <,>) and jsxCloseTag (i.e. <//>)
highlight def link jsxCloseString Comment
highlight def link jsxPunct jsxCloseString
highlight def link jsxOpenPunct jsxPunct
highlight def link jsxClosePunct jsxPunct
highlight def link jsxCloseTag jsxCloseString
highlight def link jsxComment Comment
highlight def link jsxSpreadOperator Operator
if s:highlight_close_tag
highlight! def link jsxOpenPunct jsxTag
highlight! def link jsxCloseString Identifier
endif
let s:vim_jsx_pretty_colorful_config = get(g:, 'vim_jsx_pretty_colorful_config', 0)
if s:vim_jsx_pretty_colorful_config == 1
highlight def link jsObjectKey Label
highlight def link jsArrowFuncArgs Type
highlight def link jsFuncArgs Type
endif
endfunction

72
autoload/puppet/align.vim Normal file
View File

@@ -0,0 +1,72 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'puppet') != -1
finish
endif
function! puppet#align#IndentLevel(lnum)
return indent(a:lnum) / &shiftwidth
endfunction
function! puppet#align#LinesInBlock(lnum)
let lines = []
let indent_level = puppet#align#IndentLevel(a:lnum)
let marker = a:lnum - 1
while marker >= 1
let line_text = getline(marker)
let line_indent = puppet#align#IndentLevel(marker)
if line_text =~? '\v\S'
if line_indent < indent_level
break
elseif line_indent == indent_level
call add(lines, marker)
endif
endif
let marker -= 1
endwhile
let marker = a:lnum
while marker <= line('$')
let line_text = getline(marker)
let line_indent = puppet#align#IndentLevel(marker)
if line_text =~? '\v\S'
if line_indent < indent_level
break
elseif line_indent == indent_level
call add(lines, marker)
endif
endif
let marker += 1
endwhile
return lines
endfunction
""
" Format lines with hashrocket (=>)
" @param a:1 a line where function should search for first hashrocket
" expression, if param is not given, line with active cursor is used
function! puppet#align#AlignHashrockets(...) abort
let l:lnum = get(a:, 1, line('.'))
let lines_in_block = puppet#align#LinesInBlock(l:lnum)
let max_left_len = 0
let indent_str = printf('%' . indent(l:lnum) . 's', '')
for line_num in lines_in_block
let data = matchlist(getline(line_num), '^\s*\(.\{-}\S\)\s*=>\s*\(.*\)$')
if !empty(data)
let max_left_len = max([max_left_len, strlen(data[1])])
endif
endfor
for line_num in lines_in_block
let data = matchlist(getline(line_num), '^\s*\(.\{-}\S\)\s*=>\s*\(.*\)$')
if !empty(data)
let new_line = printf('%s%-' . max_left_len . 's => %s', indent_str, data[1], data[2])
call setline(line_num, new_line)
endif
endfor
endfunction

40
autoload/puppet/ctags.vim Normal file
View File

@@ -0,0 +1,40 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'puppet') != -1
finish
endif
if !exists('s:ctags_type')
let s:ctags_type = 0
endif
let s:ctags_options_dir = expand('<sfile>:p:h:h:h') . '/ctags/'
" Return full path to option file for ctags application
function! puppet#ctags#OptionFile()
if puppet#ctags#Type() == 'universal'
let l:ctags_options = 'puppet_u.ctags'
else
let l:ctags_options = 'puppet.ctags'
endif
return s:ctags_options_dir . l:ctags_options
endfunction
" Return type of installed ctags application,
" can be 'universal' or 'exuberant'
function! puppet#ctags#Type()
if !s:ctags_type
let l:version = system('ctags --version')
if l:version =~ 'Universal Ctags'
let s:ctags_type = 'universal'
elseif l:version =~ 'Exuberant Ctags'
let s:ctags_type = 'exuberant'
else
echoerr 'Unknown version of Ctags'
endif
endif
return s:ctags_type
endfunction

View File

@@ -0,0 +1,61 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'puppet') != -1
finish
endif
"
" Simple format using puppet's l:indents and align hashrockets function
function! puppet#format#Format() abort
let l:start_lnum = v:lnum
let l:end_lnum = v:lnum + v:count - 1
call puppet#format#Indention(l:start_lnum, l:end_lnum)
call puppet#format#Hashrocket(l:start_lnum, l:end_lnum)
call puppet#format#Fallback(l:start_lnum, l:end_lnum)
endfunction
""
" Format hashrockets expressions in every line in range start_lnum and
" end_lnum, both ends included
"
" TODO way of using AlignHashrockets function is ineffective, because it
" formats same lines again and again, find better way to do it
function! puppet#format#Hashrocket(start_lnum, end_lnum) abort
let l:lnum = a:start_lnum
while l:lnum <= a:end_lnum
call puppet#align#AlignHashrockets(l:lnum)
let l:lnum += 1
endwhile
endfunction
""
" Format indention in every line in range start_lnum and end_lnum, both ends
" included
"
function! puppet#format#Indention(start_lnum, end_lnum) abort
execute 'normal! ' . a:start_lnum . 'gg=' . a:end_lnum . 'gg'
endfunction
""
" Use internal vim default autoformat method for every line in range, only
" lines which exeed &widthline are formated
"
function! puppet#format#Fallback(start_lnum, end_lnum) abort
" I'm using it to check if autoformat expand range
let l:eof_lnum = line('$')
let l:lnum = a:start_lnum
let l:end_lnum = a:end_lnum
while l:lnum <= l:end_lnum
if strlen(getline(l:lnum)) > &textwidth
call cursor(l:lnum)
execute 'normal! gww'
" Checking if autoformat expand number of lines if yes, I will extend
" range too
if l:eof_lnum < line('$')
let l:end_lnum += line('$') - l:eof_lnum
let l:eof_lnum = line('$')
endif
endif
let l:lnum += 1
endwhile
endfunction

View File

@@ -509,7 +509,7 @@ function! rust#Test(all, options) abort
return rust#Run(1, '--test ' . a:options) return rust#Run(1, '--test ' . a:options)
endif endif
if exists(':terminal') if has('terminal') || has('nvim')
let cmd = 'terminal ' let cmd = 'terminal '
else else
let cmd = '!' let cmd = '!'
@@ -530,7 +530,7 @@ function! rust#Test(all, options) abort
let func_name = s:SearchTestFunctionNameUnderCursor() let func_name = s:SearchTestFunctionNameUnderCursor()
if func_name ==# '' if func_name ==# ''
echohl ErrorMsg echohl ErrorMsg
echo 'No test function was found under the cursor. Please add ! to command if you want to run all tests' echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests'
echohl None echohl None
return return
endif endif

View File

@@ -5,6 +5,7 @@ endif
" For debugging, inspired by https://github.com/w0rp/rust/blob/master/autoload/rust/debugging.vim " For debugging, inspired by https://github.com/w0rp/rust/blob/master/autoload/rust/debugging.vim
let s:global_variable_list = [ let s:global_variable_list = [
\ '_rustfmt_autosave_because_of_config',
\ 'ftplugin_rust_source_path', \ 'ftplugin_rust_source_path',
\ 'loaded_syntastic_rust_cargo_checker', \ 'loaded_syntastic_rust_cargo_checker',
\ 'loaded_syntastic_rust_filetype', \ 'loaded_syntastic_rust_filetype',
@@ -32,7 +33,6 @@ let s:global_variable_list = [
\ 'rustc_makeprg_no_percent', \ 'rustc_makeprg_no_percent',
\ 'rustc_path', \ 'rustc_path',
\ 'rustfmt_autosave', \ 'rustfmt_autosave',
\ 'rustfmt_autosave_because_of_config',
\ 'rustfmt_autosave_if_config_present', \ 'rustfmt_autosave_if_config_present',
\ 'rustfmt_command', \ 'rustfmt_command',
\ 'rustfmt_emit_files', \ 'rustfmt_emit_files',
@@ -48,7 +48,9 @@ endfunction
function! s:EchoGlobalVariables() abort function! s:EchoGlobalVariables() abort
for l:key in s:global_variable_list for l:key in s:global_variable_list
call s:Echo('let g:' . l:key . ' = ' . string(get(g:, l:key, v:null))) if l:key !~# '^_'
call s:Echo('let g:' . l:key . ' = ' . string(get(g:, l:key, v:null)))
endif
if has_key(b:, l:key) if has_key(b:, l:key)
call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key])) call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key]))

21
autoload/rust/tags.vim Normal file
View File

@@ -0,0 +1,21 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'rust') != -1
finish
endif
" Tagbar support code, for the sake of not automatically overriding its
" configuration in case Universal Ctags is detected.
let s:ctags_is_uctags = 0
let s:checked_ctags = 0
function! rust#tags#IsUCtags() abort
if s:checked_ctags == 0
if system('ctags --version') =~? 'universal ctags'
let s:ctags_is_uctags = 1
endif
let s:checked_ctags = 1
endif
return s:ctags_is_uctags
endfunction
" vim: set et sw=4 sts=4 ts=8:

View File

@@ -246,7 +246,12 @@ function! rustfmt#PreWrite()
if rust#GetConfigVar('rustfmt_autosave_if_config_present', 0) if rust#GetConfigVar('rustfmt_autosave_if_config_present', 0)
if findfile('rustfmt.toml', '.;') !=# '' || findfile('.rustfmt.toml', '.;') !=# '' if findfile('rustfmt.toml', '.;') !=# '' || findfile('.rustfmt.toml', '.;') !=# ''
let b:rustfmt_autosave = 1 let b:rustfmt_autosave = 1
let b:rustfmt_autosave_because_of_config = 1 let b:_rustfmt_autosave_because_of_config = 1
endif
else
if has_key(b:, '_rustfmt_autosave_because_of_config')
unlet b:_rustfmt_autosave_because_of_config
unlet b:rustfmt_autosave
endif endif
endif endif

View File

@@ -2,24 +2,59 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'terraform') != -
finish finish
endif endif
" Adapted from vim-hclfmt:
" https://github.com/fatih/vim-hclfmt/blob/master/autoload/fmt.vim
function! terraform#fmt() function! terraform#fmt()
if !filereadable(expand('%:p')) if !filereadable(expand('%:p'))
return return
endif endif
let l:curw = winsaveview() let l:curw = winsaveview()
let l:tmpfile = tempname() . '.tf' " Make a fake change so that the undo point is right.
call writefile(getline(1, '$'), l:tmpfile) normal! ix
let output = system('terraform fmt -write ' . l:tmpfile) normal! "_x
if v:shell_error == 0 silent execute '%!terraform fmt -no-color -'
try | silent undojoin | catch | endtry if v:shell_error != 0
call rename(l:tmpfile, resolve(expand('%'))) let output = getline(1, '$')
silent edit! silent undo
let &syntax = &syntax echo join(output, "\n")
else
echo output
call delete(l:tmpfile)
endif endif
call winrestview(l:curw) call winrestview(l:curw)
endfunction endfunction
function! terraform#align()
let p = '^.*=[^>]*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
function! terraform#commands(A, L, P)
return [
\ 'apply',
\ 'console',
\ 'destroy',
\ 'env',
\ 'fmt',
\ 'get',
\ 'graph',
\ 'import',
\ 'init',
\ 'output',
\ 'plan',
\ 'providers',
\ 'refresh',
\ 'show',
\ 'taint',
\ 'untaint',
\ 'validate',
\ 'version',
\ 'workspace',
\ '0.12upgrade',
\ 'debug',
\ 'force-unlock',
\ 'push',
\ 'state'
\ ]
endfunction

28
build
View File

@@ -6,13 +6,13 @@ DIRS="syntax indent compiler autoload ftplugin after/syntax after/indent after/f
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIRS_BASIC="syntax compiler indent after/syntax after/indent" DIRS_BASIC="syntax compiler indent after/syntax after/indent"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIRS_ALL="syntax indent compiler autoload ftplugin after" DIRS_ALL="syntax indent compiler autoload ftplugin after extras"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIRS_SYNTAX="syntax indent after/syntax after/indent" DIRS_SYNTAX="syntax indent after/syntax after/indent"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
DIRS_NOAFTER="syntax compiler indent autoload ftplugin" DIRS_NOAFTER="syntax compiler indent autoload ftplugin"
DIRS_JAVASCRIPT="${DIRS} extras" DIRS_JAVASCRIPT="${DIRS} extras"
read -r -a DIRS_RM <<<"$DIRS_JAVASCRIPT" read -r -a DIRS_RM <<<"$DIRS_ALL"
OUTPUT="" OUTPUT=""
@@ -127,7 +127,11 @@ copy_file() {
touch "$file_in_dst" touch "$file_in_dst"
# Use comma instead of / to handle cases like c/c++ # Use comma instead of / to handle cases like c/c++
sed -e "s,%%PACK%%,${package_name}," -e "/%%CONTENT%%/{r ${file_in_tmp}" -e "d;}" plugin_guard.vim.template >> "$file_in_dst" if [[ "${package_name}" == "jsx" ]]; then
sed -e "s,%%PACK%%,${package_name}," -e "/%%CONTENT%%/{r ${file_in_tmp}" -e "d;}" plugin_guard_jsx.vim.template >> "$file_in_dst"
else
sed -e "s,%%PACK%%,${package_name}," -e "/%%CONTENT%%/{r ${file_in_tmp}" -e "d;}" plugin_guard.vim.template >> "$file_in_dst"
fi
} }
update_readme() { update_readme() {
@@ -178,6 +182,7 @@ PACKS="
cucumber:tpope/vim-cucumber cucumber:tpope/vim-cucumber
cue:mgrabovsky/vim-cuesheet cue:mgrabovsky/vim-cuesheet
dart:dart-lang/dart-vim-plugin dart:dart-lang/dart-vim-plugin
dhall:vmchale/dhall-vim
dlang:JesseKPhillips/d.vim dlang:JesseKPhillips/d.vim
dockerfile:ekalinin/Dockerfile.vim dockerfile:ekalinin/Dockerfile.vim
elixir:elixir-lang/vim-elixir elixir:elixir-lang/vim-elixir
@@ -186,7 +191,7 @@ PACKS="
emblem:yalesov/vim-emblem emblem:yalesov/vim-emblem
erlang:vim-erlang/vim-erlang-runtime erlang:vim-erlang/vim-erlang-runtime
ferm:vim-scripts/ferm.vim ferm:vim-scripts/ferm.vim
fish:dag/vim-fish fish:georgewitteman/vim-fish
flatbuffers:dcharbon/vim-flatbuffers flatbuffers:dcharbon/vim-flatbuffers
fsharp:fsharp/vim-fsharp:_BASIC fsharp:fsharp/vim-fsharp:_BASIC
git:tpope/vim-git git:tpope/vim-git
@@ -194,6 +199,7 @@ PACKS="
gmpl:maelvalais/gmpl.vim gmpl:maelvalais/gmpl.vim
gnuplot:vim-scripts/gnuplot-syntax-highlighting gnuplot:vim-scripts/gnuplot-syntax-highlighting
go:fatih/vim-go:_BASIC go:fatih/vim-go:_BASIC
graphql:jparise/vim-graphql:_ALL
gradle:tfnico/vim-gradle gradle:tfnico/vim-gradle
groovy:vim-scripts/groovy.vim groovy:vim-scripts/groovy.vim
groovy-indent:vim-scripts/groovyindent-unix groovy-indent:vim-scripts/groovyindent-unix
@@ -203,6 +209,7 @@ PACKS="
haskell:neovimhaskell/haskell-vim haskell:neovimhaskell/haskell-vim
haxe:yaymukund/vim-haxe haxe:yaymukund/vim-haxe
hcl:b4b4r07/vim-hcl hcl:b4b4r07/vim-hcl
helm:towolf/vim-helm
hive:zebradil/hive.vim hive:zebradil/hive.vim
html5:othree/html5.vim html5:othree/html5.vim
i3:mboughaba/i3config.vim i3:mboughaba/i3config.vim
@@ -246,19 +253,18 @@ PACKS="
powershell:PProvost/vim-ps1 powershell:PProvost/vim-ps1
protobuf:uarun/vim-protobuf protobuf:uarun/vim-protobuf
pug:digitaltoad/vim-pug pug:digitaltoad/vim-pug
puppet:voxpupuli/vim-puppet puppet:rodjek/vim-puppet
purescript:purescript-contrib/purescript-vim purescript:purescript-contrib/purescript-vim
python-compiler:aliev/vim-compiler-python python-compiler:aliev/vim-compiler-python
python-indent:Vimjas/vim-python-pep8-indent python-indent:Vimjas/vim-python-pep8-indent
python:vim-python/python-syntax python:vim-python/python-syntax
qmake:artoj/qmake-syntax-vim qmake:artoj/qmake-syntax-vim
qml:peterhoeg/vim-qml qml:peterhoeg/vim-qml
r-lang:vim-scripts/R.vim r-lang:vim-scripts/R.vim:_BASIC
racket:wlangstroth/vim-racket racket:wlangstroth/vim-racket
ragel:jneen/ragel.vim ragel:jneen/ragel.vim
raml:IN3D/vim-raml raml:IN3D/vim-raml
reason:reasonml-editor/vim-reason-plus reason:reasonml-editor/vim-reason-plus
rego:tsandall/vim-rego
rspec:sheerun/rspec.vim rspec:sheerun/rspec.vim
rst:marshallward/vim-restructuredtext rst:marshallward/vim-restructuredtext
ruby:vim-ruby/vim-ruby ruby:vim-ruby/vim-ruby
@@ -270,8 +276,9 @@ PACKS="
slime:slime-lang/vim-slime-syntax slime:slime-lang/vim-slime-syntax
smt2:bohlender/vim-smt2 smt2:bohlender/vim-smt2
solidity:tomlion/vim-solidity solidity:tomlion/vim-solidity
styled-components:styled-components/vim-styled-components#main styled-components:styled-components/vim-styled-components#main:_ALL
stylus:wavded/vim-stylus stylus:wavded/vim-stylus
svelte:evanleck/vim-svelte
svg-indent:jasonshell/vim-svg-indent svg-indent:jasonshell/vim-svg-indent
svg:vim-scripts/svg.vim svg:vim-scripts/svg.vim
swift:keith/swift.vim swift:keith/swift.vim
@@ -280,12 +287,12 @@ PACKS="
terraform:hashivim/vim-terraform terraform:hashivim/vim-terraform
textile:timcharper/textile.vim textile:timcharper/textile.vim
thrift:solarnz/thrift.vim thrift:solarnz/thrift.vim
tmux:ericpruitt/tmux.vim tmux:ericpruitt/tmux.vim:_ALL:/vim/
tomdoc:wellbredgrapefruit/tomdoc.vim tomdoc:wellbredgrapefruit/tomdoc.vim
toml:cespare/vim-toml toml:cespare/vim-toml
tptp:c-cube/vim-tptp tptp:c-cube/vim-tptp
twig:lumiliet/vim-twig twig:lumiliet/vim-twig
typescript:leafgarland/typescript-vim typescript:HerringtonDarkholme/yats.vim
vala:arrufat/vala.vim vala:arrufat/vala.vim
vbnet:vim-scripts/vbnet.vim vbnet:vim-scripts/vbnet.vim
vcl:smerrill/vcl-vim-plugin vcl:smerrill/vcl-vim-plugin
@@ -297,6 +304,7 @@ PACKS="
xls:vim-scripts/XSLT-syntax xls:vim-scripts/XSLT-syntax
yaml:stephpy/vim-yaml yaml:stephpy/vim-yaml
yard:sheerun/vim-yardoc yard:sheerun/vim-yardoc
zephir:xwsoul/vim-zephir
zig:ziglang/zig.vim zig:ziglang/zig.vim
" "

View File

@@ -11,5 +11,5 @@ if exists(":CompilerSet") != 2
command -nargs=* CompilerSet setlocal <args> command -nargs=* CompilerSet setlocal <args>
endif endif
CompilerSet errorformat=%f:%l:\ %t:\ %m CompilerSet errorformat=%f:%l:%c:\ %t:\ %m,%f:%l:\ %t:\ %m
CompilerSet makeprg=mix\ credo\ suggest\ --format=flycheck CompilerSet makeprg=mix\ credo\ suggest\ --format=flycheck

View File

@@ -11,5 +11,10 @@ if exists(":CompilerSet") != 2
command -nargs=* CompilerSet setlocal <args> command -nargs=* CompilerSet setlocal <args>
endif endif
CompilerSet errorformat=%A%t%*[^:]:\ %m,%C%f:%l:\ %m,%C%f:%l,%Z CompilerSet makeprg=mix\ compile
CompilerSet makeprg=mix CompilerSet errorformat=
\%Wwarning:\ %m,
\%C%f:%l,%Z,
\%E==\ Compilation\ error\ in\ file\ %f\ ==,
\%C**\ (%\\w%\\+)\ %f:%l:\ %m,%Z

View File

@@ -25,7 +25,11 @@ endif
if get(g:, 'rustc_makeprg_no_percent', 0) if get(g:, 'rustc_makeprg_no_percent', 0)
CompilerSet makeprg=rustc CompilerSet makeprg=rustc
else else
CompilerSet makeprg=rustc\ \% if has('patch-7.4.191')
CompilerSet makeprg=rustc\ \%:S
else
CompilerSet makeprg=rustc\ \%
endif
endif endif
" New errorformat (after nightly 2016/08/10) " New errorformat (after nightly 2016/08/10)

View File

@@ -2,33 +2,24 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') !=
finish finish
endif endif
if exists("current_compiler") if exists('current_compiler')
finish finish
endif endif
let current_compiler = "typescript"
if !exists("g:typescript_compiler_binary") let current_compiler='typescript'
let g:typescript_compiler_binary = "tsc"
if !exists('g:typescript_compiler_binary')
let g:typescript_compiler_binary = 'tsc'
endif endif
if !exists("g:typescript_compiler_options") if !exists('g:typescript_compiler_options')
let g:typescript_compiler_options = "" if exists('g:syntastic_typescript_tsc_args')
let g:typescript_compiler_options = g:syntastic_typescript_tsc_args
else
let g:typescript_compiler_options = ''
endif
endif endif
if exists(":CompilerSet") != 2 let &l:makeprg = g:typescript_compiler_binary . ' ' . g:typescript_compiler_options . ' $* %'
command! -nargs=* CompilerSet setlocal <args>
endif
let s:cpo_save = &cpo
set cpo-=C
execute 'CompilerSet makeprg='
\ . escape(g:typescript_compiler_binary, ' ')
\ . '\ '
\ . escape(g:typescript_compiler_options, ' ')
\ . '\ $*\ %'
CompilerSet errorformat=%+A\ %#%f\ %#(%l\\\,%c):\ %m,%C%m CompilerSet errorformat=%+A\ %#%f\ %#(%l\\\,%c):\ %m,%C%m
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@@ -1,9 +1,3 @@
function! s:setf(filetype) abort
if &filetype !=# a:filetype
let &filetype = a:filetype
endif
endfunction
" Enable jsx syntax by default " Enable jsx syntax by default
if !exists('g:jsx_ext_required') if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 0 let g:jsx_ext_required = 0
@@ -50,8 +44,9 @@ augroup filetypedetect
" elixir " elixir
au BufRead,BufNewFile *.ex,*.exs call s:setf('elixir') au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
au BufRead,BufNewFile *.eex call s:setf('eelixir') au BufRead,BufNewFile *.eex,*.leex set filetype=eelixir
au BufRead,BufNewFile mix.lock set filetype=elixir
" fish " fish
autocmd BufRead,BufNewFile *.fish setfiletype fish autocmd BufRead,BufNewFile *.fish setfiletype fish
@@ -91,3 +86,7 @@ augroup END
if (!exists('g:graphql_javascript_tags')) if (!exists('g:graphql_javascript_tags'))
let g:graphql_javascript_tags = ['gql', 'graphql', 'Relay.QL'] let g:graphql_javascript_tags = ['gql', 'graphql', 'Relay.QL']
endif endif
augroup filetypedetect
autocmd BufNewFile,BufReadPost *.tsx setlocal filetype=typescript.tsx
augroup END

View File

@@ -1,9 +1,3 @@
function! s:setf(filetype) abort
if &filetype !=# a:filetype
let &filetype = a:filetype
endif
endfunction
" Enable jsx syntax by default " Enable jsx syntax by default
if !exists('g:jsx_ext_required') if !exists('g:jsx_ext_required')
let g:jsx_ext_required = 0 let g:jsx_ext_required = 0
@@ -50,8 +44,9 @@ augroup filetypedetect
" elixir " elixir
au BufRead,BufNewFile *.ex,*.exs call s:setf('elixir') au BufRead,BufNewFile *.ex,*.exs set filetype=elixir
au BufRead,BufNewFile *.eex call s:setf('eelixir') au BufRead,BufNewFile *.eex,*.leex set filetype=eelixir
au BufRead,BufNewFile mix.lock set filetype=elixir
" fish " fish
autocmd BufRead,BufNewFile *.fish setfiletype fish autocmd BufRead,BufNewFile *.fish setfiletype fish
@@ -91,6 +86,10 @@ augroup END
if (!exists('g:graphql_javascript_tags')) if (!exists('g:graphql_javascript_tags'))
let g:graphql_javascript_tags = ['gql', 'graphql', 'Relay.QL'] let g:graphql_javascript_tags = ['gql', 'graphql', 'Relay.QL']
endif endif
augroup filetypedetect
autocmd BufNewFile,BufReadPost *.tsx setlocal filetype=typescript.tsx
augroup END
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'acpiasl') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'acpiasl') == -1
augroup filetypedetect augroup filetypedetect
" acpiasl, from asl.vim in martinlroth/vim-acpi-asl " acpiasl, from asl.vim in martinlroth/vim-acpi-asl
@@ -290,6 +289,15 @@ autocmd BufRead,BufNewFile *.dart set filetype=dart
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dhall') == -1
augroup filetypedetect
" dhall, from dhall.vim in vmchale/dhall-vim
augroup dhall
autocmd BufNewFile,BufRead *.dhall set filetype=dhall
augroup END
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dlang') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dlang') == -1
augroup filetypedetect augroup filetypedetect
" dlang, from d.vim in JesseKPhillips/d.vim " dlang, from d.vim in JesseKPhillips/d.vim
@@ -328,6 +336,8 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1
augroup filetypedetect augroup filetypedetect
" dockerfile, from Dockerfile.vim in ekalinin/Dockerfile.vim " dockerfile, from Dockerfile.vim in ekalinin/Dockerfile.vim
" vint: -ProhibitAutocmdWithNoGroup
" Dockerfile " Dockerfile
autocmd BufRead,BufNewFile [Dd]ockerfile set ft=Dockerfile autocmd BufRead,BufNewFile [Dd]ockerfile set ft=Dockerfile
autocmd BufRead,BufNewFile Dockerfile* set ft=Dockerfile autocmd BufRead,BufNewFile Dockerfile* set ft=Dockerfile
@@ -340,6 +350,8 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1
augroup filetypedetect augroup filetypedetect
" dockerfile, from docker-compose.vim in ekalinin/Dockerfile.vim " dockerfile, from docker-compose.vim in ekalinin/Dockerfile.vim
" vint: -ProhibitAutocmdWithNoGroup
" docker-compose.yml " docker-compose.yml
autocmd BufRead,BufNewFile docker-compose*.{yaml,yml}* set ft=yaml.docker-compose autocmd BufRead,BufNewFile docker-compose*.{yaml,yml}* set ft=yaml.docker-compose
augroup end augroup end
@@ -493,6 +505,14 @@ unlet s:cpo_save
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1
augroup filetypedetect
" graphql, from graphql.vim in jparise/vim-graphql:_ALL
" vint: -ProhibitAutocmdWithNoGroup
au BufRead,BufNewFile *.graphql,*.graphqls,*.gql setfiletype graphql
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gradle') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gradle') == -1
augroup filetypedetect augroup filetypedetect
" gradle, from gradle.vim in tfnico/vim-gradle " gradle, from gradle.vim in tfnico/vim-gradle
@@ -513,8 +533,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'handlebars') ==
augroup filetypedetect augroup filetypedetect
" handlebars, from mustache.vim in mustache/vim-mustache-handlebars " handlebars, from mustache.vim in mustache/vim-mustache-handlebars
if has("autocmd") if has("autocmd")
au BufNewFile,BufRead *.mustache,*.hogan,*.hulk,*.hjs set filetype=html.mustache syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim au BufNewFile,BufRead *.mustache,*.hogan,*.hulk,*.hjs set filetype=html.mustache syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim indent/handlebars.vim
au BufNewFile,BufRead *.handlebars,*.hbs set filetype=html.handlebars syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim au BufNewFile,BufRead *.handlebars,*.hdbs,*.hbs,*.hb set filetype=html.handlebars syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim
endif endif
augroup end augroup end
endif endif
@@ -552,6 +572,13 @@ autocmd BufNewFile,BufRead Appfile set filetype=hcl
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'helm') == -1
augroup filetypedetect
" helm, from helm.vim in towolf/vim-helm
autocmd BufRead,BufNewFile */templates/*.yaml,*/templates/*.tpl set ft=helm
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'hive') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'hive') == -1
augroup filetypedetect augroup filetypedetect
" hive, from hive.vim in zebradil/hive.vim " hive, from hive.vim in zebradil/hive.vim
@@ -615,11 +642,8 @@ fun! s:SelectJavascript()
endif endif
endfun endfun
augroup javascript_syntax_detection autocmd BufNewFile,BufRead *.{js,mjs,jsm,es,es6},Jakefile setfiletype javascript
autocmd! autocmd BufNewFile,BufRead * call s:SelectJavascript()
autocmd BufNewFile,BufRead *.{js,mjs,jsm,es,es6},Jakefile setfiletype javascript
autocmd BufNewFile,BufRead * call s:SelectJavascript()
augroup END
augroup end augroup end
endif endif
@@ -627,11 +651,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jenkins') == -1
augroup filetypedetect augroup filetypedetect
" jenkins, from Jenkinsfile.vim in martinda/Jenkinsfile-vim-syntax " jenkins, from Jenkinsfile.vim in martinda/Jenkinsfile-vim-syntax
" Jenkinsfile " Jenkinsfile
autocmd BufRead,BufNewFile Jenkinsfile set ft=Jenkinsfile
autocmd BufRead,BufNewFile Jenkinsfile* setf Jenkinsfile augroup JenkinsAUGroup
autocmd BufRead,BufNewFile *.jenkinsfile set ft=Jenkinsfile autocmd BufRead,BufNewFile *Jenkins* set ft=Jenkinsfile
autocmd BufRead,BufNewFile *.jenkinsfile setf Jenkinsfile autocmd BufRead,BufNewFile *jenkins* set ft=Jenkinsfile
autocmd BufRead,BufNewFile *.Jenkinsfile setf Jenkinsfile augroup END
augroup end augroup end
endif endif
@@ -1031,7 +1055,7 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'puppet') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'puppet') == -1
augroup filetypedetect augroup filetypedetect
" puppet, from puppet.vim in voxpupuli/vim-puppet " puppet, from puppet.vim in rodjek/vim-puppet
au! BufRead,BufNewFile *.pp setfiletype puppet au! BufRead,BufNewFile *.pp setfiletype puppet
au! BufRead,BufNewFile Puppetfile setfiletype ruby au! BufRead,BufNewFile Puppetfile setfiletype ruby
augroup end augroup end
@@ -1081,7 +1105,7 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1
augroup filetypedetect augroup filetypedetect
" racket, from racket.vim in wlangstroth/vim-racket " racket, from racket.vim in wlangstroth/vim-racket
au BufRead,BufNewFile *.rkt,*.rktl setf racket au BufRead,BufNewFile *.rkt,*.rktl set filetype=racket
augroup end augroup end
endif endif
@@ -1103,17 +1127,6 @@ au BufNewFile,BufRead .merlin set ft=merlin
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rego') == -1
augroup filetypedetect
" rego, from rego.vim in tsandall/vim-rego
autocmd BufRead,BufNewFile *.rego set filetype=rego
" Use # as a comment prefix
setlocal comments=b:#,fb:-
setlocal commentstring=#\ %s
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ruby') == -1
augroup filetypedetect augroup filetypedetect
" ruby, from ruby.vim in vim-ruby/vim-ruby " ruby, from ruby.vim in vim-ruby/vim-ruby
@@ -1240,7 +1253,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
" vint: -ProhibitAutocmdWithNoGroup " vint: -ProhibitAutocmdWithNoGroup
autocmd BufRead,BufNewFile *.rs call s:set_rust_filetype() autocmd BufRead,BufNewFile *.rs call s:set_rust_filetype()
autocmd BufRead,BufNewFile Cargo.toml setf FALLBACK cfg
if has('patch-8.0.613')
autocmd BufRead,BufNewFile Cargo.toml setf FALLBACK cfg
endif
function! s:set_rust_filetype() abort function! s:set_rust_filetype() abort
if &filetype !=# 'rust' if &filetype !=# 'rust'
@@ -1309,6 +1325,13 @@ autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1
augroup filetypedetect
" svelte, from svelte.vim in evanleck/vim-svelte
au BufRead,BufNewFile *.svelte setfiletype svelte
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sxhkd') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sxhkd') == -1
augroup filetypedetect augroup filetypedetect
" sxhkd, from sxhkdrc.vim in baskerville/vim-sxhkdrc " sxhkd, from sxhkdrc.vim in baskerville/vim-sxhkdrc
@@ -1337,6 +1360,8 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1
augroup filetypedetect augroup filetypedetect
" terraform, from terraform.vim in hashivim/vim-terraform " terraform, from terraform.vim in hashivim/vim-terraform
" By default, Vim associates .tf files with TinyFugue - tell it not to.
autocmd! filetypedetect BufRead,BufNewFile *.tf
autocmd BufRead,BufNewFile *.tf set filetype=terraform autocmd BufRead,BufNewFile *.tf set filetype=terraform
autocmd BufRead,BufNewFile *.tfvars set filetype=terraform autocmd BufRead,BufNewFile *.tfvars set filetype=terraform
autocmd BufRead,BufNewFile *.tfstate set filetype=json autocmd BufRead,BufNewFile *.tfstate set filetype=json
@@ -1365,6 +1390,18 @@ au BufNewFile,BufRead *.thrift setlocal filetype=thrift
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'tmux') == -1
augroup filetypedetect
" tmux, from tmux.vim in ericpruitt/tmux.vim:_ALL:/vim/
" Language: tmux(1) configuration file
" URL: https://github.com/ericpruitt/tmux.vim/
" Maintainer: Eric Pruitt <eric.pruitt@gmail.com>
" Last Changed: 2017 Mar 10
autocmd BufNewFile,BufRead {.,}tmux.conf setfiletype tmux
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1
augroup filetypedetect augroup filetypedetect
" toml, from toml.vim in cespare/vim-toml " toml, from toml.vim in cespare/vim-toml
@@ -1400,11 +1437,15 @@ endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
augroup filetypedetect augroup filetypedetect
" typescript, from typescript.vim in leafgarland/typescript-vim " typescript, from tsx.vim in HerringtonDarkholme/yats.vim
" use `set filetype` to override default filetype=xml for *.ts files autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx
autocmd BufNewFile,BufRead *.ts set filetype=typescript augroup end
" use `setfiletype` to not override any other plugins like ianks/vim-tsx endif
autocmd BufNewFile,BufRead *.tsx setfiletype typescript
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
augroup filetypedetect
" typescript, from typescript.vim in HerringtonDarkholme/yats.vim
autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript
augroup end augroup end
endif endif
@@ -1435,6 +1476,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
" vifm, from vifm.vim in vifm/vifm.vim " vifm, from vifm.vim in vifm/vifm.vim
autocmd BufRead,BufNewFile vifmrc :set filetype=vifm autocmd BufRead,BufNewFile vifmrc :set filetype=vifm
autocmd BufRead,BufNewFile *vifm/colors/* :set filetype=vifm autocmd BufRead,BufNewFile *vifm/colors/* :set filetype=vifm
autocmd BufRead,BufNewFile *.vifm :set filetype=vifm
augroup end augroup end
endif endif
@@ -1460,6 +1502,13 @@ autocmd BufNewFile,BufRead *.xdc setfiletype xdc
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'zephir') == -1
augroup filetypedetect
" zephir, from zephir.vim in xwsoul/vim-zephir
autocmd BufNewFile,BufReadPost *.zep set filetype=zephir
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'zig') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'zig') == -1
augroup filetypedetect augroup filetypedetect
" zig, from zig.vim in ziglang/zig.vim " zig, from zig.vim in ziglang/zig.vim

View File

@@ -2,6 +2,12 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dockerfile') !=
finish finish
endif endif
" Define comment string
setlocal commentstring=#\ %s
" Enable automatic comment insertion
setlocal formatoptions+=cro
function! DockerfileReplaceInstruction(original, replacement) function! DockerfileReplaceInstruction(original, replacement)
let syn = synIDtrans(synID(line("."), col(".") - 1, 0)) let syn = synIDtrans(synID(line("."), col(".") - 1, 0))
if syn != hlID("Comment") && syn != hlID("Constant") && strlen(getline(".")) == 0 if syn != hlID("Comment") && syn != hlID("Constant") && strlen(getline(".")) == 0

39
ftplugin/dhall.vim Normal file
View File

@@ -0,0 +1,39 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dhall') != -1
finish
endif
if exists('b:dhall_ftplugin')
finish
endif
let b:dhall_ftplugin = 1
setlocal commentstring=--\ %s
set smarttab
if exists('g:dhall_use_ctags')
if g:dhall_use_ctags == 1
augroup dhall
autocmd BufWritePost *.dhall silent !ctags -R .
augroup END
endif
endif
function! StripTrailingWhitespace()
let myline=line('.')
let mycolumn = col('.')
exec 'silent %s/ *$//'
call cursor(myline, mycolumn)
endfunction
if exists('g:dhall_strip_whitespace')
if g:dhall_strip_whitespace == 1
augroup dhall
au BufWritePre *.dhall silent! call StripTrailingWhitespace()
augroup END
endif
endif
augroup dhall
au BufNewFile,BufRead *.dhall setl shiftwidth=2
augroup END

View File

@@ -0,0 +1,9 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dockerfile') != -1
finish
endif
" Define comment string
setlocal commentstring=#\ %s
" Enable automatic comment insertion
setlocal formatoptions+=cro

22
ftplugin/graphql.vim Normal file
View File

@@ -0,0 +1,22 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1
finish
endif
" Vim filetype plugin
" Language: GraphQL
" Maintainer: Jon Parise <jon@indelible.org>
if (exists('b:did_ftplugin'))
finish
endif
let b:did_ftplugin = 1
setlocal comments=:#
setlocal commentstring=#\ %s
setlocal formatoptions-=t
setlocal iskeyword+=$,@-@
setlocal softtabstop=2
setlocal shiftwidth=2
setlocal expandtab
let b:undo_ftplugin = 'setlocal com< cms< fo< isk< sts< sw< et<'

View File

@@ -25,6 +25,9 @@ if exists("loaded_matchit") && exists("b:match_words")
\ . '\%({{\)\@<=/\s*\1\s*}}' \ . '\%({{\)\@<=/\s*\1\s*}}'
endif endif
" Set template for comment
setlocal commentstring={{!--\ %s\ --}}
if exists("g:mustache_abbreviations") if exists("g:mustache_abbreviations")
inoremap <buffer> {{{ {{{}}}<left><left><left> inoremap <buffer> {{{ {{{}}}<left><left><left>
inoremap <buffer> {{ {{}}<left><left> inoremap <buffer> {{ {{}}<left><left>

View File

@@ -28,7 +28,9 @@ if exists('loaded_matchit')
\ ',\<hnote\>:\<endhnote\>' . \ ',\<hnote\>:\<endhnote\>' .
\ ',\<title\>:\<endtitle\>' . \ ',\<title\>:\<endtitle\>' .
\ ',\<\while\>:\<endwhile\>' . \ ',\<\while\>:\<endwhile\>' .
\ ',@startuml:@enduml' \ ',@startuml:@enduml' .
\ ',@startwbs:@endwbs' .
\ ',@startmindmap:@endmindmap'
endif endif
if get(g:, 'plantuml_set_makeprg', 1) if get(g:, 'plantuml_set_makeprg', 1)

View File

@@ -0,0 +1,48 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'puppet') != -1
finish
endif
" Puppet set up for Tagbar plugin
" (https://github.com/majutsushi/tagbar).
if !exists(':Tagbar')
finish
endif
let g:tagbar_type_puppet = {
\ 'ctagstype': 'puppet',
\ 'kinds': [
\ 'c:Classes',
\ 's:Sites',
\ 'n:Nodes',
\ 'v:Variables',
\ 'i:Includes',
\ 'd:Definitions',
\ 'r:Resources',
\ 'f:Defaults',
\ 't:Types',
\ 'u:Functions',
\],
\}
if puppet#ctags#Type() == 'universal'
" There no sense to split objects by colon
let g:tagbar_type_puppet.sro = '__'
let g:tagbar_type_puppet.kind2scope = {
\ 'd': 'definition',
\ 'c': 'class',
\ 'r': 'resource',
\ 'i': 'include',
\ 'v': 'variable',
\}
let g:tagbar_type_puppet.scope2kind = {
\ 'definition' : 'd',
\ 'class' : 'c',
\ 'resource' : 'r',
\ 'include' : 'i',
\ 'variable' : 'v',
\}
endif
let g:tagbar_type_puppet.deffile = puppet#ctags#OptionFile()

View File

@@ -1,73 +0,0 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'r-lang') != -1
finish
endif
" ftplugin for R files
"
" Author: Iago Mosqueira <i.mosqueira@ic.ac.uk>
" Author: Johannes Ranke <jranke@uni-bremen.de>
" Author: Fernando Henrique Ferraz Pereira da Rosa <feferraz@ime.usp.br>
" Maintainer: Johannes Ranke <jranke@uni-bremen.de>
" Last Change: 2007 Nov 21
" SVN: $Id: r.vim 75 2007-11-21 13:34:02Z ranke $
"
" Code written in vim is sent to R through a perl pipe
" [funnel.pl, by Larry Clapp <vim@theclapp.org>], as individual lines,
" blocks, or the whole file.
" Press <F2> to open a new xterm with a new R interpreter listening
" to its standard input (you can type R commands into the xterm)
" as well as to code pasted from within vim.
"
" After selecting a visual block, 'r' sends it to the R interpreter
"
" In insert mode, <M-Enter> sends the active line to R and moves to the next
" line (write and process mode).
"
" Maps:
" <F2> Start a listening R interpreter in new xterm
" <F3> Start a listening R-devel interpreter in new xterm
" <F4> Start a listening R --vanilla interpreter in new xterm
" <F5> Run current file
" <F9> Run line under cursor
" r Run visual block
" <M-Enter> Write and process
" Only do this when not yet done for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
" Disable backup for .r-pipe
setl backupskip=.*pipe
" Set tabstop so it is compatible with the emacs edited code. Personally, I
" prefer shiftwidth=2, which I have in my .vimrc anyway
set expandtab
set shiftwidth=4
set tabstop=8
" Start a listening R interpreter in new xterm
noremap <buffer> <F2> :!xterm -T 'R' -e funnel.pl ~/.r-pipe "R && echo -e 'Interpreter has finished. Exiting. Goodbye.\n'"&<CR><CR>
" Start a listening R-devel interpreter in new xterm
noremap <buffer> <F3> :!xterm -T 'R' -e funnel.pl ~/.r-pipe "R-devel && echo 'Interpreter has finished. Exiting. Goodbye.'"&<CR><CR>
" Start a listening R --vanilla interpreter in new xterm
noremap <buffer> <F4> :!xterm -T 'R' -e funnel.pl ~/.r-pipe "R -vanilla && echo 'Interpreter has finished. Exiting. Goodbye.'"&<CR><CR>
" Send line under cursor to R
noremap <buffer> <F9> :execute line(".") 'w >> ~/.r-pipe'<CR>
inoremap <buffer> <F9> <Esc> :execute line(".") 'w >> ~/.r-pipe'<CR>
" Send visual selected block to R
vnoremap <buffer> r :w >> ~/.r-pipe<CR>
" Write and process mode (somehow mapping <C-Enter> does not work)
inoremap <M-Enter> <Esc>:execute line(".") 'w >> ~/.r-pipe'<CR>o
" Send current file to R
noremap <buffer> <F5> :execute '1 ,' line("$") 'w >> ~/.r-pipe' <CR><CR>

View File

@@ -1,52 +0,0 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'r-lang') != -1
finish
endif
" ftplugin for R help files
"
" Author: Johannes Ranke <jranke@uni-bremen.de>
" Last Change: 2007 Nov 21
" SVN: $Id: rhelp.vim 75 2007-11-21 13:34:02Z ranke $
"
" Usage:
"
" Press <F2> to open a new xterm with a new R interpreter listening
" to its standard input (you can type R commands into the xterm)
" as well as to code pasted from within vim.
"
" After selecting a visual block, 'r' sends it to the R interpreter
"
" Add to filetypes.vim, if you don't use vim 7
" au BufNewFile,BufRead *.Rd,*.rd setf rhelp
"
" Maps:
" <F2> Start a listening R interpreter in new xterm
" <F9> Run line under cursor
" r Run visual block
" <M-Enter> Write and process R code
" Only do this when not yet done for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
" Set tabbing
set expandtab
set tabstop=2
set shiftwidth=2
" Start a listening R interpreter in new xterm
noremap <buffer> <F2> :!xterm -T 'R' -e funnel.pl ~/.r-pipe "R && echo -e 'Interpreter has finished. Exiting. Goodbye.\n'"&<CR><CR>
" Send line under cursor to R
noremap <buffer> <F9> :execute line(".") 'w >> ~/.r-pipe'<CR>
inoremap <buffer> <F9> <Esc> :execute line(".") 'w >> ~/.r-pipe'<CR>
" Send visual selected block to R
vnoremap <buffer> r :w >> ~/.r-pipe<CR>
" Write and process mode (somehow mapping <C-Enter> does not work)
inoremap <M-Enter> <Esc>:execute line(".") 'w >> ~/.r-pipe'<CR>o

View File

@@ -1,63 +0,0 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'r-lang') != -1
finish
endif
" ftplugin for Sweave files containing both LaTeX and R code
"
" Maintainer: Johannes Ranke <jranke@uni-bremen.de>
" Last Change: 2007 Nov 21
" SVN: $Id: rnoweb.vim 75 2007-11-21 13:34:02Z ranke $
"
" Usage:
"
" Press <F2> to open a new xterm with a new R interpreter listening
" to its standard input (you can type R commands into the xterm)
" as well as to code pasted from within vim.
"
" A Makefile for producing R noweb files is in included in my Vim script
" R.vim:
" http://www.vim.org/scripts/script.php?script_id=1048
" You can also look in my SVN repository under:
" http://kri/viewcvs/*checkout*/Makefile.rnoweb?root=vim
"
"
" After selecting a visual block, 'r' sends it to the R interpreter
"
" Add to filetypes.vim, if you don't use vim 7
" au BufNewFile,BufRead *.Rnw,*.rnw setf rnoweb
" and/or
" au BufNewFile,BufRead *.Snw,*.snw setf rnoweb
"
" Maps:
" <F2> Start a listening R interpreter in new xterm
" <F9> Run line under cursor
" r Run visual block
" <M-Enter> Write and process R code
" Only do this when not yet done for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
" Disable backup for .r-pipe
setl backupskip=.*pipe
" Set R friendly tabbing
set expandtab
set shiftwidth=2
" Start a listening R interpreter in new xterm
noremap <buffer> <F2> :!xterm -T 'R' -e funnel.pl ~/.r-pipe "R && echo -e 'Interpreter has finished. Exiting. Goodbye.\n'"&<CR><CR>
" Send line under cursor to R
noremap <buffer> <F9> :execute line(".") 'w >> ~/.r-pipe'<CR>
inoremap <buffer> <F9> <Esc> :execute line(".") 'w >> ~/.r-pipe'<CR>
" Send visual selected block to R
vnoremap <buffer> r :w >> ~/.r-pipe<CR>
" Write and process mode (somehow mapping <C-Enter> does not work)
inoremap <M-Enter> <Esc>:execute line(".") 'w >> ~/.r-pipe'<CR>o

View File

@@ -38,7 +38,7 @@ if exists("g:rst_style") && g:rst_style != 0
setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8 setlocal expandtab shiftwidth=3 softtabstop=3 tabstop=8
endif endif
if has('patch-7.3.867') " Introduced the TextChanged event. if g:rst_fold_enabled != 0 && has('patch-7.3.867') " Introduced the TextChanged event.
setlocal foldmethod=expr setlocal foldmethod=expr
setlocal foldexpr=RstFold#GetRstFold() setlocal foldexpr=RstFold#GetRstFold()
setlocal foldtext=RstFold#GetRstFoldText() setlocal foldtext=RstFold#GetRstFoldText()

View File

@@ -90,7 +90,7 @@ endfunction
function! s:build_path(path) abort function! s:build_path(path) abort
let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',') let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$' if &g:path !~# '\v^%(\.,)=%(/%(usr|emx)/include,)=,$'
let path = substitute(&g:path,',,$',',','') . ',' . path let path = substitute(&g:path,',,$',',','') . ',' . path
endif endif
return path return path

View File

@@ -39,7 +39,7 @@ if get(g:, 'rust_bang_comment_leader', 0)
" leaders. I'm fairly sure that's a Vim bug. " leaders. I'm fairly sure that's a Vim bug.
setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,:// setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,://
else else
setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,:// setlocal comments=s0:/*!,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,://
endif endif
setlocal commentstring=//%s setlocal commentstring=//%s
setlocal formatoptions-=t formatoptions+=croqnl setlocal formatoptions-=t formatoptions+=croqnl
@@ -195,7 +195,7 @@ augroup END
setlocal matchpairs+=<:> setlocal matchpairs+=<:>
" For matchit.vim (rustArrow stops `Fn() -> X` messing things up) " For matchit.vim (rustArrow stops `Fn() -> X` messing things up)
let b:match_skip = 's:comment\|string\|rustArrow' let b:match_skip = 's:comment\|string\|rustCharacter\|rustArrow'
" vint: -ProhibitAbbreviationOption " vint: -ProhibitAbbreviationOption
let &cpo = s:save_cpo let &cpo = s:save_cpo

View File

@@ -5,7 +5,7 @@ endif
" "
" Support for Tagbar -- https://github.com/majutsushi/tagbar " Support for Tagbar -- https://github.com/majutsushi/tagbar
" "
if !exists(':Tagbar') if !exists(':Tagbar') || rust#tags#IsUCtags()
finish finish
endif endif

View File

@@ -29,8 +29,8 @@ setlocal commentstring=//\ %s
setlocal shiftwidth=2 softtabstop=2 expandtab setlocal shiftwidth=2 softtabstop=2 expandtab
setlocal include='^\s*import' setlocal include=^\\s*import
setlocal includeexpr='substitute(v:fname,"\\.","/","g")' setlocal includeexpr=substitute(v:fname,'\\.','/','g')
setlocal path+=src/main/scala,src/test/scala setlocal path+=src/main/scala,src/test/scala
setlocal suffixesadd=.scala setlocal suffixesadd=.scala

View File

@@ -11,128 +11,34 @@ endif
let b:did_ftplugin = 1 let b:did_ftplugin = 1
let s:cpo_save = &cpoptions let s:cpo_save = &cpoptions
setlocal formatoptions-=t
let b:undo_ftplugin = 'setlocal formatoptions<'
" Include hyphens as keyword characters so that a keyword appearing as part of
" a longer name doesn't get partially highlighted.
setlocal iskeyword+=-
let b:undo_ftplugin .= ' iskeyword<'
set cpoptions&vim set cpoptions&vim
if !exists('g:terraform_align') " j is a relatively recent addition; silence warnings when setting it.
let g:terraform_align = 0 setlocal formatoptions-=t formatoptions+=croql
silent! setlocal formatoptions+=j
let b:undo_ftplugin = 'setlocal formatoptions<'
if !has('patch-7.4.1142')
" Include hyphens as keyword characters so that a keyword appearing as
" part of a longer name doesn't get partially highlighted.
setlocal iskeyword+=-
let b:undo_ftplugin .= ' iskeyword<'
endif endif
if !exists('g:terraform_remap_spacebar') if get(g:, 'terraform_fold_sections', 0)
let g:terraform_remap_spacebar = 0 setlocal foldmethod=syntax
endif let b:undo_ftplugin .= ' foldmethod<'
if !exists('g:terraform_fold_sections')
let g:terraform_fold_sections = 0
endif
if g:terraform_align && exists(':Tabularize')
inoremap <buffer> <silent> = =<Esc>:call <SID>terraformalign()<CR>a
function! s:terraformalign()
let p = '^.*=[^>]*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
endif
if g:terraform_fold_sections
function! TerraformFolds()
let thisline = getline(v:lnum)
if match(thisline, '^resource') >= 0
return '>1'
elseif match(thisline, '^provider') >= 0
return '>1'
elseif match(thisline, '^module') >= 0
return '>1'
elseif match(thisline, '^variable') >= 0
return '>1'
elseif match(thisline, '^output') >= 0
return '>1'
elseif match(thisline, '^data') >= 0
return '>1'
elseif match(thisline, '^terraform') >= 0
return '>1'
elseif match(thisline, '^locals') >= 0
return '>1'
else
return '='
endif
endfunction
setlocal foldmethod=expr
setlocal foldexpr=TerraformFolds()
setlocal foldlevel=1
let b:undo_ftplugin .= ' foldmethod< foldexpr< foldlevel<'
function! TerraformFoldText()
let foldsize = (v:foldend-v:foldstart)
return getline(v:foldstart).' ('.foldsize.' lines)'
endfunction
setlocal foldtext=TerraformFoldText()
let b:undo_ftplugin .= ' foldtext<'
endif
" Re-map the space bar to fold and unfold
if get(g:, 'terraform_remap_spacebar', 1)
"inoremap <space> <C-O>za
nnoremap <space> za
onoremap <space> <C-C>za
vnoremap <space> zf
endif endif
" Set the commentstring " Set the commentstring
if exists('g:terraform_commentstring') setlocal commentstring=#%s
let &l:commentstring=g:terraform_commentstring
else
setlocal commentstring=#%s
endif
let b:undo_ftplugin .= ' commentstring<' let b:undo_ftplugin .= ' commentstring<'
if !exists('g:terraform_fmt_on_save') if get(g:, 'terraform_align', 0) && exists(':Tabularize')
let g:terraform_fmt_on_save = 0 inoremap <buffer> <silent> = =<Esc>:call terraform#align()<CR>a
let b:undo_ftplugin .= '|iunmap <buffer> ='
endif endif
function! s:commands(A, L, P)
return [
\ 'apply',
\ 'console',
\ 'destroy',
\ 'env',
\ 'fmt',
\ 'get',
\ 'graph',
\ 'import',
\ 'init',
\ 'output',
\ 'plan',
\ 'providers',
\ 'push',
\ 'refresh',
\ 'show',
\ 'taint',
\ 'untaint',
\ 'validate',
\ 'version',
\ 'workspace',
\ '0.12checklist',
\ 'debug',
\ 'force-unlock',
\ 'state'
\ ]
endfunction
let &cpoptions = s:cpo_save let &cpoptions = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
@@ -141,13 +47,14 @@ if !executable('terraform')
endif endif
let s:cpo_save = &cpoptions let s:cpo_save = &cpoptions
set cpoptions&vim
command! -nargs=+ -complete=customlist,s:commands -buffer Terraform execute '!terraform '.<q-args>. ' -no-color' command! -nargs=+ -complete=customlist,terraform#commands -buffer Terraform execute '!terraform '.<q-args>. ' -no-color'
command! -nargs=0 -buffer TerraformFmt call terraform#fmt() command! -nargs=0 -buffer TerraformFmt call terraform#fmt()
let b:undo_ftplugin .= '|delcommand Terraform|delcommand TerraformFmt' let b:undo_ftplugin .= '|delcommand Terraform|delcommand TerraformFmt'
if get(g:, 'terraform_fmt_on_save', 1) if get(g:, 'terraform_fmt_on_save', 0)
augroup terraform augroup vim.terraform.fmt
autocmd! autocmd!
autocmd BufWritePre *.tf call terraform#fmt() autocmd BufWritePre *.tf call terraform#fmt()
autocmd BufWritePre *.tfvars call terraform#fmt() autocmd BufWritePre *.tfvars call terraform#fmt()

16
ftplugin/tmux.vim Normal file
View File

@@ -0,0 +1,16 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'tmux') != -1
finish
endif
" Vim filetype plugin file
" Language: tmux(1) configuration file
" URL: https://github.com/ericpruitt/tmux.vim/
" Maintainer: Eric Pruitt <eric.pruitt@gmail.com>
" Last Changed: 2017 Mar 10
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
setlocal commentstring=#\ %s

15
ftplugin/tsx.vim Normal file
View File

@@ -0,0 +1,15 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
" modified from mxw/vim-jsx from html.vim
if exists("loaded_matchit") && !exists('b:tsx_match_words')
let b:match_ignorecase = 0
let b:tsx_match_words = '(:),\[:\],{:},<:>,' .
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
let b:match_words = exists('b:match_words')
\ ? b:match_words . ',' . b:tsx_match_words
\ : b:tsx_match_words
endif
set suffixesadd+=.tsx

View File

@@ -2,6 +2,8 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') !=
finish finish
endif endif
" set Vi-incompatible, compiler and commentstring
if exists("b:did_ftplugin") if exists("b:did_ftplugin")
finish finish
endif endif
@@ -17,9 +19,68 @@ setlocal commentstring=//\ %s
" " and insert the comment leader when hitting <CR> or using "o". " " and insert the comment leader when hitting <CR> or using "o".
setlocal formatoptions-=t formatoptions+=croql setlocal formatoptions-=t formatoptions+=croql
setlocal suffixesadd+=.ts,.tsx " setlocal foldmethod=syntax
let b:undo_ftplugin = "setl fo< ofu< com< cms<"
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
function! TsIncludeExpr(file)
if (filereadable(a:file))
return l:file
else
let l:file2=substitute(a:file,'$','/index.ts','g')
return l:file2
endif
endfunction
set path+=./node_modules/**,node_modules/**
set include=import\_s.\\zs[^'\"]*\\ze
set includeexpr=TsIncludeExpr(v:fname)
set suffixesadd=.ts
"
" TagBar
"
let g:tagbar_type_typescript = {
\ 'ctagstype' : 'typescript',
\ 'kinds' : [
\ 'c:classes',
\ 'a:abstract classes',
\ 't:types',
\ 'n:modules',
\ 'f:functions',
\ 'v:variables',
\ 'l:varlambdas',
\ 'm:members',
\ 'i:interfaces',
\ 'e:enums'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'c' : 'classes',
\ 'a' : 'abstract classes',
\ 't' : 'types',
\ 'f' : 'functions',
\ 'v' : 'variables',
\ 'l' : 'varlambdas',
\ 'm' : 'members',
\ 'i' : 'interfaces',
\ 'e' : 'enums'
\ },
\ 'scope2kind' : {
\ 'classes' : 'c',
\ 'abstract classes' : 'a',
\ 'types' : 't',
\ 'functions' : 'f',
\ 'variables' : 'v',
\ 'varlambdas' : 'l',
\ 'members' : 'm',
\ 'interfaces' : 'i',
\ 'enums' : 'e'
\ }
\ }
" In case you've updated/customized your ~/.ctags and prefer to use it.
if get(g:, 'typescript_use_builtin_tagbar_defs', 1)
let g:tagbar_type_typescript.deffile = expand('<sfile>:p:h:h') . '/ctags/typescript.ctags'
endif

14
indent/dune.vim Normal file
View File

@@ -0,0 +1,14 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'ocaml') != -1
finish
endif
" Vim indent file
" Language: dune
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
" dune format-dune-file uses 1 space to indent
set softtabstop=1 shiftwidth=1 expandtab

81
indent/graphql.vim Normal file
View File

@@ -0,0 +1,81 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1
finish
endif
" Vim indent file
" Language: GraphQL
" Maintainer: Jon Parise <jon@indelible.org>
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
setlocal autoindent
setlocal nocindent
setlocal nolisp
setlocal nosmartindent
setlocal indentexpr=GetGraphQLIndent()
setlocal indentkeys=0{,0},0),0[,0],0#,!^F,o,O
" If our indentation function already exists, we have nothing more to do.
if exists('*GetGraphQLIndent')
finish
endif
let s:cpo_save = &cpoptions
set cpoptions&vim
" Check if the character at lnum:col is inside a string.
function s:InString(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') is# 'graphqlString'
endfunction
function GetGraphQLIndent()
" If this is the first non-blank line, we have nothing more to do because
" all of our indentation rules are based on matching against earlier lines.
let l:prevlnum = prevnonblank(v:lnum - 1)
if l:prevlnum == 0
return 0
endif
let l:line = getline(v:lnum)
" If this line contains just a closing bracket, find its matching opening
" bracket and indent the closing backet to match.
let l:col = matchend(l:line, '^\s*[]})]')
if l:col > 0 && !s:InString(v:lnum, l:col)
let l:bracket = l:line[l:col - 1]
call cursor(v:lnum, l:col)
if l:bracket is# '}'
let l:matched = searchpair('{', '', '}', 'bW')
elseif l:bracket is# ']'
let l:matched = searchpair('\[', '', '\]', 'bW')
elseif l:bracket is# ')'
let l:matched = searchpair('(', '', ')', 'bW')
else
let l:matched = -1
endif
return l:matched > 0 ? indent(l:matched) : virtcol('.') - 1
endif
" If we're inside of a multiline string, continue with the same indentation.
if s:InString(v:lnum, matchend(l:line, '^\s*') + 1)
return indent(v:lnum)
endif
" If the previous line contained an opening bracket, and we are still in it,
" add indent depending on the bracket type.
if getline(l:prevlnum) =~# '[[{(]\s*$'
return indent(l:prevlnum) + shiftwidth()
endif
" Default to the existing indentation level.
return indent(l:prevlnum)
endfunction
let &cpoptions = s:cpo_save
unlet s:cpo_save

View File

@@ -23,9 +23,6 @@ endif
unlet! b:did_indent unlet! b:did_indent
setlocal indentexpr= setlocal indentexpr=
" keep track of whether or not we are in a block expression for indenting
unlet! s:in_block_expr
runtime! indent/html.vim runtime! indent/html.vim
unlet! b:did_indent unlet! b:did_indent
@@ -87,23 +84,19 @@ function! GetHandlebarsIndent(...)
" tag is on a separate line " tag is on a separate line
" indent after block {{#block " indent after block {{#block
if prevLine =~# '\v\s*\{\{\#.*\s*' if prevLine =~# '\v\s*\{\{[#^].*\s*'
let s:in_block_expr = 1
let ind = ind + sw let ind = ind + sw
endif endif
" but not if the block ends on the same line " but not if the block ends on the same line
if prevLine =~# '\v\s*\{\{\#(.+)(\s+|\}\}).*\{\{\/\1' if prevLine =~# '\v\s*\{\{\#(.+)(\s+|\}\}).*\{\{\/\1'
let s:in_block_expr = 0
let ind = ind - sw let ind = ind - sw
endif endif
" unindent after block close {{/block}} " unindent after block close {{/block}}
if currentLine =~# '\v^\s*\{\{\/\S*\}\}\s*' if currentLine =~# '\v^\s*\{\{\/\S*\}\}\s*'
let s:in_block_expr = 0
let ind = ind - sw let ind = ind - sw
endif endif
" indent after component block {{a-component " indent after component block {{a-component
if prevLine =~# '\v\s*\{\{\w' if prevLine =~# '\v\s*\{\{\w'
let s:in_block_expr = 0
let ind = ind + sw let ind = ind + sw
endif endif
" but not if the component block ends on the same line " but not if the component block ends on the same line
@@ -111,9 +104,16 @@ function! GetHandlebarsIndent(...)
let ind = ind - sw let ind = ind - sw
endif endif
" unindent }} lines, and following lines if not inside a block expression " unindent }} lines, and following lines if not inside a block expression
let savedPos = getpos('.')
if currentLine =~# '\v^\s*\}\}\s*$' || (currentLine !~# '\v^\s*\{\{\/' && prevLine =~# '\v^\s*[^\{\} \t]+\}\}\s*$') if currentLine =~# '\v^\s*\}\}\s*$' || (currentLine !~# '\v^\s*\{\{\/' && prevLine =~# '\v^\s*[^\{\} \t]+\}\}\s*$')
if !s:in_block_expr let closingLnum = search('}}\s*$', 'Wbc', lnum)
let ind = ind - sw let [openingLnum, col] = searchpairpos('{{', '', '}}', 'Wb')
if openingLnum > 0 && closingLnum > 0
if strpart(getline(openingLnum), col - 1, 3) !~ '{{[#^]'
let ind = ind - sw
endif
else
call setpos('.', savedPos)
endif endif
endif endif
" unindent {{else}} " unindent {{else}}

View File

@@ -396,7 +396,9 @@ function GetJavascriptIndent()
if idx != -1 if idx != -1
call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:SkipFunc()') call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:SkipFunc()')
elseif getline(v:lnum) !~ '^\S' && s:stack[-1] =~? 'block\|^jsobject$' elseif getline(v:lnum) !~ '^\S' && s:stack[-1] =~? 'block\|^jsobject$'
call s:GetPair('{','}','bW','s:SkipFunc()') if !s:GetPair('{','}','bW','s:SkipFunc()') && s:stack[-1] ==# 'jsObject'
return indent(l:lnum)
endif
else else
call s:AlternatePair() call s:AlternatePair()
endif endif

View File

@@ -24,7 +24,7 @@ setlocal indentkeys-=:
setlocal indentkeys-=0# setlocal indentkeys-=0#
setlocal indentkeys-=e setlocal indentkeys-=e
if has('patch-7.3.694') || (v:version == 703 && has('patch694')) if exists('*shiftwidth')
fun! s:shiftwidth() fun! s:shiftwidth()
return shiftwidth() return shiftwidth()
endf endf
@@ -41,16 +41,12 @@ endif
" SQL is generally case insensitive, so this files assumes that " SQL is generally case insensitive, so this files assumes that
" These keywords are something that would trigger an indent LEFT, not " These keywords are something that would trigger an indent LEFT, not
" an indent right, since the SQLBlockStart is used for those keywords " an indent right, since the SQLBlockStart is used for those keywords
setlocal indentkeys+==~end,=~else,=~elseif,=~elsif,0=~when,0=) setlocal indentkeys+==~begin,=~end,=~else,=~elseif,=~elsif,0=~when,=~exception,0=)
" GetSQLIndent is executed whenever one of the expressions " GetSQLIndent is executed whenever one of the expressions
" in the indentkeys is typed " in the indentkeys is typed
setlocal indentexpr=GetSQLIndent() setlocal indentexpr=GetSQLIndent()
" Only define the functions once.
if exists("*GetSQLIndent")
finish
endif
let s:keepcpo= &cpo let s:keepcpo= &cpo
set cpo&vim set cpo&vim
@@ -340,7 +336,7 @@ function! GetSQLIndent()
" Check current line; search for simplistic matching start-of-block " Check current line; search for simplistic matching start-of-block
let line = getline(v:lnum) let line = getline(v:lnum)
if line =~? '^\s*els' if line =~? '^\s*els' || line =~? '^\s*begin' || line =~? '^\s*exception'
" Any line when you type else will automatically back up one " Any line when you type else will automatically back up one
" ident level (ie else, elseif, elsif) " ident level (ie else, elseif, elsif)
let ind = ind - s:shiftwidth() let ind = ind - s:shiftwidth()

View File

@@ -16,6 +16,7 @@ let b:did_indent = 1
setlocal autoindent smartindent setlocal autoindent smartindent
setlocal indentexpr=GetPuppetIndent() setlocal indentexpr=GetPuppetIndent()
setlocal indentkeys+=0],0) setlocal indentkeys+=0],0)
setlocal formatexpr=puppet#format#Format()
if exists("*GetPuppetIndent") if exists("*GetPuppetIndent")
finish finish
@@ -33,7 +34,7 @@ function! s:PartOfInclude(lnum)
if line !~ ',$' if line !~ ',$'
break break
endif endif
if line =~ '^\s*include\s\+[^,]\+,$' if line =~ '^\s*include\s\+[^,]\+,$' && line !~ '[=>]>'
return 1 return 1
endif endif
endwhile endwhile
@@ -42,24 +43,70 @@ endfunction
function! s:OpenBrace(lnum) function! s:OpenBrace(lnum)
call cursor(a:lnum, 1) call cursor(a:lnum, 1)
return searchpair('{\|\[\|(', '', '}\|\]\|)', 'nbW') return searchpair('{\|\[\|(', '', '}\|\]\|)', 'nbW',
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "comment\\|string"')
endfunction endfunction
function! GetPuppetIndent() function! s:InsideMultilineString(lnum)
let pnum = prevnonblank(v:lnum - 1) return synIDattr(synID(a:lnum, 1, 0), 'name') =~? 'string'
endfunction
function! s:PrevNonMultilineString(lnum)
let l:lnum = a:lnum
while l:lnum > 0 && s:InsideMultilineString(lnum)
let l:lnum = l:lnum - 1
endwhile
return l:lnum
endfunction
""
" Get indent number for line, line can be given as params, otherwise function
" use line where cursor is
" @param a:1 (optional) line number in current buffer
" @return integer
function! GetPuppetIndent(...)
let l:lnum = get(a:, 1, v:lnum)
let pnum = prevnonblank(l:lnum - 1)
if pnum == 0 if pnum == 0
return 0 return 0
endif endif
let line = getline(v:lnum) let line = getline(l:lnum)
let pline = getline(pnum) let pline = getline(pnum)
let ind = indent(pnum) let ind = indent(pnum)
" Avoid cases of closing braces or parens on the current line: returning
" the same indent here would be premature since for that particular case
" we want to instead get the indent level of the matching opening brace or
" parenthenses.
if pline =~ '^\s*#' && line !~ '^\s*\(}\(,\|;\)\?$\|]:\|],\|}]\|];\?$\|)\)'
return ind
endif
" We are inside a multi-line string: if we interfere with indentation here
" we're actually changing the contents of of the string!
if s:InsideMultilineString(l:lnum)
return indent(l:lnum)
endif
" Previous line was inside a multi-line string: we've lost the indent
" level. We need to find this value from the last line that was not inside
" of a multi-line string to restore proper alignment.
if s:InsideMultilineString(pnum)
if pnum - 1 == 0
return ind
endif
let ind = indent(s:PrevNonMultilineString(pnum - 1))
endif
if pline =~ '\({\|\[\|(\|:\)\s*\(#.*\)\?$' if pline =~ '\({\|\[\|(\|:\)\s*\(#.*\)\?$'
let ind += &sw let ind += &sw
elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*' elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*'
let ind -= &sw let ind -= &sw
elseif pline =~ '^\s*include\s\+.*,$' elseif pline =~ '^\s*include\s\+.*,$' && pline !~ '[=+]>'
let ind += &sw let ind += &sw
endif endif
@@ -76,7 +123,6 @@ function! GetPuppetIndent()
if line =~ '^\s*}\s*els\(e\|if\).*{\s*$' if line =~ '^\s*}\s*els\(e\|if\).*{\s*$'
let ind -= &sw let ind -= &sw
endif endif
" Don't indent resources that are one after another with a ->(ordering arrow) " Don't indent resources that are one after another with a ->(ordering arrow)
" file {'somefile': " file {'somefile':
" ... " ...

View File

@@ -15,8 +15,8 @@ endif
let b:did_indent = 1 let b:did_indent = 1
setlocal cindent setlocal cindent
setlocal cinoptions=L0,(0,Ws,J1,j1,m1 setlocal cinoptions=L0,(s,Ws,J1,j1,m1
setlocal cinkeys=0{,0},!^F,o,O,0[,0] setlocal cinkeys=0{,0},!^F,o,O,0[,0],0(,0)
" Don't think cinwords will actually do anything at all... never mind " Don't think cinwords will actually do anything at all... never mind
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern,macro setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern,macro
@@ -24,7 +24,7 @@ setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,ex
setlocal nolisp " Make sure lisp indenting doesn't supersede us setlocal nolisp " Make sure lisp indenting doesn't supersede us
setlocal autoindent " indentexpr isn't much help otherwise setlocal autoindent " indentexpr isn't much help otherwise
" Also do indentkeys, otherwise # gets shoved to column 0 :-/ " Also do indentkeys, otherwise # gets shoved to column 0 :-/
setlocal indentkeys=0{,0},!^F,o,O,0[,0] setlocal indentkeys=0{,0},!^F,o,O,0[,0],0(,0)
setlocal indentexpr=GetRustIndent(v:lnum) setlocal indentexpr=GetRustIndent(v:lnum)
@@ -85,8 +85,17 @@ function! s:is_string_comment(lnum, col)
endif endif
endfunction endfunction
function GetRustIndent(lnum) if exists('*shiftwidth')
function! s:shiftwidth()
return shiftwidth()
endfunc
else
function! s:shiftwidth()
return &shiftwidth
endfunc
endif
function GetRustIndent(lnum)
" Starting assumption: cindent (called at the end) will do it right " Starting assumption: cindent (called at the end) will do it right
" normally. We just want to fix up a few cases. " normally. We just want to fix up a few cases.
@@ -132,14 +141,65 @@ function GetRustIndent(lnum)
let prevline = s:get_line_trimmed(prevlinenum) let prevline = s:get_line_trimmed(prevlinenum)
endwhile endwhile
" A standalone '{', '}', or 'where'
let l:standalone_open = line =~# '\V\^\s\*{\s\*\$'
let l:standalone_close = line =~# '\V\^\s\*}\s\*\$'
let l:standalone_where = line =~# '\V\^\s\*where\s\*\$'
if l:standalone_open || l:standalone_close || l:standalone_where
" ToDo: we can search for more items than 'fn' and 'if'.
let [l:found_line, l:col, l:submatch] =
\ searchpos('\<\(fn\)\|\(if\)\>', 'bnWp')
if l:found_line !=# 0
" Now we count the number of '{' and '}' in between the match
" locations and the current line (there is probably a better
" way to compute this).
let l:i = l:found_line
let l:search_line = strpart(getline(l:i), l:col - 1)
let l:opens = 0
let l:closes = 0
while l:i < a:lnum
let l:search_line2 = substitute(l:search_line, '\V{', '', 'g')
let l:opens += strlen(l:search_line) - strlen(l:search_line2)
let l:search_line3 = substitute(l:search_line2, '\V}', '', 'g')
let l:closes += strlen(l:search_line2) - strlen(l:search_line3)
let l:i += 1
let l:search_line = getline(l:i)
endwhile
if l:standalone_open || l:standalone_where
if l:opens ==# l:closes
return indent(l:found_line)
endif
else
" Expect to find just one more close than an open
if l:opens ==# l:closes + 1
return indent(l:found_line)
endif
endif
endif
endif
" A standalone 'where' adds a shift.
let l:standalone_prevline_where = prevline =~# '\V\^\s\*where\s\*\$'
if l:standalone_prevline_where
return indent(prevlinenum) + 4
endif
" Handle where clauses nicely: subsequent values should line up nicely. " Handle where clauses nicely: subsequent values should line up nicely.
if prevline[len(prevline) - 1] ==# "," if prevline[len(prevline) - 1] ==# ","
\ && prevline =~# '^\s*where\s' \ && prevline =~# '^\s*where\s'
return indent(prevlinenum) + 6 return indent(prevlinenum) + 6
endif endif
if prevline[len(prevline) - 1] ==# "," let l:last_prevline_character = prevline[len(prevline) - 1]
\ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{}]'
" A line that ends with '.<expr>;' is probably an end of a long list
" of method operations.
if prevline =~# '\V\^\s\*.' && l:last_prevline_character ==# ';'
return indent(prevlinenum) - s:shiftwidth()
endif
if l:last_prevline_character ==# ","
\ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{})]'
\ && prevline !~# '^\s*fn\s' \ && prevline !~# '^\s*fn\s'
\ && prevline !~# '([^()]\+,$' \ && prevline !~# '([^()]\+,$'
\ && s:get_line_trimmed(a:lnum) !~# '^\s*\S\+\s*=>' \ && s:get_line_trimmed(a:lnum) !~# '^\s*\S\+\s*=>'

View File

@@ -21,7 +21,10 @@ if exists("*GetScalaIndent")
finish finish
endif endif
let s:defMatcher = '\%(\%(private\|protected\)\%(\[[^\]]*\]\)\?\s\+\|abstract\s\+\|override\s\+\)*\<def\>' let s:annotationMatcher = '@[A-Za-z._]\+\s\+'
let s:modifierMatcher = s:annotationMatcher . '\|\%(private\|protected\)\%(\[[^\]]*\]\)\?\s\+\|abstract\s\+\|override\s\+\|final\s\+'
let s:defMatcher = '\%(' . s:modifierMatcher . '\)*\<def\>'
let s:valMatcher = '\%(' . s:modifierMatcher . '\|lazy\s\+\)*\<va[lr]\>'
let s:funcNameMatcher = '\w\+' let s:funcNameMatcher = '\w\+'
let s:typeSpecMatcher = '\%(\s*\[\_[^\]]*\]\)' let s:typeSpecMatcher = '\%(\s*\[\_[^\]]*\]\)'
let s:defArgMatcher = '\%((\_.\{-})\)' let s:defArgMatcher = '\%((\_.\{-})\)'
@@ -185,7 +188,7 @@ function! scala#NumberOfBraceGroups(line)
endfunction endfunction
function! scala#MatchesIncompleteDefValr(line) function! scala#MatchesIncompleteDefValr(line)
if a:line =~ '^\s*\%(' . s:defMatcher . '\|\<va[lr]\>\).*[=({]\s*$' if a:line =~ '^\s*\%(' . s:defMatcher . '\|' . s:valMatcher . '\).*[=({]\s*$'
return 1 return 1
else else
return 0 return 0
@@ -435,7 +438,7 @@ function! GetScalaIndent()
" If 'val', 'var', 'def' end with =, this is a one-line block " If 'val', 'var', 'def' end with =, this is a one-line block
if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1) if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1)
\ || prevline =~ '^\s*' . s:defMatcher . '.*=\s*$' \ || prevline =~ '^\s*' . s:defMatcher . '.*=\s*$'
\ || prevline =~ '^\s*\<va[lr]\>.*[=]\s*$' \ || prevline =~ '^\s*' . s:valMatcher . '.*[=]\s*$'
\ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$' \ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$'
\ || prevline =~ '=\s*$' \ || prevline =~ '=\s*$'
call scala#ConditionalConfirm("4") call scala#ConditionalConfirm("4")

148
indent/svelte.vim Normal file
View File

@@ -0,0 +1,148 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'svelte') != -1
finish
endif
" Vim indent file
" Language: Svelte 3 (HTML/JavaScript)
" Author: Evan Lecklider <evan@lecklider.com>
" Maintainer: Evan Lecklide <evan@lecklider.com>
" URL: https://github.com/evanleck/vim-svelte
if exists("b:did_indent")
finish
endif
runtime! indent/html.vim
unlet! b:did_indent
let s:html_indent = &l:indentexpr
let b:did_indent = 1
if !exists('g:svelte_indent_script')
let g:svelte_indent_script = 1
endif
if !exists('g:svelte_indent_style')
let g:svelte_indent_style = 1
endif
setlocal indentexpr=GetSvelteIndent()
setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],!^F,;,=:else,=:then,=:catch,=/if,=/each,=/await
" Only define the function once.
if exists('*GetSvelteIndent')
finish
endif
function! GetSvelteIndent()
let current_line_number = v:lnum
if current_line_number == 0
return 0
endif
let current_line = getline(current_line_number)
" Opening script and style tags should be all the way outdented.
if current_line =~ '^\s*</\?\(script\|style\)'
return 0
endif
let previous_line_number = prevnonblank(current_line_number - 1)
let previous_line = getline(previous_line_number)
let previous_line_indent = indent(previous_line_number)
" The inside of scripts an styles should be indented unless disabled.
if previous_line =~ '^\s*<script'
if g:svelte_indent_script
return previous_line_indent + shiftwidth()
else
return previous_line_indent
endif
endif
if previous_line =~ '^\s*<style'
if g:svelte_indent_style
return previous_line_indent + shiftwidth()
else
return previous_line_indent
endif
endif
execute "let indent = " . s:html_indent
" For some reason, the HTML CSS indentation keeps indenting the next line over
" and over after each style declaration.
if searchpair('<style>', '', '</style>', 'bW') && previous_line =~ ';$' && current_line !~ '}'
return previous_line_indent
endif
" "/await" or ":catch" or ":then"
if current_line =~ '^\s*{\s*\/await' || current_line =~ '^\s*{\s*:\(catch\|then\)'
let await_start = searchpair('{\s*#await\>', '', '{\s*\/await\>', 'bW')
if await_start
return indent(await_start)
endif
endif
" "/each"
if current_line =~ '^\s*{\s*\/each'
let each_start = searchpair('{\s*#each\>', '', '{\s*\/each\>', 'bW')
if each_start
return indent(each_start)
endif
endif
" "/if"
if current_line =~ '^\s*{\s*\/if'
let if_start = searchpair('{\s*#if\>', '', '{\s*\/if\>', 'bW')
if if_start
return indent(if_start)
endif
endif
" ":else" is tricky because it can match an opening "#each" _or_ an opening
" "#if", so we try to be smart and look for the closest of the two.
if current_line =~ '^\s*{\s*:else'
let if_start = searchpair('{\s*#if\>', '', '{\s*\/if\>', 'bW')
" If it's an "else if" then we know to look for an "#if"
if current_line =~ '^\s*{\s*:else if' && if_start
return indent(if_start)
else
" The greater line number will be closer to the cursor position because
" we're searching backward.
return indent(max([if_start, searchpair('{\s*#each\>', '', '{\s*\/each\>', 'bW')]))
endif
endif
" "#if" or "#each"
if previous_line =~ '^\s*{\s*#\(if\|each\|await\)'
return previous_line_indent + shiftwidth()
endif
" ":else" or ":then"
if previous_line =~ '^\s*{\s*:\(else\|catch\|then\)'
return previous_line_indent + shiftwidth()
endif
" Custom element juggling for abnormal self-closing tags (<Widget />),
" capitalized component tags (<Widget></Widget>), and custom svelte tags
" (<svelte:head></svelte:head>).
if synID(previous_line_number, match(previous_line, '\S') + 1, 0) == hlID('htmlTag')
\ && synID(current_line_number, match(current_line, '\S') + 1, 0) != hlID('htmlEndTag')
let indents_match = indent == previous_line_indent
let previous_closes = previous_line =~ '/>$'
if indents_match && !previous_closes && previous_line =~ '<\(\u\|\l\+:\l\+\)'
return previous_line_indent + shiftwidth()
elseif !indents_match && previous_closes
return previous_line_indent
endif
endif
return indent
endfunction

View File

@@ -34,24 +34,19 @@ function! TerraformIndent(lnum)
return 0 return 0
endif endif
" Previous non-blank line should continue the indent level " Usual case is to continue at the same indent as the previous non-blank line.
let prevlnum = prevnonblank(a:lnum-1) let prevlnum = prevnonblank(a:lnum-1)
let thisindent = indent(prevlnum)
" Previous line without comments should continue the indent level " If that previous line is a non-comment ending in [ { (, increase the
let prevline = substitute(getline(prevlnum), '//.*$', '', '') " indent level.
let previndent = indent(prevlnum) let prevline = getline(prevlnum)
let thisindent = previndent if prevline !~# '^\s*\(#\|//\)' && prevline =~# '[\[{\(]\s*$'
" Config block starting with [ { ( should increase the indent level
if prevline =~# '[\[{\(]\s*$'
let thisindent += &shiftwidth let thisindent += &shiftwidth
endif endif
" Current line without comments should continue the indent level " If the current line ends a block, decrease the indent level.
let thisline = substitute(getline(a:lnum), '//.*$', '', '') let thisline = getline(a:lnum)
" Config block ending with ) } ] should get the indentation
" level from the initial config block
if thisline =~# '^\s*[\)}\]]' if thisline =~# '^\s*[\)}\]]'
let thisindent -= &shiftwidth let thisindent -= &shiftwidth
endif endif

114
indent/tsx.vim Normal file
View File

@@ -0,0 +1,114 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
" Save the current JavaScript indentexpr.
let b:tsx_ts_indentexpr = &indentexpr
" Prologue; load in XML indentation.
if exists('b:did_indent')
let s:did_indent=b:did_indent
unlet b:did_indent
endif
exe 'runtime! indent/xml.vim'
if exists('s:did_indent')
let b:did_indent=s:did_indent
endif
setlocal indentexpr=GetTsxIndent()
" JS indentkeys
setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
" XML indentkeys
setlocal indentkeys+=*<Return>,<>>,<<>,/
" Multiline end tag regex (line beginning with '>' or '/>')
let s:endtag = '^\s*\/\?>\s*;\='
let s:startexp = '[\{\(]\s*$'
" Get all syntax types at the beginning of a given line.
fu! SynSOL(lnum)
return map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")')
endfu
" Get all syntax types at the end of a given line.
fu! SynEOL(lnum)
let lnum = prevnonblank(a:lnum)
let col = strlen(getline(lnum))
return map(synstack(lnum, col), 'synIDattr(v:val, "name")')
endfu
" Check if a syntax attribute is XMLish.
fu! SynAttrXMLish(synattr)
return a:synattr =~ "^xml" || a:synattr =~ "^tsx"
endfu
" Check if a synstack is XMLish (i.e., has an XMLish last attribute).
fu! SynXMLish(syns)
return SynAttrXMLish(get(a:syns, -1))
endfu
" Check if a synstack denotes the end of a TSX block.
fu! SynTSXBlockEnd(syns)
return get(a:syns, -1) =~ '\%(ts\|typescript\)Braces' &&
\ SynAttrXMLish(get(a:syns, -2))
endfu
" Determine how many tsxRegions deep a synstack is.
fu! SynTSXDepth(syns)
return len(filter(copy(a:syns), 'v:val ==# "tsxRegion"'))
endfu
" Check whether `cursyn' continues the same tsxRegion as `prevsyn'.
fu! SynTSXContinues(cursyn, prevsyn)
let curdepth = SynTSXDepth(a:cursyn)
let prevdepth = SynTSXDepth(a:prevsyn)
" In most places, we expect the nesting depths to be the same between any
" two consecutive positions within a tsxRegion (e.g., between a parent and
" child node, between two TSX attributes, etc.). The exception is between
" sibling nodes, where after a completed element (with depth N), we return
" to the parent's nesting (depth N - 1). This case is easily detected,
" since it is the only time when the top syntax element in the synstack is
" tsxRegion---specifically, the tsxRegion corresponding to the parent.
return prevdepth == curdepth ||
\ (prevdepth == curdepth + 1 && get(a:cursyn, -1) ==# 'tsxRegion')
endfu
" Cleverly mix JS and XML indentation.
fu! GetTsxIndent()
let cursyn = SynSOL(v:lnum)
let prevsyn = SynEOL(v:lnum - 1)
" Use XML indenting iff:
" - the syntax at the end of the previous line was either TSX or was the
" closing brace of a jsBlock whose parent syntax was TSX; and
" - the current line continues the same tsxRegion as the previous line.
if (SynXMLish(prevsyn) || SynTSXBlockEnd(prevsyn)) &&
\ SynTSXContinues(cursyn, prevsyn)
let ind = XmlIndentGet(v:lnum, 0)
let l:line = getline(v:lnum)
let l:pline = getline(v:lnum - 1)
" Align '/>' and '>' with '<' for multiline tags.
" Align end of expression ')' or '}'.
if l:line =~? s:endtag
let ind = ind - shiftwidth()
endif
" Then correct the indentation of any TSX following '/>' or '>'.
" Align start of expression '(' or '{'
if l:pline =~? s:endtag || l:pline =~? s:startexp
let ind = ind + shiftwidth()
endif
else
if len(b:tsx_ts_indentexpr)
" Invoke the base TS package's custom indenter
let ind = eval(b:tsx_ts_indentexpr)
else
let ind = cindent(v:lnum)
endif
endif
return ind
endfu

View File

@@ -3,361 +3,503 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') !=
endif endif
" Vim indent file " Vim indent file
" Language: Typescript " Language: TypeScript
" Acknowledgement: Almost direct copy from https://github.com/pangloss/vim-javascript " Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org
" 0. Initialization {{{1
" =================
" Only load this indent file when no other was loaded. " Only load this indent file when no other was loaded.
if exists('b:did_indent') || get(g:, 'typescript_indent_disable', 0) if exists("b:did_indent")
finish finish
endif endif
let b:did_indent = 1 let b:did_indent = 1
setlocal nosmartindent
" Now, set up our indentation expression and keys that trigger it. " Now, set up our indentation expression and keys that trigger it.
setlocal indentexpr=GetTypescriptIndent() setlocal indentexpr=GetTypescriptIndent()
setlocal autoindent nolisp nosmartindent setlocal formatexpr=Fixedgq(v:lnum,v:count)
setlocal indentkeys+=0],0) setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<'
" Only define the function once. " Only define the function once.
if exists('*GetTypescriptIndent') if exists("*GetTypescriptIndent")
finish finish
endif endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
" Get shiftwidth value " 1. Variables {{{1
if exists('*shiftwidth') " ============
function s:sw()
return shiftwidth()
endfunction
else
function s:sw()
return &sw
endfunction
endif
" searchpair() wrapper let s:js_keywords = '^\s*\(break\|case\|catch\|continue\|debugger\|default\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)'
if has('reltime')
function s:GetPair(start,end,flags,skip,time,...)
return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time)
endfunction
else
function s:GetPair(start,end,flags,skip,...)
return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,get(a:000,1)]))
endfunction
endif
" Regex of syntax group names that are or delimit string or are comments. " Regex of syntax group names that are or delimit string or are comments.
let s:syng_strcom = 'string\|comment\|regex\|special\|doc\|template\%(braces\)\@!' let s:syng_strcom = 'string\|regex\|comment\c'
let s:syng_str = 'string\|template\|special'
let s:syng_com = 'comment\|doc' " Regex of syntax group names that are strings.
let s:syng_string = 'regex\c'
" Regex of syntax group names that are strings or documentation.
let s:syng_multiline = 'comment\c'
" Regex of syntax group names that are line comment.
let s:syng_linecom = 'linecomment\c'
" Expression used to check whether we should skip a match with searchpair(). " Expression used to check whether we should skip a match with searchpair().
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'" let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
function s:skip_func() let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
if !s:free || search('\m`\|\${\|\*\/','nW',s:looksyn)
let s:free = !eval(s:skip_expr) " Regex that defines continuation lines, not including (, {, or [.
let s:looksyn = line('.') let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=]=[^=].*,\)' . s:line_term
return !s:free
endif " Regex that defines continuation lines.
let s:looksyn = line('.') " TODO: this needs to deal with if ...: and so on
return getline('.') =~ '\%<'.col('.').'c\/.\{-}\/\|\%>'.col('.').'c[''"]\|\\$' && let s:msl_regex = s:continuation_regex
\ eval(s:skip_expr)
let s:one_line_scope_regex = '\<\%(if\|else\|for\|while\)\>[^{;]*' . s:line_term
" Regex that defines blocks.
let s:block_regex = '\%([{[]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
let s:var_stmt = '^\s*var'
let s:comma_first = '^\s*,'
let s:comma_last = ',\s*$'
let s:ternary = '^\s\+[?|:]'
let s:ternary_q = '^\s\+?'
" 2. Auxiliary Functions {{{1
" ======================
" Check if the character at lnum:col is inside a string, comment, or is ascii.
function s:IsInStringOrComment(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom
endfunction endfunction
function s:alternatePair(stop) " Check if the character at lnum:col is inside a string.
let pos = getpos('.')[1:2] function s:IsInString(lnum, col)
while search('\m[][(){}]','bW',a:stop) return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
if !s:skip_func() endfunction
let idx = stridx('])}',s:looking_at())
if idx + 1 " Check if the character at lnum:col is inside a multi-line comment.
if s:GetPair(['\[','(','{'][idx], '])}'[idx],'bW','s:skip_func()',2000,a:stop) <= 0 function s:IsInMultilineComment(lnum, col)
break return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
endif endfunction
else
return " Check if the character at lnum:col is a line comment.
endif function s:IsLineComment(lnum, col)
endif return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_linecom
endfunction
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
function s:PrevNonBlankNonString(lnum)
let in_block = 0
let lnum = prevnonblank(a:lnum)
while lnum > 0
" Go in and out of blocks comments as necessary.
" If the line isn't empty (with opt. comment) or in a string, end search.
let line = getline(lnum)
if line =~ '/\*'
if in_block
let in_block = 0
else
break
endif
elseif !in_block && line =~ '\*/'
let in_block = 1
elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && s:IsInStringOrComment(lnum, strlen(line)))
break
endif
let lnum = prevnonblank(lnum - 1)
endwhile endwhile
call call('cursor',pos) return lnum
endfunction endfunction
function s:save_pos(f,...) " Find line above 'lnum' that started the continuation 'lnum' may be part of.
let l:pos = getpos('.')[1:2] function s:GetMSL(lnum, in_one_line_scope)
let ret = call(a:f,a:000) " Start on the line we're at and use its indent.
call call('cursor',l:pos) let msl = a:lnum
return ret let lnum = s:PrevNonBlankNonString(a:lnum - 1)
endfunction while lnum > 0
" If we have a continuation line, or we're in a string, use line as MSL.
function s:syn_at(l,c) " Otherwise, terminate search as we have found our MSL already.
return synIDattr(synID(a:l,a:c,0),'name') let line = getline(lnum)
endfunction let col = match(line, s:msl_regex) + 1
if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line))
function s:looking_at() let msl = lnum
return getline('.')[col('.')-1] else
endfunction " Don't use lines that are part of a one line scope as msl unless the
" flag in_one_line_scope is set to 1
function s:token() "
return s:looking_at() =~ '\k' ? expand('<cword>') : s:looking_at() if a:in_one_line_scope
endfunction break
end
function s:previous_token() let msl_one_line = s:Match(lnum, s:one_line_scope_regex)
let l:n = line('.') if msl_one_line == 0
if (s:looking_at() !~ '\k' || search('\m\<','cbW')) && search('\m\S','bW') break
if (getline('.')[col('.')-2:col('.')-1] == '*/' || line('.') != l:n && endif
\ getline('.') =~ '\%<'.col('.').'c\/\/') && s:syn_at(line('.'),col('.')) =~? s:syng_com endif
while search('\m\/\ze[/*]','cbW') let lnum = s:PrevNonBlankNonString(lnum - 1)
if !search('\m\S','bW')
break
elseif s:syn_at(line('.'),col('.')) !~? s:syng_com
return s:token()
endif
endwhile
else
return s:token()
endif
endif
return ''
endfunction
function s:others(p)
return "((line2byte(line('.')) + col('.')) <= ".(line2byte(a:p[0]) + a:p[1]).") || ".s:skip_expr
endfunction
function s:tern_skip(p)
return s:GetPair('{','}','nbW',s:others(a:p),200,a:p[0]) > 0
endfunction
function s:tern_col(p)
return s:GetPair('?',':\@<!::\@!','nbW',s:others(a:p)
\ .' || s:tern_skip('.string(a:p).')',200,a:p[0]) > 0
endfunction
function s:label_col()
let pos = getpos('.')[1:2]
let [s:looksyn,s:free] = pos
call s:alternatePair(0)
if s:save_pos('s:IsBlock')
let poss = getpos('.')[1:2]
return call('cursor',pos) || !s:tern_col(poss)
elseif s:looking_at() == ':'
return !s:tern_col([0,0])
endif
endfunction
" configurable regexes that define continuation lines, not including (, {, or [.
let s:opfirst = '^' . get(g:,'typescript_opfirst',
\ '\%([<>=,?^%|*/&]\|\([-.:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)')
let s:continuation = get(g:,'typescript_continuation',
\ '\%([-+<>=,.~!?/*^%|&:]\|\<\%(typeof\|delete\|void\|in\|instanceof\)\)') . '$'
function s:continues(ln,con)
return !cursor(a:ln, match(' '.a:con,s:continuation)) &&
\ eval( (['s:syn_at(line("."),col(".")) !~? "regex"'] +
\ repeat(['getline(".")[col(".")-2] != tr(s:looking_at(),">","=")'],3) +
\ repeat(['s:previous_token() != "."'],5) + [1])[
\ index(split('/ > - + typeof in instanceof void delete'),s:token())])
endfunction
" get the line of code stripped of comments and move cursor to the last
" non-comment char.
function s:Trim(ln)
call cursor(a:ln+1,1)
call s:previous_token()
return strpart(getline('.'),0,col('.'))
endfunction
" Find line above 'lnum' that isn't empty or in a comment
function s:PrevCodeLine(lnum)
let l:n = prevnonblank(a:lnum)
while l:n
if getline(l:n) =~ '^\s*\/[/*]'
if (stridx(getline(l:n),'`') > 0 || getline(l:n-1)[-1:] == '\') &&
\ s:syn_at(l:n,1) =~? s:syng_str
return l:n
endif
let l:n = prevnonblank(l:n-1)
elseif getline(l:n) =~ '\([/*]\)\1\@![/*]' && s:syn_at(l:n,1) =~? s:syng_com
let l:n = s:save_pos('eval',
\ 'cursor('.l:n.',1) + search(''\m\/\*'',"bW")')
else
return l:n
endif
endwhile endwhile
return msl
endfunction endfunction
" Check if line 'lnum' has a balanced amount of parentheses. function s:RemoveTrailingComments(content)
function s:Balanced(lnum) let single = '\/\/\(.*\)\s*$'
let l:open = 0 let multi = '\/\*\(.*\)\*\/\s*$'
let l:line = getline(a:lnum) return substitute(substitute(a:content, single, '', ''), multi, '', '')
let pos = match(l:line, '[][(){}]', 0) endfunction
" Find if the string is inside var statement (but not the first string)
function s:InMultiVarStatement(lnum)
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
" let type = synIDattr(synID(lnum, indent(lnum) + 1, 0), 'name')
" loop through previous expressions to find a var statement
while lnum > 0
let line = getline(lnum)
" if the line is a js keyword
if (line =~ s:js_keywords)
" check if the line is a var stmt
" if the line has a comma first or comma last then we can assume that we
" are in a multiple var statement
if (line =~ s:var_stmt)
return lnum
endif
" other js keywords, not a var
return 0
endif
let lnum = s:PrevNonBlankNonString(lnum - 1)
endwhile
" beginning of program, not a var
return 0
endfunction
" Find line above with beginning of the var statement or returns 0 if it's not
" this statement
function s:GetVarIndent(lnum)
let lvar = s:InMultiVarStatement(a:lnum)
let prev_lnum = s:PrevNonBlankNonString(a:lnum - 1)
if lvar
let line = s:RemoveTrailingComments(getline(prev_lnum))
" if the previous line doesn't end in a comma, return to regular indent
if (line !~ s:comma_last)
return indent(prev_lnum) - shiftwidth()
else
return indent(lvar) + shiftwidth()
endif
endif
return -1
endfunction
" Check if line 'lnum' has more opening brackets than closing ones.
function s:LineHasOpeningBrackets(lnum)
let open_0 = 0
let open_2 = 0
let open_4 = 0
let line = getline(a:lnum)
let pos = match(line, '[][(){}]', 0)
while pos != -1 while pos != -1
if s:syn_at(a:lnum,pos + 1) !~? s:syng_strcom if !s:IsInStringOrComment(a:lnum, pos + 1)
let l:open += match(' ' . l:line[pos],'[[({]') let idx = stridx('(){}[]', line[pos])
if l:open < 0 if idx % 2 == 0
return let open_{idx} = open_{idx} + 1
endif else
endif let open_{idx - 1} = open_{idx - 1} - 1
let pos = match(l:line, '[][(){}]', pos + 1) endif
endif
let pos = match(line, '[][(){}]', pos + 1)
endwhile endwhile
return !l:open return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
endfunction endfunction
function s:OneScope(lnum) function s:Match(lnum, regex)
let pline = s:Trim(a:lnum) let col = match(getline(a:lnum), a:regex) + 1
let kw = 'else do' return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0
if pline[-1:] == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 endfunction
call s:previous_token()
let kw = 'for if let while with' function s:IndentWithContinuation(lnum, ind, width)
if index(split('await each'),s:token()) + 1 " Set up variables to use and search for MSL to the previous line.
call s:previous_token() let p_lnum = a:lnum
let kw = 'for' let lnum = s:GetMSL(a:lnum, 1)
endif let line = getline(lnum)
" If the previous line wasn't a MSL and is continuation return its indent.
" TODO: the || s:IsInString() thing worries me a bit.
if p_lnum != lnum
if s:Match(p_lnum,s:continuation_regex)||s:IsInString(p_lnum,strlen(line))
return a:ind
endif
endif endif
return pline[-2:] == '=>' || index(split(kw),s:token()) + 1 &&
\ s:save_pos('s:previous_token') != '.'
endfunction
" returns braceless levels started by 'i' and above lines * &sw. 'num' is the " Set up more variables now that we know we aren't continuation bound.
" lineNr which encloses the entire context, 'cont' if whether line 'i' + 1 is let msl_ind = indent(lnum)
" a continued expression, which could have started in a braceless context
function s:iscontOne(i,num,cont)
let [l:i, l:num, bL] = [a:i, a:num + !a:num, 0]
let pind = a:num ? indent(l:num) + s:W : 0
let ind = indent(l:i) + (a:cont ? 0 : s:W)
while l:i >= l:num && (ind > pind || l:i == l:num)
if indent(l:i) < ind && s:OneScope(l:i)
let bL += s:W
let l:i = line('.')
elseif !a:cont || bL || ind < indent(a:i)
break
endif
let ind = min([ind, indent(l:i)])
let l:i = s:PrevCodeLine(l:i - 1)
endwhile
return bL
endfunction
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader " If the previous line ended with [*+/.-=], start a continuation that
function s:IsBlock() " indents an extra level.
if s:looking_at() == '{' if s:Match(lnum, s:continuation_regex)
let l:n = line('.') if lnum == p_lnum
let char = s:previous_token() return msl_ind + a:width
if match(s:stack,'xml\|jsx') + 1 && s:syn_at(line('.'),col('.')-1) =~? 'xml\|jsx' else
return char != '{' return msl_ind
elseif char =~ '\k' endif
return index(split('return const let import export yield default delete var await void typeof throw case new in instanceof')
\ ,char) < (line('.') != l:n) || s:previous_token() == '.'
elseif char == '>'
return getline('.')[col('.')-2] == '=' || s:syn_at(line('.'),col('.')) =~? '^jsflow'
elseif char == ':'
return getline('.')[col('.')-2] != ':' && s:label_col()
elseif char == '/'
return s:syn_at(line('.'),col('.')) =~? 'regex'
endif
return char !~ '[=~!<*,?^%|&([]' &&
\ (char !~ '[-+]' || l:n != line('.') && getline('.')[col('.')-2] == char)
endif endif
return a:ind
endfunction endfunction
function s:InOneLineScope(lnum)
let msl = s:GetMSL(a:lnum, 1)
if msl > 0 && s:Match(msl, s:one_line_scope_regex)
return msl
endif
return 0
endfunction
function s:ExitingOneLineScope(lnum)
let msl = s:GetMSL(a:lnum, 1)
if msl > 0
" if the current line is in a one line scope ..
if s:Match(msl, s:one_line_scope_regex)
return 0
else
let prev_msl = s:GetMSL(msl - 1, 1)
if s:Match(prev_msl, s:one_line_scope_regex)
return prev_msl
endif
endif
endif
return 0
endfunction
" 3. GetTypescriptIndent Function {{{1
" =========================
function GetTypescriptIndent() function GetTypescriptIndent()
let b:js_cache = get(b:,'js_cache',[0,0,0]) " 3.1. Setup {{{2
" ----------
" Set up variables for restoring position in file. Could use v:lnum here.
let vcol = col('.')
" 3.2. Work on the current line {{{2
" -----------------------------
let ind = -1
" Get the current line. " Get the current line.
call cursor(v:lnum,1) let line = getline(v:lnum)
let l:line = getline('.') " previous nonblank line number
" use synstack as it validates syn state and works in an empty line let prevline = prevnonblank(v:lnum - 1)
let s:stack = synstack(v:lnum,1)
let syns = synIDattr(get(s:stack,-1),'name')
" start with strings,comments,etc. " If we got a closing bracket on an empty line, find its match and indent
if syns =~? s:syng_com " according to it. For parentheses we indent to its column - 1, for the
if l:line =~ '^\s*\*' " others we indent to the containing line's MSL's level. Return -1 if fail.
return cindent(v:lnum) let col = matchend(line, '^\s*[],})]')
elseif l:line !~ '^\s*\/[/*]' if col > 0 && !s:IsInStringOrComment(v:lnum, col)
return -1 call cursor(v:lnum, col)
endif
elseif syns =~? s:syng_str && l:line !~ '^[''"]' let lvar = s:InMultiVarStatement(v:lnum)
if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1) if lvar
let b:js_cache[0] = v:lnum let prevline_contents = s:RemoveTrailingComments(getline(prevline))
endif
return -1 " check for comma first
endif if (line[col - 1] =~ ',')
let l:lnum = s:PrevCodeLine(v:lnum - 1) " if the previous line ends in comma or semicolon don't indent
if !l:lnum if (prevline_contents =~ '[;,]\s*$')
return return indent(s:GetMSL(line('.'), 0))
" get previous line indent, if it's comma first return prevline indent
elseif (prevline_contents =~ s:comma_first)
return indent(prevline)
" otherwise we indent 1 level
else
return indent(lvar) + shiftwidth()
endif
endif
endif
let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2)
if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
if line[col-1]==')' && col('.') != col('$') - 1
let ind = virtcol('.')-1
else
let ind = indent(s:GetMSL(line('.'), 0))
endif
endif
return ind
endif endif
let l:line = substitute(l:line,'^\s*','','') " If the line is comma first, dedent 1 level
if l:line[:1] == '/*' if (getline(prevline) =~ s:comma_first)
let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','') return indent(prevline) - shiftwidth()
endif
if l:line =~ '^\/[/*]'
let l:line = ''
endif endif
" the containing paren, bracket, or curly. Many hacks for performance if (line =~ s:ternary)
let idx = index([']',')','}'],l:line[0]) if (getline(prevline) =~ s:ternary_q)
if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum && return indent(prevline)
\ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) else
call call('cursor',b:js_cache[1:]) return indent(prevline) + shiftwidth()
endif
endif
" If we are in a multi-line comment, cindent does the right thing.
if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1)
return cindent(v:lnum)
endif
" Check for multiple var assignments
" let var_indent = s:GetVarIndent(v:lnum)
" if var_indent >= 0
" return var_indent
" endif
" 3.3. Work on the previous line. {{{2
" -------------------------------
" If the line is empty and the previous nonblank line was a multi-line
" comment, use that comment's indent. Deduct one char to account for the
" space in ' */'.
if line =~ '^\s*$' && s:IsInMultilineComment(prevline, 1)
return indent(prevline) - 1
endif
" Find a non-blank, non-multi-line string line above the current line.
let lnum = s:PrevNonBlankNonString(v:lnum - 1)
" If the line is empty and inside a string, use the previous line.
if line =~ '^\s*$' && lnum != prevline
return indent(prevnonblank(v:lnum))
endif
" At the start of the file use zero indent.
if lnum == 0
return 0
endif
" Set up variables for current line.
let line = getline(lnum)
let ind = indent(lnum)
" If the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex)
return indent(s:GetMSL(lnum, 0)) + shiftwidth()
endif
" If the previous line contained an opening bracket, and we are still in it,
" add indent depending on the bracket type.
if line =~ '[[({]'
let counts = s:LineHasOpeningBrackets(lnum)
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
if col('.') + 1 == col('$')
return ind + shiftwidth()
else
return virtcol('.')
endif
elseif counts[1] == '1' || counts[2] == '1'
return ind + shiftwidth()
else
call cursor(v:lnum, vcol)
end
endif
" 3.4. Work on the MSL line. {{{2
" --------------------------
let ind_con = ind
let ind = s:IndentWithContinuation(lnum, ind_con, shiftwidth())
" }}}2
"
"
let ols = s:InOneLineScope(lnum)
if ols > 0
let ind = ind + shiftwidth()
else else
let [s:looksyn, s:free, top] = [v:lnum - 1, 1, (!indent(l:lnum) && let ols = s:ExitingOneLineScope(lnum)
\ s:syn_at(l:lnum,1) !~? s:syng_str) * l:lnum] while ols > 0 && ind > 0
if idx + 1 let ind = ind - shiftwidth()
call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:skip_func()',2000,top) let ols = s:InOneLineScope(ols - 1)
elseif getline(v:lnum) !~ '^\S' && syns =~? 'block' endwhile
call s:GetPair('{','}','bW','s:skip_func()',2000,top)
else
call s:alternatePair(top)
endif
endif endif
let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [0,0] : getpos('.')[1:2]) return ind
let num = b:js_cache[1]
let [s:W, isOp, bL, switch_offset] = [s:sw(),0,0,0]
if !num || s:IsBlock()
let ilnum = line('.')
let pline = s:save_pos('s:Trim',l:lnum)
if num && s:looking_at() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
let num = ilnum == num ? line('.') : num
if idx < 0 && s:previous_token() ==# 'switch' && s:previous_token() != '.'
if &cino !~ ':'
let switch_offset = s:W
else
let cinc = matchlist(&cino,'.*:\zs\(-\)\=\(\d*\)\(\.\d\+\)\=\(s\)\=\C')
let switch_offset = max([cinc[0] is '' ? 0 : (cinc[1].1) *
\ ((strlen(cinc[2].cinc[3]) ? str2nr(cinc[2].str2nr(cinc[3][1])) : 10) *
\ (cinc[4] is '' ? 1 : s:W)) / 10, -indent(num)])
endif
if pline[-1:] != '.' && l:line =~# '^\%(default\|case\)\>'
return indent(num) + switch_offset
endif
endif
endif
if idx < 0 && pline !~ '[{;]$'
if pline =~# ':\@<!:$'
call cursor(l:lnum,strlen(pline))
let isOp = s:tern_col(b:js_cache[1:2]) * s:W
else
let isOp = (l:line =~# s:opfirst || s:continues(l:lnum,pline)) * s:W
endif
let bL = s:iscontOne(l:lnum,b:js_cache[1],isOp)
let bL -= (bL && l:line[0] == '{') * s:W
endif
endif
" main return
if idx + 1 || l:line[:1] == '|}'
return indent(num)
elseif num
return indent(num) + s:W + switch_offset + bL + isOp
endif
return bL + isOp
endfunction endfunction
" }}}1
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
function! Fixedgq(lnum, count)
let l:tw = &tw ? &tw : 80;
let l:count = a:count
let l:first_char = indent(a:lnum) + 1
if mode() == 'i' " gq was not pressed, but tw was set
return 1
endif
" This gq is only meant to do code with strings, not comments
if s:IsLineComment(a:lnum, l:first_char) || s:IsInMultilineComment(a:lnum, l:first_char)
return 1
endif
if len(getline(a:lnum)) < l:tw && l:count == 1 " No need for gq
return 1
endif
" Put all the lines on one line and do normal spliting after that
if l:count > 1
while l:count > 1
let l:count -= 1
normal! J
endwhile
endif
let l:winview = winsaveview()
call cursor(a:lnum, l:tw + 1)
let orig_breakpoint = searchpairpos(' ', '', '\.', 'bcW', '', a:lnum)
call cursor(a:lnum, l:tw + 1)
let breakpoint = searchpairpos(' ', '', '\.', 'bcW', s:skip_expr, a:lnum)
" No need for special treatment, normal gq handles edgecases better
if breakpoint[1] == orig_breakpoint[1]
call winrestview(l:winview)
return 1
endif
" Try breaking after string
if breakpoint[1] <= indent(a:lnum)
call cursor(a:lnum, l:tw + 1)
let breakpoint = searchpairpos('\.', '', ' ', 'cW', s:skip_expr, a:lnum)
endif
if breakpoint[1] != 0
call feedkeys("r\<CR>")
else
let l:count = l:count - 1
endif
" run gq on new lines
if l:count == 1
call feedkeys("gqq")
endif
return 0
endfunction

View File

@@ -0,0 +1,5 @@
if exists('g:polyglot_disabled') && (index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'typescript') != -1 || index(g:polyglot_disabled, 'jsx') != -1)
finish
endif
%%CONTENT%%

View File

@@ -61,8 +61,3 @@ hi link dockerfileTodo Todo
hi link bashStatement Function hi link bashStatement Function
let b:current_syntax = "dockerfile" let b:current_syntax = "dockerfile"
set commentstring=#\ %s
" Enable automatic comment insertion
setlocal fo+=cro

69
syntax/basic/class.vim Normal file
View File

@@ -0,0 +1,69 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
"don't add typescriptMembers to nextgroup, let outer scope match it
" so we won't match abstract method outside abstract class
syntax keyword typescriptAbstract abstract
\ nextgroup=typescriptClassKeyword
\ skipwhite skipnl
syntax keyword typescriptClassKeyword class
\ nextgroup=typescriptClassName,typescriptClassExtends,typescriptClassBlock
\ skipwhite
syntax match typescriptClassName contained /\K\k*/
\ nextgroup=typescriptClassBlock,typescriptClassExtends,typescriptClassTypeParameter
\ skipwhite skipnl
syntax region typescriptClassTypeParameter
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptClassBlock,typescriptClassExtends
\ contained skipwhite skipnl
syntax keyword typescriptClassExtends contained extends implements nextgroup=typescriptClassHeritage skipwhite skipnl
syntax match typescriptClassHeritage contained /\v(\k|\.|\(|\))+/
\ nextgroup=typescriptClassBlock,typescriptClassExtends,typescriptMixinComma,typescriptClassTypeArguments
\ contains=@typescriptValue
\ skipwhite skipnl
\ contained
syntax region typescriptClassTypeArguments matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=@typescriptType
\ nextgroup=typescriptClassExtends,typescriptClassBlock,typescriptMixinComma
\ contained skipwhite skipnl
syntax match typescriptMixinComma /,/ contained nextgroup=typescriptClassHeritage skipwhite skipnl
" we need add arrowFunc to class block for high order arrow func
" see test case
syntax region typescriptClassBlock matchgroup=typescriptBraces start=/{/ end=/}/
\ contains=@typescriptPropertyMemberDeclaration,typescriptAbstract,@typescriptComments,typescriptBlock,typescriptAssign,typescriptDecorator,typescriptAsyncFuncKeyword,typescriptArrowFunc
\ contained fold
syntax keyword typescriptInterfaceKeyword interface nextgroup=typescriptInterfaceName skipwhite
syntax match typescriptInterfaceName contained /\k\+/
\ nextgroup=typescriptObjectType,typescriptInterfaceExtends,typescriptInterfaceTypeParameter
\ skipwhite skipnl
syntax region typescriptInterfaceTypeParameter
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptObjectType,typescriptInterfaceExtends
\ contained
\ skipwhite skipnl
syntax keyword typescriptInterfaceExtends contained extends nextgroup=typescriptInterfaceHeritage skipwhite skipnl
syntax match typescriptInterfaceHeritage contained /\v(\k|\.)+/
\ nextgroup=typescriptObjectType,typescriptInterfaceComma,typescriptInterfaceTypeArguments
\ skipwhite
syntax region typescriptInterfaceTypeArguments matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/ skip=/\s*,\s*/
\ contains=@typescriptType
\ nextgroup=typescriptObjectType,typescriptInterfaceComma
\ contained skipwhite
syntax match typescriptInterfaceComma /,/ contained nextgroup=typescriptInterfaceHeritage skipwhite skipnl

42
syntax/basic/cluster.vim Normal file
View File

@@ -0,0 +1,42 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
"Block VariableStatement EmptyStatement ExpressionStatement IfStatement IterationStatement ContinueStatement BreakStatement ReturnStatement WithStatement LabelledStatement SwitchStatement ThrowStatement TryStatement DebuggerStatement
syntax cluster typescriptStatement
\ contains=typescriptBlock,typescriptVariable,
\ @typescriptTopExpression,typescriptAssign,
\ typescriptConditional,typescriptRepeat,typescriptBranch,
\ typescriptLabel,typescriptStatementKeyword,
\ typescriptFuncKeyword,
\ typescriptTry,typescriptExceptions,typescriptDebugger,
\ typescriptExport,typescriptInterfaceKeyword,typescriptEnum,
\ typescriptModule,typescriptAliasKeyword,typescriptImport
syntax cluster typescriptPrimitive contains=typescriptString,typescriptTemplate,typescriptRegexpString,typescriptNumber,typescriptBoolean,typescriptNull,typescriptArray
syntax cluster typescriptEventTypes contains=typescriptEventString,typescriptTemplate,typescriptNumber,typescriptBoolean,typescriptNull
" top level expression: no arrow func
" also no func keyword. funcKeyword is contained in statement
" funcKeyword allows overloading (func without body)
" funcImpl requires body
syntax cluster typescriptTopExpression
\ contains=@typescriptPrimitive,
\ typescriptIdentifier,typescriptIdentifierName,
\ typescriptOperator,typescriptUnaryOp,
\ typescriptParenExp,typescriptRegexpString,
\ typescriptGlobal,typescriptAsyncFuncKeyword,
\ typescriptClassKeyword,typescriptTypeCast
" no object literal, used in type cast and arrow func
" TODO: change func keyword to funcImpl
syntax cluster typescriptExpression
\ contains=@typescriptTopExpression,
\ typescriptArrowFuncDef,
\ typescriptFuncImpl
syntax cluster typescriptValue
\ contains=@typescriptExpression,typescriptObjectLiteral
syntax cluster typescriptEventExpression contains=typescriptArrowFuncDef,typescriptParenExp,@typescriptValue,typescriptRegexpString,@typescriptEventTypes,typescriptOperator,typescriptGlobal,jsxRegion

View File

@@ -0,0 +1,7 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
syntax match typescriptDecorator /@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>/
\ nextgroup=typescriptArgumentList,typescriptTypeArguments
\ contains=@_semantic,typescriptDotNotation

87
syntax/basic/doc.vim Normal file
View File

@@ -0,0 +1,87 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
"Syntax coloring for Node.js shebang line
syntax match shellbang "^#!.*node\>"
syntax match shellbang "^#!.*iojs\>"
"JavaScript comments
syntax keyword typescriptCommentTodo TODO FIXME XXX TBD
syntax match typescriptLineComment "//.*"
\ contains=@Spell,typescriptCommentTodo,typescriptRef
syntax region typescriptComment
\ start="/\*" end="\*/"
\ contains=@Spell,typescriptCommentTodo extend
syntax cluster typescriptComments
\ contains=typescriptDocComment,typescriptComment,typescriptLineComment
syntax match typescriptRef +///\s*<reference\s\+.*\/>$+
\ contains=typescriptString
syntax match typescriptRef +///\s*<amd-dependency\s\+.*\/>$+
\ contains=typescriptString
syntax match typescriptRef +///\s*<amd-module\s\+.*\/>$+
\ contains=typescriptString
"JSDoc
syntax case ignore
syntax region typescriptDocComment matchgroup=typescriptComment
\ start="/\*\*" end="\*/"
\ contains=typescriptDocNotation,typescriptCommentTodo,@Spell
\ fold keepend
syntax match typescriptDocNotation contained /@/ nextgroup=typescriptDocTags
syntax keyword typescriptDocTags contained constant constructor constructs function ignore inner private public readonly static
syntax keyword typescriptDocTags contained const dict expose inheritDoc interface nosideeffects override protected struct internal
syntax keyword typescriptDocTags contained example global
syntax keyword typescriptDocTags contained alpha beta defaultValue eventProperty experimental label
syntax keyword typescriptDocTags contained packageDocumentation privateRemarks remarks sealed typeParam
" syntax keyword typescriptDocTags contained ngdoc nextgroup=typescriptDocNGDirective
syntax keyword typescriptDocTags contained ngdoc scope priority animations
syntax keyword typescriptDocTags contained ngdoc restrict methodOf propertyOf eventOf eventType nextgroup=typescriptDocParam skipwhite
syntax keyword typescriptDocNGDirective contained overview service object function method property event directive filter inputType error
syntax keyword typescriptDocTags contained abstract virtual access augments
syntax keyword typescriptDocTags contained arguments callback lends memberOf name type kind link mixes mixin tutorial nextgroup=typescriptDocParam skipwhite
syntax keyword typescriptDocTags contained variation nextgroup=typescriptDocNumParam skipwhite
syntax keyword typescriptDocTags contained author class classdesc copyright default defaultvalue nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained deprecated description external host nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained file fileOverview overview namespace requires since version nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained summary todo license preserve nextgroup=typescriptDocDesc skipwhite
syntax keyword typescriptDocTags contained borrows exports nextgroup=typescriptDocA skipwhite
syntax keyword typescriptDocTags contained param arg argument property prop module nextgroup=typescriptDocNamedParamType,typescriptDocParamName skipwhite
syntax keyword typescriptDocTags contained define enum extends implements this typedef nextgroup=typescriptDocParamType skipwhite
syntax keyword typescriptDocTags contained return returns throws exception nextgroup=typescriptDocParamType,typescriptDocParamName skipwhite
syntax keyword typescriptDocTags contained see nextgroup=typescriptDocRef skipwhite
syntax keyword typescriptDocTags contained function func method nextgroup=typescriptDocName skipwhite
syntax match typescriptDocName contained /\h\w*/
syntax keyword typescriptDocTags contained fires event nextgroup=typescriptDocEventRef skipwhite
syntax match typescriptDocEventRef contained /\h\w*#\(\h\w*\:\)\?\h\w*/
syntax match typescriptDocNamedParamType contained /{.\+}/ nextgroup=typescriptDocParamName skipwhite
syntax match typescriptDocParamName contained /\[\?0-9a-zA-Z_\.]\+\]\?/ nextgroup=typescriptDocDesc skipwhite
syntax match typescriptDocParamType contained /{.\+}/ nextgroup=typescriptDocDesc skipwhite
syntax match typescriptDocA contained /\%(#\|\w\|\.\|:\|\/\)\+/ nextgroup=typescriptDocAs skipwhite
syntax match typescriptDocAs contained /\s*as\s*/ nextgroup=typescriptDocB skipwhite
syntax match typescriptDocB contained /\%(#\|\w\|\.\|:\|\/\)\+/
syntax match typescriptDocParam contained /\%(#\|\w\|\.\|:\|\/\|-\)\+/
syntax match typescriptDocNumParam contained /\d\+/
syntax match typescriptDocRef contained /\%(#\|\w\|\.\|:\|\/\)\+/
syntax region typescriptDocLinkTag contained matchgroup=typescriptDocLinkTag start=/{/ end=/}/ contains=typescriptDocTags
syntax cluster typescriptDocs contains=typescriptDocParamType,typescriptDocNamedParamType,typescriptDocParam
if main_syntax == "typescript"
syntax sync clear
syntax sync ccomment typescriptComment minlines=200
endif
syntax case match

71
syntax/basic/function.vim Normal file
View File

@@ -0,0 +1,71 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
syntax keyword typescriptAsyncFuncKeyword async
\ nextgroup=typescriptFuncKeyword,typescriptArrowFuncDef
\ skipwhite
syntax keyword typescriptAsyncFuncKeyword await
\ nextgroup=@typescriptValue
\ skipwhite
syntax keyword typescriptFuncKeyword function
\ nextgroup=typescriptAsyncFunc,typescriptFuncName,@typescriptCallSignature
\ skipwhite skipempty
syntax match typescriptAsyncFunc contained /*/
\ nextgroup=typescriptFuncName,@typescriptCallSignature
\ skipwhite skipempty
syntax match typescriptFuncName contained /\K\k*/
\ nextgroup=@typescriptCallSignature
\ skipwhite
" destructuring ({ a: ee }) =>
syntax match typescriptArrowFuncDef contained /({\_[^}]*}\(:\_[^)]\)\?)\s*=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty
" matches `(a) =>` or `([a]) =>` or
" `(
" a) =>`
syntax match typescriptArrowFuncDef contained /(\(\_s*[a-zA-Z\$_\[.]\_[^)]*\)*)\s*=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty
syntax match typescriptArrowFuncDef contained /\K\k*\s*=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty
" TODO: optimize this pattern
syntax region typescriptArrowFuncDef contained start=/(\_[^)]*):/ end=/=>/
\ contains=typescriptArrowFuncArg,typescriptArrowFunc,typescriptTypeAnnotation
\ nextgroup=@typescriptExpression,typescriptBlock
\ skipwhite skipempty keepend
syntax match typescriptArrowFunc /=>/
syntax match typescriptArrowFuncArg contained /\K\k*/
syntax region typescriptArrowFuncArg contained start=/<\|(/ end=/\ze=>/ contains=@typescriptCallSignature
syntax region typescriptReturnAnnotation contained start=/:/ end=/{/me=e-1 contains=@typescriptType nextgroup=typescriptBlock
syntax region typescriptFuncImpl contained start=/function/ end=/{/me=e-1
\ contains=typescriptFuncKeyword
\ nextgroup=typescriptBlock
syntax cluster typescriptCallImpl contains=typescriptGenericImpl,typescriptParamImpl
syntax region typescriptGenericImpl matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/ skip=/\s*,\s*/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptParamImpl
\ contained skipwhite
syntax region typescriptParamImpl matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=typescriptDecorator,@typescriptParameterList,@typescriptComments
\ nextgroup=typescriptReturnAnnotation,typescriptBlock
\ contained skipwhite skipnl

View File

@@ -0,0 +1,33 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
syntax cluster afterIdentifier contains=
\ typescriptDotNotation,
\ typescriptFuncCallArg,
\ typescriptTemplate,
\ typescriptIndexExpr,
\ @typescriptSymbols,
\ typescriptTypeArguments
syntax match typescriptIdentifierName /\<\K\k*/
\ nextgroup=@afterIdentifier
\ transparent
\ contains=@_semantic
\ skipnl skipwhite
syntax match typescriptProp contained /\K\k*!\?/
\ transparent
\ contains=@props
\ nextgroup=@afterIdentifier
\ skipwhite skipempty
syntax region typescriptIndexExpr contained matchgroup=typescriptProperty start=/\[/rs=s+1 end=/]/he=e-1 contains=@typescriptValue nextgroup=@typescriptSymbols,typescriptDotNotation,typescriptFuncCallArg skipwhite skipempty
syntax match typescriptDotNotation /\./ nextgroup=typescriptProp skipnl
syntax match typescriptDotStyleNotation /\.style\./ nextgroup=typescriptDOMStyle transparent
" syntax match typescriptFuncCall contained /[a-zA-Z]\k*\ze(/ nextgroup=typescriptFuncCallArg
syntax region typescriptParenExp matchgroup=typescriptParens start=/(/ end=/)/ contains=@typescriptComments,@typescriptValue,typescriptCastKeyword nextgroup=@typescriptSymbols skipwhite skipempty
syntax region typescriptFuncCallArg contained matchgroup=typescriptParens start=/(/ end=/)/ contains=@typescriptValue,@typescriptComments nextgroup=@typescriptSymbols,typescriptDotNotation skipwhite skipempty skipnl
syntax region typescriptEventFuncCallArg contained matchgroup=typescriptParens start=/(/ end=/)/ contains=@typescriptEventExpression
syntax region typescriptEventString contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/ contains=typescriptASCII,@events

95
syntax/basic/keyword.vim Normal file
View File

@@ -0,0 +1,95 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
"Import
syntax keyword typescriptImport from as import
syntax keyword typescriptExport export
syntax keyword typescriptModule namespace module
"this
"JavaScript Prototype
syntax keyword typescriptPrototype prototype
\ nextgroup=@afterIdentifier
syntax keyword typescriptCastKeyword as
\ nextgroup=@typescriptType
\ skipwhite
"Program Keywords
syntax keyword typescriptIdentifier arguments this super
\ nextgroup=@afterIdentifier
syntax keyword typescriptVariable let var
\ nextgroup=typescriptVariableDeclaration
\ skipwhite skipempty skipnl
syntax keyword typescriptVariable const
\ nextgroup=typescriptEnum,typescriptVariableDeclaration
\ skipwhite
syntax match typescriptVariableDeclaration /[A-Za-z_$]\k*/
\ nextgroup=typescriptTypeAnnotation,typescriptAssign
\ contained skipwhite skipempty skipnl
syntax region typescriptEnum matchgroup=typescriptEnumKeyword start=/enum / end=/\ze{/
\ nextgroup=typescriptBlock
\ skipwhite
syntax keyword typescriptKeywordOp
\ contained in instanceof nextgroup=@typescriptValue
syntax keyword typescriptOperator delete new typeof void
\ nextgroup=@typescriptValue
\ skipwhite skipempty
syntax keyword typescriptForOperator contained in of
syntax keyword typescriptBoolean true false nextgroup=@typescriptSymbols skipwhite skipempty
syntax keyword typescriptNull null undefined nextgroup=@typescriptSymbols skipwhite skipempty
syntax keyword typescriptMessage alert confirm prompt status
\ nextgroup=typescriptDotNotation,typescriptFuncCallArg
syntax keyword typescriptGlobal self top parent
\ nextgroup=@afterIdentifier
"Statement Keywords
syntax keyword typescriptConditional if else switch
\ nextgroup=typescriptConditionalParen
\ skipwhite skipempty skipnl
syntax keyword typescriptConditionalElse else
syntax keyword typescriptRepeat do while for nextgroup=typescriptLoopParen skipwhite skipempty
syntax keyword typescriptRepeat for nextgroup=typescriptLoopParen,typescriptAsyncFor skipwhite skipempty
syntax keyword typescriptBranch break continue containedin=typescriptBlock
syntax keyword typescriptCase case nextgroup=@typescriptPrimitive skipwhite containedin=typescriptBlock
syntax keyword typescriptDefault default containedin=typescriptBlock nextgroup=@typescriptValue,typescriptClassKeyword,typescriptInterfaceKeyword skipwhite oneline
syntax keyword typescriptStatementKeyword with
syntax keyword typescriptStatementKeyword yield skipwhite nextgroup=@typescriptValue containedin=typescriptBlock
syntax keyword typescriptStatementKeyword return skipwhite contained nextgroup=@typescriptValue containedin=typescriptBlock
syntax keyword typescriptTry try
syntax keyword typescriptExceptions catch throw finally
syntax keyword typescriptDebugger debugger
syntax keyword typescriptAsyncFor await nextgroup=typescriptLoopParen skipwhite skipempty contained
syntax region typescriptLoopParen contained matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=typescriptVariable,typescriptForOperator,typescriptEndColons,@typescriptValue,@typescriptComments
\ nextgroup=typescriptBlock
\ skipwhite skipempty
syntax region typescriptConditionalParen contained matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=@typescriptValue,@typescriptComments
\ nextgroup=typescriptBlock
\ skipwhite skipempty
syntax match typescriptEndColons /[;,]/ contained
syntax keyword typescriptAmbientDeclaration declare nextgroup=@typescriptAmbients
\ skipwhite skipempty
syntax cluster typescriptAmbients contains=
\ typescriptVariable,
\ typescriptFuncKeyword,
\ typescriptClassKeyword,
\ typescriptAbstract,
\ typescriptEnumKeyword,typescriptEnum,
\ typescriptModule

47
syntax/basic/literal.vim Normal file
View File

@@ -0,0 +1,47 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
"Syntax in the JavaScript code
" String
syntax match typescriptASCII contained /\\\d\d\d/
syntax region typescriptTemplateSubstitution matchgroup=typescriptTemplateSB
\ start=/\${/ end=/}/
\ contains=@typescriptValue
\ contained
syntax region typescriptString
\ start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ end=+$+
\ contains=typescriptSpecial,@Spell
\ extend
syntax match typescriptSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{4,5}})|c\u|.)"
" From vim runtime
" <https://github.com/vim/vim/blob/master/runtime/syntax/javascript.vim#L48>
syntax region typescriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gimuy]\{0,5\}\s*$+ end=+/[gimuy]\{0,5\}\s*[;.,)\]}]+me=e-1 nextgroup=typescriptDotNotation oneline
syntax region typescriptTemplate
\ start=/`/ skip=/\\\\\|\\`\|\n/ end=/`\|$/
\ contains=typescriptTemplateSubstitution
\ nextgroup=@typescriptSymbols
\ skipwhite skipempty
"Array
syntax region typescriptArray matchgroup=typescriptBraces
\ start=/\[/ end=/]/
\ contains=@typescriptValue,@typescriptComments
\ nextgroup=@typescriptSymbols,typescriptDotNotation
\ skipwhite skipempty fold
" Number
syntax match typescriptNumber /\<0[bB][01][01_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty
syntax match typescriptNumber /\<0[oO][0-7][0-7_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty
syntax match typescriptNumber /\<0[xX][0-9a-fA-F][0-9a-fA-F_]*\>/ nextgroup=@typescriptSymbols skipwhite skipempty
syntax match typescriptNumber /\d[0-9_]*\.\d[0-9_]*\|\d[0-9_]*\|\.\d[0-9]*/
\ nextgroup=typescriptExponent,@typescriptSymbols skipwhite skipempty
syntax match typescriptExponent /[eE][+-]\=\d[0-9]*\>/
\ nextgroup=@typescriptSymbols skipwhite skipempty contained

50
syntax/basic/members.vim Normal file
View File

@@ -0,0 +1,50 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
syntax keyword typescriptConstructor contained constructor
\ nextgroup=@typescriptCallSignature
\ skipwhite skipempty
syntax cluster memberNextGroup contains=typescriptMemberOptionality,typescriptTypeAnnotation,@typescriptCallSignature
syntax match typescriptMember /\K\k*/
\ nextgroup=@memberNextGroup
\ contained skipwhite
syntax match typescriptMethodAccessor contained /\v(get|set)\s\K/me=e-1
\ nextgroup=@typescriptMembers
syntax cluster typescriptPropertyMemberDeclaration contains=
\ typescriptClassStatic,
\ typescriptAccessibilityModifier,
\ typescriptReadonlyModifier,
\ typescriptMethodAccessor,
\ @typescriptMembers
" \ typescriptMemberVariableDeclaration
syntax match typescriptMemberOptionality /?\|!/ contained
\ nextgroup=typescriptTypeAnnotation,@typescriptCallSignature
\ skipwhite skipempty
syntax cluster typescriptMembers contains=typescriptMember,typescriptStringMember,typescriptComputedMember
syntax keyword typescriptClassStatic static
\ nextgroup=@typescriptMembers,typescriptAsyncFuncKeyword,typescriptReadonlyModifier
\ skipwhite contained
syntax keyword typescriptAccessibilityModifier public private protected contained
syntax keyword typescriptReadonlyModifier readonly contained
syntax region typescriptStringMember contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1/
\ nextgroup=@memberNextGroup
\ skipwhite skipempty
syntax region typescriptComputedMember contained matchgroup=typescriptProperty
\ start=/\[/rs=s+1 end=/]/
\ contains=@typescriptValue,typescriptMember,typescriptMappedIn
\ nextgroup=@memberNextGroup
\ skipwhite skipempty

32
syntax/basic/object.vim Normal file
View File

@@ -0,0 +1,32 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
syntax region typescriptObjectLiteral matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contains=@typescriptComments,typescriptObjectLabel,typescriptStringProperty,typescriptComputedPropertyName
\ fold contained
syntax match typescriptObjectLabel contained /\k\+\_s*/
\ nextgroup=typescriptObjectColon,@typescriptCallImpl
\ skipwhite skipempty
syntax region typescriptStringProperty contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1/
\ nextgroup=typescriptObjectColon,@typescriptCallImpl
\ skipwhite skipempty
" syntax region typescriptPropertyName contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1(/me=e-1 nextgroup=@typescriptCallSignature skipwhite skipempty oneline
syntax region typescriptComputedPropertyName contained matchgroup=typescriptBraces
\ start=/\[/rs=s+1 end=/]/
\ contains=@typescriptValue
\ nextgroup=typescriptObjectColon,@typescriptCallImpl
\ skipwhite skipempty
" syntax region typescriptComputedPropertyName contained matchgroup=typescriptPropertyName start=/\[/rs=s+1 end=/]\_s*:/he=e-1 contains=@typescriptValue nextgroup=@typescriptValue skipwhite skipempty
" syntax region typescriptComputedPropertyName contained matchgroup=typescriptPropertyName start=/\[/rs=s+1 end=/]\_s*(/me=e-1 contains=@typescriptValue nextgroup=@typescriptCallSignature skipwhite skipempty
" Value for object, statement for label statement
syntax match typescriptRestOrSpread /\.\.\./ contained
syntax match typescriptObjectSpread /\.\.\./ contained containedin=typescriptObjectLiteral,typescriptArray nextgroup=@typescriptValue
syntax match typescriptObjectColon contained /:/ nextgroup=@typescriptValue skipwhite skipempty

9
syntax/basic/patch.vim Normal file
View File

@@ -0,0 +1,9 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
" patch for generated code
syntax keyword typescriptGlobal Promise
\ nextgroup=typescriptGlobalPromiseDot,typescriptFuncCallArg,typescriptTypeArguments oneline
syntax keyword typescriptGlobal Map WeakMap
\ nextgroup=typescriptGlobalPromiseDot,typescriptFuncCallArg,typescriptTypeArguments oneline

35
syntax/basic/reserved.vim Normal file
View File

@@ -0,0 +1,35 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
syntax cluster typescriptStrings contains=typescriptProp,typescriptString,typescriptTemplate,@typescriptComments,typescriptDocComment,typescriptRegexpString,typescriptPropertyName
syntax cluster typescriptNoReserved contains=
\ @typescriptStrings,
\ @typescriptDocs,
\ @typescriptComments,
\ shellbang,
\ typescriptObjectLiteral,
\ typescriptObjectLabel,
\ typescriptClassBlock,
\ @typescriptType,
\ typescriptCall
"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved break case catch const continue
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved debugger delete do else export
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved extends finally for if
"import,typescriptRegexpString,typescriptPropertyName
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved in instanceof let new return super
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved static switch throw try typeof
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved void while with yield
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved implements package protected
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved interface private public readonly abstract
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved byte char double final float goto int
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved long native short synchronized transient
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved volatile
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved class
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved var
syntax keyword typescriptReserved containedin=ALLBUT,@typescriptNoReserved function

42
syntax/basic/symbols.vim Normal file
View File

@@ -0,0 +1,42 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
" + - ^ ~
syntax match typescriptUnaryOp /[+\-~!]/
\ nextgroup=@typescriptValue
\ skipwhite
syntax region typescriptTernary matchgroup=typescriptTernaryOp start=/?/ end=/:/ contained contains=@typescriptValue,@typescriptComments nextgroup=@typescriptValue skipwhite skipempty
syntax match typescriptAssign /=/ nextgroup=@typescriptValue
\ skipwhite skipempty
" 2: ==, ===
syntax match typescriptBinaryOp contained /===\?/ nextgroup=@typescriptValue skipwhite skipempty
" 6: >>>=, >>>, >>=, >>, >=, >
syntax match typescriptBinaryOp contained />\(>>=\|>>\|>=\|>\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 4: <<=, <<, <=, <
syntax match typescriptBinaryOp contained /<\(<=\|<\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: ||, |=, |
syntax match typescriptBinaryOp contained /|\(|\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: &&, &=, &
syntax match typescriptBinaryOp contained /&\(&\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: *=, *
syntax match typescriptBinaryOp contained /\*=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: %=, %
syntax match typescriptBinaryOp contained /%=\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: /=, /
syntax match typescriptBinaryOp contained +/\(=\|[^\*/]\@=\)+ nextgroup=@typescriptValue skipwhite skipempty
syntax match typescriptBinaryOp contained /!==\?/ nextgroup=@typescriptValue skipwhite skipempty
" 2: !=, !==
syntax match typescriptBinaryOp contained /+\(+\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: +, ++, +=
syntax match typescriptBinaryOp contained /-\(-\|=\)\?/ nextgroup=@typescriptValue skipwhite skipempty
" 3: -, --, -=
" exponentiation operator
" 2: **, **=
syntax match typescriptBinaryOp contained /\*\*=\?/ nextgroup=@typescriptValue
syntax cluster typescriptSymbols contains=typescriptBinaryOp,typescriptKeywordOp,typescriptTernary,typescriptAssign,typescriptCastKeyword

191
syntax/basic/type.vim Normal file
View File

@@ -0,0 +1,191 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
" Types
syntax match typescriptOptionalMark /?/ contained
syntax region typescriptTypeParameters matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ contained
syntax match typescriptTypeParameter /\K\k*/
\ nextgroup=typescriptConstraint,typescriptGenericDefault
\ contained skipwhite skipnl
syntax keyword typescriptConstraint extends
\ nextgroup=@typescriptType
\ contained skipwhite skipnl
syntax match typescriptGenericDefault /=/
\ nextgroup=@typescriptType
\ contained skipwhite
"><
" class A extend B<T> {} // ClassBlock
" func<T>() // FuncCallArg
syntax region typescriptTypeArguments matchgroup=typescriptTypeBrackets
\ start=/\></ end=/>/
\ contains=@typescriptType
\ nextgroup=typescriptFuncCallArg,@typescriptTypeOperator
\ contained skipwhite
syntax cluster typescriptType contains=
\ @typescriptPrimaryType,
\ typescriptUnion,
\ @typescriptFunctionType,
\ typescriptConstructorType
" array type: A[]
" type indexing A['key']
syntax region typescriptTypeBracket contained
\ start=/\[/ end=/\]/
\ contains=typescriptString,typescriptNumber
\ nextgroup=@typescriptTypeOperator
\ skipwhite skipempty
syntax cluster typescriptPrimaryType contains=
\ typescriptParenthesizedType,
\ typescriptPredefinedType,
\ typescriptTypeReference,
\ typescriptObjectType,
\ typescriptTupleType,
\ typescriptTypeQuery,
\ typescriptStringLiteralType,
\ typescriptReadonlyArrayKeyword
syntax region typescriptStringLiteralType contained
\ start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/
\ nextgroup=typescriptUnion
\ skipwhite skipempty
syntax region typescriptParenthesizedType matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=@typescriptType
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipempty fold
syntax match typescriptTypeReference /\K\k*\(\.\K\k*\)*/
\ nextgroup=typescriptTypeArguments,@typescriptTypeOperator,typescriptUserDefinedType
\ skipwhite contained skipempty
syntax keyword typescriptPredefinedType any number boolean string void never undefined null object unknown
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipempty
syntax match typescriptPredefinedType /unique symbol/
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite skipempty
syntax region typescriptObjectType matchgroup=typescriptBraces
\ start=/{/ end=/}/
\ contains=@typescriptTypeMember,typescriptEndColons,@typescriptComments,typescriptAccessibilityModifier,typescriptReadonlyModifier
\ nextgroup=@typescriptTypeOperator
\ contained skipwhite fold
syntax cluster typescriptTypeMember contains=
\ @typescriptCallSignature,
\ typescriptConstructSignature,
\ typescriptIndexSignature,
\ @typescriptMembers
syntax region typescriptTupleType matchgroup=typescriptBraces
\ start=/\[/ end=/\]/
\ contains=@typescriptType
\ contained skipwhite oneline
syntax cluster typescriptTypeOperator
\ contains=typescriptUnion,typescriptTypeBracket
syntax match typescriptUnion /|\|&/ contained nextgroup=@typescriptPrimaryType skipwhite skipempty
syntax cluster typescriptFunctionType contains=typescriptGenericFunc,typescriptFuncType
syntax region typescriptGenericFunc matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptFuncType
\ containedin=typescriptFunctionType
\ contained skipwhite skipnl
syntax region typescriptFuncType matchgroup=typescriptParens
\ start=/(/ end=/)\s*=>/me=e-2
\ contains=@typescriptParameterList
\ nextgroup=typescriptFuncTypeArrow
\ contained skipwhite skipnl oneline
syntax match typescriptFuncTypeArrow /=>/
\ nextgroup=@typescriptType
\ containedin=typescriptFuncType
\ contained skipwhite skipnl
syntax keyword typescriptConstructorType new
\ nextgroup=@typescriptFunctionType
\ contained skipwhite skipnl
syntax keyword typescriptUserDefinedType is
\ contained nextgroup=@typescriptType skipwhite skipempty
syntax keyword typescriptTypeQuery typeof keyof
\ nextgroup=typescriptTypeReference
\ contained skipwhite skipnl
syntax cluster typescriptCallSignature contains=typescriptGenericCall,typescriptCall
syntax region typescriptGenericCall matchgroup=typescriptTypeBrackets
\ start=/</ end=/>/
\ contains=typescriptTypeParameter
\ nextgroup=typescriptCall
\ contained skipwhite skipnl
syntax region typescriptCall matchgroup=typescriptParens
\ start=/(/ end=/)/
\ contains=typescriptDecorator,@typescriptParameterList,@typescriptComments
\ nextgroup=typescriptTypeAnnotation,typescriptBlock
\ contained skipwhite skipnl
syntax match typescriptTypeAnnotation /:/
\ nextgroup=@typescriptType
\ contained skipwhite skipnl
syntax cluster typescriptParameterList contains=
\ typescriptTypeAnnotation,
\ typescriptAccessibilityModifier,
\ typescriptOptionalMark,
\ typescriptRestOrSpread,
\ typescriptFuncComma,
\ typescriptDefaultParam
syntax match typescriptFuncComma /,/ contained
syntax match typescriptDefaultParam /=/
\ nextgroup=@typescriptValue
\ contained skipwhite
syntax keyword typescriptConstructSignature new
\ nextgroup=@typescriptCallSignature
\ contained skipwhite
syntax region typescriptIndexSignature matchgroup=typescriptBraces
\ start=/\[/ end=/\]/
\ contains=typescriptPredefinedType,typescriptMappedIn,typescriptString
\ nextgroup=typescriptTypeAnnotation
\ contained skipwhite oneline
syntax keyword typescriptMappedIn in
\ nextgroup=@typescriptType
\ contained skipwhite skipnl skipempty
syntax keyword typescriptAliasKeyword type
\ nextgroup=typescriptAliasDeclaration
\ skipwhite skipnl skipempty
syntax region typescriptAliasDeclaration matchgroup=typescriptUnion
\ start=/ / end=/=/
\ nextgroup=@typescriptType
\ contains=typescriptConstraint,typescriptTypeParameters
\ contained skipwhite skipempty
syntax keyword typescriptReadonlyArrayKeyword readonly
\ nextgroup=@typescriptPrimaryType
\ skipwhite

165
syntax/common.vim Normal file
View File

@@ -0,0 +1,165 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'typescript') != -1
finish
endif
" Define the default highlighting.
" For version 5.8 and later: only when an item doesn't have highlighting yet
let did_typescript_hilink = 1
syntax sync fromstart
command -nargs=+ HiLink hi def link <args>
"Dollar sign is permitted anywhere in an identifier
setlocal iskeyword-=$
if main_syntax == 'typescript' || main_syntax == 'typescript.tsx'
setlocal iskeyword+=$
" syntax cluster htmlJavaScript contains=TOP
endif
" lowest priority on least used feature
syntax match typescriptLabel /[a-zA-Z_$]\k*:/he=e-1 contains=typescriptReserved nextgroup=@typescriptStatement skipwhite skipempty
" other keywords like return,case,yield uses containedin
syntax region typescriptBlock matchgroup=typescriptBraces start=/{/ end=/}/ contains=@typescriptStatement,@typescriptComments fold
runtime syntax/basic/identifiers.vim
runtime syntax/basic/literal.vim
runtime syntax/basic/object.vim
runtime syntax/basic/symbols.vim
" runtime syntax/basic/reserved.vim
runtime syntax/basic/keyword.vim
runtime syntax/basic/doc.vim
runtime syntax/basic/type.vim
" extension
if get(g:, 'yats_host_keyword', 1)
runtime syntax/yats.vim
endif
" patch
runtime syntax/basic/patch.vim
runtime syntax/basic/members.vim
runtime syntax/basic/class.vim
runtime syntax/basic/cluster.vim
runtime syntax/basic/function.vim
runtime syntax/basic/decorator.vim
if exists("did_typescript_hilink")
HiLink typescriptReserved Error
HiLink typescriptEndColons Exception
HiLink typescriptSymbols Normal
HiLink typescriptBraces Function
HiLink typescriptParens Normal
HiLink typescriptComment Comment
HiLink typescriptLineComment Comment
HiLink typescriptDocComment Comment
HiLink typescriptCommentTodo Todo
HiLink typescriptRef Include
HiLink typescriptDocNotation SpecialComment
HiLink typescriptDocTags SpecialComment
HiLink typescriptDocNGParam typescriptDocParam
HiLink typescriptDocParam Function
HiLink typescriptDocNumParam Function
HiLink typescriptDocEventRef Function
HiLink typescriptDocNamedParamType Type
HiLink typescriptDocParamName Type
HiLink typescriptDocParamType Type
HiLink typescriptString String
HiLink typescriptSpecial Special
HiLink typescriptStringLiteralType String
HiLink typescriptStringMember String
HiLink typescriptTemplate String
HiLink typescriptEventString String
HiLink typescriptASCII Special
HiLink typescriptTemplateSB Label
HiLink typescriptRegexpString String
HiLink typescriptGlobal Constant
HiLink typescriptTestGlobal Function
HiLink typescriptPrototype Type
HiLink typescriptConditional Conditional
HiLink typescriptConditionalElse Conditional
HiLink typescriptCase Conditional
HiLink typescriptDefault typescriptCase
HiLink typescriptBranch Conditional
HiLink typescriptIdentifier Structure
HiLink typescriptVariable Identifier
HiLink typescriptEnumKeyword Identifier
HiLink typescriptRepeat Repeat
HiLink typescriptForOperator Repeat
HiLink typescriptStatementKeyword Statement
HiLink typescriptMessage Keyword
HiLink typescriptOperator Identifier
HiLink typescriptKeywordOp Identifier
HiLink typescriptCastKeyword Special
HiLink typescriptType Type
HiLink typescriptNull Boolean
HiLink typescriptNumber Number
HiLink typescriptExponent Number
HiLink typescriptBoolean Boolean
HiLink typescriptObjectLabel typescriptLabel
HiLink typescriptLabel Label
HiLink typescriptStringProperty String
HiLink typescriptImport Special
HiLink typescriptAmbientDeclaration Special
HiLink typescriptExport Special
HiLink typescriptModule Special
HiLink typescriptTry Special
HiLink typescriptExceptions Special
HiLink typescriptMember Function
HiLink typescriptMethodAccessor Operator
HiLink typescriptAsyncFuncKeyword Keyword
HiLink typescriptAsyncFor Keyword
HiLink typescriptFuncKeyword Keyword
HiLink typescriptAsyncFunc Keyword
HiLink typescriptArrowFunc Type
HiLink typescriptFuncName Function
HiLink typescriptFuncArg PreProc
HiLink typescriptArrowFuncArg PreProc
HiLink typescriptFuncComma Operator
HiLink typescriptClassKeyword Keyword
HiLink typescriptClassExtends Keyword
" HiLink typescriptClassName Function
HiLink typescriptAbstract Special
" HiLink typescriptClassHeritage Function
" HiLink typescriptInterfaceHeritage Function
HiLink typescriptClassStatic StorageClass
HiLink typescriptReadonlyModifier Keyword
HiLink typescriptInterfaceKeyword Keyword
HiLink typescriptInterfaceExtends Keyword
HiLink typescriptInterfaceName Function
HiLink shellbang Comment
HiLink typescriptTypeParameter Identifier
HiLink typescriptConstraint Keyword
HiLink typescriptPredefinedType Type
HiLink typescriptReadonlyArrayKeyword Keyword
HiLink typescriptUnion Operator
HiLink typescriptFuncTypeArrow Function
HiLink typescriptConstructorType Function
HiLink typescriptTypeQuery Keyword
HiLink typescriptAccessibilityModifier Keyword
HiLink typescriptOptionalMark PreProc
HiLink typescriptFuncType Special
HiLink typescriptMappedIn Special
HiLink typescriptCall PreProc
HiLink typescriptParamImpl PreProc
HiLink typescriptConstructSignature Identifier
HiLink typescriptAliasDeclaration Identifier
HiLink typescriptAliasKeyword Keyword
HiLink typescriptUserDefinedType Keyword
HiLink typescriptTypeReference Identifier
HiLink typescriptConstructor Keyword
HiLink typescriptDecorator Special
highlight link typeScript NONE
delcommand HiLink
unlet did_typescript_hilink
endif

66
syntax/dhall.vim Normal file
View File

@@ -0,0 +1,66 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'dhall') != -1
finish
endif
scriptencoding utf-8
if exists('b:current_syntax')
finish
endif
syntax match dhallInterpolation "\v\$\{[^\}]*\}"
syntax keyword dhallTodo TODO FIXME
syntax match dhallBrackets "[<>|]"
syntax match dhallOperator "+\|*\|#"
syntax match dhallOperator "//\|⫽"
syntax match dhallOperator "/\\\|∧"
syntax match dhallOperator "//\\\\\|⩓"
syntax match dhallNumber "\v[0-9]"
syntax match dhallNumber "\v\+[0-9]"
syntax match dhallIndex "\v\@[0-9]+" contains=dhallNumber
syntax match dhallLambda "∀\|λ\|→\|->\|\\"
syntax match dhallType "\v[A-Z][a-z0-9A-Z_]*"
syntax match dhallSpecialLabel "\v`[A-Z][a-z]*`"
syntax match dhallLabel "\v[A-Z][a-z]*/[a-z_][A-Za-z0-9\.\-]*"
syntax match dhallLabel "\v[a-z_][A-Za-z0-9\-]*"
syntax match dhallType "\v[a-zA-Z]+\.[A-Z][a-z0-9A-Z_]*"
syntax match dhallParens "(\|)\|\[\|\]\|,"
syntax match dhallRecord "{\|}\|:"
syntax keyword dhallKeyword let in forall constructors if then else merge env as
syntax match dhallEsc +\\["\\abfnrtv$/]+
syntax match dhallSingleSpecial +'''+
syntax match dhallSingleSpecial +''${+
syntax match dhallComment '\v--.*$' contains=@Spell,dhallTodo
syntax region dhallMultilineComment start="{-" end="-}" contains=@Spell,dhallTodo,dhallMultilineComment
syntax match dhallUrl "https://[a-zA-Z0-9/.\-_\?\=\&]*"
syntax match dhallUrl "http://[a-zA-Z0-9/.\-_\?\=\&]*"
syntax match dhallUrl "/[a-zA-Z0-9/.\-_]*"
syntax match dhallUrl "\.\./[a-zA-Z0-9/.\-_]*"
syntax match dhallUrl "\./[a-zA-Z0-9/.\-_]*"
syntax region dhallString start=+''+ end=+''+ contains=@Spell,dhallInterpolation,dhallSingleSpecial
syntax region dhallString start=+"+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax region dhallString start=+"/+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax keyword dhallBool True False
highlight link dhallSingleSpecial Special
highlight link dhallIndex Special
highlight link dhallSpecialLabel Operator
highlight link dhallEsc Special
highlight link dhallInterpolation Special
highlight link dhallTodo Todo
highlight link dhallBrackets Operator
highlight link dhallBool Underlined
highlight link dhallUrl String
highlight link dhallOperator Operator
highlight link dhallNumber Number
highlight link dhallLambda Special
highlight link dhallString String
highlight link dhallLabel Identifier
highlight link dhallRecord Special
highlight link dhallKeyword Keyword
highlight link dhallType Structure
highlight link dhallParens Special
highlight link dhallComment Comment
highlight link dhallMultilineComment Comment
let b:current_syntax = 'dhall'

View File

@@ -6,10 +6,10 @@ endif
" Language: Dockerfile " Language: Dockerfile
" Maintainer: Eugene Kalinin " Maintainer: Eugene Kalinin
" Latest Revision: 11 September 2013 " Latest Revision: 11 September 2013
" Source: http://docs.docker.io/en/latest/use/builder/ " Source: https://docs.docker.com/compose/
if exists("b:current_syntax") if !exists('main_syntax')
finish let main_syntax = 'yaml'
endif endif
" case sensitivity (fix #17) " case sensitivity (fix #17)
@@ -20,7 +20,7 @@ syn keyword dockercomposeKeywords build context dockerfile args cap_add cap_drop
syn keyword dockercomposeKeywords command cgroup_parent container_name devices depends_on syn keyword dockercomposeKeywords command cgroup_parent container_name devices depends_on
syn keyword dockercomposeKeywords dns dns_search tmpfs entrypoint env_file environment syn keyword dockercomposeKeywords dns dns_search tmpfs entrypoint env_file environment
syn keyword dockercomposeKeywords expose extends extends external_links extra_hosts syn keyword dockercomposeKeywords expose extends extends external_links extra_hosts
syn keyword dockercomposeKeywords group_add image isolation labels links syn keyword dockercomposeKeywords group_add image isolation labels links
syn keyword dockercomposeKeywords log_opt net network_mode networks aliases syn keyword dockercomposeKeywords log_opt net network_mode networks aliases
syn keyword dockercomposeKeywords ipv4_address ipv6_address link_local_ips pid ports syn keyword dockercomposeKeywords ipv4_address ipv6_address link_local_ips pid ports
syn keyword dockercomposeKeywords security_opt stop_signal ulimits volumes volume_driver syn keyword dockercomposeKeywords security_opt stop_signal ulimits volumes volume_driver
@@ -82,8 +82,3 @@ hi link dockercomposeTodo Todo
hi link bashStatement Function hi link bashStatement Function
let b:current_syntax = "dockercompose" let b:current_syntax = "dockercompose"
set commentstring=#\ %s
" Enable automatic comment insertion
setlocal fo+=cro

View File

@@ -2,16 +2,16 @@ if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'elixir') != -1
finish finish
endif endif
if exists("b:current_syntax") if !exists("main_syntax")
finish if exists("b:current_syntax")
finish
endif
let main_syntax = "elixir"
endif endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
" syncing starts 2000 lines before top line so docstrings don't screw things up
syn sync minlines=2000
syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments,elixirBlockDefinition,elixirUnusedVariable,elixirStructDelimiter syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments,elixirBlockDefinition,elixirUnusedVariable,elixirStructDelimiter
syn cluster elixirRegexSpecial contains=elixirRegexEscape,elixirRegexCharClass,elixirRegexQuantifier,elixirRegexEscapePunctuation syn cluster elixirRegexSpecial contains=elixirRegexEscape,elixirRegexCharClass,elixirRegexQuantifier,elixirRegexEscapePunctuation
syn cluster elixirStringContained contains=elixirInterpolation,elixirRegexEscape,elixirRegexCharClass syn cluster elixirStringContained contains=elixirInterpolation,elixirRegexEscape,elixirRegexCharClass
@@ -112,12 +112,14 @@ syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z('''\)+ end=
" LiveView Sigils surrounded with ~L""" " LiveView Sigils surrounded with ~L"""
syntax include @HTML syntax/html.vim syntax include @HTML syntax/html.vim
unlet b:current_syntax
syntax region elixirLiveViewSigil matchgroup=elixirSigilDelimiter keepend start=+\~L\z("""\)+ end=+^\s*\z1+ skip=+\\"+ contains=@HTML fold syntax region elixirLiveViewSigil matchgroup=elixirSigilDelimiter keepend start=+\~L\z("""\)+ end=+^\s*\z1+ skip=+\\"+ contains=@HTML fold
" Documentation " Documentation
if exists('g:elixir_use_markdown_for_docs') && g:elixir_use_markdown_for_docs if exists('g:elixir_use_markdown_for_docs') && g:elixir_use_markdown_for_docs
syn include @markdown syntax/markdown.vim syn include @markdown syntax/markdown.vim
unlet b:current_syntax
syn cluster elixirDocStringContained contains=@markdown,@Spell,elixirInterpolation syn cluster elixirDocStringContained contains=@markdown,@Spell,elixirInterpolation
else else
let g:elixir_use_markdown_for_docs = 0 let g:elixir_use_markdown_for_docs = 0
@@ -127,15 +129,15 @@ else
syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained
endif endif
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]{" end="}" skip="\\\\\|\\}" contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]{" end="}" skip="\\\\\|\\}" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]<" end=">" skip="\\\\\|\\>" contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]<" end=">" skip="\\\\\|\\>" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss]\[" end="\]" skip="\\\\\|\\\]" contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\[" end="\]" skip="\\\\\|\\\]" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\s\+\)\@<=\~[Ss](" end=")" skip="\\\\\|\\)" contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start="\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss](" end=")" skip="\\\\\|\\)" contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirDocStringContained keepend syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirDocStringContained keepend
syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\s\+\)\@<=\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocStringDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z('''\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\z('''\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\s\+\)\@<=\~[Ss]\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend syn region elixirDocString matchgroup=elixirDocSigilDelimiter start=+\%(@\w*doc\(\s\|(\)\+\)\@<=\~[Ss]\z("""\)+ end=+^\s*\z1+ contains=@elixirDocStringContained fold keepend
" Defines " Defines
syn match elixirDefine '\<def\>\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl syn match elixirDefine '\<def\>\(:\)\@!' nextgroup=elixirFunctionDeclaration skipwhite skipnl
@@ -172,9 +174,12 @@ syn match elixirExceptionDeclaration "[^[:space:];#<]\+" contained
syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl
" ExUnit " ExUnit
syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|on_exit\|doctest\)\>" syn match elixirExUnitMacro "\C\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|on_exit\|doctest\)\>"
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(assert\|assert_in_delta\|assert_raise\|assert_receive\|assert_received\|catch_error\)\>" syn match elixirExUnitAssert "\C\(^\s*\)\@<=\<\(assert\|assert_in_delta\|assert_raise\|assert_receive\|assert_received\|catch_error\)\>"
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(catch_exit\|catch_throw\|flunk\|refute\|refute_in_delta\|refute_receive\|refute_received\)\>" syn match elixirExUnitAssert "\C\(^\s*\)\@<=\<\(catch_exit\|catch_throw\|flunk\|refute\|refute_in_delta\|refute_receive\|refute_received\)\>"
" syncing starts 2000 lines before top line so docstrings don't screw things up
syn sync minlines=2000
hi def link elixirBlockDefinition Define hi def link elixirBlockDefinition Define
hi def link elixirDefine Define hi def link elixirDefine Define
@@ -234,5 +239,9 @@ hi def link elixirPrivateRecordDeclaration elixirRecordDeclaration
let b:current_syntax = "elixir" let b:current_syntax = "elixir"
if main_syntax == "elixir"
unlet main_syntax
endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save

View File

@@ -6,7 +6,7 @@ endif
" Language: Erlang (http://www.erlang.org) " Language: Erlang (http://www.erlang.org)
" Maintainer: Csaba Hoch <csaba.hoch@gmail.com> " Maintainer: Csaba Hoch <csaba.hoch@gmail.com>
" Contributor: Adam Rutkowski <hq@mtod.org> " Contributor: Adam Rutkowski <hq@mtod.org>
" Last Update: 2017-Mar-05 " Last Update: 2019-Jun-18
" License: Vim license " License: Vim license
" URL: https://github.com/vim-erlang/vim-erlang-runtime " URL: https://github.com/vim-erlang/vim-erlang-runtime
@@ -121,7 +121,7 @@ syn keyword erlangBIF garbage_collect get get_keys group_leader contained
syn keyword erlangBIF halt hd integer_to_binary integer_to_list contained syn keyword erlangBIF halt hd integer_to_binary integer_to_list contained
syn keyword erlangBIF iolist_to_binary iolist_size is_alive contained syn keyword erlangBIF iolist_to_binary iolist_size is_alive contained
syn keyword erlangBIF is_atom is_binary is_bitstring is_boolean contained syn keyword erlangBIF is_atom is_binary is_bitstring is_boolean contained
syn keyword erlangBIF is_float is_function is_integer is_list is_map contained syn keyword erlangBIF is_float is_function is_integer is_list is_map is_map_key contained
syn keyword erlangBIF is_number is_pid is_port is_process_alive contained syn keyword erlangBIF is_number is_pid is_port is_process_alive contained
syn keyword erlangBIF is_record is_reference is_tuple length link contained syn keyword erlangBIF is_record is_reference is_tuple length link contained
syn keyword erlangBIF list_to_atom list_to_binary contained syn keyword erlangBIF list_to_atom list_to_binary contained

View File

@@ -22,7 +22,7 @@ endif
syn include @gitcommitDiff syntax/diff.vim syn include @gitcommitDiff syntax/diff.vim
syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff
syn match gitcommitSummary ".*\%<50v" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell syn match gitcommitSummary "^.*\%<51v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell
syn match gitcommitOverflow ".*" contained contains=@Spell syn match gitcommitOverflow ".*" contained contains=@Spell
syn match gitcommitBlank "^[^#].*" contained contains=@Spell syn match gitcommitBlank "^[^#].*" contained contains=@Spell

View File

@@ -34,7 +34,7 @@ hi def link gitconfigBoolean Boolean
hi def link gitconfigNumber Number hi def link gitconfigNumber Number
hi def link gitconfigString String hi def link gitconfigString String
hi def link gitconfigDelim Delimiter hi def link gitconfigDelim Delimiter
hi def link gitconfigEscape Delimiter hi def link gitconfigEscape Special
hi def link gitconfigError Error hi def link gitconfigError Error
let b:current_syntax = "gitconfig" let b:current_syntax = "gitconfig"

View File

@@ -121,7 +121,7 @@ if go#config#HighlightFormatStrings()
\@<=%[-#0 +]*\ \@<=%[-#0 +]*\
\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\ \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\
\%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\ \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\
\%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGsp]/ contained containedin=goString,goRawString \%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGspw]/ contained containedin=goString,goRawString
hi def link goFormatSpecifier goSpecialString hi def link goFormatSpecifier goSpecialString
endif endif

68
syntax/graphql.vim Normal file
View File

@@ -0,0 +1,68 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'graphql') != -1
finish
endif
" Vim syntax file
" Language: GraphQL
" Maintainer: Jon Parise <jon@indelible.org>
if exists('b:current_syntax')
finish
endif
syn match graphqlComment "#.*$" contains=@Spell
syn match graphqlOperator "=" display
syn match graphqlOperator "!" display
syn match graphqlOperator "|" display
syn match graphqlOperator "\M..." display
syn keyword graphqlBoolean true false
syn keyword graphqlNull null
syn match graphqlNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>" display
syn region graphqlString start=+"+ skip=+\\\\\|\\"+ end=+"\|$+
syn region graphqlString start=+"""+ end=+"""+
syn keyword graphqlKeyword on nextgroup=graphqlType skipwhite
syn keyword graphqlStructure enum scalar type union nextgroup=graphqlType skipwhite
syn keyword graphqlStructure input interface subscription nextgroup=graphqlType skipwhite
syn keyword graphqlStructure implements nextgroup=graphqlType skipwhite
syn keyword graphqlStructure query mutation fragment nextgroup=graphqlName skipwhite
syn keyword graphqlStructure directive nextgroup=graphqlDirective skipwhite
syn keyword graphqlStructure extend nextgroup=graphqlStructure skipwhite
syn keyword graphqlStructure schema nextgroup=graphqlFold skipwhite
syn match graphqlDirective "\<@\h\w*\>" display
syn match graphqlVariable "\<\$\h\w*\>" display
syn match graphqlName "\<\h\w*\>" display
syn match graphqlType "\<_*\u\w*\>" display
syn match graphqlConstant "\<[A-Z_]\+\>" display
syn keyword graphqlMetaFields __schema __type __typename
syn region graphqlFold matchgroup=graphqlBraces start="{" end="}" transparent fold contains=ALLBUT,graphqlStructure
syn region graphqlList matchgroup=graphqlBraces start="\[" end="]" transparent contains=ALLBUT,graphqlDirective,graphqlStructure
hi def link graphqlComment Comment
hi def link graphqlOperator Operator
hi def link graphqlBraces Delimiter
hi def link graphqlBoolean Boolean
hi def link graphqlNull Keyword
hi def link graphqlNumber Number
hi def link graphqlString String
hi def link graphqlConstant Constant
hi def link graphqlDirective PreProc
hi def link graphqlName Identifier
hi def link graphqlMetaFields Special
hi def link graphqlKeyword Keyword
hi def link graphqlStructure Structure
hi def link graphqlType Type
hi def link graphqlVariable Identifier
syn sync minlines=500
let b:current_syntax = 'graphql'

95
syntax/helm.vim Normal file
View File

@@ -0,0 +1,95 @@
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'helm') != -1
finish
endif
if exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = 'yaml'
endif
let b:current_syntax = ''
unlet b:current_syntax
runtime! syntax/yaml.vim
let b:current_syntax = ''
unlet b:current_syntax
syntax include @Yaml syntax/yaml.vim
syn case match
" Go escapes
syn match goEscapeOctal display contained "\\[0-7]\{3}"
syn match goEscapeC display contained +\\[abfnrtv\\'"]+
syn match goEscapeX display contained "\\x\x\{2}"
syn match goEscapeU display contained "\\u\x\{4}"
syn match goEscapeBigU display contained "\\U\x\{8}"
syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
hi def link goEscapeOctal goSpecialString
hi def link goEscapeC goSpecialString
hi def link goEscapeX goSpecialString
hi def link goEscapeU goSpecialString
hi def link goEscapeBigU goSpecialString
hi def link goSpecialString Special
hi def link goEscapeError Error
" Strings and their contents
syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError
syn region goString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
syn region goRawString contained start=+`+ end=+`+
hi def link goString String
hi def link goRawString String
" Characters; their contents
syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU
syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup
hi def link goCharacter Character
" Integers
syn match goDecimalInt contained "\<\d\+\([Ee]\d\+\)\?\>"
syn match goHexadecimalInt contained "\<0x\x\+\>"
syn match goOctalInt contained "\<0\o\+\>"
syn match goOctalError contained "\<0\o*[89]\d*\>"
syn cluster goInt contains=goDecimalInt,goHexadecimalInt,goOctalInt
" Floating point
syn match goFloat contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
syn match goFloat contained "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
syn match goFloat contained "\<\d\+[Ee][-+]\d\+\>"
" Imaginary literals
syn match goImaginary contained "\<\d\+i\>"
syn match goImaginary contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
syn match goImaginary contained "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
syn match goImaginary contained "\<\d\+[Ee][-+]\d\+i\>"
hi def link goInt Number
hi def link goFloat Number
hi def link goImaginary Number
" Token groups
syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary
syn keyword gotplControl contained if else end range with template include tpl required define
syn keyword gotplFunctions contained and call html index js len not or print printf println urlquery eq ne lt le gt ge
syn keyword goSprigFunctions contained abbrev abbrevboth add add1 adler32sum ago append atoi b32dec b32enc b64dec b64enc base biggest buildCustomCert camelcase cat ceil clean coalesce \contains compact date dateInZone dateModify date_in_zone date_modify default derivePassword dict dir div empty ext fail first float64 floor fromJson fromYaml genCA genPrivateKey genSelfSignedCert genSignedCert has hasKey hasPrefix hasSuffix hello htmlDate htmlDateInZone indent initial initials int int64 isAbs join kebabcase keys kindIs kindOf last list lower max merge mergeOverwrite min mod mul nindent nospace now omit pick pluck plural prepend quote randAlpha randAlphaNum randAscii randNumeric regexFind regexFindAll regexMatch regexReplaceAll regexReplaceAllLiteral regexSplit repeat replace rest reverse round semver semverCompare set sha1sum sha256sum shuffle slice snakecase sortAlpha split splitList splitn squote sub substr swapcase ternary title toDate toJson toPrettyJson toString toStrings toToml toYaml trim trimAll trimPrefix trimSuffix trimall trunc tuple typeIs typeIsLike typeOf uniq unixEpoch unset until untilStep untitle upper uuidv4 values without wrap wrapWith
syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/
syn match goTplIdentifier contained /\.[^\s}]+\>/
hi def link gotplControl Keyword
hi def link gotplFunctions Function
hi def link goSprigFunctions Function
hi def link goTplVariable Special
syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable,goTplIdentifier containedin=yamlFlowString display
syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,goSprigFunctions,gotplVariable containedin=yamlFlowString display
syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display
syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display
hi def link gotplAction PreProc
hi def link goTplComment Comment
let b:current_syntax = "helm"
" vim: sw=2 ts=2 et

View File

@@ -65,7 +65,7 @@ syntax match jsFloat /\c\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%(e[+-]\=
" Regular Expressions " Regular Expressions
syntax match jsSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{4,5}})|c\u|.)" syntax match jsSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{4,5}})|c\u|.)"
syntax region jsTemplateExpression contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression keepend syntax region jsTemplateExpression contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression keepend
syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+ contains=jsSpecial syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+ contains=jsSpecial extend
syntax match jsRegexpBoundary contained "\v\c[$^]|\\b" syntax match jsRegexpBoundary contained "\v\c[$^]|\\b"
syntax match jsRegexpBackRef contained "\v\\[1-9]\d*" syntax match jsRegexpBackRef contained "\v\\[1-9]\d*"
syntax match jsRegexpQuantifier contained "\v[^\\]%([?*+]|\{\d+%(,\d*)?})\??"lc=1 syntax match jsRegexpQuantifier contained "\v[^\\]%([?*+]|\{\d+%(,\d*)?})\??"lc=1

View File

@@ -155,11 +155,11 @@ endif
" Strike through " Strike through
if get(g:, 'vim_markdown_strikethrough', 0) if get(g:, 'vim_markdown_strikethrough', 0)
syn region mkdStrike matchgroup=mkdStrike start="\%(\~\~\)" end="\%(\~\~\)" execute 'syn region mkdStrike matchgroup=htmlStrike start="\%(\~\~\)" end="\%(\~\~\)"' . s:concealends
HtmlHiLink mkdStrike htmlStrike HtmlHiLink mkdStrike htmlStrike
endif endif
syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,htmlStrike syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,mkdStrike
"highlighting for Markdown groups "highlighting for Markdown groups
HtmlHiLink mkdString String HtmlHiLink mkdString String

View File

@@ -73,6 +73,7 @@ syn keyword mesonBuiltin
\ add_project_arguments \ add_project_arguments
\ add_project_link_arguments \ add_project_link_arguments
\ add_test_setup \ add_test_setup
\ alias_target
\ assert \ assert
\ benchmark \ benchmark
\ both_libraries \ both_libraries
@@ -101,6 +102,7 @@ syn keyword mesonBuiltin
\ install_headers \ install_headers
\ install_man \ install_man
\ install_subdir \ install_subdir
\ is_disabler
\ is_variable \ is_variable
\ jar \ jar
\ join_paths \ join_paths

View File

@@ -6,8 +6,8 @@ endif
" Language: Mustache, Handlebars " Language: Mustache, Handlebars
" Maintainer: Juvenn Woo <machese@gmail.com> " Maintainer: Juvenn Woo <machese@gmail.com>
" Screenshot: http://imgur.com/6F408 " Screenshot: http://imgur.com/6F408
" Version: 5 " Version: 6
" Last Change: Nov 23rd 2018 " Last Change: Jul 16 2019
" Remark: " Remark:
" It lexically hilights embedded mustaches (exclusively) in html file. " It lexically hilights embedded mustaches (exclusively) in html file.
" While it was written for Ruby-based Mustache template system, it should " While it was written for Ruby-based Mustache template system, it should
@@ -45,21 +45,34 @@ endif
syntax match mustacheError '}}}\?' syntax match mustacheError '}}}\?'
syntax match mustacheInsideError '{{[{$#<>=!\/]\?' syntax match mustacheInsideError '{{[{$#<>=!\/]\?'
syntax region mustacheInside start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer
syntax match mustacheOperators '=\|\.\|/' contained containedin=mustacheInside,mustacheParam " Ember angle bracket syntax syntax starts with a capital letter:
syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=mustacheInside " https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md
syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=mustacheInside,@htmlMustacheContainer syntax case match
syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=mustacheInside,@htmlMustacheContainer syntax region mustacheAngleComponent start=/<\/\?[[:upper:]]/ end=/>/ keepend containedin=TOP,@htmlMustacheContainer
syntax match mustacheHandlebars '{{\|}}' contained containedin=mustacheInside,@htmlMustacheContainer syntax case ignore
syntax match mustacheUnescape '{{{\|}}}' contained containedin=mustacheInside,@htmlMustacheContainer syntax match mustacheAngleBrackets '</\?\|/\?>' contained containedin=mustacheAngleComponent
syntax match mustacheConditionals '\([/#]\?if\|unless\|else\)' contained containedin=mustacheInside syntax match mustacheAngleComponentName '</[[:alnum:]]\+'hs=s+2 contained containedin=mustacheAngleBrackets
syntax match mustacheHelpers '[/#]\?\(with\|link\-to\|each\(\-in\)\?\)' contained containedin=mustacheInside syntax match mustacheAngleComponentName '<[[:alnum:]]\+'hs=s+1 contained containedin=mustacheAngleBrackets
syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=mustacheInside
syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=mustacheInside syntax region mustacheHbsComponent start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer
syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,mustacheInside,@htmlMustacheContainer
syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,mustacheInside,@htmlMustacheContainer syntax cluster mustacheInside add=mustacheHbsComponent,mustacheAngleComponent
syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=mustacheInside
syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=mustacheInside syntax match mustacheOperators '=\|\.\|/^>' contained containedin=@mustacheInside,mustacheParam
syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=@mustacheInside
syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
syntax match mustacheHandlebars '{{\|}}' contained containedin=@mustacheInside
syntax match mustacheUnescape '{{{\|}}}' contained containedin=@mustacheInside
syntax match mustacheConditionals '\([/#]\?\<\(if\|unless\)\|\<else\)\>' contained containedin=@mustacheInside
syntax match mustacheHelpers '[/#]\?\<\(with\|link\-to\|each\(\-in\)\?\|let\)\>' contained containedin=@mustacheInside
syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside
syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=@mustacheInside
syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,@mustacheInside,@htmlMustacheContainer
syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,@mustacheInside,@htmlMustacheContainer
syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=@mustacheInside
syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=@mustacheInside
" Clustering " Clustering
syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue
@@ -73,6 +86,7 @@ HtmlHiLink mustacheVariableUnescape Number
HtmlHiLink mustachePartial Number HtmlHiLink mustachePartial Number
HtmlHiLink mustacheMarkerSet Number HtmlHiLink mustacheMarkerSet Number
HtmlHiLink mustacheParam htmlArg HtmlHiLink mustacheParam htmlArg
HtmlHiLink mustacheAngleComponentName htmlTag
HtmlHiLink mustacheComment Comment HtmlHiLink mustacheComment Comment
HtmlHiLink mustacheBlockComment Comment HtmlHiLink mustacheBlockComment Comment
@@ -80,6 +94,7 @@ HtmlHiLink mustacheError Error
HtmlHiLink mustacheInsideError Error HtmlHiLink mustacheInsideError Error
HtmlHiLink mustacheHandlebars Special HtmlHiLink mustacheHandlebars Special
HtmlHiLink mustacheAngleBrackets htmlTagName
HtmlHiLink mustacheUnescape Identifier HtmlHiLink mustacheUnescape Identifier
HtmlHiLink mustacheOperators Operator HtmlHiLink mustacheOperators Operator
HtmlHiLink mustacheConditionals Conditional HtmlHiLink mustacheConditionals Conditional

View File

@@ -33,6 +33,9 @@ endif
" ' can be used in OCaml identifiers " ' can be used in OCaml identifiers
setlocal iskeyword+=' setlocal iskeyword+='
" ` is part of the name of polymorphic variants
setlocal iskeyword+=`
" OCaml is case sensitive. " OCaml is case sensitive.
syn case match syn case match

Some files were not shown because too many files have changed in this diff Show More