Compare commits

...

18 Commits

Author SHA1 Message Date
Adam Stankiewicz
8cd62b9eab Change javascript provider to pangloss/vim-javascript, closes #80 2016-05-03 12:56:11 +02:00
Adam Stankiewicz
93e3f020a9 Rename jade to pug 2016-05-02 11:52:54 +02:00
Adam Stankiewicz
81ccd02032 Remove jinja syntax, closes #108 2016-05-02 11:48:38 +02:00
Adam Stankiewicz
2ae1aab49b Add purescript support, closes #110 2016-05-02 11:35:06 +02:00
Adam Stankiewicz
554ae93ef1 Add pgsql syntax, closes #111 2016-05-02 10:52:01 +02:00
Adam Stankiewicz
7a29850ae9 Add plantuml syntax, closes #116 2016-05-02 10:50:59 +02:00
Adam Stankiewicz
c200e7a0c5 Add crystal syntax, closes #118 2016-05-02 10:49:45 +02:00
Adam Stankiewicz
5529a5e8e2 Update vim-puppet source to voxpupuli/vim-puppet, closes #115 2016-05-02 10:48:28 +02:00
Adam Stankiewicz
905031eb95 Add fish syntax, closes #109 2016-05-02 10:46:45 +02:00
Adam Stankiewicz
76d23a21e6 Add cryptol syntax, closes #107 2016-05-02 10:44:59 +02:00
Adam Stankiewicz
5dd1a7e839 Update 2016-05-02 10:42:37 +02:00
Adam Stankiewicz
bc098370c1 Merge pull request #119 from MartinDelille/patch-1
Use SVG for travis badge
2016-04-25 18:05:59 +02:00
Martin Delille
b07b46bc0c Use SVG for travis badge
SVG badge are lighter and have a nicer rendering, expecially on retina display.
2016-04-24 17:08:29 +02:00
Adam Stankiewicz
b0823d2068 Change twig provider, close #102 2016-01-28 18:14:32 +01:00
Adam Stankiewicz
b4a6290b42 Update 2016-01-28 18:07:33 +01:00
Adam Stankiewicz
c324a086b2 Exclude autoload scripts for nim 2016-01-22 09:12:18 +01:00
Adam Stankiewicz
2bde381723 Add nim support 2016-01-22 09:08:30 +01:00
Adam Stankiewicz
61390f5885 Update 2016-01-22 09:08:00 +01:00
126 changed files with 11552 additions and 3355 deletions

View File

@@ -1,6 +1,6 @@
# vim-polyglot [![Build Status][travis-img-url]][travis-url] # vim-polyglot [![Build Status][travis-img-url]][travis-url]
[travis-img-url]: https://travis-ci.org/sheerun/vim-polyglot.png [travis-img-url]: https://travis-ci.org/sheerun/vim-polyglot.svg
[travis-url]: https://travis-ci.org/sheerun/vim-polyglot [travis-url]: https://travis-ci.org/sheerun/vim-polyglot
A collection of language packs for Vim. A collection of language packs for Vim.
@@ -27,12 +27,14 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [ansible](https://github.com/pearofducks/ansible-vim) (syntax, indent, ftplugin, ftdetect) - [ansible](https://github.com/pearofducks/ansible-vim) (syntax, indent, ftplugin, ftdetect)
- [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent, ftdetect) - [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent, ftdetect)
- [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftdetect) - [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftplugin, ftdetect)
- [c++11](https://github.com/octol/vim-cpp-enhanced-highlight) (syntax) - [c++11](https://github.com/octol/vim-cpp-enhanced-highlight) (syntax)
- [c/c++](https://github.com/vim-jp/vim-cpp) (syntax) - [c/c++](https://github.com/vim-jp/vim-cpp) (syntax)
- [cjsx](https://github.com/mtscout6/vim-cjsx) (ftdetect, syntax, ftplugin) - [cjsx](https://github.com/mtscout6/vim-cjsx) (ftdetect, syntax, ftplugin)
- [clojure](https://github.com/guns/vim-clojure-static) (syntax, indent, autoload, ftplugin, ftdetect) - [clojure](https://github.com/guns/vim-clojure-static) (syntax, indent, autoload, ftplugin, ftdetect)
- [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin, ftdetect) - [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin, ftdetect)
- [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim) (syntax, compiler, ftplugin, ftdetect)
- [crystal](https://github.com/rhysd/vim-crystal) (syntax, indent, autoload, ftplugin, ftdetect)
- [cql](https://github.com/elubow/cql-vim) (syntax, ftdetect) - [cql](https://github.com/elubow/cql-vim) (syntax, ftdetect)
- [css](https://github.com/JulesWang/css.vim) (syntax) - [css](https://github.com/JulesWang/css.vim) (syntax)
- [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin, ftdetect) - [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin, ftdetect)
@@ -43,6 +45,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [emberscript](https://github.com/heartsentwined/vim-ember-script) (syntax, indent, ftplugin, ftdetect) - [emberscript](https://github.com/heartsentwined/vim-ember-script) (syntax, indent, ftplugin, ftdetect)
- [emblem](https://github.com/heartsentwined/vim-emblem) (syntax, indent, ftplugin, ftdetect) - [emblem](https://github.com/heartsentwined/vim-emblem) (syntax, indent, ftplugin, ftdetect)
- [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent, ftdetect) - [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent, ftdetect)
- [fish](https://github.com/dag/vim-fish) (syntax, indent, compiler, autoload, ftplugin, ftdetect)
- [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin, ftdetect) - [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin, ftdetect)
- [glsl](https://github.com/tikhomirov/vim-glsl) (syntax, indent, ftdetect) - [glsl](https://github.com/tikhomirov/vim-glsl) (syntax, indent, ftdetect)
- [go](https://github.com/fatih/vim-go) (syntax, compiler, indent, ftdetect) - [go](https://github.com/fatih/vim-go) (syntax, compiler, indent, ftdetect)
@@ -52,10 +55,8 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin, ftdetect) - [haskell](https://github.com/neovimhaskell/haskell-vim) (syntax, indent, ftplugin, ftdetect)
- [haxe](https://github.com/yaymukund/vim-haxe) (syntax, ftdetect) - [haxe](https://github.com/yaymukund/vim-haxe) (syntax, ftdetect)
- [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin) - [html5](https://github.com/othree/html5.vim) (syntax, indent, autoload, ftplugin)
- [jade](https://github.com/digitaltoad/vim-jade) (syntax, indent, ftplugin, ftdetect)
- [jasmine](https://github.com/glanotte/vim-jasmine) (syntax, ftdetect) - [jasmine](https://github.com/glanotte/vim-jasmine) (syntax, ftdetect)
- [javascript](https://github.com/sheerun/yajs.vim) (syntax, indent) - [javascript](https://github.com/pangloss/vim-javascript) (syntax, indent, ftplugin, ftdetect)
- [jinja](https://github.com/Glench/Vim-Jinja2-Syntax) (syntax, indent, ftdetect)
- [json](https://github.com/sheerun/vim-json) (syntax, indent, ftdetect) - [json](https://github.com/sheerun/vim-json) (syntax, indent, ftdetect)
- [jst](https://github.com/briancollins/vim-jst) (syntax, indent, ftdetect) - [jst](https://github.com/briancollins/vim-jst) (syntax, indent, ftdetect)
- [jsx](https://github.com/mxw/vim-jsx) (ftdetect, after) - [jsx](https://github.com/mxw/vim-jsx) (ftdetect, after)
@@ -66,16 +67,21 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin, ftdetect) - [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin, ftdetect)
- [markdown](https://github.com/tpope/vim-markdown) (syntax, ftplugin, ftdetect) - [markdown](https://github.com/tpope/vim-markdown) (syntax, ftplugin, ftdetect)
- [nginx](https://github.com/nginx/nginx) (syntax, indent, ftdetect) - [nginx](https://github.com/nginx/nginx) (syntax, indent, ftdetect)
- [nim](https://github.com/zah/nim.vim) (syntax, compiler, indent, ftdetect)
- [nix](https://github.com/spwhitt/vim-nix) (syntax, ftplugin, ftdetect) - [nix](https://github.com/spwhitt/vim-nix) (syntax, ftplugin, ftdetect)
- [objc](https://github.com/b4winckler/vim-objc) (ftplugin, syntax, indent) - [objc](https://github.com/b4winckler/vim-objc) (ftplugin, syntax, indent)
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin) - [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax) - [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
- [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin, ftdetect) - [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin, ftdetect)
- [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin, ftdetect) - [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin, ftdetect)
- [pgsql](https://github.com/exu/pgsql.vim) (syntax, ftdetect)
- [php](https://github.com/StanAngeloff/php.vim) (syntax) - [php](https://github.com/StanAngeloff/php.vim) (syntax)
- [plantuml](https://github.com/aklt/plantuml-syntax) (syntax, ftplugin, ftdetect)
- [powershell](https://github.com/Persistent13/vim-ps1) (syntax, indent, ftplugin, ftdetect) - [powershell](https://github.com/Persistent13/vim-ps1) (syntax, indent, ftplugin, ftdetect)
- [protobuf](https://github.com/uarun/vim-protobuf) (syntax, ftdetect) - [protobuf](https://github.com/uarun/vim-protobuf) (syntax, ftdetect)
- [puppet](https://github.com/rodjek/vim-puppet) (syntax, indent, ftplugin, ftdetect) - [pug](https://github.com/digitaltoad/vim-pug) (syntax, indent, ftplugin, ftdetect)
- [puppet](https://github.com/voxpupuli/vim-puppet) (syntax, indent, ftplugin, ftdetect)
- [purescript](https://github.com/raichoo/purescript-vim) (syntax, indent, ftdetect)
- [python](https://github.com/mitsuhiko/vim-python-combined) (syntax, indent) - [python](https://github.com/mitsuhiko/vim-python-combined) (syntax, indent)
- [qml](https://github.com/peterhoeg/vim-qml) (syntax, indent, ftplugin, ftdetect) - [qml](https://github.com/peterhoeg/vim-qml) (syntax, indent, ftplugin, ftdetect)
- [r-lang](https://github.com/vim-scripts/R.vim) (syntax, ftplugin) - [r-lang](https://github.com/vim-scripts/R.vim) (syntax, ftplugin)
@@ -95,7 +101,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [tmux](https://github.com/tejr/vim-tmux) (syntax, ftdetect) - [tmux](https://github.com/tejr/vim-tmux) (syntax, ftdetect)
- [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, ftdetect) - [toml](https://github.com/cespare/vim-toml) (syntax, ftplugin, ftdetect)
- [twig](https://github.com/beyondwords/vim-twig) (syntax, ftplugin, ftdetect) - [twig](https://github.com/evidens/vim-twig) (syntax, ftplugin)
- [typescript](https://github.com/leafgarland/typescript-vim) (syntax, indent, compiler, ftplugin, ftdetect) - [typescript](https://github.com/leafgarland/typescript-vim) (syntax, indent, compiler, ftplugin, ftdetect)
- [vala](https://github.com/tkztmk/vim-vala) (syntax, indent, ftdetect) - [vala](https://github.com/tkztmk/vim-vala) (syntax, indent, ftdetect)
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax) - [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)

View File

@@ -1,7 +1,6 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
setlocal comments=s1fl:{-,mb:-,ex:-},:-- setlocal comments=s1fl:{-,mb:-,ex:-},:--
setlocal formatoptions-=cro formatoptions+=j
setlocal iskeyword+=-,.,* setlocal iskeyword+=-,.,*
setlocal commentstring=--\ %s setlocal commentstring=--\ %s

View File

@@ -1,7 +1,6 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
setlocal comments=s1fl:{-,mb:-,ex:-},:-- setlocal comments=s1fl:{-,mb:-,ex:-},:--
setlocal formatoptions-=cro formatoptions+=j
setlocal iskeyword+=' setlocal iskeyword+='
endif endif

View File

@@ -26,8 +26,8 @@ setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
" XML indentkeys " XML indentkeys
setlocal indentkeys+=*<Return>,<>>,<<>,/ setlocal indentkeys+=*<Return>,<>>,<<>,/
" Self-closing tag regex. " Multiline end tag regex (line beginning with '>' or '/>')
let s:sctag = '^\s*\/>\s*;\=' let s:endtag = '^\s*\/\?>\s*;\='
" Get all syntax types at the beginning of a given line. " Get all syntax types at the beginning of a given line.
fu! SynSOL(lnum) fu! SynSOL(lnum)
@@ -76,13 +76,13 @@ fu! GetJsxIndent()
if (SynXMLish(prevsyn) || SynJSXBlockEnd(prevsyn)) && SynXMLishAny(cursyn) if (SynXMLish(prevsyn) || SynJSXBlockEnd(prevsyn)) && SynXMLishAny(cursyn)
let ind = XmlIndentGet(v:lnum, 0) let ind = XmlIndentGet(v:lnum, 0)
" Align '/>' with '<' for multiline self-closing tags. " Align '/>' and '>' with '<' for multiline tags.
if getline(v:lnum) =~? s:sctag if getline(v:lnum) =~? s:endtag
let ind = ind - &sw let ind = ind - &sw
endif endif
" Then correct the indentation of any JSX following '/>'. " Then correct the indentation of any JSX following '/>' or '>'.
if getline(v:lnum - 1) =~? s:sctag if getline(v:lnum - 1) =~? s:endtag
let ind = ind + &sw let ind = ind + &sw
endif endif
else else

View File

@@ -36,22 +36,56 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1
" Functions " Functions
syn match cCustomParen "(" contains=cParen contains=cCppParen syn match cCustomParen "(" contains=cParen contains=cCppParen
syn match cCustomFunc "\w\+\s*(\@=" contains=cCustomParen syn match cCustomFunc "\w\+\s*(\@="
hi def link cCustomFunc Function hi def link cCustomFunc Function
" Template functions
if exists('g:cpp_experimental_template_highlight') && g:cpp_experimental_template_highlight
syn region cCustomAngleBrackets matchgroup=AngleBracketContents start="\v%(<operator\_s*)@<!%(%(\_i|template\_s*)@<=\<[<=]@!|\<@<!\<[[:space:]<=]@!)" end='>' contains=@cppSTLgroup,cppStructure,cType,cCustomClass,cCustomAngleBrackets,cNumbers
syn match cCustomBrack "<\|>" contains=cCustomAngleBrackets
syn match cCustomTemplateFunc "\w\+\s*<.*>(\@=" contains=cCustomBrack,cCustomAngleBrackets
hi def link cCustomTemplateFunc Function
endif
" Class and namespace scope " Class and namespace scope
if exists('g:cpp_class_scope_highlight') && g:cpp_class_scope_highlight if exists('g:cpp_class_scope_highlight') && g:cpp_class_scope_highlight
syn match cCustomScope "::" syn match cCustomScope "::"
syn match cCustomClass "\w\+\s*::" contains=cCustomScope syn match cCustomClass "\w\+\s*::"
hi def link cCustomClass Function " disabled for now \contains=cCustomScope
" hi def link cCustomClass Function " disabled for now
syn match cCustomClass "\<\u\w*\s*\>"
endif
" Template functions
if exists('g:cpp_experimental_template_highlight') && g:cpp_experimental_template_highlight
syn match cCustomAngleBracketStart "<\_[^;()]\{-}>" contained
\contains=cCustomAngleBracketStart, cCustomAngleBracketEnd
hi def link cCustomAngleBracketStart cCustomAngleBracketContent
syn match cCustomAngleBracketEnd ">\_[^<>;()]\{-}>" contained
\contains=cCustomAngleBracketEnd
hi def link cCustomAngleBracketEnd cCustomAngleBracketContent
syn match cCustomTemplateFunc "\<\l\w*\s*<\_[^;()]\{-}>(\@="hs=s,he=e-1
\contains=cCustomAngleBracketStart
hi def link cCustomTemplateFunc cCustomFunc
syn match cCustomTemplateClass "\<\w\+\s*<\_[^;()]\{-}>"
\contains=cCustomAngleBracketStart,cCustomTemplateFunc
hi def link cCustomTemplateClass cCustomClass
" Remove 'template' from cppStructure and use a custom match
syn clear cppStructure
syn keyword cppStructure class typename namespace
syn match cCustomTemplate "\<template\>"
hi def link cCustomTemplate cppStructure
syn match cTemplateDeclare "\<template\_s*<\_[^;()]\{-}>"
\contains=cppStructure,cCustomTemplate,cCustomAngleBracketStart
" Remove 'operator' from cppStructure and use a custom match
syn clear cppOperator
syn keyword cppOperator typeid
syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
syn match cCustomOperator "\<operator\>"
hi def link cCustomOperator cppStructure
syn match cTemplateOperatorDeclare "\<operator\_s*<\_[^;()]\{-}>[<>]=\?"
\contains=cppOperator,cCustomOperator,cCustomAngleBracketStart
endif endif
" Alternative syntax that is used in: " Alternative syntax that is used in:
@@ -65,7 +99,7 @@ syn cluster cppSTLgroup contains=cppSTLfunction,cppSTLfunctional,cppSTLconst
" ----------------------------------------------------------------------------- " -----------------------------------------------------------------------------
" Standard library types and functions. " Standard library types and functions.
" "
" Mainly based on the excellent STL Syntax vim script by " Mainly based on the excellent STL Syntax vim script by
" Mizuchi <ytj000@gmail.com> " Mizuchi <ytj000@gmail.com>
" http://www.vim.org/scripts/script.php?script_id=4293 " http://www.vim.org/scripts/script.php?script_id=4293
" which in turn is based on the scripts " which in turn is based on the scripts
@@ -136,7 +170,6 @@ syntax keyword cppSTLfunctional binary_negate
syntax keyword cppSTLfunctional bit_and syntax keyword cppSTLfunctional bit_and
syntax keyword cppSTLfunctional bit_not syntax keyword cppSTLfunctional bit_not
syntax keyword cppSTLfunctional bit_or syntax keyword cppSTLfunctional bit_or
syntax keyword cppSTLfunctional bit_xor
syntax keyword cppSTLfunctional divides syntax keyword cppSTLfunctional divides
syntax keyword cppSTLfunctional equal_to syntax keyword cppSTLfunctional equal_to
syntax keyword cppSTLfunctional greater syntax keyword cppSTLfunctional greater
@@ -1324,31 +1357,6 @@ if !exists("cpp_no_cpp14")
"dynarray "dynarray
syntax keyword cppSTLtype dynarray syntax keyword cppSTLtype dynarray
"helper type traits types
syntax keyword cppSTLtype remove_cv_t
syntax keyword cppSTLtype remove_const_t
syntax keyword cppSTLtype remove_volatile_t
syntax keyword cppSTLtype add_cv_t
syntax keyword cppSTLtype add_const_t
syntax keyword cppSTLtype add_volatile_t
syntax keyword cppSTLtype remove_reference_t
syntax keyword cppSTLtype add_lvalue_reference_t
syntax keyword cppSTLtype add_rvalue_reference_t
syntax keyword cppSTLtype remove_pointer_t
syntax keyword cppSTLtype add_pointer_t
syntax keyword cppSTLtype remove_extent_t
syntax keyword cppSTLtype remove_all_extents_t
syntax keyword cppSTLtype make_signed_t
syntax keyword cppSTLtype make_unsigned_t
syntax keyword cppSTLtype aligned_storage_t
syntax keyword cppSTLtype aligned_union_t
syntax keyword cppSTLtype decay_t
syntax keyword cppSTLtype enable_if_t
syntax keyword cppSTLtype conditional_t
syntax keyword cppSTLtype common_type_t
syntax keyword cppSTLtype underlying_type_t
syntax keyword cppSTLtype result_of_t
"thread "thread
syntax keyword cppSTLtype shared_mutex syntax keyword cppSTLtype shared_mutex
syntax keyword cppSTLtype shared_lock syntax keyword cppSTLtype shared_lock
@@ -1387,7 +1395,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits")
HiLink cppSTLenum Typedef HiLink cppSTLenum Typedef
HiLink cppSTLios Function HiLink cppSTLios Function
HiLink cppSTLcast Statement " be consistent with official syntax HiLink cppSTLcast Statement " be consistent with official syntax
HiLink cppRawString String HiLink cppRawString String
HiLink cppRawDelimiter Delimiter HiLink cppRawDelimiter Delimiter
delcommand HiLink delcommand HiLink
endif endif

View File

@@ -32,12 +32,23 @@ endif
" - othree/yajs.vim: javascriptNoReserved " - othree/yajs.vim: javascriptNoReserved
" JSX attributes should color as JS. Note the trivial end pattern; we let
" jsBlock take care of ending the region.
syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock
" JSX child blocks behave just like JSX attributes, except that (a) they are
" syntactically distinct, and (b) they need the syn-extend argument, or else
" nested XML end-tag patterns may end the outer jsxRegion.
syn region jsxChild contained start=+{+ end=++ contains=jsBlock,javascriptBlock
\ extend
" Highlight JSX regions as XML; recursively match. " Highlight JSX regions as XML; recursively match.
" "
" Note that we prohibit JSX tags from having a < or word character immediately " Note that we prohibit JSX tags from having a < or word character immediately
" preceding it, to avoid conflicts with, respectively, the left shift operator " preceding it, to avoid conflicts with, respectively, the left shift operator
" and generic Flow type annotations (http://flowtype.org/). " and generic Flow type annotations (http://flowtype.org/).
syn region jsxRegion contains=@XMLSyntax,jsxRegion,jsBlock,javascriptBlock syn region jsxRegion
\ contains=@XMLSyntax,jsxRegion,jsxChild,jsBlock,javascriptBlock
\ start=+\%(<\|\w\)\@<!<\z([a-zA-Z][a-zA-Z0-9:\-.]*\)+ \ start=+\%(<\|\w\)\@<!<\z([a-zA-Z][a-zA-Z0-9:\-.]*\)+
\ skip=+<!--\_.\{-}-->+ \ skip=+<!--\_.\{-}-->+
\ end=+</\z1\_\s\{-}>+ \ end=+</\z1\_\s\{-}>+
@@ -45,10 +56,6 @@ syn region jsxRegion contains=@XMLSyntax,jsxRegion,jsBlock,javascriptBlock
\ keepend \ keepend
\ extend \ extend
" JSX attributes should color as JS. Note the trivial end pattern; we let
" jsBlock take care of ending the region.
syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock
" Add jsxRegion to the lowest-level JS syntax cluster. " Add jsxRegion to the lowest-level JS syntax cluster.
syn cluster jsExpression add=jsxRegion syn cluster jsExpression add=jsxRegion

332
autoload/crystal_lang.vim Normal file
View File

@@ -0,0 +1,332 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
let s:save_cpo = &cpo
set cpo&vim
let s:V = vital#of('crystal')
let s:P = s:V.import('Process')
let s:J = s:V.import('Web.JSON')
let s:C = s:V.import('ColorEcho')
function! s:echo_error(msg, ...) abort
echohl ErrorMsg
if a:0 == 0
echomsg a:msg
else
echomsg call('printf', [a:msg] + a:000)
endif
echohl None
endfunction
function! s:run_cmd(cmd) abort
if !executable(g:crystal_compiler_command)
throw "vim-crystal: Error: '" . g:crystal_compiler_command . "' command is not found."
endif
return s:P.system(a:cmd)
endfunction
function! s:find_root_by_spec(d) abort
let dir = finddir('spec', a:d . ';')
if dir ==# ''
return ''
endif
" Note: ':h:h' for {root}/spec/ -> {root}/spec -> {root}
return fnamemodify(dir, ':p:h:h')
endfunction
function! crystal_lang#entrypoint_for(file_path) abort
let parent_dir = fnamemodify(a:file_path, ':p:h')
let root_dir = s:find_root_by_spec(parent_dir)
if root_dir ==# ''
" No spec diretory found. No need to make temporary file
return a:file_path
endif
let temp_name = root_dir . '/__vim-crystal-temporary-entrypoint-' . fnamemodify(a:file_path, ':t')
let contents = [
\ 'require "spec"',
\ 'require "./spec/**"',
\ printf('require "./%s"', fnamemodify(a:file_path, ':p')[strlen(root_dir)+1 : ])
\ ]
let result = writefile(contents, temp_name)
if result == -1
" Note: When writefile() failed
return a:file_path
endif
return temp_name
endfunction
function! crystal_lang#tool(name, file, pos, option_str) abort
let entrypoint = crystal_lang#entrypoint_for(a:file)
let cmd = printf(
\ '%s tool %s --no-color %s --cursor %s:%d:%d %s',
\ g:crystal_compiler_command,
\ a:name,
\ a:option_str,
\ a:file,
\ a:pos[1],
\ a:pos[2],
\ entrypoint
\ )
try
let output = s:run_cmd(cmd)
return {'failed': s:P.get_last_status(), 'output': output}
finally
" Note:
" If the entry point is temporary file, delete it finally.
if a:file !=# entrypoint
call delete(entrypoint)
endif
endtry
endfunction
" `pos` is assumed a returned value from getpos()
function! crystal_lang#impl(file, pos, option_str) abort
return crystal_lang#tool('implementations', a:file, a:pos, a:option_str)
endfunction
function! s:jump_to_impl(impl) abort
execute 'edit' a:impl.filename
call cursor(a:impl.line, a:impl.column)
endfunction
function! crystal_lang#jump_to_definition(file, pos) abort
echo 'analyzing definitions under cursor...'
let cmd_result = crystal_lang#impl(a:file, a:pos, '--format json')
if cmd_result.failed
return s:echo_error(cmd_result.output)
endif
let impl = s:J.decode(cmd_result.output)
if impl.status !=# 'ok'
return s:echo_error(impl.message)
endif
if len(impl.implementations) == 1
call s:jump_to_impl(impl.implementations[0])
return
endif
let message = "Multiple definitions detected. Choose a number\n\n"
for idx in range(len(impl.implementations))
let i = impl.implementations[idx]
let message .= printf("[%d] %s:%d:%d\n", idx, i.filename, i.line, i.column)
endfor
let message .= "\n"
let idx = str2nr(input(message, "\n> "))
call s:jump_to_impl(impl.implementations[idx])
endfunction
function! crystal_lang#context(file, pos, option_str) abort
return crystal_lang#tool('context', a:file, a:pos, a:option_str)
endfunction
function! crystal_lang#type_hierarchy(file, option_str) abort
let cmd = printf(
\ '%s tool hierarchy --no-color %s %s',
\ g:crystal_compiler_command,
\ a:option_str,
\ a:file
\ )
return s:run_cmd(cmd)
endfunction
function! s:find_completion_start() abort
let c = col('.')
if c <= 1
return -1
endif
let line = getline('.')[:c-2]
return match(line, '\w\+$')
endfunction
function! crystal_lang#complete(findstart, base) abort
if a:findstart
echom 'find start'
return s:find_completion_start()
endif
let cmd_result = crystal_lang#context(expand('%'), getpos('.'), '--format json')
if cmd_result.failed
return
endif
let contexts = s:J.decode(cmd_result.output)
if contexts.status !=# 'ok'
return
endif
let candidates = []
for c in contexts.contexts
for [name, desc] in items(c)
let candidates += [{
\ 'word': name,
\ 'menu': ': ' . desc . ' [var]',
\ }]
endfor
endfor
return candidates
endfunction
function! crystal_lang#get_spec_switched_path(absolute_path) abort
let base = fnamemodify(a:absolute_path, ':t:r')
" TODO: Make cleverer
if base =~# '_spec$'
let parent = fnamemodify(substitute(a:absolute_path, '/spec/', '/src/', ''), ':h')
return parent . '/' . matchstr(base, '.\+\ze_spec$') . '.cr'
else
let parent = fnamemodify(substitute(a:absolute_path, '/src/', '/spec/', ''), ':h')
return parent . '/' . base . '_spec.cr'
endif
endfunction
function! crystal_lang#switch_spec_file(...) abort
let path = a:0 == 0 ? expand('%:p') : fnamemodify(a:1, ':p')
if path !~# '.cr$'
return s:echo_error('Not crystal source file: ' . path)
endif
execute 'edit!' crystal_lang#get_spec_switched_path(path)
endfunction
function! s:run_spec(root, path, ...) abort
" Note:
" `crystal spec` can't understand absolute path.
let cmd = printf(
\ '%s spec %s%s',
\ g:crystal_compiler_command,
\ a:path,
\ a:0 == 0 ? '' : (':' . a:1)
\ )
let saved_cwd = getcwd()
let cd = haslocaldir() ? 'lcd' : 'cd'
try
execute cd a:root
call s:C.echo(s:run_cmd(cmd))
finally
execute cd saved_cwd
endtry
endfunction
function! crystal_lang#run_all_spec(...) abort
let path = a:0 == 0 ? expand('%:p:h') : a:1
let root_path = s:find_root_by_spec(path)
if root_path ==# ''
return s:echo_error("'spec' directory is not found")
endif
call s:run_spec(root_path, 'spec')
endfunction
function! crystal_lang#run_current_spec(...) abort
" /foo/bar/src/poyo.cr
let path = a:0 == 0 ? expand('%:p') : fnamemodify(a:1, ':p')
if path !~# '.cr$'
return s:echo_error('Not crystal source file: ' . path)
endif
" /foo/bar/src
let source_dir = fnamemodify(path, ':h')
" /foo/bar
let root_dir = s:find_root_by_spec(source_dir)
if root_dir ==# ''
return s:echo_error("'spec' directory is not found")
endif
" src
let rel_path = source_dir[strlen(root_dir)+1 : ]
if path =~# '_spec.cr$'
call s:run_spec(root_dir, path[strlen(root_dir)+1 : ], line('.'))
else
let spec_path = substitute(rel_path, '^src', 'spec', '') . '/' . fnamemodify(path, ':t:r') . '_spec.cr'
if !filereadable(root_dir . '/' . spec_path)
return s:echo_error('Error: Could not find a spec source corresponding to ' . path)
endif
call s:run_spec(root_dir, spec_path)
endif
endfunction
function! crystal_lang#format_string(code, ...) abort
let cmd = printf(
\ '%s tool format --no-color %s -',
\ g:crystal_compiler_command,
\ get(a:, 1, '')
\ )
let output = s:P.system(cmd, a:code)
if s:P.get_last_status()
throw 'vim-crystal: Error on formatting: ' . output
endif
return output
endfunction
function! s:get_saved_states() abort
let result = {}
let fname = bufname('%')
let current_winnr = winnr()
for i in range(1, winnr('$'))
let bufnr = winbufnr(i)
if bufnr == -1
continue
endif
if bufname(bufnr) ==# fname
execute i 'wincmd w'
let result[i] = {
\ 'pos': getpos('.'),
\ 'screen': winsaveview()
\ }
endif
endfor
execute current_winnr 'wincmd w'
return result
endfunction
function! crystal_lang#format(option_str) abort
if !executable(g:crystal_compiler_command)
" Finish command silently
return
endif
let formatted = crystal_lang#format_string(join(getline(1, '$'), "\n"), a:option_str)
let formatted = substitute(formatted, '\n$', '', '')
let sel_save = &l:selection
let ve_save = &virtualedit
let &l:selection = 'inclusive'
let &virtualedit = ''
let [save_g_reg, save_g_regtype] = [getreg('g'), getregtype('g')]
let windows_save = s:get_saved_states()
try
call setreg('g', formatted, 'v')
silent normal! ggvG$"gp
finally
call setreg('g', save_g_reg, save_g_regtype)
let &l:selection = sel_save
let &virtualedit = ve_save
let winnr = winnr()
for winnr in keys(windows_save)
let w = windows_save[winnr]
execute winnr 'wincmd w'
call setpos('.', w.pos)
call winrestview(w.screen)
endfor
execute winnr 'wincmd w'
endtry
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
endif

70
autoload/fish.vim Normal file
View File

@@ -0,0 +1,70 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
function! fish#Indent()
let l:prevlnum = prevnonblank(v:lnum - 1)
if l:prevlnum ==# 0
return 0
endif
let l:indent = 0
let l:prevline = getline(l:prevlnum)
if l:prevline =~# '\v^\s*switch>'
let l:indent = &shiftwidth * 2
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
let l:indent = &shiftwidth
endif
let l:line = getline(v:lnum)
if l:line =~# '\v^\s*end>'
return indent(v:lnum) - (l:indent ==# 0 ? &shiftwidth : l:indent)
elseif l:line =~# '\v^\s*%(case|else)>'
return indent(v:lnum) - &shiftwidth
endif
return indent(l:prevlnum) + l:indent
endfunction
function! fish#Format()
if mode() =~# '\v^%(i|R)$'
return 1
else
let l:command = v:lnum.','.(v:lnum+v:count-1).'!fish_indent'
echo l:command
execute l:command
endif
endfunction
function! fish#Fold()
let l:line = getline(v:lnum)
if l:line =~# '\v^\s*%(begin|if|while|for|function|switch)>'
return 'a1'
elseif l:line =~# '\v^\s*end>'
return 's1'
else
return '='
end
endfunction
function! fish#Complete(findstart, base)
if a:findstart
return getline('.') =~# '\v^\s*$' ? -1 : 0
else
if empty(a:base)
return []
endif
let l:results = []
let l:completions =
\ system('fish -c "complete -C'.shellescape(a:base).'"')
let l:cmd = substitute(a:base, '\v\S+$', '', '')
for l:line in split(l:completions, '\n')
let l:tokens = split(l:line, '\t')
call add(l:results, {'word': l:cmd.l:tokens[0],
\'abbr': l:tokens[0],
\'menu': get(l:tokens, 1, '')})
endfor
return l:results
endif
endfunction
function! fish#errorformat()
return '%Afish: %m,%-G%*\\ ^,%-Z%f (line %l):%s'
endfunction
endif

16
autoload/vital.vim Normal file
View File

@@ -0,0 +1,16 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
function! vital#of(name) abort
let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital')
let file = split(files, "\n")
if empty(file)
throw 'vital: version file not found: ' . a:name
endif
let ver = readfile(file[0], 'b')
if empty(ver)
throw 'vital: invalid version file: ' . a:name
endif
return vital#_{substitute(ver[0], '\W', '', 'g')}#new()
endfunction
endif

313
autoload/vital/_crystal.vim Normal file
View File

@@ -0,0 +1,313 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
let s:self_version = expand('<sfile>:t:r')
let s:self_file = expand('<sfile>')
" Note: The extra argument to globpath() was added in Patch 7.2.051.
let s:globpath_third_arg = v:version > 702 || v:version == 702 && has('patch51')
let s:loaded = {}
let s:cache_module_path = {}
let s:cache_sid = {}
let s:_vital_files_cache_runtimepath = ''
let s:_vital_files_cache = []
let s:_unify_path_cache = {}
function! s:import(name, ...) abort
let target = {}
let functions = []
for a in a:000
if type(a) == type({})
let target = a
elseif type(a) == type([])
let functions = a
endif
unlet a
endfor
let module = s:_import(a:name)
if empty(functions)
call extend(target, module, 'keep')
else
for f in functions
if has_key(module, f) && !has_key(target, f)
let target[f] = module[f]
endif
endfor
endif
return target
endfunction
function! s:load(...) dict abort
for arg in a:000
let [name; as] = type(arg) == type([]) ? arg[: 1] : [arg, arg]
let target = split(join(as, ''), '\W\+')
let dict = self
let dict_type = type({})
while !empty(target)
let ns = remove(target, 0)
if !has_key(dict, ns)
let dict[ns] = {}
endif
if type(dict[ns]) == dict_type
let dict = dict[ns]
else
unlet dict
break
endif
endwhile
if exists('dict')
call extend(dict, s:_import(name))
endif
unlet arg
endfor
return self
endfunction
function! s:unload() abort
let s:loaded = {}
let s:cache_sid = {}
let s:cache_module_path = {}
endfunction
function! s:exists(name) abort
return s:_get_module_path(a:name) !=# ''
endfunction
function! s:search(pattern) abort
let paths = s:_vital_files(a:pattern)
let modules = sort(map(paths, 's:_file2module(v:val)'))
return s:_uniq(modules)
endfunction
function! s:expand_modules(entry, all) abort
if type(a:entry) == type([])
let candidates = s:_concat(map(copy(a:entry), 's:search(v:val)'))
if empty(candidates)
throw printf('vital: Any of module %s is not found', string(a:entry))
endif
if eval(join(map(copy(candidates), 'has_key(a:all, v:val)'), '+'))
let modules = []
else
let modules = [candidates[0]]
endif
else
let modules = s:search(a:entry)
if empty(modules)
throw printf('vital: Module %s is not found', a:entry)
endif
endif
call filter(modules, '!has_key(a:all, v:val)')
for module in modules
let a:all[module] = 1
endfor
return modules
endfunction
function! s:_import(name) abort
if type(a:name) == type(0)
return s:_build_module(a:name)
endif
let path = s:_get_module_path(a:name)
if path ==# ''
throw 'vital: module not found: ' . a:name
endif
let sid = s:_get_sid_by_script(path)
if !sid
try
execute 'source' fnameescape(path)
catch /^Vim\%((\a\+)\)\?:E484/
throw 'vital: module not found: ' . a:name
catch /^Vim\%((\a\+)\)\?:E127/
" Ignore.
endtry
let sid = s:_get_sid_by_script(path)
endif
return s:_build_module(sid)
endfunction
function! s:_get_module_path(name) abort
let key = a:name . '_'
if has_key(s:cache_module_path, key)
return s:cache_module_path[key]
endif
if s:_is_absolute_path(a:name) && filereadable(a:name)
return a:name
endif
if a:name ==# ''
let paths = [s:self_file]
elseif a:name =~# '\v^\u\w*%(\.\u\w*)*$'
let paths = s:_vital_files(a:name)
else
throw 'vital: Invalid module name: ' . a:name
endif
call filter(paths, 'filereadable(expand(v:val, 1))')
let path = get(paths, 0, '')
let s:cache_module_path[key] = path
return path
endfunction
function! s:_get_sid_by_script(path) abort
if has_key(s:cache_sid, a:path)
return s:cache_sid[a:path]
endif
let path = s:_unify_path(a:path)
for line in filter(split(s:_redir('scriptnames'), "\n"),
\ 'stridx(v:val, s:self_version) > 0')
let list = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$')
if !empty(list) && s:_unify_path(list[2]) ==# path
let s:cache_sid[a:path] = list[1] - 0
return s:cache_sid[a:path]
endif
endfor
return 0
endfunction
function! s:_file2module(file) abort
let filename = fnamemodify(a:file, ':p:gs?[\\/]?/?')
let tail = matchstr(filename, 'autoload/vital/_\w\+/\zs.*\ze\.vim$')
return join(split(tail, '[\\/]\+'), '.')
endfunction
if filereadable(expand('<sfile>:r') . '.VIM')
" resolve() is slow, so we cache results.
" Note: On windows, vim can't expand path names from 8.3 formats.
" So if getting full path via <sfile> and $HOME was set as 8.3 format,
" vital load duplicated scripts. Below's :~ avoid this issue.
function! s:_unify_path(path) abort
if has_key(s:_unify_path_cache, a:path)
return s:_unify_path_cache[a:path]
endif
let value = tolower(fnamemodify(resolve(fnamemodify(
\ a:path, ':p')), ':~:gs?[\\/]?/?'))
let s:_unify_path_cache[a:path] = value
return value
endfunction
else
function! s:_unify_path(path) abort
return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?'))
endfunction
endif
if s:globpath_third_arg
function! s:_runtime_files(path) abort
return split(globpath(&runtimepath, a:path, 1), "\n")
endfunction
else
function! s:_runtime_files(path) abort
return split(globpath(&runtimepath, a:path), "\n")
endfunction
endif
function! s:_vital_files(pattern) abort
if s:_vital_files_cache_runtimepath !=# &runtimepath
let path = printf('autoload/vital/%s/**/*.vim', s:self_version)
let s:_vital_files_cache = s:_runtime_files(path)
let mod = ':p:gs?[\\/]\+?/?'
call map(s:_vital_files_cache, 'fnamemodify(v:val, mod)')
let s:_vital_files_cache_runtimepath = &runtimepath
endif
let target = substitute(a:pattern, '\.', '/', 'g')
let target = substitute(target, '\*', '[^/]*', 'g')
let regexp = printf('autoload/vital/%s/%s.vim', s:self_version, target)
return filter(copy(s:_vital_files_cache), 'v:val =~# regexp')
endfunction
" Copy from System.Filepath
if has('win16') || has('win32') || has('win64')
function! s:_is_absolute_path(path) abort
return a:path =~? '^[a-z]:[/\\]'
endfunction
else
function! s:_is_absolute_path(path) abort
return a:path[0] ==# '/'
endfunction
endif
function! s:_build_module(sid) abort
if has_key(s:loaded, a:sid)
return copy(s:loaded[a:sid])
endif
let functions = s:_get_functions(a:sid)
let prefix = '<SNR>' . a:sid . '_'
let module = {}
for func in functions
let module[func] = function(prefix . func)
endfor
if has_key(module, '_vital_created')
call module._vital_created(module)
endif
let export_module = filter(copy(module), 'v:key =~# "^\\a"')
let s:loaded[a:sid] = get(g:, 'vital_debug', 0) ? module : export_module
if has_key(module, '_vital_loaded')
let V = vital#{s:self_version}#new()
call module._vital_loaded(V)
endif
return copy(s:loaded[a:sid])
endfunction
if exists('+regexpengine')
function! s:_get_functions(sid) abort
let funcs = s:_redir(printf("function /\\%%#=2^\<SNR>%d_", a:sid))
let map_pat = '<SNR>' . a:sid . '_\zs\w\+'
return map(split(funcs, "\n"), 'matchstr(v:val, map_pat)')
endfunction
else
function! s:_get_functions(sid) abort
let prefix = '<SNR>' . a:sid . '_'
let funcs = s:_redir('function')
let filter_pat = '^\s*function ' . prefix
let map_pat = prefix . '\zs\w\+'
return map(filter(split(funcs, "\n"),
\ 'stridx(v:val, prefix) > 0 && v:val =~# filter_pat'),
\ 'matchstr(v:val, map_pat)')
endfunction
endif
if exists('*uniq')
function! s:_uniq(list) abort
return uniq(a:list)
endfunction
else
function! s:_uniq(list) abort
let i = len(a:list) - 1
while 0 < i
if a:list[i] ==# a:list[i - 1]
call remove(a:list, i)
let i -= 2
else
let i -= 1
endif
endwhile
return a:list
endfunction
endif
function! s:_concat(lists) abort
let result_list = []
for list in a:lists
let result_list += list
endfor
return result_list
endfunction
function! s:_redir(cmd) abort
let [save_verbose, save_verbosefile] = [&verbose, &verbosefile]
set verbose=0 verbosefile=
redir => res
silent! execute a:cmd
redir END
let [&verbose, &verbosefile] = [save_verbose, save_verbosefile]
return res
endfunction
function! vital#{s:self_version}#new() abort
return s:_import('')
endfunction
endif

View File

@@ -0,0 +1,182 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim
function! s:_is_available() abort
if has('gui_running')
return 1
endif
if has('win32') || has('win64')
return 0
endif
return exists('&t_Co') && (&t_Co == 8 || &t_Co == 256)
endfunction
function! s:is_available() abort
if exists('s:is_available_cache')
return s:is_available_cache
endif
let s:is_available_cache = s:_is_available()
return s:is_available_cache
endfunction
function! s:_define_ansi_highlights() abort
hi ansiNone cterm=NONE gui=NONE
hi ansiBlackBg ctermbg=black guibg=black cterm=none gui=none
hi ansiRedBg ctermbg=red guibg=red cterm=none gui=none
hi ansiGreenBg ctermbg=green guibg=green cterm=none gui=none
hi ansiYellowBg ctermbg=yellow guibg=yellow cterm=none gui=none
hi ansiBlueBg ctermbg=blue guibg=blue cterm=none gui=none
hi ansiMagentaBg ctermbg=magenta guibg=magenta cterm=none gui=none
hi ansiCyanBg ctermbg=cyan guibg=cyan cterm=none gui=none
hi ansiWhiteBg ctermbg=white guibg=white cterm=none gui=none
hi ansiGrayBg ctermbg=gray guibg=gray cterm=none gui=none
hi ansiBlackFg ctermfg=black guifg=black cterm=none gui=none
hi ansiRedFg ctermfg=red guifg=red cterm=none gui=none
hi ansiGreenFg ctermfg=green guifg=green cterm=none gui=none
hi ansiYellowFg ctermfg=yellow guifg=yellow cterm=none gui=none
hi ansiBlueFg ctermfg=blue guifg=blue cterm=none gui=none
hi ansiMagentaFg ctermfg=magenta guifg=magenta cterm=none gui=none
hi ansiCyanFg ctermfg=cyan guifg=cyan cterm=none gui=none
hi ansiWhiteFg ctermfg=white guifg=white cterm=none gui=none
hi ansiGrayFg ctermfg=gray guifg=gray cterm=none gui=none
hi ansiBoldBlackFg ctermfg=black guifg=black cterm=none gui=none cterm=bold gui=bold
hi ansiBoldRedFg ctermfg=red guifg=red cterm=none gui=none cterm=bold gui=bold
hi ansiBoldGreenFg ctermfg=green guifg=green cterm=none gui=none cterm=bold gui=bold
hi ansiBoldYellowFg ctermfg=yellow guifg=yellow cterm=none gui=none cterm=bold gui=bold
hi ansiBoldBlueFg ctermfg=blue guifg=blue cterm=none gui=none cterm=bold gui=bold
hi ansiBoldMagentaFg ctermfg=magenta guifg=magenta cterm=none gui=none cterm=bold gui=bold
hi ansiBoldCyanFg ctermfg=cyan guifg=cyan cterm=none gui=none cterm=bold gui=bold
hi ansiBoldWhiteFg ctermfg=white guifg=white cterm=none gui=none cterm=bold gui=bold
hi ansiBoldGrayFg ctermfg=gray guifg=gray cterm=none gui=none cterm=bold gui=bold
hi ansiUnderlineBlackFg ctermfg=black guifg=black cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineRedFg ctermfg=red guifg=red cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineGreenFg ctermfg=green guifg=green cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineYellowFg ctermfg=yellow guifg=yellow cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineBlueFg ctermfg=blue guifg=blue cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineMagentaFg ctermfg=magenta guifg=magenta cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineCyanFg ctermfg=cyan guifg=cyan cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineWhiteFg ctermfg=white guifg=white cterm=none gui=none cterm=underline gui=underline
hi ansiUnderlineGrayFg ctermfg=gray guifg=gray cterm=none gui=none cterm=underline gui=underline
endfunction
let s:echorizer = {
\ 'value': '',
\ 'attr': '',
\ }
function s:echorizer.eat() abort
let matched = match(self.value, '\e\[\d*;\=m')
if matched == -1
return {}
endif
let matched_end = matchend(self.value, '\e\[\d*;\=m')
let token = {
\ 'body': matched == 0 ? '' : self.value[ : matched-1],
\ 'code': matchstr(self.value[matched : matched_end-1], '\d\+')
\ }
let self.value = self.value[matched_end : ]
return token
endfunction
let s:COLORS = {
\ 0: "None",
\ 30: "BlackFg",
\ 31: "RedFg",
\ 32: "GreenFg",
\ 33: "YellowFg",
\ 34: "BlueFg",
\ 35: "MagentaFg",
\ 36: "CyanFg",
\ 37: "WhiteFg",
\ 40: "BlackBg",
\ 41: "RedBg",
\ 42: "GreenBg",
\ 43: "YellowBg",
\ 44: "BlueBg",
\ 45: "MagentaBg",
\ 46: "CyanBg",
\ 47: "WhiteBg",
\ 90: "GrayFg",
\ }
function s:echorizer.echo_ansi(code) abort
if !has_key(s:COLORS, a:code)
return
endif
execute 'echohl' 'ansi' . self.attr . s:COLORS[a:code]
if a:code == 0
let self.attr = ''
endif
endfunction
function s:echorizer.echo() abort
echo
while 1
let token = self.eat()
if token == {}
break
endif
if token.body !=# ''
echon token.body
endif
" TODO: Now only one attribute can be specified
if token.code == 1
let self.attr = 'Bold'
elseif token.code == 4
let self.attr = 'Underline'
elseif token.code ==# ''
call self.echo_ansi(0)
else
call self.echo_ansi(token.code)
endif
endwhile
echon self.value
echohl None
let self.value = ''
endfunction
function! s:get_echorizer(str) abort
let e = deepcopy(s:echorizer)
let e.value = a:str
return e
endfunction
function! s:echo(str) abort
if !s:is_available()
echo substitute(a:str, '\e[.*m', '', 'g')
return
endif
if !exists('g:__vital_color_echo_already_highlighted')
call s:_define_ansi_highlights()
let g:__vital_color_echo_already_highlighted = 1
endif
let echorizer = s:get_echorizer(a:str)
call echorizer.echo()
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
endif

View File

@@ -0,0 +1,446 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
" Utilities for list.
let s:save_cpo = &cpo
set cpo&vim
function! s:pop(list) abort
return remove(a:list, -1)
endfunction
function! s:push(list, val) abort
call add(a:list, a:val)
return a:list
endfunction
function! s:shift(list) abort
return remove(a:list, 0)
endfunction
function! s:unshift(list, val) abort
return insert(a:list, a:val)
endfunction
function! s:cons(x, xs) abort
return [a:x] + a:xs
endfunction
function! s:conj(xs, x) abort
return a:xs + [a:x]
endfunction
" Removes duplicates from a list.
function! s:uniq(list) abort
return s:uniq_by(a:list, 'v:val')
endfunction
" Removes duplicates from a list.
function! s:uniq_by(list, f) abort
let list = map(copy(a:list), printf('[v:val, %s]', a:f))
let i = 0
let seen = {}
while i < len(list)
let key = string(list[i][1])
if has_key(seen, key)
call remove(list, i)
else
let seen[key] = 1
let i += 1
endif
endwhile
return map(list, 'v:val[0]')
endfunction
function! s:clear(list) abort
if !empty(a:list)
unlet! a:list[0 : len(a:list) - 1]
endif
return a:list
endfunction
" Concatenates a list of lists.
" XXX: Should we verify the input?
function! s:concat(list) abort
let memo = []
for Value in a:list
let memo += Value
endfor
return memo
endfunction
" Take each elements from lists to a new list.
function! s:flatten(list, ...) abort
let limit = a:0 > 0 ? a:1 : -1
let memo = []
if limit == 0
return a:list
endif
let limit -= 1
for Value in a:list
let memo +=
\ type(Value) == type([]) ?
\ s:flatten(Value, limit) :
\ [Value]
unlet! Value
endfor
return memo
endfunction
" Sorts a list with expression to compare each two values.
" a:a and a:b can be used in {expr}.
function! s:sort(list, expr) abort
if type(a:expr) == type(function('function'))
return sort(a:list, a:expr)
endif
let s:expr = a:expr
return sort(a:list, 's:_compare')
endfunction
function! s:_compare(a, b) abort
return eval(s:expr)
endfunction
" Sorts a list using a set of keys generated by mapping the values in the list
" through the given expr.
" v:val is used in {expr}
function! s:sort_by(list, expr) abort
let pairs = map(a:list, printf('[v:val, %s]', a:expr))
return map(s:sort(pairs,
\ 'a:a[1] ==# a:b[1] ? 0 : a:a[1] ># a:b[1] ? 1 : -1'), 'v:val[0]')
endfunction
" Returns a maximum value in {list} through given {expr}.
" Returns 0 if {list} is empty.
" v:val is used in {expr}
function! s:max_by(list, expr) abort
if empty(a:list)
return 0
endif
let list = map(copy(a:list), a:expr)
return a:list[index(list, max(list))]
endfunction
" Returns a minimum value in {list} through given {expr}.
" Returns 0 if {list} is empty.
" v:val is used in {expr}
" FIXME: -0x80000000 == 0x80000000
function! s:min_by(list, expr) abort
return s:max_by(a:list, '-(' . a:expr . ')')
endfunction
" Returns List of character sequence between [a:from, a:to]
" e.g.: s:char_range('a', 'c') returns ['a', 'b', 'c']
function! s:char_range(from, to) abort
return map(
\ range(char2nr(a:from), char2nr(a:to)),
\ 'nr2char(v:val)'
\)
endfunction
" Returns true if a:list has a:value.
" Returns false otherwise.
function! s:has(list, value) abort
return index(a:list, a:value) isnot -1
endfunction
" Returns true if a:list[a:index] exists.
" Returns false otherwise.
" NOTE: Returns false when a:index is negative number.
function! s:has_index(list, index) abort
" Return true when negative index?
" let index = a:index >= 0 ? a:index : len(a:list) + a:index
return 0 <= a:index && a:index < len(a:list)
endfunction
" similar to Haskell's Data.List.span
function! s:span(f, xs) abort
let border = len(a:xs)
for i in range(len(a:xs))
if !eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g'))
let border = i
break
endif
endfor
return border == 0 ? [[], copy(a:xs)] : [a:xs[: border - 1], a:xs[border :]]
endfunction
" similar to Haskell's Data.List.break
function! s:break(f, xs) abort
return s:span(printf('!(%s)', a:f), a:xs)
endfunction
" similar to Haskell's Data.List.takeWhile
function! s:take_while(f, xs) abort
return s:span(a:f, a:xs)[0]
endfunction
" similar to Haskell's Data.List.partition
function! s:partition(f, xs) abort
return [filter(copy(a:xs), a:f), filter(copy(a:xs), '!(' . a:f . ')')]
endfunction
" similar to Haskell's Prelude.all
function! s:all(f, xs) abort
return !s:any(printf('!(%s)', a:f), a:xs)
endfunction
" similar to Haskell's Prelude.any
function! s:any(f, xs) abort
return !empty(filter(map(copy(a:xs), a:f), 'v:val'))
endfunction
" similar to Haskell's Prelude.and
function! s:and(xs) abort
return s:all('v:val', a:xs)
endfunction
" similar to Haskell's Prelude.or
function! s:or(xs) abort
return s:any('v:val', a:xs)
endfunction
function! s:map_accum(expr, xs, init) abort
let memo = []
let init = a:init
for x in a:xs
let expr = substitute(a:expr, 'v:memo', init, 'g')
let expr = substitute(expr, 'v:val', x, 'g')
let [tmp, init] = eval(expr)
call add(memo, tmp)
endfor
return memo
endfunction
" similar to Haskell's Prelude.foldl
function! s:foldl(f, init, xs) abort
let memo = a:init
for x in a:xs
let expr = substitute(a:f, 'v:val', string(x), 'g')
let expr = substitute(expr, 'v:memo', string(memo), 'g')
unlet memo
let memo = eval(expr)
endfor
return memo
endfunction
" similar to Haskell's Prelude.foldl1
function! s:foldl1(f, xs) abort
if len(a:xs) == 0
throw 'vital: Data.List: foldl1'
endif
return s:foldl(a:f, a:xs[0], a:xs[1:])
endfunction
" similar to Haskell's Prelude.foldr
function! s:foldr(f, init, xs) abort
return s:foldl(a:f, a:init, reverse(copy(a:xs)))
endfunction
" similar to Haskell's Prelude.fold11
function! s:foldr1(f, xs) abort
if len(a:xs) == 0
throw 'vital: Data.List: foldr1'
endif
return s:foldr(a:f, a:xs[-1], a:xs[0:-2])
endfunction
" similar to python's zip()
function! s:zip(...) abort
return map(range(min(map(copy(a:000), 'len(v:val)'))), "map(copy(a:000), 'v:val['.v:val.']')")
endfunction
" similar to zip(), but goes until the longer one.
function! s:zip_fill(xs, ys, filler) abort
if empty(a:xs) && empty(a:ys)
return []
elseif empty(a:ys)
return s:cons([a:xs[0], a:filler], s:zip_fill(a:xs[1 :], [], a:filler))
elseif empty(a:xs)
return s:cons([a:filler, a:ys[0]], s:zip_fill([], a:ys[1 :], a:filler))
else
return s:cons([a:xs[0], a:ys[0]], s:zip_fill(a:xs[1 :], a:ys[1: ], a:filler))
endif
endfunction
" Inspired by Ruby's with_index method.
function! s:with_index(list, ...) abort
let base = a:0 > 0 ? a:1 : 0
return map(copy(a:list), '[v:val, v:key + base]')
endfunction
" similar to Ruby's detect or Haskell's find.
function! s:find(list, default, f) abort
for x in a:list
if eval(substitute(a:f, 'v:val', string(x), 'g'))
return x
endif
endfor
return a:default
endfunction
" Returns the index of the first element which satisfies the given expr.
function! s:find_index(xs, f, ...) abort
let len = len(a:xs)
let start = a:0 > 0 ? (a:1 < 0 ? len + a:1 : a:1) : 0
let default = a:0 > 1 ? a:2 : -1
if start >=# len || start < 0
return default
endif
for i in range(start, len - 1)
if eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g'))
return i
endif
endfor
return default
endfunction
" Returns the index of the last element which satisfies the given expr.
function! s:find_last_index(xs, f, ...) abort
let len = len(a:xs)
let start = a:0 > 0 ? (a:1 < 0 ? len + a:1 : a:1) : len - 1
let default = a:0 > 1 ? a:2 : -1
if start >=# len || start < 0
return default
endif
for i in range(start, 0, -1)
if eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g'))
return i
endif
endfor
return default
endfunction
" Similar to find_index but returns the list of indices satisfying the given expr.
function! s:find_indices(xs, f, ...) abort
let len = len(a:xs)
let start = a:0 > 0 ? (a:1 < 0 ? len + a:1 : a:1) : 0
let result = []
if start >=# len || start < 0
return result
endif
for i in range(start, len - 1)
if eval(substitute(a:f, 'v:val', string(a:xs[i]), 'g'))
call add(result, i)
endif
endfor
return result
endfunction
" Return non-zero if a:list1 and a:list2 have any common item(s).
" Return zero otherwise.
function! s:has_common_items(list1, list2) abort
return !empty(filter(copy(a:list1), 'index(a:list2, v:val) isnot -1'))
endfunction
function! s:intersect(list1, list2) abort
let items = []
" for funcref
for X in a:list1
if index(a:list2, X) != -1 && index(items, X) == -1
let items += [X]
endif
endfor
return items
endfunction
" similar to Ruby's group_by.
function! s:group_by(xs, f) abort
let result = {}
let list = map(copy(a:xs), printf('[v:val, %s]', a:f))
for x in list
let Val = x[0]
let key = type(x[1]) !=# type('') ? string(x[1]) : x[1]
if has_key(result, key)
call add(result[key], Val)
else
let result[key] = [Val]
endif
unlet Val
endfor
return result
endfunction
function! s:_default_compare(a, b) abort
return a:a <# a:b ? -1 : a:a ># a:b ? 1 : 0
endfunction
function! s:binary_search(list, value, ...) abort
let Predicate = a:0 >= 1 ? a:1 : 's:_default_compare'
let dic = a:0 >= 2 ? a:2 : {}
let start = 0
let end = len(a:list) - 1
while 1
if start > end
return -1
endif
let middle = (start + end) / 2
let compared = call(Predicate, [a:value, a:list[middle]], dic)
if compared < 0
let end = middle - 1
elseif compared > 0
let start = middle + 1
else
return middle
endif
endwhile
endfunction
function! s:product(lists) abort
let result = [[]]
for pool in a:lists
let tmp = []
for x in result
let tmp += map(copy(pool), 'x + [v:val]')
endfor
let result = tmp
endfor
return result
endfunction
function! s:permutations(list, ...) abort
if a:0 > 1
throw 'vital: Data.List: too many arguments'
endif
let r = a:0 == 1 ? a:1 : len(a:list)
if r > len(a:list)
return []
elseif r < 0
throw 'vital: Data.List: {r} must be non-negative integer'
endif
let n = len(a:list)
let result = []
for indices in s:product(map(range(r), 'range(n)'))
if len(s:uniq(indices)) == r
call add(result, map(indices, 'a:list[v:val]'))
endif
endfor
return result
endfunction
function! s:combinations(list, r) abort
if a:r > len(a:list)
return []
elseif a:r < 0
throw 'vital: Data:List: {r} must be non-negative integer'
endif
let n = len(a:list)
let result = []
for indices in s:permutations(range(n), a:r)
if s:sort(copy(indices), 'a:a - a:b') == indices
call add(result, map(indices, 'a:list[v:val]'))
endif
endfor
return result
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:
endif

View File

@@ -0,0 +1,572 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
" Utilities for string.
let s:save_cpo = &cpo
set cpo&vim
function! s:_vital_loaded(V) abort
let s:V = a:V
let s:P = s:V.import('Prelude')
let s:L = s:V.import('Data.List')
endfunction
function! s:_vital_depends() abort
return ['Prelude', 'Data.List']
endfunction
" Substitute a:from => a:to by string.
" To substitute by pattern, use substitute() instead.
function! s:replace(str, from, to) abort
return s:_replace(a:str, a:from, a:to, 'g')
endfunction
" Substitute a:from => a:to only once.
" cf. s:replace()
function! s:replace_first(str, from, to) abort
return s:_replace(a:str, a:from, a:to, '')
endfunction
" implement of replace() and replace_first()
function! s:_replace(str, from, to, flags) abort
return substitute(a:str, '\V'.escape(a:from, '\'), escape(a:to, '\'), a:flags)
endfunction
function! s:scan(str, pattern) abort
let list = []
call substitute(a:str, a:pattern, '\=add(list, submatch(0)) == [] ? "" : ""', 'g')
return list
endfunction
function! s:reverse(str) abort
return join(reverse(split(a:str, '.\zs')), '')
endfunction
function! s:starts_with(str, prefix) abort
return stridx(a:str, a:prefix) == 0
endfunction
function! s:ends_with(str, suffix) abort
let idx = strridx(a:str, a:suffix)
return 0 <= idx && idx + len(a:suffix) == len(a:str)
endfunction
function! s:common_head(strs) abort
if empty(a:strs)
return ''
endif
let len = len(a:strs)
if len == 1
return a:strs[0]
endif
let strs = len == 2 ? a:strs : sort(copy(a:strs))
let pat = substitute(strs[0], '.', '\="[" . escape(submatch(0), "^\\") . "]"', 'g')
return pat == '' ? '' : matchstr(strs[-1], '\C^\%[' . pat . ']')
endfunction
" Split to two elements of List. ([left, right])
" e.g.: s:split3('neocomplcache', 'compl') returns ['neo', 'compl', 'cache']
function! s:split_leftright(expr, pattern) abort
let [left, _, right] = s:split3(a:expr, a:pattern)
return [left, right]
endfunction
function! s:split3(expr, pattern) abort
let ERROR = ['', '', '']
if a:expr ==# '' || a:pattern ==# ''
return ERROR
endif
let begin = match(a:expr, a:pattern)
if begin is -1
return ERROR
endif
let end = matchend(a:expr, a:pattern)
let left = begin <=# 0 ? '' : a:expr[: begin - 1]
let right = a:expr[end :]
return [left, a:expr[begin : end-1], right]
endfunction
" Slices into strings determines the number of substrings.
" e.g.: s:nsplit("neo compl cache", 2, '\s') returns ['neo', 'compl cache']
function! s:nsplit(expr, n, ...) abort
let pattern = get(a:000, 0, '\s')
let keepempty = get(a:000, 1, 1)
let ret = []
let expr = a:expr
if a:n <= 1
return [expr]
endif
while 1
let pos = match(expr, pattern)
if pos == -1
if expr !~ pattern || keepempty
call add(ret, expr)
endif
break
elseif pos >= 0
let left = pos > 0 ? expr[:pos-1] : ''
if pos > 0 || keepempty
call add(ret, left)
endif
let ml = len(matchstr(expr, pattern))
if pos == 0 && ml == 0
let pos = 1
endif
let expr = expr[pos+ml :]
endif
if len(expr) == 0
break
endif
if len(ret) == a:n - 1
call add(ret, expr)
break
endif
endwhile
return ret
endfunction
" Returns the number of character in a:str.
" NOTE: This returns proper value
" even if a:str contains multibyte character(s).
" s:strchars(str) {{{
if exists('*strchars')
function! s:strchars(str) abort
return strchars(a:str)
endfunction
else
function! s:strchars(str) abort
return strlen(substitute(copy(a:str), '.', 'x', 'g'))
endfunction
endif "}}}
" Returns the bool of contains any multibyte character in s:str
function! s:contains_multibyte(str) abort "{{{
return strlen(a:str) != s:strchars(a:str)
endfunction "}}}
" Remove last character from a:str.
" NOTE: This returns proper value
" even if a:str contains multibyte character(s).
function! s:chop(str) abort "{{{
return substitute(a:str, '.$', '', '')
endfunction "}}}
" Remove last \r,\n,\r\n from a:str.
function! s:chomp(str) abort "{{{
return substitute(a:str, '\%(\r\n\|[\r\n]\)$', '', '')
endfunction "}}}
" wrap() and its internal functions
" * _split_by_wcswidth_once()
" * _split_by_wcswidth()
" * _concat()
" * wrap()
"
" NOTE _concat() is just a copy of Data.List.concat().
" FIXME don't repeat yourself
function! s:_split_by_wcswidth_once(body, x) abort
let fst = s:strwidthpart(a:body, a:x)
let snd = s:strwidthpart_reverse(a:body, s:wcswidth(a:body) - s:wcswidth(fst))
return [fst, snd]
endfunction
function! s:_split_by_wcswidth(body, x) abort
let memo = []
let body = a:body
while s:wcswidth(body) > a:x
let [tmp, body] = s:_split_by_wcswidth_once(body, a:x)
call add(memo, tmp)
endwhile
call add(memo, body)
return memo
endfunction
function! s:trim(str) abort
return matchstr(a:str,'^\s*\zs.\{-}\ze\s*$')
endfunction
function! s:trim_start(str) abort
return matchstr(a:str,'^\s*\zs.\{-}$')
endfunction
function! s:trim_end(str) abort
return matchstr(a:str,'^.\{-}\ze\s*$')
endfunction
function! s:wrap(str,...) abort
let _columns = a:0 > 0 ? a:1 : &columns
return s:L.concat(
\ map(split(a:str, '\r\n\|[\r\n]'), 's:_split_by_wcswidth(v:val, _columns - 1)'))
endfunction
function! s:nr2byte(nr) abort
if a:nr < 0x80
return nr2char(a:nr)
elseif a:nr < 0x800
return nr2char(a:nr/64+192).nr2char(a:nr%64+128)
else
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
endif
endfunction
function! s:nr2enc_char(charcode) abort
if &encoding == 'utf-8'
return nr2char(a:charcode)
endif
let char = s:nr2byte(a:charcode)
if strlen(char) > 1
let char = strtrans(iconv(char, 'utf-8', &encoding))
endif
return char
endfunction
function! s:nr2hex(nr) abort
let n = a:nr
let r = ""
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunction
" If a ==# b, returns -1.
" If a !=# b, returns first index of different character.
function! s:diffidx(a, b) abort
return a:a ==# a:b ? -1 : strlen(s:common_head([a:a, a:b]))
endfunction
function! s:substitute_last(expr, pat, sub) abort
return substitute(a:expr, printf('.*\zs%s', a:pat), a:sub, '')
endfunction
function! s:dstring(expr) abort
let x = substitute(string(a:expr), "^'\\|'$", '', 'g')
let x = substitute(x, "''", "'", 'g')
return printf('"%s"', escape(x, '"'))
endfunction
function! s:lines(str) abort
return split(a:str, '\r\?\n')
endfunction
function! s:_pad_with_char(str, left, right, char) abort
return repeat(a:char, a:left). a:str. repeat(a:char, a:right)
endfunction
function! s:pad_left(str, width, ...) abort
let char = get(a:, 1, ' ')
if strdisplaywidth(char) != 1
throw "vital: Data.String: Can't use non-half-width characters for padding."
endif
let left = max([0, a:width - strdisplaywidth(a:str)])
return s:_pad_with_char(a:str, left, 0, char)
endfunction
function! s:pad_right(str, width, ...) abort
let char = get(a:, 1, ' ')
if strdisplaywidth(char) != 1
throw "vital: Data.String: Can't use non-half-width characters for padding."
endif
let right = max([0, a:width - strdisplaywidth(a:str)])
return s:_pad_with_char(a:str, 0, right, char)
endfunction
function! s:pad_both_sides(str, width, ...) abort
let char = get(a:, 1, ' ')
if strdisplaywidth(char) != 1
throw "vital: Data.String: Can't use non-half-width characters for padding."
endif
let space = max([0, a:width - strdisplaywidth(a:str)])
let left = space / 2
let right = space - left
return s:_pad_with_char(a:str, left, right, char)
endfunction
function! s:pad_between_letters(str, width, ...) abort
let char = get(a:, 1, ' ')
if strdisplaywidth(char) != 1
throw "vital: Data.String: Can't use non-half-width characters for padding."
endif
let letters = split(a:str, '\zs')
let each_width = a:width / len(letters)
let str = join(map(letters, 's:pad_both_sides(v:val, each_width, char)'), '')
if a:width - strdisplaywidth(str) > 0
return char. s:pad_both_sides(str, a:width - 1, char)
endif
return str
endfunction
function! s:justify_equal_spacing(str, width, ...) abort
let char = get(a:, 1, ' ')
if strdisplaywidth(char) != 1
throw "vital: Data.String: Can't use non-half-width characters for padding."
endif
let letters = split(a:str, '\zs')
let first_letter = letters[0]
" {width w/o the first letter} / {length w/o the first letter}
let each_width = (a:width - strdisplaywidth(first_letter)) / (len(letters) - 1)
let remainder = (a:width - strdisplaywidth(first_letter)) % (len(letters) - 1)
return first_letter. join(s:L.concat([
\ map(letters[1:remainder], 's:pad_left(v:val, each_width + 1, char)'),
\ map(letters[remainder + 1:], 's:pad_left(v:val, each_width, char)')
\ ]), '')
endfunction
function! s:levenshtein_distance(str1, str2) abort
let letters1 = split(a:str1, '\zs')
let letters2 = split(a:str2, '\zs')
let length1 = len(letters1)
let length2 = len(letters2)
let distances = map(range(1, length1 + 1), 'map(range(1, length2 + 1), "0")')
for i1 in range(0, length1)
let distances[i1][0] = i1
endfor
for i2 in range(0, length2)
let distances[0][i2] = i2
endfor
for i1 in range(1, length1)
for i2 in range(1, length2)
let cost = (letters1[i1 - 1] ==# letters2[i2 - 1]) ? 0 : 1
let distances[i1][i2] = min([
\ distances[i1 - 1][i2 ] + 1,
\ distances[i1 ][i2 - 1] + 1,
\ distances[i1 - 1][i2 - 1] + cost,
\])
endfor
endfor
return distances[length1][length2]
endfunction
function! s:padding_by_displaywidth(expr, width, float) abort
let padding_char = ' '
let n = a:width - strdisplaywidth(a:expr)
if n <= 0
let n = 0
endif
if a:float < 0
return a:expr . repeat(padding_char, n)
elseif 0 < a:float
return repeat(padding_char, n) . a:expr
else
if n % 2 is 0
return repeat(padding_char, n / 2) . a:expr . repeat(padding_char, n / 2)
else
return repeat(padding_char, (n - 1) / 2) . a:expr . repeat(padding_char, (n - 1) / 2) . padding_char
endif
endif
endfunction
function! s:split_by_displaywidth(expr, width, float, is_wrap) abort
if a:width is 0
return ['']
endif
let lines = []
let cs = split(a:expr, '\zs')
let cs_index = 0
let text = ''
while cs_index < len(cs)
if cs[cs_index] is "\n"
let text = s:padding_by_displaywidth(text, a:width, a:float)
let lines += [text]
let text = ''
else
let w = strdisplaywidth(text . cs[cs_index])
if w < a:width
let text .= cs[cs_index]
elseif a:width < w
let text = s:padding_by_displaywidth(text, a:width, a:float)
else
let text .= cs[cs_index]
endif
if a:width <= w
let lines += [text]
let text = ''
if a:is_wrap
if a:width < w
if a:width < strdisplaywidth(cs[cs_index])
while get(cs, cs_index, "\n") isnot "\n"
let cs_index += 1
endwhile
continue
else
let text = cs[cs_index]
endif
endif
else
while get(cs, cs_index, "\n") isnot "\n"
let cs_index += 1
endwhile
continue
endif
endif
endif
let cs_index += 1
endwhile
if !empty(text)
let lines += [ s:padding_by_displaywidth(text, a:width, a:float) ]
endif
return lines
endfunction
function! s:hash(str) abort
if exists('*sha256')
return sha256(a:str)
else
" This gives up sha256ing but just adds up char with index.
let sum = 0
for i in range(len(a:str))
let sum += char2nr(a:str[i]) * (i + 1)
endfor
return printf('%x', sum)
endif
endfunction
function! s:truncate(str, width) abort
" Original function is from mattn.
" http://github.com/mattn/googlereader-vim/tree/master
if a:str =~# '^[\x00-\x7f]*$'
return len(a:str) < a:width ?
\ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width)
endif
let ret = a:str
let width = s:wcswidth(a:str)
if width > a:width
let ret = s:strwidthpart(ret, a:width)
let width = s:wcswidth(ret)
endif
if width < a:width
let ret .= repeat(' ', a:width - width)
endif
return ret
endfunction
function! s:truncate_skipping(str, max, footer_width, separator) abort
let width = s:wcswidth(a:str)
if width <= a:max
let ret = a:str
else
let header_width = a:max - s:wcswidth(a:separator) - a:footer_width
let ret = s:strwidthpart(a:str, header_width) . a:separator
\ . s:strwidthpart_reverse(a:str, a:footer_width)
endif
return s:truncate(ret, a:max)
endfunction
function! s:strwidthpart(str, width) abort
if a:width <= 0
return ''
endif
let strarr = split(a:str, '\zs')
let width = s:wcswidth(a:str)
let index = len(strarr)
let diff = (index + 1) / 2
let rightindex = index - 1
while width > a:width
let index = max([rightindex - diff + 1, 0])
let partwidth = s:wcswidth(join(strarr[(index):(rightindex)], ''))
if width - partwidth >= a:width || diff <= 1
let width -= partwidth
let rightindex = index - 1
endif
if diff > 1
let diff = diff / 2
endif
endwhile
return index ? join(strarr[:index - 1], '') : ''
endfunction
function! s:strwidthpart_reverse(str, width) abort
if a:width <= 0
return ''
endif
let strarr = split(a:str, '\zs')
let width = s:wcswidth(a:str)
let strlen = len(strarr)
let diff = (strlen + 1) / 2
let leftindex = 0
let index = -1
while width > a:width
let index = min([leftindex + diff, strlen]) - 1
let partwidth = s:wcswidth(join(strarr[(leftindex):(index)], ''))
if width - partwidth >= a:width || diff <= 1
let width -= partwidth
let leftindex = index + 1
endif
if diff > 1
let diff = diff / 2
endif
endwhile
return index < strlen ? join(strarr[(index + 1):], '') : ''
endfunction
if v:version >= 703
" Use builtin function.
function! s:wcswidth(str) abort
return strwidth(a:str)
endfunction
else
function! s:wcswidth(str) abort
if a:str =~# '^[\x00-\x7f]*$'
return strlen(a:str)
endif
let mx_first = '^\(.\)'
let str = a:str
let width = 0
while 1
let ucs = char2nr(substitute(str, mx_first, '\1', ''))
if ucs == 0
break
endif
let width += s:_wcwidth(ucs)
let str = substitute(str, mx_first, '', '')
endwhile
return width
endfunction
" UTF-8 only.
function! s:_wcwidth(ucs) abort
let ucs = a:ucs
if (ucs >= 0x1100
\ && (ucs <= 0x115f
\ || ucs == 0x2329
\ || ucs == 0x232a
\ || (ucs >= 0x2e80 && ucs <= 0xa4cf
\ && ucs != 0x303f)
\ || (ucs >= 0xac00 && ucs <= 0xd7a3)
\ || (ucs >= 0xf900 && ucs <= 0xfaff)
\ || (ucs >= 0xfe30 && ucs <= 0xfe6f)
\ || (ucs >= 0xff00 && ucs <= 0xff60)
\ || (ucs >= 0xffe0 && ucs <= 0xffe6)
\ || (ucs >= 0x20000 && ucs <= 0x2fffd)
\ || (ucs >= 0x30000 && ucs <= 0x3fffd)
\ ))
return 2
endif
return 1
endfunction
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:
endif

View File

@@ -0,0 +1,389 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
let s:save_cpo = &cpo
set cpo&vim
if v:version ># 703 ||
\ (v:version is 703 && has('patch465'))
function! s:glob(expr) abort
return glob(a:expr, 1, 1)
endfunction
else
function! s:glob(expr) abort
let R = glob(a:expr, 1)
return split(R, '\n')
endfunction
endif
function! s:globpath(path, expr) abort
let R = globpath(a:path, a:expr, 1)
return split(R, '\n')
endfunction
" Wrapper functions for type().
let [
\ s:__TYPE_NUMBER,
\ s:__TYPE_STRING,
\ s:__TYPE_FUNCREF,
\ s:__TYPE_LIST,
\ s:__TYPE_DICT,
\ s:__TYPE_FLOAT] = [
\ type(3),
\ type(""),
\ type(function('tr')),
\ type([]),
\ type({}),
\ has('float') ? type(str2float('0')) : -1]
" __TYPE_FLOAT = -1 when -float
" This doesn't match to anything.
" Number or Float
function! s:is_numeric(Value) abort
let _ = type(a:Value)
return _ ==# s:__TYPE_NUMBER
\ || _ ==# s:__TYPE_FLOAT
endfunction
" Number
function! s:is_number(Value) abort
return type(a:Value) ==# s:__TYPE_NUMBER
endfunction
" Float
function! s:is_float(Value) abort
return type(a:Value) ==# s:__TYPE_FLOAT
endfunction
" String
function! s:is_string(Value) abort
return type(a:Value) ==# s:__TYPE_STRING
endfunction
" Funcref
function! s:is_funcref(Value) abort
return type(a:Value) ==# s:__TYPE_FUNCREF
endfunction
" List
function! s:is_list(Value) abort
return type(a:Value) ==# s:__TYPE_LIST
endfunction
" Dictionary
function! s:is_dict(Value) abort
return type(a:Value) ==# s:__TYPE_DICT
endfunction
function! s:truncate_skipping(str, max, footer_width, separator) abort
call s:_warn_deprecated("truncate_skipping", "Data.String.truncate_skipping")
let width = s:wcswidth(a:str)
if width <= a:max
let ret = a:str
else
let header_width = a:max - s:wcswidth(a:separator) - a:footer_width
let ret = s:strwidthpart(a:str, header_width) . a:separator
\ . s:strwidthpart_reverse(a:str, a:footer_width)
endif
return s:truncate(ret, a:max)
endfunction
function! s:truncate(str, width) abort
" Original function is from mattn.
" http://github.com/mattn/googlereader-vim/tree/master
call s:_warn_deprecated("truncate", "Data.String.truncate")
if a:str =~# '^[\x00-\x7f]*$'
return len(a:str) < a:width ?
\ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width)
endif
let ret = a:str
let width = s:wcswidth(a:str)
if width > a:width
let ret = s:strwidthpart(ret, a:width)
let width = s:wcswidth(ret)
endif
if width < a:width
let ret .= repeat(' ', a:width - width)
endif
return ret
endfunction
function! s:strwidthpart(str, width) abort
call s:_warn_deprecated("strwidthpart", "Data.String.strwidthpart")
if a:width <= 0
return ''
endif
let ret = a:str
let width = s:wcswidth(a:str)
while width > a:width
let char = matchstr(ret, '.$')
let ret = ret[: -1 - len(char)]
let width -= s:wcswidth(char)
endwhile
return ret
endfunction
function! s:strwidthpart_reverse(str, width) abort
call s:_warn_deprecated("strwidthpart_reverse", "Data.String.strwidthpart_reverse")
if a:width <= 0
return ''
endif
let ret = a:str
let width = s:wcswidth(a:str)
while width > a:width
let char = matchstr(ret, '^.')
let ret = ret[len(char) :]
let width -= s:wcswidth(char)
endwhile
return ret
endfunction
if v:version >= 703
" Use builtin function.
function! s:wcswidth(str) abort
call s:_warn_deprecated("wcswidth", "Data.String.wcswidth")
return strwidth(a:str)
endfunction
else
function! s:wcswidth(str) abort
call s:_warn_deprecated("wcswidth", "Data.String.wcswidth")
if a:str =~# '^[\x00-\x7f]*$'
return strlen(a:str)
end
let mx_first = '^\(.\)'
let str = a:str
let width = 0
while 1
let ucs = char2nr(substitute(str, mx_first, '\1', ''))
if ucs == 0
break
endif
let width += s:_wcwidth(ucs)
let str = substitute(str, mx_first, '', '')
endwhile
return width
endfunction
" UTF-8 only.
function! s:_wcwidth(ucs) abort
let ucs = a:ucs
if (ucs >= 0x1100
\ && (ucs <= 0x115f
\ || ucs == 0x2329
\ || ucs == 0x232a
\ || (ucs >= 0x2e80 && ucs <= 0xa4cf
\ && ucs != 0x303f)
\ || (ucs >= 0xac00 && ucs <= 0xd7a3)
\ || (ucs >= 0xf900 && ucs <= 0xfaff)
\ || (ucs >= 0xfe30 && ucs <= 0xfe6f)
\ || (ucs >= 0xff00 && ucs <= 0xff60)
\ || (ucs >= 0xffe0 && ucs <= 0xffe6)
\ || (ucs >= 0x20000 && ucs <= 0x2fffd)
\ || (ucs >= 0x30000 && ucs <= 0x3fffd)
\ ))
return 2
endif
return 1
endfunction
endif
let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95')
let s:is_cygwin = has('win32unix')
let s:is_mac = !s:is_windows && !s:is_cygwin
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
\ (!isdirectory('/proc') && executable('sw_vers')))
let s:is_unix = has('unix')
function! s:is_windows() abort
return s:is_windows
endfunction
function! s:is_cygwin() abort
return s:is_cygwin
endfunction
function! s:is_mac() abort
return s:is_mac
endfunction
function! s:is_unix() abort
return s:is_unix
endfunction
function! s:_warn_deprecated(name, alternative) abort
try
echohl Error
echomsg "Prelude." . a:name . " is deprecated! Please use " . a:alternative . " instead."
finally
echohl None
endtry
endfunction
function! s:smart_execute_command(action, word) abort
execute a:action . ' ' . (a:word == '' ? '' : '`=a:word`')
endfunction
function! s:escape_file_searching(buffer_name) abort
return escape(a:buffer_name, '*[]?{}, ')
endfunction
function! s:escape_pattern(str) abort
return escape(a:str, '~"\.^$[]*')
endfunction
function! s:getchar(...) abort
let c = call('getchar', a:000)
return type(c) == type(0) ? nr2char(c) : c
endfunction
function! s:getchar_safe(...) abort
let c = s:input_helper('getchar', a:000)
return type(c) == type("") ? c : nr2char(c)
endfunction
function! s:input_safe(...) abort
return s:input_helper('input', a:000)
endfunction
function! s:input_helper(funcname, args) abort
let success = 0
if inputsave() !=# success
throw 'vital: Prelude: inputsave() failed'
endif
try
return call(a:funcname, a:args)
finally
if inputrestore() !=# success
throw 'vital: Prelude: inputrestore() failed'
endif
endtry
endfunction
function! s:set_default(var, val) abort
if !exists(a:var) || type({a:var}) != type(a:val)
let {a:var} = a:val
endif
endfunction
function! s:substitute_path_separator(path) abort
return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path
endfunction
function! s:path2directory(path) abort
return s:substitute_path_separator(isdirectory(a:path) ? a:path : fnamemodify(a:path, ':p:h'))
endfunction
function! s:_path2project_directory_git(path) abort
let parent = a:path
while 1
let path = parent . '/.git'
if isdirectory(path) || filereadable(path)
return parent
endif
let next = fnamemodify(parent, ':h')
if next == parent
return ''
endif
let parent = next
endwhile
endfunction
function! s:_path2project_directory_svn(path) abort
let search_directory = a:path
let directory = ''
let find_directory = s:escape_file_searching(search_directory)
let d = finddir('.svn', find_directory . ';')
if d == ''
return ''
endif
let directory = fnamemodify(d, ':p:h:h')
" Search parent directories.
let parent_directory = s:path2directory(
\ fnamemodify(directory, ':h'))
if parent_directory != ''
let d = finddir('.svn', parent_directory . ';')
if d != ''
let directory = s:_path2project_directory_svn(parent_directory)
endif
endif
return directory
endfunction
function! s:_path2project_directory_others(vcs, path) abort
let vcs = a:vcs
let search_directory = a:path
let find_directory = s:escape_file_searching(search_directory)
let d = finddir(vcs, find_directory . ';')
if d == ''
return ''
endif
return fnamemodify(d, ':p:h:h')
endfunction
function! s:path2project_directory(path, ...) abort
let is_allow_empty = get(a:000, 0, 0)
let search_directory = s:path2directory(a:path)
let directory = ''
" Search VCS directory.
for vcs in ['.git', '.bzr', '.hg', '.svn']
if vcs ==# '.git'
let directory = s:_path2project_directory_git(search_directory)
elseif vcs ==# '.svn'
let directory = s:_path2project_directory_svn(search_directory)
else
let directory = s:_path2project_directory_others(vcs, search_directory)
endif
if directory != ''
break
endif
endfor
" Search project file.
if directory == ''
for d in ['build.xml', 'prj.el', '.project', 'pom.xml', 'package.json',
\ 'Makefile', 'configure', 'Rakefile', 'NAnt.build',
\ 'P4CONFIG', 'tags', 'gtags']
let d = findfile(d, s:escape_file_searching(search_directory) . ';')
if d != ''
let directory = fnamemodify(d, ':p:h')
break
endif
endfor
endif
if directory == ''
" Search /src/ directory.
let base = s:substitute_path_separator(search_directory)
if base =~# '/src/'
let directory = base[: strridx(base, '/src/') + 3]
endif
endif
if directory == '' && !is_allow_empty
" Use original path.
let directory = search_directory
endif
return s:substitute_path_separator(directory)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:
endif

View File

@@ -0,0 +1,185 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
" TODO: move all comments to doc file.
"
"
" FIXME: This module name should be Vital.System ?
" But the name has been already taken.
let s:save_cpo = &cpo
set cpo&vim
" FIXME: Unfortunately, can't use s:_vital_loaded() for this purpose.
" Because these variables are used when this script file is loaded.
let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95')
let s:is_unix = has('unix')
" As of 7.4.122, the system()'s 1st argument is converted internally by Vim.
" Note that Patch 7.4.122 does not convert system()'s 2nd argument and
" return-value. We must convert them manually.
let s:need_trans = v:version < 704 || (v:version == 704 && !has('patch122'))
let s:TYPE_DICT = type({})
let s:TYPE_LIST = type([])
let s:TYPE_STRING = type("")
" Execute program in the background from Vim.
" Return an empty string always.
"
" If a:expr is a List, shellescape() each argument.
" If a:expr is a String, the arguments are passed as-is.
"
" Windows:
" Using :!start , execute program without via cmd.exe.
" Spawning 'expr' with 'noshellslash'
" keep special characters from unwanted expansion.
" (see :help shellescape())
"
" Unix:
" using :! , execute program in the background by shell.
function! s:spawn(expr, ...) abort
let shellslash = 0
if s:is_windows
let shellslash = &l:shellslash
setlocal noshellslash
endif
try
if type(a:expr) is s:TYPE_LIST
let special = 1
let cmdline = join(map(a:expr, 'shellescape(v:val, special)'), ' ')
elseif type(a:expr) is s:TYPE_STRING
let cmdline = a:expr
if a:0 && a:1
" for :! command
let cmdline = substitute(cmdline, '\([!%#]\|<[^<>]\+>\)', '\\\1', 'g')
endif
else
throw 'Process.spawn(): invalid argument (value type:'.type(a:expr).')'
endif
if s:is_windows
silent execute '!start' cmdline
else
silent execute '!' cmdline '&'
endif
finally
if s:is_windows
let &l:shellslash = shellslash
endif
endtry
return ''
endfunction
" iconv() wrapper for safety.
function! s:iconv(expr, from, to) abort
if a:from == '' || a:to == '' || a:from ==? a:to
return a:expr
endif
let result = iconv(a:expr, a:from, a:to)
return result != '' ? result : a:expr
endfunction
" Check vimproc.
function! s:has_vimproc() abort
if !exists('s:exists_vimproc')
try
call vimproc#version()
let s:exists_vimproc = 1
catch
let s:exists_vimproc = 0
endtry
endif
return s:exists_vimproc
endfunction
" * {command} [, {input} [, {timeout}]]
" * {command} [, {dict}]
" {dict} = {
" use_vimproc: bool,
" input: string,
" timeout: bool,
" background: bool,
" }
function! s:system(str, ...) abort
" Process optional arguments at first
" because use_vimproc is required later
" for a:str argument.
let input = ''
let use_vimproc = s:has_vimproc()
let background = 0
let args = []
if a:0 ==# 1
" {command} [, {dict}]
" a:1 = {dict}
if type(a:1) is s:TYPE_DICT
if has_key(a:1, 'use_vimproc')
let use_vimproc = a:1.use_vimproc
endif
if has_key(a:1, 'input')
let args += [s:iconv(a:1.input, &encoding, 'char')]
endif
if use_vimproc && has_key(a:1, 'timeout')
" ignores timeout unless you have vimproc.
let args += [a:1.timeout]
endif
if has_key(a:1, 'background')
let background = a:1.background
endif
elseif type(a:1) is s:TYPE_STRING
let args += [s:iconv(a:1, &encoding, 'char')]
else
throw 'Process.system(): invalid argument (value type:'.type(a:1).')'
endif
elseif a:0 >= 2
" {command} [, {input} [, {timeout}]]
" a:000 = [{input} [, {timeout}]]
let [input; rest] = a:000
let input = s:iconv(input, &encoding, 'char')
let args += [input] + rest
endif
" Process a:str argument.
if type(a:str) is s:TYPE_LIST
let expr = use_vimproc ? '"''" . v:val . "''"' : 's:shellescape(v:val)'
let command = join(map(copy(a:str), expr), ' ')
elseif type(a:str) is s:TYPE_STRING
let command = a:str
else
throw 'Process.system(): invalid argument (value type:'.type(a:str).')'
endif
if s:need_trans
let command = s:iconv(command, &encoding, 'char')
endif
let args = [command] + args
if background && (use_vimproc || !s:is_windows)
let args[0] = args[0] . ' &'
endif
let funcname = use_vimproc ? 'vimproc#system' : 'system'
let output = call(funcname, args)
let output = s:iconv(output, 'char', &encoding)
return output
endfunction
function! s:get_last_status() abort
return s:has_vimproc() ?
\ vimproc#get_last_status() : v:shell_error
endfunction
if s:is_windows
function! s:shellescape(command) abort
return substitute(a:command, '[&()[\]{}^=;!''+,`~]', '^\0', 'g')
endfunction
else
function! s:shellescape(...) abort
return call('shellescape', a:000)
endfunction
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:
endif

View File

@@ -0,0 +1,112 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
let s:save_cpo = &cpo
set cpo&vim
function! s:_true() abort
return 1
endfunction
function! s:_false() abort
return 0
endfunction
function! s:_null() abort
return 0
endfunction
let s:const = {}
let s:const.true = function('s:_true')
let s:const.false = function('s:_false')
let s:const.null = function('s:_null')
function! s:_resolve(val, prefix) abort
let t = type(a:val)
if t == type('')
let m = matchlist(a:val, '^' . a:prefix . '\(null\|true\|false\)$')
if !empty(m)
return s:const[m[1]]
endif
elseif t == type([]) || t == type({})
return map(a:val, 's:_resolve(v:val, a:prefix)')
endif
return a:val
endfunction
function! s:_vital_created(module) abort
" define constant variables
call extend(a:module, s:const)
endfunction
function! s:_vital_loaded(V) abort
let s:V = a:V
let s:string = s:V.import('Data.String')
endfunction
function! s:_vital_depends() abort
return ['Data.String']
endfunction
" @vimlint(EVL102, 1, l:null)
" @vimlint(EVL102, 1, l:true)
" @vimlint(EVL102, 1, l:false)
function! s:decode(json, ...) abort
let settings = extend({
\ 'use_token': 0,
\}, get(a:000, 0, {}))
let json = iconv(a:json, "utf-8", &encoding)
let json = join(split(json, "\n"), '')
let json = substitute(json, '\\u34;', '\\"', 'g')
let json = substitute(json, '\\u\(\x\x\x\x\)', '\=s:string.nr2enc_char("0x".submatch(1))', 'g')
if settings.use_token
let prefix = '__Web.JSON__'
while stridx(json, prefix) != -1
let prefix .= '_'
endwhile
let [null,true,false] = map(['null','true','false'], 'prefix . v:val')
sandbox return s:_resolve(eval(json), prefix)
else
let [null,true,false] = [s:const.null(),s:const.true(),s:const.false()]
sandbox return eval(json)
endif
endfunction
" @vimlint(EVL102, 0, l:null)
" @vimlint(EVL102, 0, l:true)
" @vimlint(EVL102, 0, l:false)
function! s:encode(val) abort
if type(a:val) == 0
return a:val
elseif type(a:val) == 1
let json = '"' . escape(a:val, '\"') . '"'
let json = substitute(json, "\r", '\\r', 'g')
let json = substitute(json, "\n", '\\n', 'g')
let json = substitute(json, "\t", '\\t', 'g')
return iconv(json, &encoding, "utf-8")
elseif type(a:val) == 2
if s:const.true == a:val
return 'true'
elseif s:const.false == a:val
return 'false'
elseif s:const.null == a:val
return 'null'
else
" backward compatibility
return string(a:val)
endif
elseif type(a:val) == 3
return '[' . join(map(copy(a:val), 's:encode(v:val)'), ',') . ']'
elseif type(a:val) == 4
return '{' . join(map(keys(a:val), 's:encode(v:val).":".s:encode(a:val[v:val])'), ',') . '}'
else
return string(a:val)
endif
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:
endif

View File

@@ -1,9 +1,9 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1
" Vim completion for HTML5 data file " Vim completion for HTML5 data file
" Language: HTML5 " Language: HTML (version 5.1 Draft 2016 Jan 13)
" Maintainer: othree <othree@gmail.com> " Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com )
" Last Change: 2011 Apr 9 " Last Change: 2016 Jan 20
" Lang Tag: {{{ " Lang Tag: {{{
@@ -598,9 +598,13 @@ let g:xmldata_html5 = {
\ global_attributes \ global_attributes
\ ], \ ],
\ 'menu': [ \ 'menu': [
\ flow_elements + ['li'], \ flow_elements + ['menuitem'],
\ extend(copy(global_attributes), {'type': ['toolbar', 'context'], 'label': []}) \ extend(copy(global_attributes), {'type': ['toolbar', 'context'], 'label': []})
\ ], \ ],
\ 'menuitem': [
\ flow_elements + ['li'],
\ extend(copy(global_attributes), {'type': ['toolbar', 'context'], 'label': [], 'icon': [], 'disabled': [], 'checked': [], 'radiogroup': [], 'default': [], 'command': []})
\ ],
\ 'meta': [ \ 'meta': [
\ [], \ [],
\ extend(copy(global_attributes), {'name': ['application-name', 'author', 'description', 'generator', 'referrer', 'creator', 'googlebot', 'publisher', 'robots', 'slurp', 'viewport', 'theme-color'], 'http-equiv': ['refresh', 'default-style', 'content-type'], 'content': [], 'charset': charset}) \ extend(copy(global_attributes), {'name': ['application-name', 'author', 'description', 'generator', 'referrer', 'creator', 'googlebot', 'publisher', 'robots', 'slurp', 'viewport', 'theme-color'], 'http-equiv': ['refresh', 'default-style', 'content-type'], 'content': [], 'charset': charset})

16
build
View File

@@ -104,6 +104,8 @@ PACKS="
cjsx:mtscout6/vim-cjsx cjsx:mtscout6/vim-cjsx
clojure:guns/vim-clojure-static clojure:guns/vim-clojure-static
coffee-script:kchmck/vim-coffee-script coffee-script:kchmck/vim-coffee-script
cryptol:victoredwardocallaghan/cryptol.vim
crystal:rhysd/vim-crystal
cql:elubow/cql-vim cql:elubow/cql-vim
css:JulesWang/css.vim css:JulesWang/css.vim
cucumber:tpope/vim-cucumber cucumber:tpope/vim-cucumber
@@ -114,6 +116,7 @@ PACKS="
emberscript:heartsentwined/vim-ember-script emberscript:heartsentwined/vim-ember-script
emblem:heartsentwined/vim-emblem emblem:heartsentwined/vim-emblem
erlang:vim-erlang/vim-erlang-runtime erlang:vim-erlang/vim-erlang-runtime
fish:dag/vim-fish
git:tpope/vim-git git:tpope/vim-git
glsl:tikhomirov/vim-glsl glsl:tikhomirov/vim-glsl
go:fatih/vim-go:_BASIC go:fatih/vim-go:_BASIC
@@ -123,10 +126,8 @@ PACKS="
haskell:neovimhaskell/haskell-vim haskell:neovimhaskell/haskell-vim
haxe:yaymukund/vim-haxe haxe:yaymukund/vim-haxe
html5:othree/html5.vim html5:othree/html5.vim
jade:digitaltoad/vim-jade
jasmine:glanotte/vim-jasmine jasmine:glanotte/vim-jasmine
javascript:sheerun/yajs.vim javascript:pangloss/vim-javascript
jinja:Glench/Vim-Jinja2-Syntax
json:sheerun/vim-json json:sheerun/vim-json
jst:briancollins/vim-jst jst:briancollins/vim-jst
jsx:mxw/vim-jsx:_ALL jsx:mxw/vim-jsx:_ALL
@@ -137,16 +138,21 @@ PACKS="
liquid:tpope/vim-liquid liquid:tpope/vim-liquid
markdown:tpope/vim-markdown markdown:tpope/vim-markdown
nginx:nginx/nginx::/contrib/vim/ nginx:nginx/nginx::/contrib/vim/
nim:zah/nim.vim:_BASIC
nix:spwhitt/vim-nix nix:spwhitt/vim-nix
objc:b4winckler/vim-objc objc:b4winckler/vim-objc
ocaml:jrk/vim-ocaml ocaml:jrk/vim-ocaml
octave:vim-scripts/octave.vim-- octave:vim-scripts/octave.vim--
opencl:petRUShka/vim-opencl opencl:petRUShka/vim-opencl
perl:vim-perl/vim-perl perl:vim-perl/vim-perl
pgsql:exu/pgsql.vim
php:StanAngeloff/php.vim php:StanAngeloff/php.vim
plantuml:aklt/plantuml-syntax
powershell:Persistent13/vim-ps1 powershell:Persistent13/vim-ps1
protobuf:uarun/vim-protobuf protobuf:uarun/vim-protobuf
puppet:rodjek/vim-puppet pug:digitaltoad/vim-pug
puppet:voxpupuli/vim-puppet
purescript:raichoo/purescript-vim
python:mitsuhiko/vim-python-combined python:mitsuhiko/vim-python-combined
qml:peterhoeg/vim-qml qml:peterhoeg/vim-qml
r-lang:vim-scripts/R.vim r-lang:vim-scripts/R.vim
@@ -166,7 +172,7 @@ PACKS="
tmux:tejr/vim-tmux tmux:tejr/vim-tmux
tomdoc:wellbredgrapefruit/tomdoc.vim tomdoc:wellbredgrapefruit/tomdoc.vim
toml:cespare/vim-toml toml:cespare/vim-toml
twig:beyondwords/vim-twig twig:evidens/vim-twig
typescript:leafgarland/typescript-vim typescript:leafgarland/typescript-vim
vala:tkztmk/vim-vala vala:tkztmk/vim-vala
vbnet:vim-scripts/vbnet.vim vbnet:vim-scripts/vbnet.vim

24
compiler/cryptol.vim Normal file
View File

@@ -0,0 +1,24 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cryptol') == -1
" Vim compiler file
" Compiler: Cryptol version 1.8.19-academic Compiler
" Maintainer: Edward O'Callaghan <victoredwardocallaghan AT gmail DOT com>
" Latest Revision: 25-Apr-2013
if exists("current_compiler")
finish
endif
let current_compiler = "cryptol"
if exists(":CompilerSet") != 2
command = -nargs =* CompilerSet setlocal <args>
endif
" TODO: Work out errorformat for the Cryptol compiler, see
" :help errorformat
CompilerSet errorformat& " use the default 'errorformat'
" "%<" means the current file name without extension.
CompilerSet makeprg=cryptol\ -o\ %<\ %
endif

View File

@@ -1,10 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim compiler file
" Language: ExUnit
" Maintainer: Rein Henrichs <rein.henrichs@gmail.com>
" URL: https://github.com/elixir-lang/vim-elixir
if exists("current_compiler") if exists("current_compiler")
finish finish
endif endif

11
compiler/fish.vim Normal file
View File

@@ -0,0 +1,11 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
if exists('current_compiler')
finish
endif
let current_compiler = 'fish'
CompilerSet makeprg=fish\ --no-execute\ %
execute 'CompilerSet errorformat='.escape(fish#errorformat(), ' ')
endif

27
compiler/nim.vim Normal file
View File

@@ -0,0 +1,27 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
if exists("current_compiler")
finish
endif
let current_compiler = "nim"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
let s:cpo_save = &cpo
set cpo-=C
CompilerSet makeprg=nim\ c\ $*
CompilerSet errorformat=
\%-GHint:\ %m,
\%E%f(%l\\,\ %c)\ Error:\ %m,
\%W%f(%l\\,\ %c)\ Hint:\ %m
let &cpo = s:cpo_save
unlet s:cpo_save
endif

View File

@@ -1,15 +1,17 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ansible') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ansible') == -1
function! DetectAnsible() function! s:isAnsible()
let filepath = expand("%:p") let filepath = expand("%:p")
let filename = expand("%:t") let filename = expand("%:t")
if filepath =~ '\v/(tasks|roles)/.*\.ya?ml$' || filepath =~ '\v/(group|host)_vars/' || filename =~ '\v(playbook|site)\.ya?ml$' if filepath =~ '\v/(tasks|roles|handlers)/.*\.ya?ml$' | return 1 | en
set ft=ansible if filepath =~ '\v/(group|host)_vars/' | return 1 | en
endif if filename =~ '\v(playbook|site|main|local)\.ya?ml$' | return 1 | en
unlet filepath let shebang = getline(1)
unlet filename if shebang =~# '^#!.*/bin/env\s\+ansible-playbook\>' | return 1 | en
if shebang =~# '^#!.*/bin/ansible-playbook\>' | return 1 | en
return 0
endfunction endfunction
:au BufNewFile,BufRead *.yml,*yaml,*/{group,host}_vars/* call DetectAnsible() :au BufNewFile,BufRead * if s:isAnsible() | set ft=ansible | en
:au BufNewFile,BufRead *.j2 set ft=ansible_template :au BufNewFile,BufRead *.j2 set ft=ansible_template
:au BufNewFile,BufRead hosts set ft=ansible_hosts :au BufNewFile,BufRead hosts set ft=ansible_hosts
endif endif
@@ -19,7 +21,7 @@ au BufRead,BufNewFile *.ino,*.pde set filetype=arduino
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1
au BufNewFile,BufRead *.blade.php set filetype=blade autocmd BufNewFile,BufRead *.blade.php set filetype=blade
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cjsx') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cjsx') == -1
@@ -51,6 +53,19 @@ if has("autocmd")
au BufNewFile,BufRead *.cql set filetype=cql au BufNewFile,BufRead *.cql set filetype=cql
endif endif
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cryptol') == -1
au! BufRead,BufNewFile *.cry set filetype=cryptol
au! BufRead,BufNewFile *.cyl set filetype=cryptol
au! BufRead,BufNewFile *.lcry set filetype=cryptol
au! BufRead,BufNewFile *.lcyl set filetype=cryptol
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
autocmd BufNewFile,BufReadPost *.cr setlocal filetype=crystal
autocmd BufNewFile,BufReadPost Projectfile setlocal filetype=crystal
autocmd BufNewFile,BufReadPost *.ecr setlocal filetype=eruby
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cucumber') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cucumber') == -1
autocmd BufNewFile,BufReadPost *.feature,*.story set filetype=cucumber autocmd BufNewFile,BufReadPost *.feature,*.story set filetype=cucumber
@@ -65,19 +80,18 @@ au BufNewFile,BufRead Dockerfile set filetype=dockerfile
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
au BufRead,BufNewFile *.eex set filetype=eelixir au BufRead,BufNewFile *.ex,*.exs call s:setf('elixir')
au FileType eelixir setl sw=2 sts=2 et iskeyword+=!,? au BufRead,BufNewFile *.eex call s:setf('eelixir')
endif au BufRead,BufNewFile * call s:DetectElixir()
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 au FileType elixir,eelixir setl sw=2 sts=2 et iskeyword+=!,?
function! s:setf(filetype) abort
au BufRead,BufNewFile *.ex,*.exs set filetype=elixir let &filetype = a:filetype
au FileType elixir setl sw=2 sts=2 et iskeyword+=!,? endfunction
function! s:DetectElixir() function! s:DetectElixir()
if getline(1) =~ '^#!.*\<elixir\>' if getline(1) =~ '^#!.*\<elixir\>'
set filetype=elixir call s:setf('elixir')
endif endif
endfunction endfunction
autocmd BufNewFile,BufRead * call s:DetectElixir()
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
@@ -97,6 +111,22 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'erlang') == -1
au BufNewFile,BufRead *.erl,*.hrl,rebar.config,*.app,*.app.src,*.yaws,*.xrl set ft=erlang au BufNewFile,BufRead *.erl,*.hrl,rebar.config,*.app,*.app.src,*.yaws,*.xrl set ft=erlang
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
autocmd BufRead,BufNewFile *.fish setfiletype fish
autocmd BufRead *
\ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' |
\ setlocal filetype=fish |
\ endif
autocmd BufRead fish_funced_*_*.fish call search('^$')
autocmd BufRead,BufNewFile ~/.config/fish/fish_{read_,}history setfiletype yaml
autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly
autocmd BufNewFile ~/.config/fish/functions/*.fish
\ call append(0, ['function '.expand('%:t:r'),
\'',
\'end']) |
\ 2
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1
autocmd BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG set ft=gitcommit autocmd BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG set ft=gitcommit
@@ -126,19 +156,22 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
let s:current_fileformats = '' let s:current_fileformats = ''
let s:current_fileencodings = '' let s:current_fileencodings = ''
function! s:gofiletype_pre() function! s:gofiletype_pre(type)
let s:current_fileformats = &g:fileformats let s:current_fileformats = &g:fileformats
let s:current_fileencodings = &g:fileencodings let s:current_fileencodings = &g:fileencodings
set fileencodings=utf-8 fileformats=unix set fileencodings=utf-8 fileformats=unix
setlocal filetype=go let &l:filetype = a:type
endfunction endfunction
function! s:gofiletype_post() function! s:gofiletype_post()
let &g:fileformats = s:current_fileformats let &g:fileformats = s:current_fileformats
let &g:fileencodings = s:current_fileencodings let &g:fileencodings = s:current_fileencodings
endfunction endfunction
au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix
au BufRead *.go call s:gofiletype_pre() au BufRead *.go call s:gofiletype_pre("go")
au BufReadPost *.go call s:gofiletype_post() au BufReadPost *.go call s:gofiletype_post()
au BufNewFile *.s setfiletype asm | setlocal fileencoding=utf-8 fileformat=unix
au BufRead *.s call s:gofiletype_pre("asm")
au BufReadPost *.s call s:gofiletype_post()
au BufRead,BufNewFile *.tmpl set filetype=gohtmltmpl au BufRead,BufNewFile *.tmpl set filetype=gohtmltmpl
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haml') == -1
@@ -155,14 +188,22 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haxe') == -1
autocmd BufNewFile,BufRead *.hx setf haxe autocmd BufNewFile,BufRead *.hx setf haxe
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1
autocmd BufNewFile,BufReadPost *.jade set filetype=jade
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jasmine') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jasmine') == -1
autocmd BufNewFile,BufRead *Spec.js,*_spec.js set filetype=jasmine.javascript syntax=jasmine autocmd BufNewFile,BufRead *Spec.js,*_spec.js set filetype=jasmine.javascript syntax=jasmine
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1
au BufNewFile,BufRead *.js setf javascript
au BufNewFile,BufRead *.jsm setf javascript
au BufNewFile,BufRead Jakefile setf javascript
fun! s:SelectJavascript()
if getline(1) =~# '^#!.*/bin/env\s\+node\>'
set ft=javascript
endif
endfun
au BufNewFile,BufRead * call s:SelectJavascript()
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
if !exists('g:jsx_ext_required') if !exists('g:jsx_ext_required')
@@ -187,22 +228,6 @@ autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx
autocmd BufNewFile,BufRead *.js autocmd BufNewFile,BufRead *.js
\ if <SID>EnableJSX() | set filetype=javascript.jsx | endif \ if <SID>EnableJSX() | set filetype=javascript.jsx | endif
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1
fun! s:SelectHTML()
let n = 1
while n < 50 && n <= line("$")
" check for jinja
if getline(n) =~ '{{.*}}\|{%-\?\s*\(end.*\|extends\|block\|macro\|set\|if\|for\|include\|trans\)\>'
set ft=jinja
return
endif
let n = n + 1
endwhile
endfun
autocmd BufNewFile,BufRead *.html,*.htm,*.nunjucks,*.nunjs call s:SelectHTML()
autocmd BufNewFile,BufRead *.jinja2,*.j2,*.jinja set ft=jinja
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'json') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'json') == -1
autocmd BufNewFile,BufRead *.json set filetype=json autocmd BufNewFile,BufRead *.json set filetype=json
@@ -275,6 +300,10 @@ au BufRead,BufNewFile */etc/nginx/* set ft=nginx
au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx
au BufRead,BufNewFile nginx.conf set ft=nginx au BufRead,BufNewFile nginx.conf set ft=nginx
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
au BufNewFile,BufRead *.nim set filetype=nim
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
autocmd BufNewFile,BufRead *.nix setfiletype nix autocmd BufNewFile,BufRead *.nix setfiletype nix
@@ -314,6 +343,18 @@ endfunction
autocmd BufReadPost *.pl,*.pm,*.t call s:DetectPerl6() autocmd BufReadPost *.pl,*.pm,*.t call s:DetectPerl6()
autocmd BufNew,BufNewFile,BufRead *.nqp setf perl6 autocmd BufNew,BufNewFile,BufRead *.nqp setf perl6
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pgsql') == -1
au BufNewFile,BufRead *.pgsql setf pgsql
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'plantuml') == -1
if did_filetype()
finish
endif
autocmd BufRead,BufNewFile * :if getline(1) =~ '^.*startuml.*$'| setfiletype plantuml | endif
autocmd BufRead,BufNewFile *.pu,*.uml,*.plantuml set filetype=plantuml
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'protobuf') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'protobuf') == -1
autocmd BufNewFile,BufRead *.proto setfiletype proto autocmd BufNewFile,BufRead *.proto setfiletype proto
@@ -328,11 +369,21 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'powershell') ==
au BufNewFile,BufRead *.ps1xml set ft=ps1xml au BufNewFile,BufRead *.ps1xml set ft=ps1xml
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pug') == -1
autocmd BufNewFile,BufReadPost *.pug set filetype=pug
autocmd BufNewFile,BufReadPost *.jade set filetype=pug
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'puppet') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'puppet') == -1
au! BufRead,BufNewFile *.pp setfiletype puppet au! BufRead,BufNewFile *.pp setfiletype puppet
au! BufRead,BufNewFile Puppetfile setfiletype ruby au! BufRead,BufNewFile Puppetfile setfiletype ruby
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'purescript') == -1
au BufNewFile,BufRead *.purs setf purescript
au FileType purescript let &l:commentstring='{--%s--}'
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'qml') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'qml') == -1
autocmd BufRead,BufNewFile *.qml setfiletype qml autocmd BufRead,BufNewFile *.qml setfiletype qml
@@ -403,7 +454,7 @@ autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'swift') == -1
autocmd BufNewFile,BufRead *.swift setfiletype swift autocmd BufNewFile,BufRead *.swift set filetype=swift
autocmd BufRead * call s:Swift() autocmd BufRead * call s:Swift()
function! s:Swift() function! s:Swift()
if !empty(&filetype) if !empty(&filetype)
@@ -444,11 +495,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'toml') == -1
autocmd BufNewFile,BufRead *.toml set filetype=toml autocmd BufNewFile,BufRead *.toml set filetype=toml
autocmd BufNewFile,BufRead Cargo.lock set filetype=toml autocmd BufNewFile,BufRead Cargo.lock set filetype=toml
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
autocmd BufNewFile,BufRead *.twig set filetype=twig
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
autocmd BufNewFile,BufRead *.ts,*.tsx setlocal filetype=typescript autocmd BufNewFile,BufRead *.ts,*.tsx setlocal filetype=typescript

View File

@@ -0,0 +1,13 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ansible') == -1
if exists("b:did_ftplugin")
finish
else
let b:did_ftplugin = 1
endif
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions-=c
let b:undo_ftplugin = "setl comments< commentstring< formatoptions<"
endif

16
ftplugin/blade.vim Normal file
View File

@@ -0,0 +1,16 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1
" Vim filetype plugin
" Language: Blade (Laravel)
" Maintainer: Jason Walton <jwalton512@gmail.com>
if exists('b:did_ftplugin')
finish
endif
runtime! ftplugin/html.vim
let b:did_ftplugin = 1
setlocal iskeyword+=@-@
endif

View File

@@ -6,64 +6,4 @@ endif
let g:loaded_haskellvim_cabal = 1 let g:loaded_haskellvim_cabal = 1
function! s:makeSection(content)
return "\n" . join(a:content, "\n")
endfunction
function! s:exeTmpl(name, src)
let l:exetmpl = [ 'executable ' . a:name,
\ '-- ghc-options:',
\ 'main-is: ' . a:src,
\ '-- other-modules:',
\ '-- other-extensions:',
\ 'build-depends: base',
\ '-- hs-source-dirs:',
\ 'default-language: Haskell2010'
\ ]
return s:makeSection(l:exetmpl)
endfunction
function! s:libTmpl()
let l:libtmpl = [ 'library',
\ '-- ghc-options:',
\ '-- other-modules:',
\ '-- other-extensions:',
\ 'build-depends: base',
\ '-- hs-source-dirs:',
\ 'default-language: Haskell2010'
\ ]
return s:makeSection(l:libtmpl)
endfunction
function! s:flagTmpl(name)
let l:flagtmpl = [ 'flag ' . a:name,
\ 'description:',
\ 'default: False',
\ 'manual: True',
\ ]
return s:makeSection(l:flagtmpl)
endfunction
function! cabal#addExecutable()
let l:name = input("Enter executable name: ")
let l:src = input("Enter source file: ")
exe "normal Go" . s:exeTmpl(l:name, l:src)
endfunction
function! cabal#addLibrary()
exe "normal Go" . s:libTmpl()
endfunction
function! cabal#addFlag()
let l:name = input("Enter flag name: ")
exe "normal Go" . s:flagTmpl(l:name)
endfunction
command! -buffer CabalAddExecutable call cabal#addExecutable()
command! -buffer CabalAddLibrary call cabal#addLibrary()
command! -buffer CabalAddFlag call cabal#addFlag()
endif endif

View File

@@ -0,0 +1,50 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cryptol') == -1
" Copyright © 2013 Edward O'Callaghan. All Rights Reserved.
"setlocal foldmethod=indent
"setlocal foldignore=
setlocal foldmethod=expr
setlocal foldexpr=GetPotionFold(v:lnum)
" Helper function: To tackle non-blank lines,
" wish to know their indentation level
function! IndentLevel(lnum)
return indent(a:lnum) / &shiftwidth
endfunction
" Helper function: .
function! NextNonBlankLine(lnum)
let numlines = line('$')
let current = a:lnum + 1
while current <= numlines
if getline(current) =~? '\v\S'
return current
endif
let current += 1
endwhile
return -2
endfunction
function! GetPotionFold(lnum)
if getline(a:lnum) =~? '\v^\s*$'
return '-1'
endif
let this_indent = IndentLevel(a:lnum)
let next_indent = IndentLevel(NextNonBlankLine(a:lnum))
if next_indent == this_indent
return this_indent
elseif next_indent < this_indent
return this_indent
elseif next_indent > this_indent
return '>' . next_indent
endif
endfunction
endif

60
ftplugin/crystal.vim Normal file
View File

@@ -0,0 +1,60 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
if exists('b:did_ftplugin')
finish
endif
let b:did_ftplugin = 1
let s:save_cpo = &cpo
set cpo&vim
if exists('loaded_matchit') && !exists('b:match_words')
let b:match_ignorecase = 0
let b:match_words =
\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|struct\|lib\|macro\|ifdef\|def\|fun\|begin\)\>=\@!' .
\ ':' .
\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
\ ':' .
\ '\<end\>' .
\ ',{:},\[:\],(:)'
let b:match_skip =
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
\ "\\<crystal\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
\ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
\ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
endif
setlocal comments=:#
setlocal commentstring=#\ %s
setlocal suffixesadd=.cr
" Set format for quickfix window
setlocal errorformat=
\%ESyntax\ error\ in\ line\ %l:\ %m,
\%ESyntax\ error\ in\ %f:%l:\ %m,
\%EError\ in\ %f:%l:\ %m,
\%C%p^,
\%-C%.%#
if get(g:, 'crystal_define_mappings', 1)
nmap <buffer>gd <Plug>(crystal-jump-to-definition)
nmap <buffer>gc <Plug>(crystal-show-context)
nmap <buffer>gss <Plug>(crystal-spec-switch)
nmap <buffer>gsa <Plug>(crystal-spec-run-all)
nmap <buffer>gsc <Plug>(crystal-spec-run-current)
endif
if &l:ofu ==# ''
setlocal omnifunc=crystal_lang#complete
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: nowrap sw=2 sts=2 ts=8:
endif

View File

@@ -1,9 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim filetype plugin
" Language: Embedded Elixir
" URL: https://github.com/elixir-lang/vim-elixir
if exists("b:did_ftplugin") if exists("b:did_ftplugin")
finish finish
endif endif

View File

@@ -1,21 +1,15 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim filetype plugin
" Language: Elixir
" Maintainer: Carlos Galdino <carloshsgaldino@gmail.com>
" URL: https://github.com/elixir-lang/vim-elixir
if (exists("b:did_ftplugin")) if (exists("b:did_ftplugin"))
finish finish
endif endif
let b:did_ftplugin = 1 let b:did_ftplugin = 1
" Matchit support " Matchit support
if exists("loaded_matchit") && !exists("b:match_words") if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0 let b:match_ignorecase = 0
let b:match_words = '\<\%(do\|fn\)\:\@!\>' . let b:match_words = '\:\@<!\<\%(do\|fn\)\:\@!\>' .
\ ':' . \ ':' .
\ '\<\%(else\|elsif\|catch\|after\|rescue\)\:\@!\>' . \ '\<\%(else\|elsif\|catch\|after\|rescue\)\:\@!\>' .
\ ':' . \ ':' .
@@ -26,4 +20,42 @@ endif
setlocal comments=:# setlocal comments=:#
setlocal commentstring=#\ %s setlocal commentstring=#\ %s
function! GetElixirFilename(word)
let word = a:word
" get first thing that starts uppercase, until the first space or end of line
let word = substitute(word,'^\s*\(\u[^ ]\+\).*$','\1','g')
" remove any trailing characters that don't look like a nested module
let word = substitute(word,'\.\U.*$','','g')
" replace module dots with slash
let word = substitute(word,'\.','/','g')
" remove any special chars
let word = substitute(word,'[^A-z0-9-_/]','','g')
" convert to snake_case
let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g')
let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g')
let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g')
let word = substitute(word,'-','_','g')
let word = tolower(word)
return word
endfunction
let &l:path =
\ join([
\ getcwd().'/lib',
\ getcwd().'/src',
\ getcwd().'/deps/**/lib',
\ getcwd().'/deps/**/src',
\ &g:path
\ ], ',')
setlocal includeexpr=GetElixirFilename(v:fname)
setlocal suffixesadd=.ex,.exs,.eex,.erl,.yrl,.hrl
setlocal formatoptions-=t formatoptions+=croqlj
endif endif

43
ftplugin/fish.vim Normal file
View File

@@ -0,0 +1,43 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
setlocal comments=:#
setlocal commentstring=#%s
setlocal define=\\v^\\s*function>
setlocal foldexpr=fish#Fold()
setlocal formatoptions+=ron1
setlocal formatoptions-=t
setlocal include=\\v^\\s*\\.>
setlocal iskeyword=@,48-57,-,_,.,/
setlocal suffixesadd^=.fish
" Use the 'j' format option when available.
if v:version ># 703 || v:version ==# 703 && has('patch541')
setlocal formatoptions+=j
endif
if executable('fish_indent')
setlocal formatexpr=fish#Format()
endif
if executable('fish')
setlocal omnifunc=fish#Complete
for s:path in split(system("fish -c 'echo $fish_function_path'"))
execute 'setlocal path+='.s:path
endfor
else
setlocal omnifunc=syntaxcomplete#Complete
endif
" Use the 'man' wrapper function in fish to include fish's man pages.
" Have to use a script for this; 'fish -c man' would make the the man page an
" argument to fish instead of man.
execute 'setlocal keywordprg=fish\ '.expand('<sfile>:p:h:h').'/bin/man.fish'
let b:match_words =
\ escape('<%(begin|function|if|switch|while|for)>:<end>', '<>%|)')
let b:endwise_addition = 'end'
let b:endwise_words = 'begin,function,if,switch,while,for'
let b:endwise_syngroups = 'fishKeyword,fishConditional,fishRepeat'
endif

View File

@@ -14,6 +14,8 @@ let b:did_ftplugin = 1
if !exists('b:git_dir') if !exists('b:git_dir')
if expand('%:p') =~# '[\/]\.git[\/]modules[\/]' if expand('%:p') =~# '[\/]\.git[\/]modules[\/]'
" Stay out of the way " Stay out of the way
elseif expand('%:p') =~# '[\/]\.git[\/]worktrees'
let b:git_dir = matchstr(expand('%:p'),'.*\.git[\/]worktrees[\/][^\/]\+\>')
elseif expand('%:p') =~# '\.git\>' elseif expand('%:p') =~# '\.git\>'
let b:git_dir = matchstr(expand('%:p'),'.*\.git\>') let b:git_dir = matchstr(expand('%:p'),'.*\.git\>')
elseif $GIT_DIR != '' elseif $GIT_DIR != ''

View File

@@ -13,8 +13,10 @@ endif
runtime! ftplugin/git.vim runtime! ftplugin/git.vim
let b:did_ftplugin = 1 let b:did_ftplugin = 1
setlocal nomodeline tabstop=8 formatoptions-=croq formatoptions+=tl textwidth=72 setlocal comments=:# commentstring=#\ %s
let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw<' setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72
setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q
let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms<'
if exists("g:no_gitcommit_commands") || v:version < 700 if exists("g:no_gitcommit_commands") || v:version < 700
finish finish
@@ -26,6 +28,8 @@ endif
command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>) command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(<bang>0,b:git_dir,<f-args>)
let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached"
function! s:diffcomplete(A,L,P) function! s:diffcomplete(A,L,P)
let args = "" let args = ""
if a:P <= match(a:L." -- "," -- ")+3 if a:P <= match(a:L." -- "," -- ")+3

View File

@@ -14,10 +14,11 @@ runtime! ftplugin/git.vim
let b:did_ftplugin = 1 let b:did_ftplugin = 1
setlocal comments=:# commentstring=#\ %s formatoptions-=t setlocal comments=:# commentstring=#\ %s formatoptions-=t
setlocal nomodeline
if !exists("b:undo_ftplugin") if !exists("b:undo_ftplugin")
let b:undo_ftplugin = "" let b:undo_ftplugin = ""
endif endif
let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo<" let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo< ml<"
function! s:choose(word) function! s:choose(word)
s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e

View File

@@ -6,20 +6,15 @@ endif
let g:loaded_haskellvim_haskell = 1 let g:loaded_haskellvim_haskell = 1
function! haskell#makeModuleCommentBlock() function! haskell#sortImports(line1, line2)
let l:commenttmpl = [ '{-|', exe a:line1 . "," . a:line2 . "sort /import\\s\\+\\(qualified\\s\\+\\)\\?/"
\ 'Module : ',
\ 'Description : ',
\ 'Copyright : ',
\ 'License : ',
\ 'Maintainer : ',
\ 'Stability : ',
\ 'Portability : ',
\ '-}']
exe "normal ggO" . join(l:commenttmpl, "\n")
endfunction endfunction
command! -buffer -nargs=0 HaskellAddModuleComment call haskell#makeModuleCommentBlock() function! haskell#formatImport(line1, line2)
exec a:line1 . ",". a:line2 . "s/import\\s\\+\\([A-Z].*\\)/import \\1"
endfunction
command! -buffer -range HaskellSortImports call haskell#sortImports(<line1>, <line2>)
command! -buffer -range HaskellFormatImport call haskell#formatImport(<line1>, <line2>)
endif endif

View File

@@ -8,4 +8,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1
" setlocal iskeyword+=- " setlocal iskeyword+=-
setlocal commentstring=<!--%s-->
endif endif

View File

@@ -1,4 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1
setlocal suffixesadd+=.js
endif endif

View File

@@ -11,7 +11,7 @@ endif
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--%s-->
setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]: setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:

22
ftplugin/plantuml.vim Normal file
View File

@@ -0,0 +1,22 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'plantuml') == -1
" Vim plugin file
" Language: PlantUML
" Maintainer: Aaron C. Meadows < language name at shadowguarddev dot com>
" Last Change: 19-Jun-2012
" Version: 0.1
if exists("g:loaded_plantuml_plugin")
finish
endif
let g:loaded_plantuml_plugin = 1
if !exists("g:plantuml_executable_script")
let g:plantuml_executable_script="plantuml"
endif
autocmd Filetype plantuml let &l:makeprg=g:plantuml_executable_script . " " . fnameescape(expand("%"))
setlocal comments=s1:/',mb:',ex:'/,:' commentstring=/'%s'/ formatoptions-=t formatoptions+=croql
endif

View File

@@ -1,7 +1,7 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pug') == -1
" Vim filetype plugin " Vim filetype plugin
" Language: Jade " Language: Pug
" Maintainer: Joshua Borton " Maintainer: Joshua Borton
" Credits: Tim Pope " Credits: Tim Pope
@@ -39,7 +39,7 @@ endif
" Change the browse dialog on Win32 to show mainly Haml-related files " Change the browse dialog on Win32 to show mainly Haml-related files
if has("gui_win32") if has("gui_win32")
let b:browsefilter="Jade Files (*.jade)\t*.jade\n" . s:browsefilter let b:browsefilter="Pug Files (*.pug)\t*.pug\n" . s:browsefilter
endif endif
" Load the combined list of match_words for matchit.vim " Load the combined list of match_words for matchit.vim
@@ -49,7 +49,7 @@ endif
setlocal comments=://-,:// commentstring=//\ %s setlocal comments=://-,:// commentstring=//\ %s
setlocal suffixesadd+=.jade setlocal suffixesadd+=.pug
let b:undo_ftplugin = "setl cms< com< " let b:undo_ftplugin = "setl cms< com< "
\ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin

View File

@@ -6,5 +6,6 @@ setl sw=2
setl et setl et
setl keywordprg=puppet\ describe\ --providers setl keywordprg=puppet\ describe\ --providers
setl iskeyword=-,:,@,48-57,_,192-255 setl iskeyword=-,:,@,48-57,_,192-255
setl cms=#\ %s
endif endif

View File

@@ -8,14 +8,15 @@ if exists("b:did_ftplugin")
finish finish
endif endif
runtime! ftplugin/html.vim ftplugin/html*.vim ftplugin/html/*.vim
unlet! b:did_ftplugin
setlocal comments=s:{#,ex:#} setlocal comments=s:{#,ex:#}
setlocal formatoptions+=tcqln setlocal formatoptions+=tcqln
" setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+ " setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+
let b:undo_ftplugin .= "|setl cms< com< fo<" if exists("b:did_ftplugin")
let b:undo_ftplugin .= "|setlocal comments< formatoptions<"
else
let b:undo_ftplugin = "setlocal comments< formatoptions<"
endif
" vim:set sw=2: " vim:set sw=2:

View File

@@ -15,6 +15,8 @@ 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
let b:undo_ftplugin = "setl fo< ofu< com< cms<" let b:undo_ftplugin = "setl fo< ofu< com< cms<"
let &cpo = s:cpo_save let &cpo = s:cpo_save

View File

@@ -1,66 +1,59 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1
" Language: Blade " Vim indent file
" Author: Barry Deeney <sitemaster16@gmail.com> " Language: Blade (Laravel)
" Version: 0.1 " Maintainer: Jason Walton <jwalton512@gmail.com>
" Description: BLADE indent file based on HTML indentation...
" Check if this file has already been loaded
if exists("b:did_indent") if exists("b:did_indent")
finish finish
endif endif
" Include HTML
runtime! indent/html.vim runtime! indent/html.vim
runtime! indent/php.vim unlet! b:did_indent
silent! unlet b:did_indent
" What function do we need to use to detect indentation?
setlocal indentexpr=BladeIndent()
" What keys would trigger indentation?
setlocal indentkeys=o,O,<Return>,<>>,{,},!^F,0{,0},0),:,!^F,o,O,e,*<Return>,=?>,=<?,=*/
" THE MAIN INDENT FUNCTION. Return the amount of indent for v:lnum.
func! BladeIndent()
" What is the current line?
let current_line = v:lnum
" What is the current text?
let current_text = tolower(getline(current_line))
" What was the last non blank line?
let previous_line = prevnonblank(current_line)
" What was the last non blank text?
let previous_text = tolower(getline(previous_line))
" How large are indents??
let indent_size = &sw
" Check if we have a PHPIndent value...
let indent = GetPhpIndent()
" check if we have indent
if indent == -1
" Check if we have BLADE
if current_text =~ '^\s*@' || previous_text =~ '^\s*@'
" We need to add to the indent
return indent_size * indent(previous_text)
endif
" Check if we have HTML
if current_text =~ '^\s*<' || previous_text =~ '^\s*<'
" We now give the honors to HtmlIndent()
let indent = HtmlIndent()
endif
endif
" Give the indent back!
return indent
endfunc
" Make sure we store that flag!
let b:did_indent = 1 let b:did_indent = 1
setlocal autoindent
setlocal indentexpr=GetBladeIndent()
setlocal indentkeys=o,O,*<Return>,<>>,!^F,=@else,=@end,=@empty,=@show
" Only define the function once.
if exists("*GetBladeIndent")
finish
endif
function! GetBladeIndent()
let lnum = prevnonblank(v:lnum-1)
if lnum == 0
return 0
endif
let line = substitute(substitute(getline(lnum), '\s\+$', '', ''), '^\s\+', '', '')
let cline = substitute(substitute(getline(v:lnum), '\s\+$', '', ''), '^\s\+', '', '')
let indent = indent(lnum)
let cindent = indent(v:lnum)
if cline =~# '@\%(else\|elseif\|empty\|end\|show\)'
let indent = indent - &sw
else
if exists("*GetBladeIndentCustom")
let hindent = GetBladeIndentCustom()
else
let hindent = HtmlIndent()
endif
if hindent > -1
let indent = hindent
endif
endif
let increase = indent + &sw
if indent = indent(lnum)
let indent = cindent <= indent ? -1 : increase
endif
if line =~# '@\%(section\)\%(.*\s*@end\)\@!' && line !~# '@\%(section\)\s*([^,]*)'
return indent
elseif line =~# '@\%(if\|elseif\|else\|unless\|foreach\|forelse\|for\|while\|empty\|push\|section\|can\)\%(.*\s*@end\)\@!'
return increase
else
return indent
endif
endfunction
endif endif

639
indent/crystal.vim Normal file
View File

@@ -0,0 +1,639 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
" Only load this indent file when no other was loaded.
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
if !exists('g:crystal_indent_access_modifier_style')
" Possible values: "normal", "indent", "outdent"
let g:crystal_indent_access_modifier_style = 'normal'
endif
setlocal nosmartindent
" Now, set up our indentation expression and keys that trigger it.
setlocal indentexpr=GetCrystalIndent(v:lnum)
setlocal indentkeys=0{,0},0),0],!^F,o,O,e,:,.
setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end
setlocal indentkeys+==private,=protected,=public
" Only define the function once.
if exists('*GetCrystalIndent')
finish
endif
let s:cpo_save = &cpo
set cpo&vim
" 1. Variables {{{1
" ============
" Regex of syntax group names that are or delimit strings/symbols or are comments.
let s:syng_strcom = '\<crystal\%(Regexp\|RegexpDelimiter\|RegexpEscape' .
\ '\|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' .
\ '\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|Comment\|Documentation\)\>'
" Regex of syntax group names that are strings.
let s:syng_string =
\ '\<crystal\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>'
" Regex of syntax group names that are strings or documentation.
let s:syng_stringdoc =
\'\<crystal\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>'
" Expression used to check whether we should skip a match with searchpair().
let s:skip_expr =
\ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
" Regex used for words that, at the start of a line, add a level of indent.
let s:crystal_indent_keywords =
\ '^\s*\zs\<\%(module\|\%(abstract\)\=\s*\%(class\|struct\)\|enum\|if\|for\|macro' .
\ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\|lib' .
\ '\|\%(protected\|private\)\=\s*def\):\@!\>' .
\ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' .
\ '\|{%\s*\<\%(if\|for\|while\|until\|lib\|case\|unless\|begin\|else\|elsif\|when\)'
" Regex used for words that, at the start of a line, remove a level of indent.
let s:crystal_deindent_keywords =
\ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>' .
\ '\|{%\s*\<\%(ensure\|else\|rescue\|elsif\|when\|end\)\>'
" Regex that defines the start-match for the 'end' keyword.
" TODO: the do here should be restricted somewhat (only at end of line)?
let s:end_start_regex =
\ '{%\s*\<\%(if\|for\|while\|until\|unless\|begin\|lib\)\>\|' .
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(module\|\%(abstract\)\=\s*\%(class\|struct\)\|enum\|macro\|if\|for\|while\|until\|case\|unless\|begin\|lib' .
\ '\|\%(protected\|private\)\=\s*def\):\@!\>' .
\ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>'
" Regex that defines the middle-match for the 'end' keyword.
let s:end_middle_regex =
\ '{%\s*\<\%(ensure\|else\|when\|elsif\)\>\s*%}\|' .
\ '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>'
" Regex that defines the end-match for the 'end' keyword.
let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>\|{%\s*\<\%(end\)\>'
" Expression used for searchpair() call for finding match for 'end' keyword.
let s:end_skip_expr = s:skip_expr .
\ ' || (expand("<cword>") == "do"' .
\ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")'
" Regex that defines continuation lines, not including (, {, or [.
let s:non_bracket_continuation_regex = '\%([\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
" Regex that defines continuation lines.
let s:continuation_regex =
\ '\%(%\@<![({[\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
" Regex that defines continuable keywords
let s:continuable_regex =
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(if\|for\|while\|until\|unless\):\@!\>'
" Regex that defines bracket continuations
let s:bracket_continuation_regex = '%\@<!\%([({[]\)\s*\%(#.*\)\=$'
" Regex that defines end of bracket continuation followed by another continuation
let s:bracket_switch_continuation_regex = '^\([^(]\+\zs).\+\)\+'.s:continuation_regex
" Regex that defines the first part of a splat pattern
let s:splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$'
" Regex that defines blocks.
"
" Note that there's a slight problem with this regex and s:continuation_regex.
" Code like this will be matched by both:
"
" method_call do |(a, b)|
"
" The reason is that the pipe matches a hanging "|" operator.
"
let s:block_regex =
\ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|\s*(*\s*\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(*\s*[*@&]\=\h\w*\s*)*\s*\)*|\)\=\s*\%(#.*\)\=$'
let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex
" Regex that describes a leading operator (only a method call's dot for now)
let s:leading_operator_regex = '^\s*[.]'
" Regex that describes all indent access modifiers
let s:access_modifier_regex = '\C^\s*\%(public\|protected\|private\)\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
" Check if the character at lnum:col is inside a string.
function s:IsInString(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
endfunction
" Check if the character at lnum:col is inside a string or documentation.
function s:IsInStringOrDocumentation(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc
endfunction
" Check if the character at lnum:col is inside a string delimiter
function s:IsInStringDelimiter(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') ==# 'crystalStringDelimiter'
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 =~# '^=begin'
if in_block
let in_block = 0
else
break
endif
elseif !in_block && line =~# '^=end'
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
return lnum
endfunction
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
function s:GetMSL(lnum)
" Start on the line we're at and use its indent.
let msl = a:lnum
let msl_body = getline(msl)
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
while lnum > 0
" If we have a continuation line, or we're in a string, use line as MSL.
" Otherwise, terminate search as we have found our MSL already.
let line = getline(lnum)
if s:Match(msl, s:leading_operator_regex)
" If the current line starts with a leading operator, keep its indent
" and keep looking for an MSL.
let msl = lnum
elseif s:Match(lnum, s:splat_regex)
" If the above line looks like the "*" of a splat, use the current one's
" indentation.
"
" Example:
" Hash[*
" method_call do
" something
"
return msl
elseif s:Match(lnum, s:non_bracket_continuation_regex) &&
\ s:Match(msl, s:non_bracket_continuation_regex)
" If the current line is a non-bracket continuation and so is the
" previous one, keep its indent and continue looking for an MSL.
"
" Example:
" method_call one,
" two,
" three
"
let msl = lnum
elseif s:Match(lnum, s:non_bracket_continuation_regex) &&
\ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex))
" If the current line is a bracket continuation or a block-starter, but
" the previous is a non-bracket one, respect the previous' indentation,
" and stop here.
"
" Example:
" method_call one,
" two {
" three
"
return lnum
elseif s:Match(lnum, s:bracket_continuation_regex) &&
\ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex))
" If both lines are bracket continuations (the current may also be a
" block-starter), use the current one's and stop here
"
" Example:
" method_call(
" other_method_call(
" foo
return msl
elseif s:Match(lnum, s:block_regex) &&
\ !s:Match(msl, s:continuation_regex) &&
\ !s:Match(msl, s:block_continuation_regex)
" If the previous line is a block-starter and the current one is
" mostly ordinary, use the current one as the MSL.
"
" Example:
" method_call do
" something
" something_else
return msl
else
let col = match(line, s:continuation_regex) + 1
if (col > 0 && !s:IsInStringOrComment(lnum, col))
\ || s:IsInString(lnum, strlen(line))
let msl = lnum
else
break
endif
endif
let msl_body = getline(msl)
let lnum = s:PrevNonBlankNonString(lnum - 1)
endwhile
return msl
endfunction
" Check if line 'lnum' has more opening brackets than closing ones.
function s:ExtraBrackets(lnum)
let opening = {'parentheses': [], 'braces': [], 'brackets': []}
let closing = {'parentheses': [], 'braces': [], 'brackets': []}
let line = getline(a:lnum)
let pos = match(line, '[][(){}]', 0)
" Save any encountered opening brackets, and remove them once a matching
" closing one has been found. If a closing bracket shows up that doesn't
" close anything, save it for later.
while pos != -1
if !s:IsInStringOrComment(a:lnum, pos + 1)
if line[pos] ==# '('
call add(opening.parentheses, {'type': '(', 'pos': pos})
elseif line[pos] ==# ')'
if empty(opening.parentheses)
call add(closing.parentheses, {'type': ')', 'pos': pos})
else
let opening.parentheses = opening.parentheses[0:-2]
endif
elseif line[pos] ==# '{'
call add(opening.braces, {'type': '{', 'pos': pos})
elseif line[pos] ==# '}'
if empty(opening.braces)
call add(closing.braces, {'type': '}', 'pos': pos})
else
let opening.braces = opening.braces[0:-2]
endif
elseif line[pos] ==# '['
call add(opening.brackets, {'type': '[', 'pos': pos})
elseif line[pos] ==# ']'
if empty(opening.brackets)
call add(closing.brackets, {'type': ']', 'pos': pos})
else
let opening.brackets = opening.brackets[0:-2]
endif
endif
endif
let pos = match(line, '[][(){}]', pos + 1)
endwhile
" Find the rightmost brackets, since they're the ones that are important in
" both opening and closing cases
let rightmost_opening = {'type': '(', 'pos': -1}
let rightmost_closing = {'type': ')', 'pos': -1}
for opening in opening.parentheses + opening.braces + opening.brackets
if opening.pos > rightmost_opening.pos
let rightmost_opening = opening
endif
endfor
for closing in closing.parentheses + closing.braces + closing.brackets
if closing.pos > rightmost_closing.pos
let rightmost_closing = closing
endif
endfor
return [rightmost_opening, rightmost_closing]
endfunction
function s:Match(lnum, regex)
let line = getline(a:lnum)
let offset = match(line, '\C'.a:regex)
let col = offset + 1
while offset > -1 && s:IsInStringOrComment(a:lnum, col)
let offset = match(line, '\C'.a:regex, offset + 1)
let col = offset + 1
endwhile
if offset > -1
return col
else
return 0
endif
endfunction
" Locates the containing class/module's definition line, ignoring nested classes
" along the way.
"
function! s:FindContainingClass()
let saved_position = getpos('.')
while searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
\ s:end_skip_expr) > 0
if expand('<cword>') =~# '\<class\|module\>'
let found_lnum = line('.')
call setpos('.', saved_position)
return found_lnum
endif
endwhile
call setpos('.', saved_position)
return 0
endfunction
" 3. GetCrystalIndent Function {{{1
" =========================
function GetCrystalIndent(...)
" 3.1. Setup {{{2
" ----------
" The value of a single shift-width
if exists('*shiftwidth')
let sw = shiftwidth()
else
let sw = &sw
endif
" For the current line, use the first argument if given, else v:lnum
let clnum = a:0 ? a:1 : v:lnum
" Set up variables for restoring position in file. Could use clnum here.
let vcol = col('.')
" 3.2. Work on the current line {{{2
" -----------------------------
" Get the current line.
let line = getline(clnum)
let ind = -1
" If this line is an access modifier keyword, align according to the closest
" class declaration.
if g:crystal_indent_access_modifier_style ==? 'indent'
if s:Match(clnum, s:access_modifier_regex)
let class_line = s:FindContainingClass()
if class_line > 0
return indent(class_line) + sw
endif
endif
elseif g:crystal_indent_access_modifier_style ==? 'outdent'
if s:Match(clnum, s:access_modifier_regex)
let class_line = s:FindContainingClass()
if class_line > 0
return indent(class_line)
endif
endif
endif
" If we got a closing bracket on an empty line, find its match and indent
" according to it. For parentheses we indent to its column - 1, for the
" others we indent to the containing line's MSL's level. Return -1 if fail.
let col = matchend(line, '^\s*[]})]')
if col > 0 && !s:IsInStringOrComment(clnum, col)
call cursor(clnum, col)
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('.')))
endif
endif
return ind
endif
" If we have a =begin or =end set indent to first column.
if match(line, '^\s*\%(=begin\|=end\)$') != -1
return 0
endif
" If we have a deindenting keyword, find its match and indent to its level.
" TODO: this is messy
if s:Match(clnum, s:crystal_deindent_keywords)
call cursor(clnum, 1)
if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
\ s:end_skip_expr) > 0
let msl = s:GetMSL(line('.'))
let line = getline(line('.'))
if strpart(line, 0, col('.') - 1) =~# '=\s*$' &&
\ strpart(line, col('.') - 1, 2) !~# 'do'
" assignment to case/begin/etc, on the same line, hanging indent
let ind = virtcol('.') - 1
elseif getline(msl) =~# '=\s*\(#.*\)\=$'
" in the case of assignment to the msl, align to the starting line,
" not to the msl
let ind = indent(line('.'))
else
" align to the msl
let ind = indent(msl)
endif
endif
return ind
endif
" If we are in a multi-line string or line-comment, don't do anything to it.
if s:IsInStringOrDocumentation(clnum, matchend(line, '^\s*') + 1)
return indent('.')
endif
" If we are at the closing delimiter of a "<<" heredoc-style string, set the
" indent to 0.
if line =~# '^\k\+\s*$'
\ && s:IsInStringDelimiter(clnum, 1)
\ && search('\V<<'.line, 'nbW') > 0
return 0
endif
" If the current line starts with a leading operator, add a level of indent.
if s:Match(clnum, s:leading_operator_regex)
return indent(s:GetMSL(clnum)) + sw
endif
" 3.3. Work on the previous line. {{{2
" -------------------------------
" Find a non-blank, non-multi-line string line above the current line.
let lnum = s:PrevNonBlankNonString(clnum - 1)
" If the line is empty and inside a string, use the previous line.
if line =~# '^\s*$' && lnum != prevnonblank(clnum - 1)
return indent(prevnonblank(clnum))
endif
" At the start of the file use zero indent.
if lnum == 0
return 0
endif
" Set up variables for the previous line.
let line = getline(lnum)
let ind = indent(lnum)
if s:Match(lnum, s:continuable_regex) && s:Match(lnum, s:continuation_regex)
return indent(s:GetMSL(lnum)) + sw + sw
endif
" If the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex)
let msl = s:GetMSL(lnum)
if getline(msl) =~# '=\s*\(#.*\)\=$'
" in the case of assignment to the msl, align to the starting line,
" not to the msl
let ind = indent(lnum) + sw
else
let ind = indent(msl) + sw
endif
return ind
endif
" If the previous line started with a leading operator, use its MSL's level
" of indent
if s:Match(lnum, s:leading_operator_regex)
return indent(s:GetMSL(lnum))
endif
" If the previous line ended with the "*" of a splat, add a level of indent
if line =~ s:splat_regex
return indent(lnum) + sw
endif
" If the previous line contained unclosed opening brackets and we are still
" in them, find the rightmost one and add indent depending on the bracket
" type.
"
" If it contained hanging closing brackets, find the rightmost one, find its
" match and indent according to that.
if line =~# '[[({]' || line =~# '[])}]\s*\%(#.*\)\=$'
let [opening, closing] = s:ExtraBrackets(lnum)
if opening.pos != -1
if opening.type ==# '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
if col('.') + 1 == col('$')
return ind + sw
else
return virtcol('.')
endif
else
let nonspace = matchend(line, '\S', opening.pos + 1) - 1
return nonspace > 0 ? nonspace : ind + sw
endif
elseif closing.pos != -1
call cursor(lnum, closing.pos + 1)
normal! %
if s:Match(line('.'), s:crystal_indent_keywords)
return indent('.') + sw
else
return indent('.')
endif
else
call cursor(clnum, vcol)
end
endif
" If the previous line ended with an "end", match that "end"s beginning's
" indent.
let col = s:Match(lnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$')
if col > 0
call cursor(lnum, col)
if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW',
\ s:end_skip_expr) > 0
let n = line('.')
let ind = indent('.')
let msl = s:GetMSL(n)
if msl != n
let ind = indent(msl)
end
return ind
endif
end
let col = s:Match(lnum, s:crystal_indent_keywords)
if col > 0
call cursor(lnum, col)
let ind = virtcol('.') - 1 + sw
" TODO: make this better (we need to count them) (or, if a searchpair
" fails, we know that something is lacking an end and thus we indent a
" level
if s:Match(lnum, s:end_end_regex)
let ind = indent('.')
endif
return ind
endif
" 3.4. Work on the MSL line. {{{2
" --------------------------
" Set up variables to use and search for MSL to the previous line.
let p_lnum = lnum
let lnum = s:GetMSL(lnum)
" If the previous line wasn't a MSL.
if p_lnum != lnum
" If previous line ends bracket and begins non-bracket continuation decrease indent by 1.
if s:Match(p_lnum, s:bracket_switch_continuation_regex)
return ind - 1
" If previous line is a continuation return its indent.
" TODO: the || s:IsInString() thing worries me a bit.
elseif s:Match(p_lnum, s:non_bracket_continuation_regex) || s:IsInString(p_lnum,strlen(line))
return ind
endif
endif
" Set up more variables, now that we know we wasn't continuation bound.
let line = getline(lnum)
let msl_ind = indent(lnum)
" If the MSL line had an indenting keyword in it, add a level of indent.
" TODO: this does not take into account contrived things such as
" module Foo; class Bar; end
if s:Match(lnum, s:crystal_indent_keywords)
let ind = msl_ind + sw
if s:Match(lnum, s:end_end_regex)
let ind = ind - sw
endif
return ind
endif
" If the previous line ended with [*+/.,-=], but wasn't a block ending or a
" closing bracket, indent one extra level.
if s:Match(lnum, s:non_bracket_continuation_regex) && !s:Match(lnum, '^\s*\([\])}]\|end\)')
if lnum == p_lnum
let ind = msl_ind + sw
else
let ind = msl_ind
endif
return ind
endif
" }}}2
return ind
endfunction
" }}}1
let &cpo = s:cpo_save
unlet s:cpo_save
" vim:set sw=2 sts=2 ts=8 et:
endif

View File

@@ -29,6 +29,7 @@ function! GetCucumberIndent()
let line = getline(prevnonblank(v:lnum-1)) let line = getline(prevnonblank(v:lnum-1))
let cline = getline(v:lnum) let cline = getline(v:lnum)
let nline = getline(nextnonblank(v:lnum+1)) let nline = getline(nextnonblank(v:lnum+1))
let sw = exists('*shiftwidth') ? shiftwidth() : &sw
let syn = s:syn(prevnonblank(v:lnum-1)) let syn = s:syn(prevnonblank(v:lnum-1))
let csyn = s:syn(v:lnum) let csyn = s:syn(v:lnum)
let nsyn = s:syn(nextnonblank(v:lnum+1)) let nsyn = s:syn(nextnonblank(v:lnum+1))
@@ -37,38 +38,38 @@ function! GetCucumberIndent()
return 0 return 0
elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):' elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):'
" examples heading " examples heading
return 2 * &sw return 2 * sw
elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
" background, scenario or outline heading " background, scenario or outline heading
return &sw return sw
elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:' elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:'
" line after feature heading " line after feature heading
return &sw return sw
elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):' elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):'
" line after examples heading " line after examples heading
return 3 * &sw return 3 * sw
elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
" line after background, scenario or outline heading " line after background, scenario or outline heading
return 2 * &sw return 2 * sw
elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0) elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0)
" tag or comment before a feature heading " tag or comment before a feature heading
return 0 return 0
elseif cline =~# '^\s*@' elseif cline =~# '^\s*@'
" other tags " other tags
return &sw return sw
elseif cline =~# '^\s*[#|]' && line =~# '^\s*|' elseif cline =~# '^\s*[#|]' && line =~# '^\s*|'
" mid-table " mid-table
" preserve indent " preserve indent
return indent(prevnonblank(v:lnum-1)) return indent(prevnonblank(v:lnum-1))
elseif cline =~# '^\s*|' && line =~# '^\s*[^|]' elseif cline =~# '^\s*|' && line =~# '^\s*[^|]'
" first line of a table, relative indent " first line of a table, relative indent
return indent(prevnonblank(v:lnum-1)) + &sw return indent(prevnonblank(v:lnum-1)) + sw
elseif cline =~# '^\s*[^|]' && line =~# '^\s*|' elseif cline =~# '^\s*[^|]' && line =~# '^\s*|'
" line after a table, relative unindent " line after a table, relative unindent
return indent(prevnonblank(v:lnum-1)) - &sw return indent(prevnonblank(v:lnum-1)) - sw
elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):') elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):')
" comments on scenarios " comments on scenarios
return &sw return sw
endif endif
return indent(prevnonblank(v:lnum-1)) return indent(prevnonblank(v:lnum-1))
endfunction endfunction

View File

@@ -1,10 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim indent file
" Language: Embedded Elixir
" URL: https://github.com/elixir-lang/vim-elixir
if exists("b:did_indent") if exists("b:did_indent")
finish finish
endif endif

View File

@@ -1,10 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim indent file
" Language: Elixir
" Maintainer: Carlos Galdino <carloshsgaldino@gmail.com>
" Last Change: 2013 Apr 24
if exists("b:did_indent") if exists("b:did_indent")
finish finish
endif endif
@@ -13,7 +8,7 @@ let b:did_indent = 1
setlocal nosmartindent setlocal nosmartindent
setlocal indentexpr=GetElixirIndent() setlocal indentexpr=GetElixirIndent()
setlocal indentkeys+=0=end,0=else,0=match,0=elsif,0=catch,0=after,0=rescue setlocal indentkeys+=0),0],0=end,0=else,0=match,0=elsif,0=catch,0=after,0=rescue
if exists("*GetElixirIndent") if exists("*GetElixirIndent")
finish finish
@@ -22,27 +17,41 @@ endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
let s:skip_syntax = '\%(Comment\|String\)$' let s:no_colon_before = ':\@<!'
let s:block_skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . s:skip_syntax . "'" let s:no_colon_after = ':\@!'
let s:block_start = 'do\|fn' let s:symbols_end = '\]\|}\|)'
let s:block_middle = 'else\|match\|elsif\|catch\|after\|rescue' let s:symbols_start = '\[\|{\|('
let s:block_end = 'end' let s:arrow = '^.*->$'
let s:symbols_end = '\]\|}' let s:skip_syntax = '\%(Comment\|String\)$'
let s:arrow = '^.*->$' let s:block_skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '".s:skip_syntax."'"
let s:pipeline = '^\s*|>.*$' let s:block_start = '\<\%(do\|fn\)\>'
let s:block_middle = 'else\|match\|elsif\|catch\|after\|rescue'
let s:block_end = 'end'
let s:starts_with_pipeline = '^\s*|>.*$'
let s:ending_with_assignment = '=\s*$'
let s:indent_keywords = '\<\%(' . s:block_start . '\|' . s:block_middle . '\)$' . '\|' . s:arrow let s:indent_keywords = '\<'.s:no_colon_before.'\%('.s:block_start.'\|'.s:block_middle.'\)$'.'\|'.s:arrow
let s:deindent_keywords = '^\s*\<\%(' . s:block_end . '\|' . s:block_middle . '\)\>' . '\|' . s:arrow let s:deindent_keywords = '^\s*\<\%('.s:block_end.'\|'.s:block_middle.'\)\>'.'\|'.s:arrow
let s:pair_start = '\<\%('.s:no_colon_before.s:block_start.'\)\>'.s:no_colon_after
let s:pair_middle = '\<\%('.s:block_middle.'\)\>'.s:no_colon_after.'\zs'
let s:pair_end = '\<\%('.s:no_colon_before.s:block_end.'\)\>\zs'
let s:inside_block = 0
function! GetElixirIndent() function! GetElixirIndent()
let lnum = prevnonblank(v:lnum - 1) let lnum = prevnonblank(v:lnum - 1)
let ind = indent(lnum)
" At the start of the file use zero indent. " At the start of the file use zero indent.
if lnum == 0 if lnum == 0
return 0 return 0
endif endif
let opened_symbol = 0
let current_line = getline(v:lnum)
let last_line = getline(lnum)
let ind = indent(lnum)
" TODO: Remove these 2 lines " TODO: Remove these 2 lines
" I don't know why, but for the test on spec/indent/lists_spec.rb:24. " I don't know why, but for the test on spec/indent/lists_spec.rb:24.
" Vim is making some mess on parsing the syntax of 'end', it is being " Vim is making some mess on parsing the syntax of 'end', it is being
@@ -52,58 +61,71 @@ function! GetElixirIndent()
syntax sync fromstart syntax sync fromstart
if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax
let current_line = getline(v:lnum)
let last_line = getline(lnum)
let splited_line = split(last_line, '\zs') if last_line !~ s:arrow
let opened_symbol = 0 let split_line = split(last_line, '\zs')
let opened_symbol += count(splited_line, '[') - count(splited_line, ']') let opened_symbol += count(split_line, '(') - count(split_line, ')')
let opened_symbol += count(splited_line, '{') - count(splited_line, '}') let opened_symbol += count(split_line, '[') - count(split_line, ']')
let opened_symbol += count(split_line, '{') - count(split_line, '}')
end
let ind += opened_symbol * &sw " if start symbol is followed by a character, indent based on the
" whitespace after the symbol, otherwise use the default shiftwidth
if last_line =~ '\('.s:symbols_start.'\).'
let opened_prefix = matchlist(last_line, '\('.s:symbols_start.'\)\s*')[0]
let ind += (opened_symbol * strlen(opened_prefix))
else
let ind += (opened_symbol * &sw)
endif
if last_line =~ '^\s*\(' . s:symbols_end . '\)' if last_line =~ '^\s*\('.s:symbols_end.'\)' || last_line =~ s:indent_keywords
let ind += &sw let ind += &sw
endif endif
if current_line =~ '^\s*\(' . s:symbols_end . '\)' if current_line =~ '^\s*\('.s:symbols_end.'\)'
let ind -= &sw let ind -= &sw
endif endif
if last_line =~ s:indent_keywords if last_line =~ s:ending_with_assignment && opened_symbol == 0
let b:old_ind = indent(lnum)
let ind += &sw let ind += &sw
endif end
" if line starts with pipeline " if line starts with pipeline
" and last line contains pipeline(s) " and last line ends with a pipeline,
" align them " align them
if last_line =~ '|>.*$' && if last_line =~ '|>.*$' &&
\ current_line =~ s:pipeline \ current_line =~ s:starts_with_pipeline
let ind = float2nr(match(last_line, '|>') / &sw) * &sw let ind = float2nr(match(last_line, '|>') / &sw) * &sw
" if line starts with pipeline " if line starts with pipeline
" and last line is an attribution " and last line is an attribution
" indents pipeline in same level as attribution " indents pipeline in same level as attribution
elseif current_line =~ s:pipeline && elseif current_line =~ s:starts_with_pipeline &&
\ last_line =~ '^[^=]\+=.\+$' \ last_line =~ '^[^=]\+=.\+$'
let b:old_ind = ind
if !exists('b:old_ind') || b:old_ind == 0
let b:old_ind = indent(lnum)
end
let ind = float2nr(matchend(last_line, '=\s*[^ ]') / &sw) * &sw let ind = float2nr(matchend(last_line, '=\s*[^ ]') / &sw) * &sw
endif endif
" if last line starts with pipeline " if last line starts with pipeline
" and current line doesn't start with pipeline " and current line doesn't start with pipeline
" returns the indentation before the pipeline " returns the indentation before the pipeline
if last_line =~ s:pipeline && if last_line =~ s:starts_with_pipeline &&
\ current_line !~ s:pipeline \ current_line !~ s:starts_with_pipeline
let ind = b:old_ind let ind = b:old_ind
endif endif
if current_line =~ s:deindent_keywords if current_line =~ s:deindent_keywords
let bslnum = searchpair( '\<\%(' . s:block_start . '\):\@!\>', let bslnum = searchpair(
\ '\<\%(' . s:block_middle . '\):\@!\>\zs', \ s:pair_start,
\ '\<:\@<!' . s:block_end . '\>\zs', \ s:pair_middle,
\ s:pair_end,
\ 'nbW', \ 'nbW',
\ s:block_skip ) \ s:block_skip
\ )
let ind = indent(bslnum) let ind = indent(bslnum)
endif endif

View File

@@ -92,7 +92,7 @@ function! GetErubyIndent(...)
if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>' if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>'
let ind = ind + sw let ind = ind + sw
endif endif
if line !~# '^\s*<%' && line =~# '%>\s*$' if line !~# '^\s*<%' && line =~# '%>\s*$' && line !~# '^\s*end\>'
let ind = ind - sw let ind = ind - sw
endif endif
if cline =~# '^\s*[-=]\=%>\s*$' if cline =~# '^\s*[-=]\=%>\s*$'

6
indent/fish.vim Normal file
View File

@@ -0,0 +1,6 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
setlocal indentexpr=fish#Indent()
setlocal indentkeys+==end,=else,=case
endif

View File

@@ -22,17 +22,18 @@ if exists("*GetGitconfigIndent")
endif endif
function! GetGitconfigIndent() function! GetGitconfigIndent()
let sw = exists('*shiftwidth') ? shiftwidth() : &sw
let line = getline(prevnonblank(v:lnum-1)) let line = getline(prevnonblank(v:lnum-1))
let cline = getline(v:lnum) let cline = getline(v:lnum)
if line =~ '\\\@<!\%(\\\\\)*\\$' if line =~ '\\\@<!\%(\\\\\)*\\$'
" odd number of slashes, in a line continuation " odd number of slashes, in a line continuation
return 2 * &sw return 2 * sw
elseif cline =~ '^\s*\[' elseif cline =~ '^\s*\['
return 0 return 0
elseif cline =~ '^\s*\a' elseif cline =~ '^\s*\a'
return &sw return sw
elseif cline == '' && line =~ '^\[' elseif cline == '' && line =~ '^\['
return &sw return sw
else else
return -1 return -1
endif endif

View File

@@ -6,4 +6,43 @@ endif
runtime! indent/html.vim runtime! indent/html.vim
" Indent Golang HTML templates
setlocal indentexpr=GetGoHTMLTmplIndent(v:lnum)
setlocal indentkeys+==else,=end
" Only define the function once.
if exists("*GetGoHTMLTmplIndent")
finish
endif
function! GetGoHTMLTmplIndent(lnum)
" Get HTML indent
if exists('*HtmlIndent')
let ind = HtmlIndent()
else
let ind = HtmlIndentGet(a:lnum)
endif
" The value of a single shift-width
if exists('*shiftwidth')
let sw = shiftwidth()
else
let sw = &sw
endif
" If need to indent based on last line
let last_line = getline(a:lnum-1)
if last_line =~ '^\s*{{\s*\%(if\|else\|range\|with\|define\|block\).*}}'
let ind += sw
endif
" End of FuncMap block
let current_line = getline(a:lnum)
if current_line =~ '^\s*{{\s*\%(else\|end\).*}}'
let ind -= sw
endif
return ind
endfunction
endif endif

View File

@@ -39,10 +39,11 @@ function! GetHamlIndent()
let line = substitute(line,'^\s\+','','') let line = substitute(line,'^\s\+','','')
let indent = indent(lnum) let indent = indent(lnum)
let cindent = indent(v:lnum) let cindent = indent(v:lnum)
let sw = exists('*shiftwidth') ? shiftwidth() : &sw
if cline =~# '\v^-\s*%(elsif|else|when)>' if cline =~# '\v^-\s*%(elsif|else|when)>'
let indent = cindent < indent ? cindent : indent - &sw let indent = cindent < indent ? cindent : indent - sw
endif endif
let increase = indent + &sw let increase = indent + sw
if indent == indent(lnum) if indent == indent(lnum)
let indent = cindent <= indent ? -1 : increase let indent = cindent <= indent ? -1 : increase
endif endif

View File

@@ -2,8 +2,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
" indentation for haskell " indentation for haskell
" "
" Based on idris indentation
"
" author: raichoo (raichoo@googlemail.com) " author: raichoo (raichoo@googlemail.com)
" "
" Modify g:haskell_indent_if and g:haskell_indent_case to " Modify g:haskell_indent_if and g:haskell_indent_case to
@@ -18,7 +16,7 @@ endif
let b:did_indent = 1 let b:did_indent = 1
if !exists('g:haskell_indent_if') if !exists('g:haskell_indent_if')
" if bool " if x
" >>>then ... " >>>then ...
" >>>else ... " >>>else ...
let g:haskell_indent_if = 3 let g:haskell_indent_if = 3
@@ -55,96 +53,130 @@ if !exists('g:haskell_indent_in')
let g:haskell_indent_in = 1 let g:haskell_indent_in = 1
endif endif
if !exists('g:haskell_indent_guard')
" f x y
" >>|
let g:haskell_indent_guard = 2
endif
setlocal indentexpr=GetHaskellIndent() setlocal indentexpr=GetHaskellIndent()
setlocal indentkeys=!^F,o,O,0\|,0=where,0=in,0=let,0=deriving,0=->,0=\=>,<CR>,0} setlocal indentkeys=0{,0},0(,0),0[,0],!^F,o,O,0\=,0=where,0=let,0=deriving,0\,,<space>
function! s:isInBlock(hlstack)
return index(a:hlstack, 'haskellParens') > -1 || index(a:hlstack, 'haskellBrackets') > -1 || index(a:hlstack, 'haskellBlock') > -1
endfunction
function! s:getNesting(hlstack)
return filter(a:hlstack, 'v:val == "haskellBlock" || v:val == "haskellBrackets" || v:val == "haskellParens"')
endfunction
function! s:getHLStack()
return map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunction
" indent matching character
function! s:indentMatching(char)
normal! 0
call search(a:char, 'cW')
normal! %
return col('.') - 1
endfunction
" backtrack to find guard clause
function! s:indentGuard(pos, prevline)
let l:l = a:prevline
let l:c = 1
while v:lnum != l:c
" empty line, stop looking
if l:l =~ '^$'
return a:pos
" guard found
elseif l:l =~ '^\s*|\s\+'
return match(l:l, '|')
" found less deeper indentation (not starting with `,` or `=`)
" stop looking
else
let l:m = match(l:l, '\S')
if l:l !~ '^\s*[=,]' && l:m <= a:pos
return l:m + g:haskell_indent_guard
endif
endif
let l:c += 1
let l:l = getline(v:lnum - l:c)
endwhile
return -1
endfunction
function! GetHaskellIndent() function! GetHaskellIndent()
let l:prevline = getline(v:lnum - 1) let l:hlstack = s:getHLStack()
" do not indent in strings and quasiquotes
if index(l:hlstack, 'haskellString') > -1 || index(l:hlstack, 'haskellQuasiQuote') > -1
return -1
endif
" blockcomment handling
if index(l:hlstack, 'haskellBlockComment') > -1
for l:c in range(v:lnum - 1, 0, -1)
let l:line = getline(l:c)
if l:line =~ '{-'
return 1 + match(l:line, '{-')
endif
endfor
return 1
endif
let l:prevline = getline(v:lnum - 1)
let l:line = getline(v:lnum)
" reset
if l:prevline =~ '^\s*$' && l:line !~ '^\s*\S'
return 0
endif
" comment indentation
if l:prevline =~ '^\s*--' if l:prevline =~ '^\s*--'
return match(l:prevline, '\S') return match(l:prevline, '\S')
endif endif
if synIDattr(synID(line("."), col("."), 1), "name") == 'haskellBlockComment' " operator at end of previous line
for l:c in range(v:lnum - 1, 0, -1) if l:prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
let l:bline = getline(l:c) return match(l:prevline, '\S') + &shiftwidth
if l:bline =~ '{-'
return 1 + match(l:bline, '{-')
endfor
return 1
endif
if l:prevline =~ '^\s*$'
return 0
endif
let l:line = getline(v:lnum)
if l:line =~ '\C^\s*\<where\>'
let l:s = match(l:prevline, '\S')
return l:s + &shiftwidth
endif
if l:line =~ '\C^\s*\<deriving\>'
let l:s = match(l:prevline, '\C\<\(newtype\|data\)\>')
if l:s >= 0
return l:s + &shiftwidth
endif
endif
if l:line =~ '\C^\s*\<let\>'
let l:s = match(l:prevline, '\C\<let\>')
if l:s != 0
return l:s
endif
endif
if l:line =~ '\C^\s*\<in\>'
let l:s = match(l:prevline, '\C\<let\>')
if l:s >= 0
return l:s + g:haskell_indent_in
elseif match(l:prevline, '=') > 0
let l:s = match(l:prevline, '\S')
return l:s - (4 - g:haskell_indent_in)
endif
endif
if l:line =~ '^\s*|'
if match(l:prevline, '^\s*data') < 0
if match(l:prevline, '^\s*|\s') >= 0
return match(l:prevline, '|')
else
return &shiftwidth
endif
endif
endif
if l:line =~ '^\s*[=-]>'
let l:s = match(l:prevline, ' :: ')
if l:s >= 0
return l:s + 1
endif
endif
if l:prevline =~ '\s\+[!#$%&*+./<>?@\\^|~-]\+\s*$'
let l:s = match(l:prevline, '\S')
if l:s > 0
return l:s + &shiftwidth
endif
endif
if l:prevline =~ '[{([][^})\]]\+$'
return match(l:prevline, '[{([]')
endif endif
" let foo =
" >>>>>>bar
if l:prevline =~ '\C\<let\>\s\+[^=]\+=\s*$' if l:prevline =~ '\C\<let\>\s\+[^=]\+=\s*$'
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let + &shiftwidth return match(l:prevline, '\C\<let\>') + g:haskell_indent_let + &shiftwidth
endif endif
if l:prevline =~ '\C\<let\>\s\+.\+\(\<in\>\)\?\s*$' " let x = 1 in
" >>>>x
if l:prevline =~ '\C\<let\>\s\+.\+\<in\>\?$' && l:line !~ '\C^\s*\<in\>'
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let return match(l:prevline, '\C\<let\>') + g:haskell_indent_let
endif endif
" let x = 1
" let y = 2
"
" let x = 1
" >in x
"
" let x = 1
" >>>>y = 2
if l:prevline =~ '\C\<let\>\s\+.\+$'
if l:line =~ '\C^\s*\<let\>'
return match(l:prevline, '\C\<let\>')
elseif l:line =~ '\C^\s*\<in\>'
return match(l:prevline, '\C\<let\>') + g:haskell_indent_in
else
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let
endif
endif
" if handling
if l:prevline !~ '\C\<else\>' if l:prevline !~ '\C\<else\>'
let l:s = match(l:prevline, '\C\<if\>.*\&.*\zs\<then\>') let l:s = match(l:prevline, '\C\<if\>.*\&.*\zs\<then\>')
if l:s > 0 if l:s > 0
@@ -157,30 +189,252 @@ function! GetHaskellIndent()
endif endif
endif endif
if l:prevline =~ '\C\(\<where\>\|\<do\>\|=\|[{([]\)\s*$' " where
" >>foo
"
" do
" >>foo
"
" foo =
" >>bar
if l:prevline =~ '\C\(\<where\>\|\<do\>\|=\)\s*$'
return match(l:prevline, '\S') + &shiftwidth return match(l:prevline, '\S') + &shiftwidth
endif endif
"" where foo
"" >>>>>>bar
if l:prevline =~ '\C\<where\>\s\+\S\+.*$' if l:prevline =~ '\C\<where\>\s\+\S\+.*$'
return match(l:prevline, '\C\<where\>') + g:haskell_indent_where if l:line =~ '^\s*[=-]>\s' && l:prevline =~ ' :: '
return match(l:prevline, ':: ')
else
return match(l:prevline, '\C\<where\>') + g:haskell_indent_where
endif
endif endif
" do foo
" >>>bar
if l:prevline =~ '\C\<do\>\s\+\S\+.*$' if l:prevline =~ '\C\<do\>\s\+\S\+.*$'
return match(l:prevline, '\C\<do\>') + g:haskell_indent_do return match(l:prevline, '\C\<do\>') + g:haskell_indent_do
endif endif
if l:prevline =~ '\C^\s*\<data\>\s\+[^=]\+\s\+=\s\+\S\+.*$' " case foo of
if l:line =~ '^\s*|' " >>bar -> quux
return match(l:prevline, '=') if l:prevline =~ '\C\<case\>.\+\<of\>\s*$'
endif
endif
if l:prevline =~ '\C\<case\>\s\+.\+\<of\>\s*$'
return match(l:prevline, '\C\<case\>') + g:haskell_indent_case return match(l:prevline, '\C\<case\>') + g:haskell_indent_case
endif endif
if l:prevline =~ '\C^\s*\<\data\>\s\+\S\+\s*$' " newtype Foo = Foo
return match(l:prevline, '\C\<data\>') + &shiftwidth " >>deriving
if l:prevline =~ '\C\s*\<\(newtype\|data\)\>[^{]\+' && l:line =~ '\C^\s*\<deriving\>'
return match(l:prevline, '\S') + &shiftwidth
endif
" foo :: Int
" >>>>-> Int
"
" foo
" :: Int
" foo
if l:prevline =~ '\s::\s'
if l:line =~ '^\s*[-=]>'
return match(l:prevline, '::\s')
elseif match(l:prevline, '^\s\+::') > -1
return match(l:prevline, '::\s') - &shiftwidth
endif
endif
" foo :: Int
" -> Int
" foo x
"
" foo
" :: Int
" -> Int
" foo x
if l:prevline =~ '^\s*[-=]>' && l:line !~ '^\s*[-=]>'
if s:isInBlock(l:hlstack)
return match(l:prevline, '[^\s-=>]')
else
let l:m = matchstr(l:line, '^\s*\zs\<\S\+\>\ze')
let l:l = l:prevline
let l:c = 1
while v:lnum != l:c
" fun decl
let l:s = match(l:l, l:m)
if l:s >= 0
if match(l:l, '\C^\s*\<default\>') > -1
return l:s - 8
else
return l:s
endif
" empty line, stop looking
elseif l:l =~ '^$'
return 0
endif
let l:c += 1
let l:l = getline(v:lnum - l:c)
endwhile
return 0
endif
endif
" | otherwise = ...
" foo
"
" | foo
" >>, bar
"
" | foo
" >>= bar
"
" | Foo
" >>deriving
if l:prevline =~ '^\s\+|' && !s:isInBlock(l:hlstack)
if l:line =~ '\s*[,=]'
return match(l:prevline, '|')
elseif l:line =~ '\C^\s*\<deriving\>'
return match(l:prevline, '|')
elseif l:line !~ '^\s*|'
return match(l:prevline, '|') - g:haskell_indent_guard
endif
endif
" foo :: ( Monad m
" , Functor f
" )
">>>>>=> Int
if l:prevline =~ '^\s*)' && l:line =~ '^\s*=>'
let l:s = match(l:prevline, ')')
return l:s - (&shiftwidth + 1)
endif
" module Foo
" >>( bar
if l:prevline =~ '\C^\<module\>'
return &shiftwidth
endif
" foo
" >>{
if l:line =~ '^\s*{' && l:prevline !~ '^{'
return match(l:prevline, '\S') + &shiftwidth
endif
" in foo
" where bar
if l:line =~ '\C^\s*\<where\>'
if match(l:prevline, '\C^\s\+in\s\+') == 0
return match(l:prevline, 'in') - g:haskell_indent_in
endif
return match(l:prevline, '\S') + &shiftwidth
endif
" let x = 1
" y = 2
" >in x + 1
if l:line =~ '\C^\s*\<in\>'
return match(l:prevline, '\S') - (4 - g:haskell_indent_in)
endif
" data Foo
" >>= Bar
"
" |
" ...
" >>=
"
" foo
" >>=
if l:line =~ '^\s*='
if l:prevline =~ '\C^\<data\>\s\+[^=]\+\s*$'
return match(l:prevline, '\C\<data\>') + &shiftwidth
else
let l:s = s:indentGuard(match(l:line, '='), l:prevline)
if l:s > 0
return l:s
else
return &shiftwidth
endif
endif
endif
" { foo :: Int
" >>,
"
" |
" ...
" >>,
if l:line =~ '^\s*,'
if s:isInBlock(l:hlstack)
normal! 0
call search(',', 'cW')
let l:n = s:getNesting(s:getHLStack())
call search('[(\[{]', 'bW')
while l:n != s:getNesting(s:getHLStack())
call search('[(\[{]', 'bW')
endwhile
return col('.') - 1
else
let l:s = s:indentGuard(match(l:line, ','), l:prevline)
if l:s > -1
return l:s
end
endif
endif
" |
" ...
" >>|
"
" data Foo = Bar
" >>>>>>>>>|
if l:line =~ '^\s*|\s'
if l:prevline =~ '\C^\s*\<data\>.\+=.\+$'
return match(l:prevline, '=')
else
let l:s = s:indentGuard(match(l:line, '|'), l:prevline)
if l:s > -1
return l:s
endif
endif
endif
" foo
" >>:: Int
if l:line =~ '^\s*::\s'
return match(l:prevline, '\S') + &shiftwidth
endif
" indent closing brace, paren or bracket
if l:line =~ '^\s*}'
return s:indentMatching('}')
endif
if l:line =~ '^\s*)'
return s:indentMatching(')')
endif
if l:line =~ '^\s*]'
return s:indentMatching(']')
endif
"
" indent import
if l:line =~ '\C^\s*import'
return 0
endif
" do not reindent indented lines
if match(l:prevline, '\S') < match(l:line, '\S')
return -1
endif
if l:line !~ '^\s*[=-]>\s' && l:line =~ '^\s*[!#$%&*+./<>?@\\^|~-]\+'
return -1
endif endif
return match(l:prevline, '\S') return match(l:prevline, '\S')

View File

@@ -177,7 +177,24 @@ call add(s:tags, 'tr')
call add(s:tags, 'th') call add(s:tags, 'th')
call add(s:tags, 'td') call add(s:tags, 'td')
let s:no_tags = []
call add(s:no_tags, 'base')
call add(s:no_tags, 'link')
call add(s:no_tags, 'meta')
call add(s:no_tags, 'hr')
call add(s:no_tags, 'br')
call add(s:no_tags, 'wbr')
call add(s:no_tags, 'img')
call add(s:no_tags, 'embed')
call add(s:no_tags, 'param')
call add(s:no_tags, 'source')
call add(s:no_tags, 'track')
call add(s:no_tags, 'area')
call add(s:no_tags, 'col')
call add(s:no_tags, 'input')
call add(s:no_tags, 'keygen')
call add(s:no_tags, 'menuitem')
let s:omittable = [ let s:omittable = [
\ ['address', 'article', 'aside', 'blockquote', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'], \ ['address', 'article', 'aside', 'blockquote', 'dir', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'],
@@ -187,16 +204,21 @@ let s:omittable = [
\ ['th', 'td'], \ ['th', 'td'],
\] \]
let s:html_noindent_tags = join(s:no_tags, '\|')
if exists('g:html_exclude_tags') if exists('g:html_exclude_tags')
for tag in g:html_exclude_tags for tag in g:html_exclude_tags
call remove(s:tags, index(s:tags, tag)) call remove(s:tags, index(s:tags, tag))
endfor endfor
let s:html_noindent_tags = s:html_noindent_tags.'\|'.join(g:html_exclude_tags, '\|')
endif endif
let s:html_indent_tags = join(s:tags, '\|')
let s:html_indent_tags = s:html_indent_tags.'\|\w\+\(-\w\+\)\+' " let s:html_indent_tags = join(s:tags, '\|')
if exists('g:html_indent_tags') let s:html_indent_tags = '[a-z_][a-z0-9_.-]*'
let s:html_indent_tags = s:html_indent_tags.'\|'.g:html_indent_tags " if exists('g:html_indent_tags')
endif " let s:html_indent_tags = s:html_indent_tags.'\|'.g:html_indent_tags
" endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo-=C set cpo-=C
@@ -231,8 +253,8 @@ endfun
fun! <SID>HtmlIndentSum(lnum, style) fun! <SID>HtmlIndentSum(lnum, style)
if a:style == match(getline(a:lnum), '^\s*</') if a:style == match(getline(a:lnum), '^\s*</')
if a:style == match(getline(a:lnum), '^\s*</\<\('.s:html_indent_tags.'\)\>') if a:style == match(getline(a:lnum), '^\s*</\<\('.s:html_indent_tags.'\)\>')
let open = <SID>HtmlIndentOpen(a:lnum, s:html_indent_tags) let open = <SID>HtmlIndentOpen(a:lnum, s:html_indent_tags) - <SID>HtmlIndentOpen(a:lnum, s:html_noindent_tags)
let close = <SID>HtmlIndentClose(a:lnum, s:html_indent_tags) let close = <SID>HtmlIndentClose(a:lnum, s:html_indent_tags) - <SID>HtmlIndentClose(a:lnum, s:html_noindent_tags)
if 0 != open || 0 != close if 0 != open || 0 != close
return open - close return open - close
endif endif

View File

@@ -18,7 +18,7 @@ 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=GetJavascriptIndent() setlocal indentexpr=GetJavascriptIndent()
setlocal formatexpr=Fixedgq(v:lnum,v:count) setlocal formatexpr=Fixedgq(v:lnum,v:count)
setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e setlocal indentkeys=0{,0},0),0],0\,:,!^F,o,O,e
" Only define the function once. " Only define the function once.
if exists("*GetJavascriptIndent") if exists("*GetJavascriptIndent")
@@ -28,13 +28,27 @@ endif
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim set cpo&vim
" Get shiftwidth value
if exists('*shiftwidth')
func s:sw()
return shiftwidth()
endfunc
else
func s:sw()
return &sw
endfunc
endif
" 1. Variables {{{1 " 1. Variables {{{1
" ============ " ============
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\)' let s:js_keywords = '^\s*\(break\|catch\|const\|continue\|debugger\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|let\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)'
let s:expr_case = '^\s*\(case\s\+[^\:]*\|default\)\s*:\s*'
" 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\|regex\|comment\c' let s:syng_strcom = '\%(\%(template\)\@<!string\|regex\|comment\)\c'
" Regex of syntax group names that are or delimit template strings
let s:syng_template = 'template\c'
" Regex of syntax group names that are strings. " Regex of syntax group names that are strings.
let s:syng_string = 'regex\c' let s:syng_string = 'regex\c'
@@ -51,25 +65,34 @@ let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_st
let s:line_term = '\s*\%(\%(\/\/\).*\)\=$' let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
" Regex that defines continuation lines, not including (, {, or [. " Regex that defines continuation lines, not including (, {, or [.
let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=]=[^=].*,\)' . s:line_term let s:continuation_regex = '\%([\\*/.:]\|+\@<!+\|-\@<!-\|\%(<%\)\@<!=\|\W[|&?]\|||\|&&\|[^=]=[^=>].*,\)' . s:line_term
" Regex that defines continuation lines. " Regex that defines continuation lines.
" TODO: this needs to deal with if ...: and so on " TODO: this needs to deal with if ...: and so on
let s:msl_regex = s:continuation_regex let s:msl_regex = s:continuation_regex.'\|'.s:expr_case
let s:one_line_scope_regex = '\<\%(if\|else\|for\|while\)\>[^{;]*' . s:line_term let s:one_line_scope_regex = '\%(\%(\<else\>\|\<\%(if\|for\|while\)\>\s*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*([^()]*)[^()]*\))[^()]*\))[^()]*\))\)\|=>\)' . s:line_term
" Regex that defines blocks. " Regex that defines blocks.
let s:block_regex = '\%([{[]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term let s:block_regex = '\%([{([]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
let s:var_stmt = '^\s*var' let s:operator_first = '^\s*\%([*/.:?]\|\([-+]\)\1\@!\|||\|&&\)'
let s:var_stmt = '^\s*\%(const\|let\|var\)'
let s:comma_first = '^\s*,' let s:comma_first = '^\s*,'
let s:comma_last = ',\s*$' let s:comma_last = ',\s*$'
let s:ternary = '^\s\+[?|:]' let s:case_indent = s:sw()
let s:ternary_q = '^\s\+?' let s:case_indent_after = s:sw()
let s:m = matchlist(&cinoptions, ':\(.\)')
if (len(s:m) > 2)
let s:case_indent = s:m[1]
endif
let s:m = matchlist(&cinoptions, '=\(.\)')
if (len(s:m) > 2)
let s:case_indent_after = s:m[1]
endif
" 2. Auxiliary Functions {{{1 " 2. Auxiliary Functions {{{1
" ====================== " ======================
@@ -83,6 +106,11 @@ function s:IsInString(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
endfunction endfunction
" Check if the character at lnum:col is inside a template string.
function s:IsInTempl(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_template
endfunction
" Check if the character at lnum:col is inside a multi-line comment. " Check if the character at lnum:col is inside a multi-line comment.
function s:IsInMultilineComment(lnum, col) function s:IsInMultilineComment(lnum, col)
return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
@@ -101,13 +129,13 @@ function s:PrevNonBlankNonString(lnum)
" Go in and out of blocks comments as necessary. " Go in and out of blocks comments as necessary.
" If the line isn't empty (with opt. comment) or in a string, end search. " If the line isn't empty (with opt. comment) or in a string, end search.
let line = getline(lnum) let line = getline(lnum)
if line =~ '/\*' if s:IsInMultilineComment(lnum, matchend(line, '/\*') - 1)
if in_block if in_block
let in_block = 0 let in_block = 0
else else
break break
endif endif
elseif !in_block && line =~ '\*/' elseif !in_block && s:IsInMultilineComment(lnum, matchend(line, '\*/') - 1)
let in_block = 1 let in_block = 1
elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && s:IsInStringOrComment(lnum, strlen(line))) elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && s:IsInStringOrComment(lnum, strlen(line)))
break break
@@ -127,9 +155,21 @@ function s:GetMSL(lnum, in_one_line_scope)
" Otherwise, terminate search as we have found our MSL already. " Otherwise, terminate search as we have found our MSL already.
let line = getline(lnum) let line = getline(lnum)
let col = match(line, s:msl_regex) + 1 let col = match(line, s:msl_regex) + 1
let line2 = getline(msl)
let col2 = matchend(line2, ')')
if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line)) if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line))
let msl = lnum let msl = lnum
" if there are more closing brackets, continue from the line which has the matching opening bracket
elseif col2 > 0 && !s:IsInStringOrComment(msl, col2) && s:LineHasOpeningBrackets(msl)[0] == '2' && !a:in_one_line_scope
call cursor(msl, 1)
if searchpair('(', '', ')', 'bW', s:skip_expr) > 0
let lnum = line('.')
let msl = lnum
endif
else else
" Don't use lines that are part of a one line scope as msl unless the " 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 " flag in_one_line_scope is set to 1
" "
@@ -140,7 +180,7 @@ function s:GetMSL(lnum, in_one_line_scope)
if msl_one_line == 0 if msl_one_line == 0
break break
endif endif
endif end
let lnum = s:PrevNonBlankNonString(lnum - 1) let lnum = s:PrevNonBlankNonString(lnum - 1)
endwhile endwhile
return msl return msl
@@ -193,9 +233,9 @@ function s:GetVarIndent(lnum)
" if the previous line doesn't end in a comma, return to regular indent " if the previous line doesn't end in a comma, return to regular indent
if (line !~ s:comma_last) if (line !~ s:comma_last)
return indent(prev_lnum) - &sw return indent(prev_lnum) - s:sw()
else else
return indent(lvar) + &sw return indent(lvar) + s:sw()
endif endif
endif endif
@@ -221,7 +261,7 @@ function s:LineHasOpeningBrackets(lnum)
endif endif
let pos = match(line, '[][(){}]', pos + 1) let pos = match(line, '[][(){}]', pos + 1)
endwhile endwhile
return (open_0 > 0) . (open_2 > 0) . (open_4 > 0) return (open_0 > 0 ? 1 : (open_0 == 0 ? 0 : 2)) . (open_2 > 0) . (open_4 > 0)
endfunction endfunction
function s:Match(lnum, regex) function s:Match(lnum, regex)
@@ -302,6 +342,17 @@ function GetJavascriptIndent()
" previous nonblank line number " previous nonblank line number
let prevline = prevnonblank(v:lnum - 1) let prevline = prevnonblank(v:lnum - 1)
if (line =~ s:expr_case)
if (getline(prevline) =~ s:expr_case)
return indent(prevline)
else
if (getline(prevline) =~ s:block_regex)
return indent(prevline) + s:case_indent
else
return indent(prevline) - s:case_indent_after
endif
endif
endif
" If we got a closing bracket on an empty line, find its match and indent " If we got a closing bracket on an empty line, find its match and indent
" according to it. For parentheses we indent to its column - 1, for the " according to it. For parentheses we indent to its column - 1, for the
" others we indent to the containing line's MSL's level. Return -1 if fail. " others we indent to the containing line's MSL's level. Return -1 if fail.
@@ -323,7 +374,7 @@ function GetJavascriptIndent()
return indent(prevline) return indent(prevline)
" otherwise we indent 1 level " otherwise we indent 1 level
else else
return indent(lvar) + &sw return indent(lvar) + s:sw()
endif endif
endif endif
endif endif
@@ -342,15 +393,51 @@ function GetJavascriptIndent()
" If the line is comma first, dedent 1 level " If the line is comma first, dedent 1 level
if (getline(prevline) =~ s:comma_first) if (getline(prevline) =~ s:comma_first)
return indent(prevline) - &sw return indent(prevline) - s:sw()
endif
if (getline(prevline) =~ s:expr_case)
return indent(prevline) + s:case_indent_after
endif endif
if (line =~ s:ternary) " If line starts with an operator...
if (getline(prevline) =~ s:ternary_q) if (s:Match(v:lnum, s:operator_first))
if (s:Match(prevline, s:operator_first))
" and so does previous line, don't indent
return indent(prevline) return indent(prevline)
else end
return indent(prevline) + &sw let counts = s:LineHasOpeningBrackets(prevline)
if counts[0] == '2'
call cursor(prevline, 1)
" Search for the opening tag
let mnum = searchpair('(', '', ')', 'bW', s:skip_expr)
if mnum > 0 && s:Match(mnum, s:operator_first)
return indent(mnum)
end
elseif counts[0] != '1' && counts[1] != '1' && counts[2] != '1'
" otherwise, indent 1 level
return indent(prevline) + s:sw()
end
" If previous line starts with an operator...
elseif s:Match(prevline, s:operator_first) && !s:Match(prevline, s:comma_last) && !s:Match(prevline, '};\=' . s:line_term)
let counts = s:LineHasOpeningBrackets(prevline)
if counts[0] == '2' && counts[1] == '1'
call cursor(prevline, 1)
" Search for the opening tag
let mnum = searchpair('(', '', ')', 'bW', s:skip_expr)
if mnum > 0 && !s:Match(mnum, s:operator_first)
return indent(mnum) + s:sw()
end
elseif counts[0] != '1' && counts[1] != '1' && counts[2] != '1'
return indent(prevline) - s:sw()
end
end
if getline(prevline) =~ '^\s*`$' && s:IsInTempl(v:lnum, 1)
if line !~ '^\s*`$'
return indent(prevline) + s:sw()
endif endif
elseif line =~ '^\s*`$' && s:IsInTempl(prevline, 1)
return indent(prevline) - s:sw()
endif endif
" If we are in a multi-line comment, cindent does the right thing. " If we are in a multi-line comment, cindent does the right thing.
@@ -387,48 +474,71 @@ function GetJavascriptIndent()
return 0 return 0
endif 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 the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex) if s:Match(lnum, s:block_regex)
return indent(s:GetMSL(lnum, 0)) + &sw if (line =~ s:expr_case)
return indent(s:GetMSL(lnum, 0)) + s:sw()/2
else
return indent(s:GetMSL(lnum, 0)) + s:sw()
endif
endif endif
" Set up variables for current line.
let line = getline(lnum)
let ind = indent(lnum)
" If the previous line contained an opening bracket, and we are still in it, " If the previous line contained an opening bracket, and we are still in it,
" add indent depending on the bracket type. " add indent depending on the bracket type.
if line =~ '[[({]' if line =~ '[[({]'
let counts = s:LineHasOpeningBrackets(lnum) let counts = s:LineHasOpeningBrackets(lnum)
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
if col('.') + 1 == col('$') if col('.') + 1 == col('$') || line =~ s:one_line_scope_regex
return ind + &sw return ind + s:sw()
else else
return virtcol('.') return virtcol('.')
endif endif
elseif counts[1] == '1' || counts[2] == '1' elseif counts[1] == '1' || counts[2] == '1' && counts[0] != '2'
return ind + &sw return ind + s:sw()
else else
call cursor(v:lnum, vcol) call cursor(v:lnum, vcol)
end end
endif elseif line =~ '.\+};\=' . s:line_term
call cursor(lnum, 1)
" Search for the opening tag
let mnum = searchpair('{', '', '}', 'bW', s:skip_expr)
if mnum > 0
return indent(s:GetMSL(mnum, 0))
end
elseif line =~ '.\+);\=' || line =~ s:comma_last
let counts = s:LineHasOpeningBrackets(lnum)
if counts[0] == '2'
call cursor(lnum, 1)
" Search for the opening tag
let mnum = searchpair('(', '', ')', 'bW', s:skip_expr)
if mnum > 0
return indent(s:GetMSL(mnum, 0))
end
elseif line !~ s:var_stmt
return indent(prevline)
end
end
" 3.4. Work on the MSL line. {{{2 " 3.4. Work on the MSL line. {{{2
" -------------------------- " --------------------------
let ind_con = ind let ind_con = ind
let ind = s:IndentWithContinuation(lnum, ind_con, &sw) let ind = s:IndentWithContinuation(lnum, ind_con, s:sw())
" }}}2 " }}}2
" "
" "
let ols = s:InOneLineScope(lnum) let ols = s:InOneLineScope(lnum)
if ols > 0 if ols > 0
let ind = ind + &sw let ind = ind + s:sw()
else else
let ols = s:ExitingOneLineScope(lnum) let ols = s:ExitingOneLineScope(lnum)
while ols > 0 && ind > 0 while ols > 0 && ind > 0
let ind = ind - &sw let ind = ind - s:sw()
let ols = s:InOneLineScope(ols - 1) let ols = s:InOneLineScope(ols - 1)
endwhile endwhile
endif endif

View File

@@ -1,16 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1
" Vim indent file
" Language: Jinja HTML template
" Maintainer: Evan Hammer <evan@evanhammer.com>
" Last Change: 2013 Jan 26
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
" Use HTML formatting rules.
runtime! indent/html.vim
endif

View File

@@ -56,10 +56,11 @@ function! GetLiquidIndent(...)
let line = substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') let line = substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','')
let line .= matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+') let line .= matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+')
let cline = substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') let cline = substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','')
let ind += &sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>') let sw = exists('*shiftwidth') ? shiftwidth() : &sw
let ind -= &sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>') let ind += sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>')
let ind -= &sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>') let ind -= sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>')
let ind -= &sw * s:count(cline,'{%\s*end\w*$') let ind -= sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>')
let ind -= sw * s:count(cline,'{%\s*end\w*$')
return ind return ind
endfunction endfunction

146
indent/nim.vim Normal file
View File

@@ -0,0 +1,146 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
" Some preliminary settings
setlocal nolisp " Make sure lisp indenting doesn't supersede us
setlocal autoindent " indentexpr isn't much help otherwise
setlocal indentexpr=GetNimIndent(v:lnum)
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif
" Only define the function once.
if exists("*GetNimIndent")
finish
endif
function! s:FindStartLine(fromln, pattern)
let lnum = a:fromln
let safechoice = indent(lnum)
while getline(lnum) !~ a:pattern
if indent(lnum) == 0 || lnum == 1
return safechoice
endif
let lnum = lnum - 1
endwhile
return indent(lnum)
endfunction
function! GetNimIndent(lnum)
" Search backwards for the previous non-empty line.
let plnum = prevnonblank(a:lnum - 1)
if plnum == 0
" This is the first non-empty line, use zero indent.
return 0
endif
" If the start of the line is in a string don't change the indent.
if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$"
return -1
endif
let pline = getline(plnum)
let cline = getline(a:lnum)
let pline_len = strlen(pline)
let plindent = indent(plnum)
let clindent = indent(a:lnum)
" Remove any trailing comment from previous line.
" Use syntax highlighting attributes when possible.
if has('syntax_items')
" If the last character in the line is a comment, do a binary search for
" the start of the comment. synID() is slow, a linear search would take
" too long on a long line.
if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$"
let min = 1
let max = pline_len
while min < max
let col = (min + max) / 2
if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$"
let max = col
else
let min = col + 1
endif
endwhile
let pline = strpart(pline, 0, min - 1)
endif
else
let col = 0
while col < pline_len
if pline[col] == '#'
let pline = strpart(pline, 0, col)
break
endif
let col = col + 1
endwhile
endif
if cline =~ '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>'
" This is a benign line, do nothing
return -1
endif
" If the current line begins with a keyword that lines up with "try"
if cline =~ '^\s*\(except\|finally\)\>'
let lnum = a:lnum - 1
while lnum >= 1
if getline(lnum) =~ '^\s*\(try\|except\)\>'
let ind = indent(lnum)
if ind >= clindent
return -1 " indent is already less than this
endif
return ind " line up with previous try or except
endif
let lnum = lnum - 1
endwhile
return -1 " no matching "try"!
endif
" If the current line begins with a header keyword, dedent
if cline =~ '^\s*\(elif\|else\)\>'
return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)')
endif
if pline =~ ':\s*$'
"return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\<do\>') + &sw
return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw
endif
if pline =~ '=\s*$'
return s:FindStartLine(plnum, '^\s*\(proc\|template\|macro\|iterator\)\>') + &sw
endif
" if we got here, this should be the begging of a multi-line if expression for example
if pline =~ '^\s*\(if\|when\|proc\|iterator\|macro\|template\|for\|while\)[^:]*$'
return plindent + &sw
endif
if pline =~ '\(type\|import\|const\|var\)\s*$'
\ || pline =~ '=\s*\(object\|enum\|tuple\|generic\)'
return plindent + &sw
endif
" If the previous line was a stop-execution statement...
if pline =~ '^\s*\(break\|continue\|raise\|return\)\>'
" See if the user has already dedented
if indent(a:lnum) > plindent - &sw
" If not, recommend one dedent
return plindent - &sw
endif
" Otherwise, trust the user
return -1
endif
return -1
endfunction
" vim:sw=2
endif

View File

@@ -1,9 +1,9 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pug') == -1
" Vim indent file " Vim indent file
" Language: Jade " Language: Pug
" Maintainer: Joshua Borton " Maintainer: Joshua Borton
" Credits: Tim Pope (vim-jade) " Credits: Tim Pope (vim-pug)
" Last Change: 2010 Sep 22 " Last Change: 2010 Sep 22
if exists("b:did_indent") if exists("b:did_indent")
@@ -14,25 +14,25 @@ unlet! b:did_indent
let b:did_indent = 1 let b:did_indent = 1
setlocal autoindent setlocal autoindent
setlocal indentexpr=GetJadeIndent() setlocal indentexpr=GetPugIndent()
setlocal indentkeys=o,O,*<Return>,},],0),!^F setlocal indentkeys=o,O,*<Return>,},],0),!^F
" Only define the function once. " Only define the function once.
if exists("*GetJadeIndent") if exists("*GetPugIndent")
finish finish
endif endif
let s:attributes = '\%((.\{-\})\)' let s:attributes = '\%((.\{-\})\)'
let s:tag = '\([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' let s:tag = '\([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*'
if !exists('g:jade_self_closing_tags') if !exists('g:pug_self_closing_tags')
let g:jade_self_closing_tags = 'meta|link|img|hr|br|input' let g:pug_self_closing_tags = 'meta|link|img|hr|br|input'
endif endif
setlocal formatoptions+=r setlocal formatoptions+=r
setlocal comments+=n:\| setlocal comments+=n:\|
function! GetJadeIndent() function! GetPugIndent()
let lnum = prevnonblank(v:lnum-1) let lnum = prevnonblank(v:lnum-1)
if lnum == 0 if lnum == 0
return 0 return 0
@@ -60,9 +60,9 @@ function! GetJadeIndent()
return increase return increase
elseif line == '-#' elseif line == '-#'
return increase return increase
elseif line =~? '^\v%('.g:jade_self_closing_tags.')>' elseif line =~? '^\v%('.g:pug_self_closing_tags.')>'
return indent return indent
elseif group =~? '\v^%(jadeAttributesDelimiter|jadeClass|jadeId|htmlTagName|htmlSpecialTagName|jadeFilter|jadeTagBlockChar)$' elseif group =~? '\v^%(pugAttributesDelimiter|pugClass|pugId|htmlTagName|htmlSpecialTagName|pugFilter|pugTagBlockChar)$'
return increase return increase
else else
return indent return indent

View File

@@ -53,11 +53,7 @@ function! GetPuppetIndent()
let pline = getline(pnum) let pline = getline(pnum)
let ind = indent(pnum) let ind = indent(pnum)
if pline =~ '^\s*#' if pline =~ '\({\|\[\|(\|:\)\s*\(#.*\)\?$'
return ind
endif
if pline =~ '\({\|\[\|(\|:\)$'
let ind += &sw let ind += &sw
elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*' elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*'
let ind -= &sw let ind -= &sw

141
indent/purescript.vim Normal file
View File

@@ -0,0 +1,141 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'purescript') == -1
" indentation for purescript
"
" Based on idris indentation
"
" author: raichoo (raichoo@googlemail.com)
"
" Modify g:purescript_indent_if and g:purescript_indent_case to
" change indentation for `if'(default 3) and `case'(default 5).
" Example (in .vimrc):
" > let g:purescript_indent_if = 2
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
if !exists('g:purescript_indent_if')
" if bool
" >>>then ...
" >>>else ...
let g:purescript_indent_if = 3
endif
if !exists('g:purescript_indent_case')
" case xs of
" >>>>>[] -> ...
" >>>>>(y:ys) -> ...
let g:purescript_indent_case = 5
endif
if !exists('g:purescript_indent_let')
" let x = 0 in
" >>>>x
let g:purescript_indent_let = 4
endif
if !exists('g:purescript_indent_where')
" where f :: Int -> Int
" >>>>>>f x = x
let g:purescript_indent_where = 6
endif
if !exists('g:purescript_indent_do')
" do x <- a
" >>>y <- b
let g:purescript_indent_do = 3
endif
setlocal indentexpr=GetPurescriptIndent()
setlocal indentkeys=!^F,o,O,},=where,=in
function! GetPurescriptIndent()
let prevline = getline(v:lnum - 1)
let line = getline(v:lnum)
if line =~ '^\s*\<where\>'
let s = match(prevline, '\S')
return s + 2
endif
if line =~ '^\s*\<in\>'
let n = v:lnum
let s = 0
while s <= 0 && n > 0
let n = n - 1
let s = match(getline(n),'\<let\>')
endwhile
return s + 1
endif
if prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
let s = match(prevline, '=')
if s > 0
return s + 2
endif
let s = match(prevline, ':')
if s > 0
return s + 3
else
return match(prevline, '\S')
endif
endif
if prevline =~ '[{([][^})\]]\+$'
return match(prevline, '[{([]')
endif
if prevline =~ '\<let\>\s\+.\+\(\<in\>\)\?\s*$'
return match(prevline, '\<let\>') + g:purescript_indent_let
endif
if prevline !~ '\<else\>'
let s = match(prevline, '\<if\>.*\&.*\zs\<then\>')
if s > 0
return s
endif
let s = match(prevline, '\<if\>')
if s > 0
return s + g:purescript_indent_if
endif
endif
if prevline =~ '\(\<where\>\|\<do\>\|=\|[{([]\)\s*$'
return match(prevline, '\S') + &shiftwidth
endif
if prevline =~ '\<where\>\s\+\S\+.*$'
return match(prevline, '\<where\>') + g:purescript_indent_where
endif
if prevline =~ '\<do\>\s\+\S\+.*$'
return match(prevline, '\<do\>') + g:purescript_indent_do
endif
if prevline =~ '^\s*\<data\>\s\+[^=]\+\s\+=\s\+\S\+.*$'
return match(prevline, '=')
endif
if prevline =~ '\<case\>\s\+.\+\<of\>\s*$'
return match(prevline, '\<case\>') + g:purescript_indent_case
endif
if prevline =~ '^\s*\<\data\>\s\+\S\+\s*$'
return match(prevline, '\<data\>') + &shiftwidth
endif
if (line =~ '^\s*}\s*' && prevline !~ '^\s*;')
return match(prevline, '\S') - &shiftwidth
endif
return match(prevline, '\S')
endfunction
endif

View File

@@ -125,7 +125,7 @@ let s:indent_access_modifier_regex = '\C^\s*\%(protected\|private\)\s*\%(#.*\)\=
" The reason is that the pipe matches a hanging "|" operator. " The reason is that the pipe matches a hanging "|" operator.
" "
let s:block_regex = let s:block_regex =
\ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|\s*(*\s*\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(*\s*[*@&]\=\h\w*\s*)*\s*\)*|\)\=\s*\%(#.*\)\=$' \ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|[^|]*|\)\=\s*\%(#.*\)\=$'
let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex

View File

@@ -31,9 +31,7 @@ function! GetSassIndent()
let indent = indent(lnum) let indent = indent(lnum)
let cindent = indent(v:lnum) let cindent = indent(v:lnum)
if line !~ s:property && line !~ s:extend && cline =~ s:property if line !~ s:property && line !~ s:extend && cline =~ s:property
return indent + &sw return indent + (exists('*shiftwidth') ? shiftwidth() : &sw)
"elseif line =~ s:property && cline !~ s:property
"return indent - &sw
else else
return -1 return -1
endif endif

View File

@@ -14,7 +14,6 @@ let s:cpo_save = &cpo
set cpo&vim set cpo&vim
setlocal nosmartindent setlocal nosmartindent
setlocal indentkeys-=:
setlocal indentkeys-=e setlocal indentkeys-=e
setlocal indentkeys+=0] setlocal indentkeys+=0]
setlocal indentexpr=SwiftIndent() setlocal indentexpr=SwiftIndent()
@@ -95,11 +94,13 @@ function! SwiftIndent(...)
return -1 return -1
endif endif
return indent(openingSquare) " - Line starts with closing square, indent as opening square
endif if line =~ '\v^\s*]'
return indent(openingSquare)
endif
if s:IsExcludedFromIndent() " - Line contains closing square and more, indent a level above opening
return previousIndent return indent(openingSquare) + shiftwidth()
endif endif
if line =~ ":$" if line =~ ":$"
@@ -153,7 +154,8 @@ function! SwiftIndent(...)
endif endif
return indent(openingBracket) return indent(openingBracket)
else else
return -1 " - Current line is blank, and the user presses 'o'
return previousIndent
endif endif
endif endif
@@ -195,7 +197,7 @@ function! SwiftIndent(...)
endif endif
let previousParen = match(previous, "(") let previousParen = match(previous, "(")
return previousParen + 1 return indent(previousParen) + shiftwidth()
endif endif
if numOpenBrackets > numCloseBrackets if numOpenBrackets > numCloseBrackets
@@ -207,6 +209,11 @@ function! SwiftIndent(...)
return indent(openingParen) + shiftwidth() return indent(openingParen) + shiftwidth()
endif endif
" - Previous line has close then open braces, indent previous + 1 'sw'
if previous =~ "}.*{"
return previousIndent + shiftwidth()
endif
let line = line(".") let line = line(".")
let column = col(".") let column = col(".")
call cursor(previousNum, column) call cursor(previousNum, column)
@@ -216,9 +223,14 @@ function! SwiftIndent(...)
return indent(openingParen) return indent(openingParen)
endif endif
" - Line above has (unmatched) open paren, next line needs indent
if numOpenParens > 0 if numOpenParens > 0
let previousParen = match(previous, "(") let savePosition = getcurpos()
return previousParen + 1 " Must be at EOL because open paren has to be above (left of) the cursor
call cursor(previousNum, col("$"))
let previousParen = searchpair("(", "", ")", "bWn", "s:IsExcludedFromIndent()")
call setpos(".", savePosition)
return indent(previousParen) + shiftwidth()
endif endif
return cindent return cindent

View File

@@ -1,105 +1,505 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'typescript') == -1
" Vim indent file, taken from indent/java.vim " Vim indent file
" Language: Typescript " Language: Typescript
" Maintainer: None! Wanna improve this? " Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org
" Last Change: 2015 Mar 07
if get(g:, 'typescript_indent_disable') " 0. Initialization {{{1
finish " =================
endif
" 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") if exists("b:did_indent")
finish finish
endif endif
let b:did_indent = 1 let b:did_indent = 1
" Use javascript cindent options setlocal nosmartindent
setlocal cindent cinoptions& cinoptions+=j1,J1
setlocal indentkeys&
" Load typescript indent function " Now, set up our indentation expression and keys that trigger it.
setlocal indentexpr=GetTypescriptIndent() setlocal indentexpr=GetTypescriptIndent()
setlocal formatexpr=Fixedgq(v:lnum,v:count)
setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e
let b:undo_indent = "setl cin< cino< indentkeys< indentexpr<" " Only define the function once.
" Only define the function once
if exists("*GetTypescriptIndent") if exists("*GetTypescriptIndent")
finish finish
endif endif
" Make sure we have vim capabilities let s:cpo_save = &cpo
let s:keepcpo = &cpo
set cpo&vim set cpo&vim
function! TypescriptPrevNonBlankOrComment(lnum) " 1. Variables {{{1
let pnum = prevnonblank(a:lnum) " ============
" skip any comments (either `//`, `/*` or `*`)
while getline(pnum) =~ '^\s*\(\/\/\|\/\*\|\*\)' let s:ts_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\)'
let pnum = prevnonblank(pnum-1)
endwhile " Regex of syntax group names that are or delimit string or are comments.
return pnum let s:syng_strcom = 'string\|regex\|comment\c'
" 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().
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
" Regex that defines continuation lines, not including (, {, or [.
let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=]=[^=].*,\)' . s:line_term
" Regex that defines continuation lines.
" TODO: this needs to deal with if ...: and so on
let s:msl_regex = s:continuation_regex
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
" Check if the character at lnum:col is inside a string.
function s:IsInString(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
endfunction
" Check if the character at lnum:col is inside a multi-line comment.
function s:IsInMultilineComment(lnum, col)
return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
endfunction
" Check if the character at lnum:col is a line comment.
function s:IsLineComment(lnum, col)
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
return lnum
endfunction
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
function s:GetMSL(lnum, in_one_line_scope)
" Start on the line we're at and use its indent.
let msl = a:lnum
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
while lnum > 0
" If we have a continuation line, or we're in a string, use line as MSL.
" Otherwise, terminate search as we have found our MSL already.
let line = getline(lnum)
let col = match(line, s:msl_regex) + 1
if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line))
let msl = lnum
else
" 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
"
if a:in_one_line_scope
break
end
let msl_one_line = s:Match(lnum, s:one_line_scope_regex)
if msl_one_line == 0
break
endif
endif
let lnum = s:PrevNonBlankNonString(lnum - 1)
endwhile
return msl
endfunction
function s:RemoveTrailingComments(content)
let single = '\/\/\(.*\)\s*$'
let multi = '\/\*\(.*\)\*\/\s*$'
return substitute(substitute(a:content, single, '', ''), multi, '', '')
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 ts keyword
if (line =~ s:ts_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 ts 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) - &sw
else
return indent(lvar) + &sw
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
if !s:IsInStringOrComment(a:lnum, pos + 1)
let idx = stridx('(){}[]', line[pos])
if idx % 2 == 0
let open_{idx} = open_{idx} + 1
else
let open_{idx - 1} = open_{idx - 1} - 1
endif
endif
let pos = match(line, '[][(){}]', pos + 1)
endwhile
return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
endfunction
function s:Match(lnum, regex)
let col = match(getline(a:lnum), a:regex) + 1
return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0
endfunction
function s:IndentWithContinuation(lnum, ind, width)
" Set up variables to use and search for MSL to the previous line.
let p_lnum = a:lnum
let lnum = s:GetMSL(a:lnum, 1)
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
" Set up more variables now that we know we aren't continuation bound.
let msl_ind = indent(lnum)
" If the previous line ended with [*+/.-=], start a continuation that
" indents an extra level.
if s:Match(lnum, s:continuation_regex)
if lnum == p_lnum
return msl_ind + a:width
else
return msl_ind
endif
endif
return a:ind
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()
" 3.1. Setup {{{2
" ----------
" default value: trust cindent " Set up variables for restoring position in file. Could use v:lnum here.
let ind = cindent(v:lnum) let vcol = col('.')
if getline(v:lnum) =~ '^\s*[{}\*]' " 3.2. Work on the current line {{{2
return ind " -----------------------------
endif
" The last non-empty line let ind = -1
let prev = TypescriptPrevNonBlankOrComment(v:lnum-1) " Get the current line.
let line = getline(v:lnum)
" previous nonblank line number
let prevline = prevnonblank(v:lnum - 1)
" Check if the previous line consists of a single `<variable> : <type>;` " If we got a closing bracket on an empty line, find its match and indent
" declaration (e.g. in interface definitions) " according to it. For parentheses we indent to its column - 1, for the
if getline(prev) =~ '^\s*\w\+\s*:[^{]\+;\s*$' " others we indent to the containing line's MSL's level. Return -1 if fail.
return indent(prev) let col = matchend(line, '^\s*[],})]')
endif if col > 0 && !s:IsInStringOrComment(v:lnum, col)
call cursor(v:lnum, col)
" If the previous line starts with '@', we should have the same indent as let lvar = s:InMultiVarStatement(v:lnum)
" the previous one if lvar
if getline(prev) =~ '^\s*@\S\+\s*$' let prevline_contents = s:RemoveTrailingComments(getline(prevline))
return indent(prev)
endif
" If a var, let, or const was declared and the semicolon omitted, do not " check for comma first
" indent the next line if (line[col - 1] =~ ',')
if getline(prev) =~ '^\s*\(var\|let\|const\)\s\+\w\+' " if the previous line ends in comma or semicolon don't indent
return indent(prev) if (prevline_contents =~ '[;,]\s*$')
endif return indent(s:GetMSL(line('.'), 0))
" get previous line indent, if it's comma first return prevline indent
" If the line ended with a ',', we should have the same indent as elseif (prevline_contents =~ s:comma_first)
" the previous one return indent(prevline)
if getline(prev) =~ ',\s*$' " otherwise we indent 1 level
return indent(prev) else
endif return indent(lvar) + &sw
" Try to find out whether the last `}` ended a `<variable> : {` block
if getline(prev) =~ '};\s*$'
" jump to matching `{` bracket
call cursor(prev, 1)
silent normal %
" See if current line is type annotation without closing ';' but open
" `{` bracket
let lnum = line('.')
if getline(lnum) =~ '^\s*\w\+\s*:[^;]\+{'
let ind = indent(lnum)
endif endif
endif
endif endif
return ind
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
" If the line is comma first, dedent 1 level
if (getline(prevline) =~ s:comma_first)
return indent(prevline) - &sw
endif
if (line =~ s:ternary)
if (getline(prevline) =~ s:ternary_q)
return indent(prevline)
else
return indent(prevline) + &sw
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)) + &sw
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 + &sw
else
return virtcol('.')
endif
elseif counts[1] == '1' || counts[2] == '1'
return ind + &sw
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, &sw)
" }}}2
"
"
let ols = s:InOneLineScope(lnum)
if ols > 0
let ind = ind + &sw
else
let ols = s:ExitingOneLineScope(lnum)
while ols > 0 && ind > 0
let ind = ind - &sw
let ols = s:InOneLineScope(ols - 1)
endwhile
endif
return ind
endfunction endfunction
" Restore compatibility mode " }}}1
let &cpo = s:keepcpo
unlet s:keepcpo
" vim: et let &cpo = 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
endif endif

View File

@@ -80,11 +80,17 @@ endif
syn keyword ansible_debug_keywords debug containedin=yamlBlockMappingKey contained syn keyword ansible_debug_keywords debug containedin=yamlBlockMappingKey contained
highlight link ansible_debug_keywords Debug highlight link ansible_debug_keywords Debug
syn match ansible_with_keywords "\vwith_.+" containedin=yamlBlockMappingKey contained if exists("g:ansible_extra_keywords_highlight")
syn keyword ansible_extra_special_keywords register always_run changed_when failed_when no_log args vars delegate_to ignore_errors containedin=yamlBlockMappingKey contained
highlight link ansible_extra_special_keywords Statement
endif
syn keyword ansible_special_keywords include until retries delay when only_if become become_user block rescue always notify containedin=yamlBlockMappingKey contained syn keyword ansible_special_keywords include until retries delay when only_if become become_user block rescue always notify containedin=yamlBlockMappingKey contained
highlight link ansible_with_keywords Statement
highlight link ansible_special_keywords Statement highlight link ansible_special_keywords Statement
syn match ansible_with_keywords "\vwith_.+" containedin=yamlBlockMappingKey contained
highlight link ansible_with_keywords Statement
let b:current_syntax = "ansible" let b:current_syntax = "ansible"
endif endif

View File

@@ -1,45 +1,51 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'blade') == -1
" Language: Blade " Vim syntax file
" Language: Blade (Laravel)
" Maintainer: Jason Walton <jwalton512@gmail.com> " Maintainer: Jason Walton <jwalton512@gmail.com>
" URL: https://github.com/xsbeats/vim-blade " Filenames: *.blade.php
" License: DBAD
" Check if our syntax is already loaded if exists('b:current_syntax')
if exists('b:current_syntax') && b:current_syntax == 'blade'
finish finish
endif endif
" Include PHP if !exists("main_syntax")
let main_syntax = 'blade'
endif
runtime! syntax/html.vim
unlet! b:current_syntax
runtime! syntax/php.vim runtime! syntax/php.vim
silent! unlet b:current_syntax unlet! b:current_syntax
" Echos syn case match
syn region bladeUnescapedEcho matchgroup=bladeEchoDelim start=/@\@<!\s*{!!/ end=/!!}\s*/ oneline contains=@phpClTop containedin=ALLBUT,bladeComment syn clear htmlError
syn region bladeEscapedEcho matchgroup=bladeEchoDelim start=/@\@<!\s*{{{\@!/ end=/}}\s*/ oneline contains=@phpClTop containedin=ALLBUT,bladeComment
syn region bladeEscapedEcho matchgroup=bladeEchoDelim start=/@\@<!\s*{{{{\@!/ end=/}}}/ oneline contains=@phpClTop containedin=ALLBUT,bladeComment
" Structures syn region bladeEcho matchgroup=bladeDelimiter start="@\@<!{{" end="}}" contains=@bladePhp,bladePhpParenBlock containedin=ALLBUT,@bladeExempt keepend
syn match bladeStructure /\s*@\(else\|empty\|endfor\|endforeach\|endforelse\|endif\|endpush\|endsection\|endunless\|endwhile\|overwrite\|show\|stop\)\>/ syn region bladeEcho matchgroup=bladeDelimiter start="{!!" end="!!}" contains=@bladePhp,bladePhpParenBlock containedin=ALLBUT,@bladeExempt keepend
syn match bladeStructure /\s*@\(append\|choice\|each\|elseif\|extends\|for\|foreach\|forelse\|if\|include\|lang\|push\|section\|stack\|unless\|while\|yield\|\)\>\s*/ nextgroup=bladeParens syn region bladeComment matchgroup=bladeDelimiter start="{{--" end="--}}" contains=bladeTodo containedin=ALLBUT,@bladeExempt keepend
syn region bladeParens matchgroup=bladeParen start=/(/ end=/)/ contained contains=@bladeAll,@phpClTop
" Comments syn keyword bladeKeyword @if @elseif @foreach @forelse @for @while @can @include @each @inject @extends @section @stack @push @unless @yield @parent @hasSection nextgroup=bladePhpParenBlock skipwhite containedin=ALLBUT,@bladeExempt
syn region bladeComments start=/\s*{{--/ end=/--}}/ contains=bladeComment keepend syn keyword bladeKeyword @else @endif @endunless @endfor @endforeach @empty @endforelse @endwhile @endcan @stop @append @endsection @endpush @show containedin=ALLBUT,@bladeExempt
syn match bladeComment /.*/ contained containedin=bladeComments
" Clusters syn region bladePhpParenBlock matchgroup=bladeDelimiter start="\s*(" end=")" contains=@bladePhp,bladePhpParenBlock skipwhite contained
syn cluster bladeAll contains=bladeStructure,bladeParens
" Highlighting syn cluster bladePhp contains=@phpClTop
syn cluster bladeExempt contains=bladeComment,@htmlTop
syn cluster htmlPreproc add=bladeEcho,bladeComment
syn keyword bladeTodo todo fixme xxx contained
hi def link bladeDelimiter PreProc
hi def link bladeComment Comment hi def link bladeComment Comment
hi def link bladeEchoDelim Delimiter hi def link bladeTodo Todo
hi def link bladeParen Delimiter hi def link bladeKeyword Statement
hi def link bladeStructure Keyword
let b:current_syntax = 'blade'
if !exists('b:current_syntax') if exists('main_syntax') && main_syntax == 'blade'
let b:current_syntax = 'blade' unlet main_syntax
endif endif
endif endif

View File

@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c/c++') == -1
" Vim syntax file " Vim syntax file
" Language: C " Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org> " Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2015 Mar 05 " Last Change: 2016 Apr 10
" Quit when a (custom) syntax file was already loaded " Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax") if exists("b:current_syntax")
@@ -250,6 +250,10 @@ if !exists("c_no_c99") " ISO C99
syn keyword cType _Bool bool _Complex complex _Imaginary imaginary syn keyword cType _Bool bool _Complex complex _Imaginary imaginary
syn keyword cType int8_t int16_t int32_t int64_t syn keyword cType int8_t int16_t int32_t int64_t
syn keyword cType uint8_t uint16_t uint32_t uint64_t syn keyword cType uint8_t uint16_t uint32_t uint64_t
if !exists("c_no_bsd")
" These are BSD specific.
syn keyword cType u_int8_t u_int16_t u_int32_t u_int64_t
endif
syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t
syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t
syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t
@@ -266,7 +270,7 @@ syn keyword cStorageClass static register auto volatile extern const
if exists("c_gnu") if exists("c_gnu")
syn keyword cStorageClass inline __attribute__ syn keyword cStorageClass inline __attribute__
endif endif
if !exists("c_no_c99") if !exists("c_no_c99") && s:ft !=# 'cpp'
syn keyword cStorageClass inline restrict syn keyword cStorageClass inline restrict
endif endif
if !exists("c_no_c11") if !exists("c_no_c11")

View File

@@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c/c++') == -1
" Language: C++ " Language: C++
" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu> " Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
" Last Change: 2015 Sep 23 " Last Change: 2015 Nov 10
" For version 5.x: Clear all syntax items " For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded " For version 6.x: Quit when a syntax file was already loaded

114
syntax/cryptol.vim Normal file
View File

@@ -0,0 +1,114 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cryptol') == -1
" Vim syntax file
" Language: Cryptol
" Maintainer: Fergus Henderson
" Last Change: Thu Feb 10 13:14:24 PST 2005
"
" Remove any old syntax stuff hanging around
if version < 600
syn clear
elseif exists("b:current_syntax")
finish
endif
set expandtab
set list lcs=tab:>-,trail:.
" (Qualified) identifiers (no default highlighting)
" XXX copied from Haskell
syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>"
syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>"
" Infix operators--most punctuation characters and any (qualified) identifier
" enclosed in `backquotes`. An operator starting with : is a constructor,
" others are variables (e.g. functions).
" XXX copied from Haskell
syn match cryVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*"
syn match cryConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*"
syn match cryVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`"
syn match cryConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`"
" Reserved symbols
syn match cryDelimiter "(\|)\|\[|\||]\|||\|\[\|\]\|,\|;\|{\|}"
" Strings and constants
" XXX Copied from Haskell
syn match crySpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
syn match crySpecialChar contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)"
syn match crySpecialCharError contained "\\&\|'''\+"
syn region cryString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=crySpecialChar
syn region cryString start=+``+ skip=+\\\\\|\\"+ end=+``+ contains=hsSpecialChar
syn match cryCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=crySpecialChar,crySpecialCharError
syn match cryCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=crySpecialChar,crySpecialCharError
syn match cryNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
" Keyword definitions.
syn keyword cryInclude include
syn keyword cryConditional if then else
syn keyword cryWhere where
syn keyword cryTypeSyn type
syn keyword cryPragma pragma
syn keyword cryProp extern theorem proof forall codeGen Cpp Haskell SMT Isabelle axioms
syn keyword cryType Bit inf
" Primitives
syn keyword cryBoolean False True
syn keyword cryPrimitive zero undefined
syn keyword cryPrimitive error parity lg2 pmod pdiv pmult format
syn keyword cryPrimitive join split groupBy take drop min max negate reverse
syn keyword cryPrimitive project tail width
syn keyword cryPrimitive ASSERT
" Comments
syn match cryLineComment "//.*"
syn region cryBlockComment start="/\*" end="\*/" contains=cryBlockComment
if !exists("cry_minlines")
let cry_minlines = 50
endif
exec "syn sync lines=" . cry_minlines
if version >= 508 || !exists("did_cry_syntax_inits")
if version < 508
let did_cry_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
hi link cryInclude Include
hi link cryTypeSyn Keyword
hi link cryImportMod cryImport
hi link cryConditional Conditional
hi link crySpecialChar SpecialChar
hi link cryTypedef Typedef
hi link cryPragma Keyword
hi link cryVarSym cryOperator
hi link cryConSym cryOperator
hi link cryOperator Operator
hi link cryDelimiter Delimiter
hi link crySpecialCharError Error
hi link cryString String
hi link cryCharacter Character
hi link cryNumber Number
hi link cryConditional Conditional
hi link cryWhere Keyword
hi link cryPrimitive Keyword
hi link cryBlockComment cryComment
hi link cryLineComment cryComment
hi link cryComment Comment
hi link cryBoolean Boolean
hi link cryType Type
hi link cryProp Keyword
delcommand HiLink
endif
let b:current_syntax = "cryptol"
" Options for vi: ts=8 sw=2 sts=2 nowrap noexpandtab ft=vim
endif

393
syntax/crystal.vim Normal file
View File

@@ -0,0 +1,393 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
" Language: Crystal
" Based on Ruby syntax highlight
" which is made by Mirko Nasato and Doug Kearns
" ---------------------------------------------
if exists('b:current_syntax')
finish
endif
syn cluster crystalNotTop contains=@crystalExtendedStringSpecial,@crystalRegexpSpecial,@crystalDeclaration,crystalConditional,crystalExceptional,crystalMethodExceptional,crystalTodo,crystalLinkAttr
if exists('crystal_space_errors')
if !exists('crystal_no_trail_space_error')
syn match crystalSpaceError display excludenl "\s\+$"
endif
if !exists('crystal_no_tab_space_error')
syn match crystalSpaceError display " \+\t"me=e-1
endif
endif
" Operators
if exists('crystal_operators')
syn match crystalOperator "[~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::"
syn match crystalOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!="
syn region crystalBracketOperator matchgroup=crystalOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@crystalNotTop
endif
" Expression Substitution and Backslash Notation
syn match crystalStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}" contained display
syn match crystalStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display
syn region crystalInterpolation matchgroup=crystalInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@crystalNotTop
syn match crystalInterpolation "#\%(\$\|@@\=\)\w\+" display contained contains=crystalInterpolationDelimiter,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable,crystalPredefinedVariable
syn match crystalInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained
syn match crystalInterpolation "#\$\%(-\w\|\W\)" display contained contains=crystalInterpolationDelimiter,crystalPredefinedVariable,crystalInvalidVariable
syn match crystalInterpolationDelimiter "#\ze\$\%(-\w\|\W\)" display contained
syn region crystalNoInterpolation start="\\#{" end="}" contained
syn match crystalNoInterpolation "\\#{" display contained
syn match crystalNoInterpolation "\\#\%(\$\|@@\=\)\w\+" display contained
syn match crystalNoInterpolation "\\#\$\W" display contained
syn match crystalDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE
syn region crystalNestedParentheses start="(" skip="\\\\\|\\)" matchgroup=crystalString end=")" transparent contained
syn region crystalNestedCurlyBraces start="{" skip="\\\\\|\\}" matchgroup=crystalString end="}" transparent contained
syn region crystalNestedAngleBrackets start="<" skip="\\\\\|\\>" matchgroup=crystalString end=">" transparent contained
syn region crystalNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=crystalString end="\]" transparent contained
" These are mostly Oniguruma ready
syn region crystalRegexpComment matchgroup=crystalRegexpSpecial start="(?#" skip="\\)" end=")" contained
syn region crystalRegexpParens matchgroup=crystalRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)" end=")" contained transparent contains=@crystalRegexpSpecial
syn region crystalRegexpBrackets matchgroup=crystalRegexpCharClass start="\[\^\=" skip="\\\]" end="\]" contained transparent contains=crystalStringEscape,crystalRegexpEscape,crystalRegexpCharClass oneline
syn match crystalRegexpCharClass "\\[DdHhSsWw]" contained display
syn match crystalRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained
syn match crystalRegexpEscape "\\[].*?+^$|\\/(){}[]" contained
syn match crystalRegexpQuantifier "[*?+][?+]\=" contained display
syn match crystalRegexpQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display
syn match crystalRegexpAnchor "[$^]\|\\[ABbGZz]" contained display
syn match crystalRegexpDot "\." contained display
syn match crystalRegexpSpecial "|" contained display
syn match crystalRegexpSpecial "\\[1-9]\d\=\d\@!" contained display
syn match crystalRegexpSpecial "\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display
syn match crystalRegexpSpecial "\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display
syn match crystalRegexpSpecial "\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display
syn match crystalRegexpSpecial "\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display
syn cluster crystalStringSpecial contains=crystalInterpolation,crystalNoInterpolation,crystalStringEscape
syn cluster crystalExtendedStringSpecial contains=@crystalStringSpecial,crystalNestedParentheses,crystalNestedCurlyBraces,crystalNestedAngleBrackets,crystalNestedSquareBrackets
syn cluster crystalRegexpSpecial contains=crystalInterpolation,crystalNoInterpolation,crystalStringEscape,crystalRegexpSpecial,crystalRegexpEscape,crystalRegexpBrackets,crystalRegexpCharClass,crystalRegexpDot,crystalRegexpQuantifier,crystalRegexpAnchor,crystalRegexpParens,crystalRegexpComment
" Numbers and ASCII Codes
syn match crystalASCIICode "\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)"
syn match crystalInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*\%(_*[ufi]\%(32\|64\)\)\=\>" display
syn match crystalInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(_\x\+\)*\%(_*[ufi]\%(32\|64\)\)\=\>" display
syn match crystalInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*\%(_\x\+\)*\%(_*[ufi]\%(32\|64\)\)\=\>" display
syn match crystalInteger "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*\%(_\x\+\)*\%(_*[ufi]\%(32\|64\)\)\=\>" display
syn match crystalFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*\%(_*f\%(32\|64\)\)\=\>" display
syn match crystalFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\%(_*f\%(32\|64\)\)\=\>" display
" Identifiers
syn match crystalLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
syn match crystalBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent
syn match crystalConstant "\%(\%([.@$]\@<!\.\)\@<!\<\|::\)\_s*\zs\u\w*\%(\>\|::\)\@="
syn match crystalClassVariable "@@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display
syn match crystalInstanceVariable "@\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display
syn match crystalGlobalVariable "$\%(\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*\|-.\)"
syn match crystalFreshVariable "\%(\h\|[^\x00-\x7F]\)\@<!%\%(\h\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" display
syn match crystalSymbol "[]})\"':]\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[][=?]\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)"
syn match crystalSymbol "[]})\"':]\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)"
syn match crystalSymbol "[]})\"':]\@<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*"
syn match crystalSymbol "[]})\"':]\@<!:\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\="
syn match crystalSymbol "\%([{(,]\_s*\)\@<=\l\w*[!?]\=::\@!"he=e-1
syn match crystalSymbol "[]})\"':]\@<!\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:\s\@="he=e-1
syn match crystalSymbol "\%([{(,]\_s*\)\@<=[[:space:],{]\l\w*[!?]\=::\@!"hs=s+1,he=e-1
syn match crystalSymbol "[[:space:],{]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:\s\@="hs=s+1,he=e-1
syn region crystalSymbol start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@crystalStringSpecial fold
syn match crystalBlockParameter "\%(\h\|%\|[^\x00-\x7F]\)\%(\w\|%\|[^\x00-\x7F]\)*" contained
syn region crystalBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=crystalBlockParameter
syn match crystalInvalidVariable "$[^ %A-Za-z_-]"
syn match crystalPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~]#
syn match crystalPredefinedVariable "$\d\+" display
syn match crystalPredefinedVariable "$_\>" display
syn match crystalPredefinedVariable "$-[0FIKadilpvw]\>" display
syn match crystalPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display
syn match crystalPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display
syn match crystalPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>\%(\s*(\)\@!"
syn match crystalPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(DATA\|FALSE\|NIL\)\>\%(\s*(\)\@!"
syn match crystalPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!"
syn match crystalPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(crystal_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!"
" Normal Regular Expression
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|ifdef\|when\|not\|then\|else\)\|[;\~=!|&(,[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial fold
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@crystalRegexpSpecial fold
" Generalized Regular Expression
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.? /]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@crystalRegexpSpecial fold
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r{" end="}[iomxneus]*" skip="\\\\\|\\}" contains=@crystalRegexpSpecial fold
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r<" end=">[iomxneus]*" skip="\\\\\|\\>" contains=@crystalRegexpSpecial,crystalNestedAngleBrackets,crystalDelimEscape fold
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r\[" end="\][iomxneus]*" skip="\\\\\|\\\]" contains=@crystalRegexpSpecial fold
syn region crystalRegexp matchgroup=crystalRegexpDelimiter start="%r(" end=")[iomxneus]*" skip="\\\\\|\\)" contains=@crystalRegexpSpecial fold
" Normal String and Shell Command Output
syn region crystalString matchgroup=crystalStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@crystalStringSpecial,@Spell fold
syn region crystalString matchgroup=crystalStringDelimiter start="`" end="`" skip="\\\\\|\\`" contains=@crystalStringSpecial fold
" Character
syn match crystalCharLiteral "'\%([^\\]\|\\[abefnrstv'\\]\|\\\o\{1,3}\|\\x\x\{1,2}\|\\u\x\{4}\)'" contained display
" Generalized Single Quoted String, Symbol and Array of Strings
syn region crystalString matchgroup=crystalStringDelimiter start="%[qwi]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[qwi]{" end="}" skip="\\\\\|\\}" fold contains=crystalNestedCurlyBraces,crystalDelimEscape
syn region crystalString matchgroup=crystalStringDelimiter start="%[qwi]<" end=">" skip="\\\\\|\\>" fold contains=crystalNestedAngleBrackets,crystalDelimEscape
syn region crystalString matchgroup=crystalStringDelimiter start="%[qwi]\[" end="\]" skip="\\\\\|\\\]" fold contains=crystalNestedSquareBrackets,crystalDelimEscape
syn region crystalString matchgroup=crystalStringDelimiter start="%[qwi](" end=")" skip="\\\\\|\\)" fold contains=crystalNestedParentheses,crystalDelimEscape
syn region crystalString matchgroup=crystalStringDelimiter start="%q " end=" " skip="\\\\\|\\)" fold
syn region crystalSymbol matchgroup=crystalSymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.? /]\)" end="\z1" skip="\\\\\|\\\z1" fold
syn region crystalSymbol matchgroup=crystalSymbolDelimiter start="%s{" end="}" skip="\\\\\|\\}" fold contains=crystalNestedCurlyBraces,crystalDelimEscape
syn region crystalSymbol matchgroup=crystalSymbolDelimiter start="%s<" end=">" skip="\\\\\|\\>" fold contains=crystalNestedAngleBrackets,crystalDelimEscape
syn region crystalSymbol matchgroup=crystalSymbolDelimiter start="%s\[" end="\]" skip="\\\\\|\\\]" fold contains=crystalNestedSquareBrackets,crystalDelimEscape
syn region crystalSymbol matchgroup=crystalSymbolDelimiter start="%s(" end=")" skip="\\\\\|\\)" fold contains=crystalNestedParentheses,crystalDelimEscape
" Generalized Double Quoted String and Array of Strings and Shell Command Output
" Note: %= is not matched here as the beginning of a double quoted string
syn region crystalString matchgroup=crystalStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@crystalStringSpecial fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[QWIx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@crystalStringSpecial fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[QWIx]\={" end="}" skip="\\\\\|\\}" contains=@crystalStringSpecial,crystalNestedCurlyBraces,crystalDelimEscape fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[QWIx]\=<" end=">" skip="\\\\\|\\>" contains=@crystalStringSpecial,crystalNestedAngleBrackets,crystalDelimEscape fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[QWIx]\=\[" end="\]" skip="\\\\\|\\\]" contains=@crystalStringSpecial,crystalNestedSquareBrackets,crystalDelimEscape fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[QWIx]\=(" end=")" skip="\\\\\|\\)" contains=@crystalStringSpecial,crystalNestedParentheses,crystalDelimEscape fold
syn region crystalString matchgroup=crystalStringDelimiter start="%[Qx] " end=" " skip="\\\\\|\\)" contains=@crystalStringSpecial fold
" Here Document
syn region crystalHeredocStart matchgroup=crystalStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@crystalNotTop
syn region crystalHeredocStart matchgroup=crystalStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@crystalNotTop
syn region crystalHeredocStart matchgroup=crystalStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@crystalNotTop
syn region crystalHeredocStart matchgroup=crystalStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@crystalNotTop
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=crystalStringDelimiter end=+^\z1$+ contains=crystalHeredocStart,crystalHeredoc,@crystalStringSpecial fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=crystalStringDelimiter end=+^\z1$+ contains=crystalHeredocStart,crystalHeredoc,@crystalStringSpecial fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=crystalStringDelimiter end=+^\z1$+ contains=crystalHeredocStart,crystalHeredoc fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=crystalStringDelimiter end=+^\z1$+ contains=crystalHeredocStart,crystalHeredoc,@crystalStringSpecial fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=crystalStringDelimiter end=+^\s*\zs\z1$+ contains=crystalHeredocStart,@crystalStringSpecial fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-"\z([^"]*\)"\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=crystalStringDelimiter end=+^\s*\zs\z1$+ contains=crystalHeredocStart,@crystalStringSpecial fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-'\z([^']*\)'\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=crystalStringDelimiter end=+^\s*\zs\z1$+ contains=crystalHeredocStart fold keepend
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=crystalStringDelimiter end=+^\s*\zs\z1$+ contains=crystalHeredocStart,@crystalStringSpecial fold keepend
if exists('main_syntax') && g:main_syntax ==# 'ecrystal'
let b:crystal_no_expensive = 1
end
syn match crystalAliasDeclaration "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable nextgroup=crystalAliasDeclaration2 skipwhite
syn match crystalAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable
syn match crystalMethodDeclaration "[^[:space:];#(]\+" contained contains=crystalConstant,crystalBoolean,crystalPseudoVariable,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable
syn match crystalFunctionDeclaration "[^[:space:];#=]\+" contained contains=crystalConstant
syn match crystalTypeDeclaration "[^[:space:];#=]\+" contained contains=crystalConstant
syn match crystalClassDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
syn match crystalModuleDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
syn match crystalStructDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
syn match crystalLibDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
syn match crystalMacroDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant,crystalOperator
syn match crystalEnumDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant
syn match crystalFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=crystalMethodDeclaration,crystalFunctionDeclaration
syn match crystalFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2
syn match crystalFunction "\%([[:space:].]\|^\)\@<=\%(\[\][=?]\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration
syn cluster crystalDeclaration contains=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration,crystalModuleDeclaration,crystalClassDeclaration,crystalStructDeclaration,crystalLibDeclaration,crystalMacroDeclaration,crystalFunction,crystalBlockParameter,crystalTypeDeclaration,crystalEnumDeclaration
" Keywords
" Note: the following keywords have already been defined:
" begin case class def do end for if module unless until while
syn match crystalControl "\<\%(break\|in\|next\|rescue\|return\)\>[?!]\@!"
syn match crystalOperator "\<defined?" display
syn match crystalKeyword "\<\%(super\|previous_def\|yield\|as\|of\|with\)\>[?!]\@!"
syn match crystalBoolean "\<\%(true\|false\)\>[?!]\@!"
syn match crystalPseudoVariable "\<\%(nil\|self\|__DIR__\|__FILE__\|__LINE__\)\>[?!]\@!" " TODO: reorganise
" Expensive Mode - match 'end' with the appropriate opening keyword for syntax
" based folding and special highlighting of module/class/method definitions
if !exists('b:crystal_no_expensive') && !exists('crystal_no_expensive')
syn match crystalDefine "\<alias\>" nextgroup=crystalAliasDeclaration skipwhite skipnl
syn match crystalDefine "\<def\>" nextgroup=crystalMethodDeclaration skipwhite skipnl
syn match crystalDefine "\<fun\>" nextgroup=crystalFunctionDeclaration skipwhite skipnl
syn match crystalDefine "\<undef\>" nextgroup=crystalFunction skipwhite skipnl
syn match crystalDefine "\<\%(type\|alias\)\>\%(\s*\h\w*\s*=\)\@=" nextgroup=crystalTypeDeclaration skipwhite skipnl
syn match crystalClass "\<class\>" nextgroup=crystalClassDeclaration skipwhite skipnl
syn match crystalModule "\<module\>" nextgroup=crystalModuleDeclaration skipwhite skipnl
syn match crystalStruct "\<struct\>" nextgroup=crystalStructDeclaration skipwhite skipnl
syn match crystalLib "\<lib\>" nextgroup=crystalLibDeclaration skipwhite skipnl
syn match crystalMacro "\<macro\>" nextgroup=crystalMacroDeclaration skipwhite skipnl
syn match crystalEnum "\<enum\>" nextgroup=crystalEnumDeclaration skipwhite skipnl
syn region crystalMethodBlock start="\<\%(def\|macro\)\>" matchgroup=crystalDefine end="\%(\<\%(def\|macro\)\_s\+\)\@<!\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalBlock start="\<class\>" matchgroup=crystalClass end="\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalBlock start="\<module\>" matchgroup=crystalModule end="\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalBlock start="\<struct\>" matchgroup=crystalStruct end="\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalBlock start="\<lib\>" matchgroup=crystalLib end="\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalBlock start="\<enum\>" matchgroup=crystalEnum end="\<end\>" contains=ALLBUT,@crystalNotTop fold
" modifiers
syn match crystalConditionalModifier "\<\%(if\|unless\|ifdef\)\>" display
syn match crystalRepeatModifier "\<\%(while\|until\)\>" display
syn region crystalDoBlock matchgroup=crystalControl start="\<do\>" end="\<end\>" contains=ALLBUT,@crystalNotTop fold
" curly bracket block or hash literal
syn region crystalCurlyBlock matchgroup=crystalCurlyBlockDelimiter start="{" end="}" contains=ALLBUT,@crystalNotTop fold
syn region crystalArrayLiteral matchgroup=crystalArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@crystalNotTop fold
" statements without 'do'
syn region crystalBlockExpression matchgroup=crystalControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalCaseExpression matchgroup=crystalConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@crystalNotTop fold
syn region crystalConditionalExpression matchgroup=crystalConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|ifdef\|unless\)\>" end="\%(\%(\%(\.\@<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@crystalNotTop fold
syn match crystalConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=crystalCaseExpression
syn match crystalConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=crystalConditionalExpression
syn match crystalExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=crystalBlockExpression
syn match crystalMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=crystalMethodBlock
" statements with optional 'do'
syn region crystalOptionalDoLine matchgroup=crystalRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=crystalOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@crystalNotTop
syn region crystalRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=crystalRepeat end="\<end\>" contains=ALLBUT,@crystalNotTop nextgroup=crystalOptionalDoLine fold
if !exists('crystal_minlines')
let crystal_minlines = 500
endif
exec 'syn sync minlines=' . crystal_minlines
else
syn match crystalControl "\<def\>[?!]\@!" nextgroup=crystalMethodDeclaration skipwhite skipnl
syn match crystalControl "\<fun\>[?!]\@!" nextgroup=crystalFunctionDeclaration skipwhite skipnl
syn match crystalControl "\<class\>[?!]\@!" nextgroup=crystalClassDeclaration skipwhite skipnl
syn match crystalControl "\<module\>[?!]\@!" nextgroup=crystalModuleDeclaration skipwhite skipnl
syn match crystalControl "\<struct\>[?!]\@!" nextgroup=crystalStructDeclaration skipwhite skipnl
syn match crystalControl "\<lib\>[?!]\@!" nextgroup=crystalLibDeclaration skipwhite skipnl
syn match crystalControl "\<macro\>[?!]\@!" nextgroup=crystalMacroDeclaration skipwhite skipnl
syn match crystalControl "\<enum\>[?!]\@!" nextgroup=crystalEnumDeclaration skipwhite skipnl
syn match crystalControl "\<\%(case\|begin\|do\|for\|if\|ifdef\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!"
syn match crystalKeyword "\<\%(alias\|undef\)\>[?!]\@!"
endif
" Link attribute
syn region crystalLinkAttrRegion start="@\[" nextgroup=crystalLinkAttrRegionInner end="]" contains=crystalLinkAttr,crystalLinkAttrRegionInner transparent display oneline
syn region crystalLinkAttrRegionInner start="\%(@\[\)\@<=" end="]\@=" contained contains=ALLBUT,@crystalNotTop transparent display oneline
syn match crystalLinkAttr "@\[" contained containedin=crystalLinkAttrRegion display
syn match crystalLinkAttr "]" contained containedin=crystalLinkAttrRegion display
" Special Methods
if !exists('crystal_no_special_methods')
syn keyword crystalAccess protected private
" attr is a common variable name
syn keyword crystalAttribute getter setter property abstract
syn match crystalControl "\<\%(abort\|at_exit\|exit\|fork\|loop\)\>[?!]\@!" display
syn keyword crystalException raise
" false positive with 'include?'
syn match crystalInclude "\<include\>[?!]\@!" display
syn keyword crystalInclude extend require
syn keyword crystalKeyword caller typeof pointerof sizeof instance_sizeof
syn match crystalRecord "\<record\>[?!]\@!" display
endif
" Macro
syn region crystalMacroRegion start="{%" end="%}" contains=ALLBUT,@crystalNotTop transparent display oneline
syn region crystalMacroRegion start="{{" end="}}" contains=ALLBUT,@crystalNotTop transparent display oneline
syn match crystalMacro "\%({%\|%}\|{{\|}}\)" nextgroup=crystalMacroRegion skipwhite display
" Comments and Documentation
syn match crystalSharpBang "\%^#!.*" display
syn keyword crystalTodo FIXME NOTE TODO OPTIMIZE XXX todo contained
syn match crystalComment "#.*" contains=crystalSharpBang,crystalSpaceError,crystalTodo,@Spell
if !exists('crystal_no_comment_fold')
syn region crystalMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=crystalComment transparent fold keepend
endif
" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(elsif\|end\|ensure\|false\|for\|if\|ifdef\|in\|module\|next\|nil\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(rescue\|return\|self\|super\|previous_def\|then\|true\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|with\|__FILE__\|__LINE__\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)[?!]" transparent contains=NONE
syn match crystalKeywordAsMethod "\<\%(if\|ifdef\|module\|undef\|unless\|until\|while\)[?!]" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(abort\|at_exit\|caller\|exit\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(extend\|fork\|include\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(loop\|private\|protected\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(require\|raise\)\>" transparent contains=NONE
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(typeof\|pointerof\|sizeof\|instance_sizeof\|\)\>" transparent contains=NONE
hi def link crystalClass crystalDefine
hi def link crystalModule crystalDefine
hi def link crystalStruct crystalDefine
hi def link crystalLib crystalDefine
hi def link crystalMacro crystalDefine
hi def link crystalEnum crystalDefine
hi def link crystalMethodExceptional crystalDefine
hi def link crystalDefine Define
hi def link crystalFunction Function
hi def link crystalConditional Conditional
hi def link crystalConditionalModifier crystalConditional
hi def link crystalExceptional crystalConditional
hi def link crystalRepeat Repeat
hi def link crystalRepeatModifier crystalRepeat
hi def link crystalOptionalDo crystalRepeat
hi def link crystalControl Statement
hi def link crystalInclude Include
hi def link crystalRecord Statement
hi def link crystalInteger Number
hi def link crystalASCIICode Character
hi def link crystalFloat Float
hi def link crystalBoolean Boolean
hi def link crystalException Exception
if !exists('crystal_no_identifiers')
hi def link crystalIdentifier Identifier
else
hi def link crystalIdentifier NONE
endif
hi def link crystalClassVariable crystalIdentifier
hi def link crystalConstant Type
hi def link crystalGlobalVariable crystalIdentifier
hi def link crystalBlockParameter crystalIdentifier
hi def link crystalInstanceVariable crystalIdentifier
hi def link crystalFreshVariable crystalIdentifier
hi def link crystalPredefinedIdentifier crystalIdentifier
hi def link crystalPredefinedConstant crystalPredefinedIdentifier
hi def link crystalPredefinedVariable crystalPredefinedIdentifier
hi def link crystalSymbol Constant
hi def link crystalKeyword Keyword
hi def link crystalOperator Operator
hi def link crystalAccess Statement
hi def link crystalAttribute Statement
hi def link crystalPseudoVariable Constant
hi def link crystalCharLiteral Character
hi def link crystalComment Comment
hi def link crystalTodo Todo
hi def link crystalStringEscape Special
hi def link crystalInterpolationDelimiter Delimiter
hi def link crystalNoInterpolation crystalString
hi def link crystalSharpBang PreProc
hi def link crystalRegexpDelimiter crystalStringDelimiter
hi def link crystalSymbolDelimiter crystalStringDelimiter
hi def link crystalStringDelimiter Delimiter
hi def link crystalHeredoc crystalString
hi def link crystalString String
hi def link crystalRegexpEscape crystalRegexpSpecial
hi def link crystalRegexpQuantifier crystalRegexpSpecial
hi def link crystalRegexpAnchor crystalRegexpSpecial
hi def link crystalRegexpDot crystalRegexpCharClass
hi def link crystalRegexpCharClass crystalRegexpSpecial
hi def link crystalRegexpSpecial Special
hi def link crystalRegexpComment Comment
hi def link crystalRegexp crystalString
hi def link crystalLinkAttr PreProc
hi def link crystalMacro PreProc
hi def link crystalInvalidVariable Error
hi def link crystalError Error
hi def link crystalSpaceError crystalError
let b:current_syntax = 'crystal'
" vim: nowrap sw=2 sts=2 ts=8 noet:
endif

View File

@@ -70,21 +70,16 @@ catch /^.*/
syn match cssIdentifier "#[A-Za-z_@][A-Za-z0-9_@-]*" syn match cssIdentifier "#[A-Za-z_@][A-Za-z0-9_@-]*"
endtry endtry
" digits " digits and units
syn match cssValueInteger contained "[-+]\=\d\+" contains=cssUnitDecorators syn match cssValueNumber contained "[-+]\=\d\+\(\.\d*\)\=%\=" contains=cssUnitDecorators
syn match cssValueNumber contained "[-+]\=\d\+\(\.\d*\)\=" contains=cssUnitDecorators syn match cssValue contained transparent "[-+]\=\d\+\(\.\d*\)\=\([a-z]\+\)\=\>" contains=cssUnitDecorators,cssValueNumber
syn match cssValueLength contained "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|rem\|dpi\|dppx\|dpcm\)\>" contains=cssUnitDecorators
syn match cssValueAngle contained "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\)\>" contains=cssUnitDecorators
syn match cssValueTime contained "+\=\d\+\(\.\d*\)\=\(ms\|s\)\>" contains=cssUnitDecorators
syn match cssValueFrequency contained "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)\>" contains=cssUnitDecorators
syn match cssIncludeKeyword /@\(-[a-z]\+-\)\=\(media\|keyframes\|import\|charset\|namespace\|page\)/ contained syn match cssIncludeKeyword /@\(-[a-z]\+-\)\=\(media\|keyframes\|import\|charset\|namespace\|page\)/ contained
" @media " @media
syn region cssInclude start=/@media\>/ end=/\ze{/ skipwhite skipnl contains=cssMediaProp,cssValueLength,cssMediaKeyword,cssValueInteger,cssMediaAttr,cssVendor,cssMediaType,cssIncludeKeyword,cssMediaComma,cssComment nextgroup=cssMediaBlock syn region cssInclude start=/@media\>/ end=/\ze{/ skipwhite skipnl contains=cssMediaProp,cssValueLength,cssMediaKeyword,cssValueInteger,cssMediaAttr,cssVendor,cssMediaType,cssIncludeKeyword,cssMediaComma,cssComment nextgroup=cssMediaBlock
syn keyword cssMediaType contained screen print aural braille embossed handheld projection tty tv speech all contained skipwhite skipnl syn keyword cssMediaType contained screen print aural braille embossed handheld projection tty tv speech all contained skipwhite skipnl
syn keyword cssMediaKeyword only not and contained syn keyword cssMediaKeyword only not and contained
syn region cssMediaBlock transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssTagName,cssClassName,cssIdentifier,cssPseudoClass,cssSelectorOp,cssSelectorOp2,cssAttributeSelector fold syn region cssMediaBlock transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Prop,cssComment,cssValue,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssTagName,cssClassName,cssIdentifier,cssPseudoClass,cssSelectorOp,cssSelectorOp2,cssAttributeSelector fold
syn match cssMediaComma "," skipwhite skipnl contained syn match cssMediaComma "," skipwhite skipnl contained
" Reference: http://www.w3.org/TR/css3-mediaqueries/ " Reference: http://www.w3.org/TR/css3-mediaqueries/
@@ -99,7 +94,7 @@ syn keyword cssMediaAttr contained portrait landscape progressive interlace
" http://www.w3.org/TR/css3-page/ " http://www.w3.org/TR/css3-page/
syn match cssPage "@page\>[^{]*{\@=" contains=cssPagePseudo,cssIncludeKeyword nextgroup=cssPageWrap transparent skipwhite skipnl syn match cssPage "@page\>[^{]*{\@=" contains=cssPagePseudo,cssIncludeKeyword nextgroup=cssPageWrap transparent skipwhite skipnl
syn match cssPagePseudo /:\(left\|right\|first\|blank\)/ contained skipwhite skipnl syn match cssPagePseudo /:\(left\|right\|first\|blank\)/ contained skipwhite skipnl
syn region cssPageWrap contained transparent matchgroup=cssBraces start="{" end="}" contains=cssPageMargin,cssPageProp,cssAttrRegion,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssHacks syn region cssPageWrap contained transparent matchgroup=cssBraces start="{" end="}" contains=cssPageMargin,cssPageProp,cssAttrRegion,css.*Prop,cssComment,cssValue,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssHacks
syn match cssPageMargin /@\(\(top\|left\|right\|bottom\)-\(left\|center\|right\|middle\|bottom\)\)\(-corner\)\=/ contained nextgroup=cssDefinition skipwhite skipnl syn match cssPageMargin /@\(\(top\|left\|right\|bottom\)-\(left\|center\|right\|middle\|bottom\)\)\(-corner\)\=/ contained nextgroup=cssDefinition skipwhite skipnl
syn keyword cssPageProp contained content size syn keyword cssPageProp contained content size
" http://www.w3.org/TR/CSS2/page.html#break-inside " http://www.w3.org/TR/CSS2/page.html#break-inside
@@ -109,7 +104,7 @@ syn keyword cssPageProp contained orphans widows
" http://www.w3.org/TR/css3-animations/#keyframes " http://www.w3.org/TR/css3-animations/#keyframes
syn match cssKeyFrame "@\(-[a-z]\+-\)\=keyframes\>[^{]*{\@=" nextgroup=cssKeyFrameWrap contains=cssVendor,cssIncludeKeyword skipwhite skipnl transparent syn match cssKeyFrame "@\(-[a-z]\+-\)\=keyframes\>[^{]*{\@=" nextgroup=cssKeyFrameWrap contains=cssVendor,cssIncludeKeyword skipwhite skipnl transparent
syn region cssKeyFrameWrap contained transparent matchgroup=cssBraces start="{" end="}" contains=cssKeyFrameSelector syn region cssKeyFrameWrap contained transparent matchgroup=cssBraces start="{" end="}" contains=cssKeyFrameSelector
syn match cssKeyFrameSelector /\(\d*%\|from\|to\)\=/ contained skipwhite skipnl nextgroup=cssDefinition syn match cssKeyFrameSelector /\([-+]\=\d\+\(\.\d*\)\=%\|from\|to\)\=/ contained skipwhite skipnl nextgroup=cssDefinition
" @import " @import
syn region cssInclude start=/@import\>/ end=/\ze;/ transparent contains=cssStringQ,cssStringQQ,cssUnicodeEscape,cssComment,cssIncludeKeyword,cssURL,cssMediaProp,cssValueLength,cssMediaKeyword,cssValueInteger,cssMediaAttr,cssVendor,cssMediaType syn region cssInclude start=/@import\>/ end=/\ze;/ transparent contains=cssStringQ,cssStringQQ,cssUnicodeEscape,cssComment,cssIncludeKeyword,cssURL,cssMediaProp,cssValueLength,cssMediaKeyword,cssValueInteger,cssMediaAttr,cssVendor,cssMediaType
@@ -119,7 +114,7 @@ syn region cssInclude start=/@namespace\>/ end=/\ze;/ transparent contains=cssSt
" @font-face " @font-face
" http://www.w3.org/TR/css3-fonts/#at-font-face-rule " http://www.w3.org/TR/css3-fonts/#at-font-face-rule
syn match cssFontDescriptor "@font-face\>" nextgroup=cssFontDescriptorBlock skipwhite skipnl syn match cssFontDescriptor "@font-face\>" nextgroup=cssFontDescriptorBlock skipwhite skipnl
syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssComment,cssError,cssUnicodeEscape,cssCommonAttr,cssFontDescriptorProp,cssValue.*,cssFontDescriptorFunction,cssFontDescriptorAttr,cssNoise syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssComment,cssError,cssUnicodeEscape,cssCommonAttr,cssFontDescriptorProp,cssValue,cssFontDescriptorFunction,cssFontDescriptorAttr,cssNoise
syn match cssFontDescriptorProp contained "\<font-family\>" syn match cssFontDescriptorProp contained "\<font-family\>"
syn keyword cssFontDescriptorProp contained src syn keyword cssFontDescriptorProp contained src
@@ -188,10 +183,10 @@ syn match cssColor contained "#[0-9A-Fa-f]\{3\}\>" contains=cssUnitDecorators
syn match cssColor contained "#[0-9A-Fa-f]\{6\}\>" contains=cssUnitDecorators syn match cssColor contained "#[0-9A-Fa-f]\{6\}\>" contains=cssUnitDecorators
syn region cssURL contained matchgroup=cssFunctionName start="\<url\s*(" end=")" contains=cssStringQ,cssStringQQ oneline syn region cssURL contained matchgroup=cssFunctionName start="\<url\s*(" end=")" contains=cssStringQ,cssStringQQ oneline
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgb\|clip\|attr\|counter\|rect\|cubic-bezier\|steps\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssFunctionComma syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgb\|clip\|attr\|counter\|rect\|cubic-bezier\|steps\)\s*(" end=")" oneline contains=cssValue,cssFunctionComma
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgba\|hsl\|hsla\|color-stop\|from\|to\)\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunctionComma,cssFunction syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgba\|hsl\|hsla\|color-stop\|from\|to\)\s*(" end=")" oneline contains=cssColor,cssValue,cssFunctionComma,cssFunction
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(linear-\|radial-\)\=\gradient\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunction,cssGradientAttr,cssFunctionComma syn region cssFunction contained matchgroup=cssFunctionName start="\<\(linear-\|radial-\)\=\gradient\s*(" end=")" oneline contains=cssColor,cssValue,cssFunction,cssGradientAttr,cssFunctionComma
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(matrix\(3d\)\=\|scale\(3d\|X\|Y\|Z\)\=\|translate\(3d\|X\|Y\|Z\)\=\|skew\(X\|Y\)\=\|rotate\(3d\|X\|Y\|Z\)\=\|perspective\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssValueAngle,cssFunctionComma syn region cssFunction contained matchgroup=cssFunctionName start="\<\(matrix\(3d\)\=\|scale\(3d\|X\|Y\|Z\)\=\|translate\(3d\|X\|Y\|Z\)\=\|skew\(X\|Y\)\=\|rotate\(3d\|X\|Y\|Z\)\=\|perspective\)\s*(" end=")" oneline contains=cssValueInteger,cssValue,cssFunctionComma
syn keyword cssGradientAttr contained top bottom left right cover center middle ellipse at syn keyword cssGradientAttr contained top bottom left right cover center middle ellipse at
syn match cssFunctionComma contained "," syn match cssFunctionComma contained ","
@@ -277,7 +272,7 @@ syn keyword cssFlexibleBoxProp contained order
syn match cssFlexibleBoxAttr contained "\<\(row\|column\|wrap\)\(-reverse\)\=\>" syn match cssFlexibleBoxAttr contained "\<\(row\|column\|wrap\)\(-reverse\)\=\>"
syn keyword cssFlexibleBoxAttr contained nowrap stretch baseline center syn keyword cssFlexibleBoxAttr contained nowrap stretch baseline center
syn match cssFlexibleBoxAttr contained "\<flex-\(start\|end\)\>" syn match cssFlexibleBoxAttr contained "\<flex\(-\(start\|end\)\)\=\>"
syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\)\)\=\>" syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\)\)\=\>"
" CSS Fonts Module Level 3 " CSS Fonts Module Level 3
@@ -319,8 +314,8 @@ syn match cssMultiColumnProp contained "\<break-\(after\|before\|inside\)\>"
syn match cssMultiColumnProp contained "\<column-\(count\|fill\|gap\|rule\(-\(color\|style\|width\)\)\=\|span\|width\)\>" syn match cssMultiColumnProp contained "\<column-\(count\|fill\|gap\|rule\(-\(color\|style\|width\)\)\=\|span\|width\)\>"
syn keyword cssMultiColumnProp contained columns syn keyword cssMultiColumnProp contained columns
syn keyword cssMultiColumnAttr contained balance medium syn keyword cssMultiColumnAttr contained balance medium
syn keyword cssMultiColumnAttr contained always avoid left right page column syn keyword cssMultiColumnAttr contained always left right page column
syn match cssMultiColumnAttr contained "\<avoid-\(page\|column\)\>" syn match cssMultiColumnAttr contained "\<avoid\(-\(page\|column\)\)\=\>"
" http://www.w3.org/TR/css3-break/#page-break " http://www.w3.org/TR/css3-break/#page-break
syn match cssMultiColumnProp contained "\<page\(-break-\(before\|after\|inside\)\)\=\>" syn match cssMultiColumnProp contained "\<page\(-break-\(before\|after\|inside\)\)\=\>"
@@ -357,7 +352,7 @@ syn match cssPositioningAttr contained "\<list-item\>"
syn match cssPositioningAttr contained "\<inline\(-\(block\|box\|table\)\)\=\>" syn match cssPositioningAttr contained "\<inline\(-\(block\|box\|table\)\)\=\>"
syn keyword cssPositioningAttr contained static relative absolute fixed syn keyword cssPositioningAttr contained static relative absolute fixed
syn keyword cssPrintAttr contained landscape portrait crop cross always avoid syn keyword cssPrintAttr contained landscape portrait crop cross always
syn match cssTableProp contained "\<\(caption-side\|table-layout\|border-collapse\|border-spacing\|empty-cells\)\>" syn match cssTableProp contained "\<\(caption-side\|table-layout\|border-collapse\|border-spacing\|empty-cells\)\>"
syn keyword cssTableAttr contained fixed collapse separate show hide once always syn keyword cssTableAttr contained fixed collapse separate show hide once always
@@ -430,6 +425,10 @@ syn keyword cssUIAttr contained both horizontal vertical
syn match cssUIProp contained "\<text-overflow\>" syn match cssUIProp contained "\<text-overflow\>"
syn keyword cssUIAttr contained clip ellipsis syn keyword cssUIAttr contained clip ellipsis
syn match cssUIProp contained "\<image-rendering\>"
syn keyword cssUIAttr contained pixellated
syn match cssUIAttr contained "\<crisp-edges\>"
" Already highlighted Props: font content " Already highlighted Props: font content
"------------------------------------------------ "------------------------------------------------
" Webkit/iOS specific attributes " Webkit/iOS specific attributes
@@ -469,7 +468,7 @@ syn match cssMobileTextProp contained "\<text-size-adjust\>"
syn match cssBraces contained "[{}]" syn match cssBraces contained "[{}]"
syn match cssError contained "{@<>" syn match cssError contained "{@<>"
syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=cssAttrRegion,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssHacks,cssNoise fold syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=cssAttrRegion,css.*Prop,cssComment,cssValue,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssHacks,cssNoise fold
syn match cssBraceError "}" syn match cssBraceError "}"
syn match cssAttrComma "," syn match cssAttrComma ","
@@ -488,7 +487,7 @@ syn match cssPseudoClassId contained "\<focus\(-inner\)\=\>"
syn match cssPseudoClassId contained "\<\(input-\)\=placeholder\>" syn match cssPseudoClassId contained "\<\(input-\)\=placeholder\>"
" Misc highlight groups " Misc highlight groups
syntax match cssUnitDecorators /\(#\|-\|%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|ch\|rem\|vh\|vw\|vmin\|vmax\|dpi\|dppx\|dpcm\|Hz\|kHz\|s\|ms\|deg\|grad\|rad\)/ contained syntax match cssUnitDecorators /\(#\|-\|+\|%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|ch\|rem\|vh\|vw\|vmin\|vmax\|dpi\|dppx\|dpcm\|Hz\|kHz\|s\|ms\|deg\|grad\|rad\)/ contained
syntax match cssNoise contained /\(:\|;\|\/\)/ syntax match cssNoise contained /\(:\|;\|\/\)/
" Comment " Comment
@@ -513,11 +512,11 @@ syn match cssHacks contained /\(_\|*\)/
" Attr Enhance " Attr Enhance
" Some keywords are both Prop and Attr, so we have to handle them " Some keywords are both Prop and Attr, so we have to handle them
syn region cssAttrRegion start=/:/ end=/\ze\(;\|)\|}\)/ contained contains=css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise syn region cssAttrRegion start=/:/ end=/\ze\(;\|)\|}\)/ contained contains=css.*Attr,cssColor,cssImportant,cssValue,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise
" Hack for transition " Hack for transition
" 'transition' has Props after ':'. " 'transition' has Props after ':'.
syn region cssAttrRegion start=/transition\s*:/ end=/\ze\(;\|)\|}\)/ contained contains=css.*Prop,css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise syn region cssAttrRegion start=/transition\s*:/ end=/\ze\(;\|)\|}\)/ contained contains=css.*Prop,css.*Attr,cssColor,cssImportant,cssValue,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise
if main_syntax == "css" if main_syntax == "css"
@@ -612,12 +611,7 @@ if version >= 508 || !exists("did_css_syn_inits")
HiLink cssPseudoClassId PreProc HiLink cssPseudoClassId PreProc
HiLink cssPseudoClassLang Constant HiLink cssPseudoClassLang Constant
HiLink cssValueLength Number
HiLink cssValueInteger Number
HiLink cssValueNumber Number HiLink cssValueNumber Number
HiLink cssValueAngle Number
HiLink cssValueTime Number
HiLink cssValueFrequency Number
HiLink cssFunction Constant HiLink cssFunction Constant
HiLink cssURL String HiLink cssURL String
HiLink cssFunctionName Function HiLink cssFunctionName Function

View File

@@ -1,9 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim syntax file
" Language: Embedded Elixir
" URL: https://github.com/elixir-lang/vim-elixir
if exists("b:current_syntax") if exists("b:current_syntax")
finish finish
endif endif
@@ -66,5 +62,4 @@ if main_syntax == 'eelixir'
unlet main_syntax unlet main_syntax
endif endif
endif endif

View File

@@ -1,10 +1,5 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
" Vim syntax file
" Language: Elixir
" Maintainer: Carlos Galdino <carloshsgaldino@gmail.com>
" Last Change: 2013 Apr 24
if exists("b:current_syntax") if exists("b:current_syntax")
finish finish
endif endif
@@ -12,21 +7,21 @@ endif
" syncing starts 2000 lines before top line so docstrings don't screw things up " syncing starts 2000 lines before top line so docstrings don't screw things up
syn sync minlines=2000 syn sync minlines=2000
syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments,elixirBlockDefinition
syn match elixirComment '#.*' contains=elixirTodo,@Spell syn match elixirComment '#.*' contains=elixirTodo,@Spell
syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained
syn keyword elixirKeyword case when cond for if unless try receive send syn keyword elixirKeyword case when with cond for if unless try receive send
syn keyword elixirKeyword exit raise throw after rescue catch else do end syn keyword elixirKeyword exit raise throw after rescue catch else
syn keyword elixirKeyword quote unquote super spawn spawn_link spawn_monitor syn keyword elixirKeyword quote unquote super spawn spawn_link spawn_monitor
" Functions used on guards " Functions used on guards
syn keyword elixirKeyword contained is_atom is_binary is_bitstring is_boolean syn keyword elixirKeyword contained is_atom is_binary is_bitstring is_boolean
syn keyword elixirKeyword contained is_float is_function is_integer is_list syn keyword elixirKeyword contained is_float is_function is_integer is_list
syn keyword elixirKeyword contained is_map is_number is_pid is_port is_record syn keyword elixirKeyword contained is_map is_nil is_number is_pid is_port
syn keyword elixirKeyword contained is_reference is_tuple is_exception abs syn keyword elixirKeyword contained is_record is_reference is_tuple is_exception
syn keyword elixirKeyword contained bit_size byte_size div elem hd length syn keyword elixirKeyword contained abs bit_size byte_size div elem hd length
syn keyword elixirKeyword contained map_size node rem round tl trunc tuple_size syn keyword elixirKeyword contained map_size node rem round tl trunc tuple_size
syn match elixirGuard '.*when.*' contains=ALLBUT,@elixirNotTop syn match elixirGuard '.*when.*' contains=ALLBUT,@elixirNotTop
@@ -38,7 +33,7 @@ syn keyword elixirSelf self
syn match elixirId '\<[_a-zA-Z]\w*[!?]\?\>' syn match elixirId '\<[_a-zA-Z]\w*[!?]\?\>'
" This unfortunately also matches function names in function calls " This unfortunately also matches function names in function calls
syn match elixirUnusedVariable '\<_\w*\>' syn match elixirUnusedVariable '\(([^)]*\)\@<=\<_\w*\>'
syn keyword elixirOperator and not or when xor in syn keyword elixirOperator and not or when xor in
syn match elixirOperator '!==\|!=\|!' syn match elixirOperator '!==\|!=\|!'
@@ -57,7 +52,7 @@ syn match elixirAtom '\(:\)\@<!:\%([a-zA-Z_]\w*\%([?!]\|=[>=]\@!\)\?\|<>\|===\
syn match elixirAtom '\(:\)\@<!:\%(<=>\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)' syn match elixirAtom '\(:\)\@<!:\%(<=>\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)'
syn match elixirAtom "\%([a-zA-Z_]\w*[?!]\?\):\(:\)\@!" syn match elixirAtom "\%([a-zA-Z_]\w*[?!]\?\):\(:\)\@!"
syn match elixirAlias '\<[A-Z]\w*\(\.[A-Z]\w*\)*\>' syn match elixirAlias '\<[!]\?[A-Z]\w*\(\.[A-Z]\w*\)*\>'
syn keyword elixirBoolean true false nil syn keyword elixirBoolean true false nil
@@ -87,14 +82,14 @@ syn region elixirInterpolation matchgroup=elixirInterpolationDelimiter start="#{
syn region elixirDocStringStart matchgroup=elixirDocString start=+"""+ end=+$+ oneline contains=ALLBUT,@elixirNotTop syn region elixirDocStringStart matchgroup=elixirDocString start=+"""+ end=+$+ oneline contains=ALLBUT,@elixirNotTop
syn region elixirDocStringStart matchgroup=elixirDocString start=+'''+ end=+$+ oneline contains=ALLBUT,@elixirNotTop syn region elixirDocStringStart matchgroup=elixirDocString start=+'''+ end=+$+ oneline contains=ALLBUT,@elixirNotTop
syn region elixirDocString start=+\z("""\)+ end=+^\s*\zs\z1+ contains=elixirDocStringStart,elixirTodo,elixirInterpolation,@Spell fold keepend syn region elixirDocString start=+\z("""\)+ end=+^\s*\zs\z1+ contains=elixirDocStringStart,elixirTodo,elixirInterpolation,@Spell keepend fold
syn region elixirDocString start=+\z('''\)+ end=+^\s*\zs\z1+ contains=elixirDocStringStart,elixirTodo,elixirInterpolation,@Spell fold keepend syn region elixirDocString start=+\z('''\)+ end=+^\s*\zs\z1+ contains=elixirDocStringStart,elixirTodo,elixirInterpolation,@Spell keepend fold
syn match elixirAtomInterpolated ':\("\)\@=' contains=elixirString syn match elixirAtomInterpolated ':\("\)\@=' contains=elixirString
syn match elixirString "\(\w\)\@<!?\%(\\\(x\d{1,2}\|\h{1,2}\h\@!\>\|0[0-7]{0,2}[0-7]\@!\>\|[^x0MC]\)\|(\\[MC]-)+\w\|[^\s\\]\)" syn match elixirString "\(\w\)\@<!?\%(\\\(x\d{1,2}\|\h{1,2}\h\@!\>\|0[0-7]{0,2}[0-7]\@!\>\|[^x0MC]\)\|(\\[MC]-)+\w\|[^\s\\]\)"
syn region elixirBlock matchgroup=elixirKeyword start="\<do\>\(:\)\@!" end="\<end\>" contains=ALLBUT,@elixirNotTop fold syn region elixirBlock matchgroup=elixirBlockDefinition start="\<do\>:\@!" end="\<end\>" contains=ALLBUT,@elixirNotTop fold
syn region elixirAnonymousFunction matchgroup=elixirKeyword start="\<fn\>" end="\<end\>" contains=ALLBUT,@elixirNotTop fold syn region elixirAnonymousFunction matchgroup=elixirBlockDefinition start="\<fn\>" end="\<end\>" contains=ALLBUT,@elixirNotTop fold
syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirAtom,elixirPseudoVariable,elixirAlias,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirAtomInterpolated,elixirRegex,elixirString,elixirStringDelimiter,elixirRegexDelimiter,elixirInterpolationDelimiter,elixirSigilDelimiter syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirAtom,elixirPseudoVariable,elixirAlias,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirAtomInterpolated,elixirRegex,elixirString,elixirStringDelimiter,elixirRegexDelimiter,elixirInterpolationDelimiter,elixirSigilDelimiter
@@ -106,11 +101,11 @@ syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\u<"
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\u\[" end="\]" skip="\\\\\|\\\]" contains=elixirDelimEscape fold syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\u\[" end="\]" skip="\\\\\|\\\]" contains=elixirDelimEscape fold
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\u(" end=")" skip="\\\\\|\\)" contains=elixirDelimEscape fold syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\u(" end=")" skip="\\\\\|\\)" contains=elixirDelimEscape fold
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" fold syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l\z(/\|\"\|'\||\)" end="\z1" skip="\\\\\|\\\z1" fold
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l{" end="}" skip="\\\\\|\\}" fold contains=@elixirStringContained,elixirRegexEscapePunctuation syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l{" end="}" skip="\\\\\|\\}" contains=@elixirStringContained,elixirRegexEscapePunctuation fold
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l<" end=">" skip="\\\\\|\\>" fold contains=@elixirStringContained,elixirRegexEscapePunctuation syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l<" end=">" skip="\\\\\|\\>" contains=@elixirStringContained,elixirRegexEscapePunctuation fold
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l\[" end="\]" skip="\\\\\|\\\]" fold contains=@elixirStringContained,elixirRegexEscapePunctuation syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l\[" end="\]" skip="\\\\\|\\\]" contains=@elixirStringContained,elixirRegexEscapePunctuation fold
syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l(" end=")" skip="\\\\\|\\)" fold contains=@elixirStringContained,elixirRegexEscapePunctuation syn region elixirSigil matchgroup=elixirSigilDelimiter start="\~\l(" end=")" skip="\\\\\|\\)" contains=@elixirStringContained,elixirRegexEscapePunctuation fold
" Sigils surrounded with docString " Sigils surrounded with docString
syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z("""\)+ end=+^\s*\zs\z1+ skip=+\\"+ fold syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z("""\)+ end=+^\s*\zs\z1+ skip=+\\"+ fold
@@ -147,6 +142,7 @@ syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained con
syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirModuleDeclaration,elixirProtocolDeclaration,elixirImplDeclaration,elixirRecordDeclaration,elixirMacroDeclaration,elixirDelegateDeclaration,elixirOverridableDeclaration,elixirExceptionDeclaration,elixirCallbackDeclaration,elixirStructDeclaration syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirModuleDeclaration,elixirProtocolDeclaration,elixirImplDeclaration,elixirRecordDeclaration,elixirMacroDeclaration,elixirDelegateDeclaration,elixirOverridableDeclaration,elixirExceptionDeclaration,elixirCallbackDeclaration,elixirStructDeclaration
hi def link elixirBlockDefinition Keyword
hi def link elixirDefine Define hi def link elixirDefine Define
hi def link elixirPrivateDefine Define hi def link elixirPrivateDefine Define
hi def link elixirModuleDefine Define hi def link elixirModuleDefine Define
@@ -191,4 +187,6 @@ hi def link elixirRegexDelimiter Delimiter
hi def link elixirInterpolationDelimiter Delimiter hi def link elixirInterpolationDelimiter Delimiter
hi def link elixirSigilDelimiter Delimiter hi def link elixirSigilDelimiter Delimiter
let b:current_syntax = "elixir"
endif endif

View File

@@ -79,8 +79,8 @@ syn match erlangAtom '\<\l[[:alnum:]_@]*' contains=erlangBoolean
syn keyword erlangBoolean true false contained syn keyword erlangBoolean true false contained
syn match erlangLocalFuncCall '\<\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*(\)\@=' contains=erlangBIF syn match erlangLocalFuncCall '\<\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*(\)\@=' contains=erlangBIF
syn match erlangLocalFuncRef '\<\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@=' syn match erlangLocalFuncRef '\<\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@='
syn match erlangGlobalFuncCall '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*(\)\@=' contains=erlangComment syn match erlangGlobalFuncCall '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*(\)\@=' contains=erlangComment,erlangVariable
syn match erlangGlobalFuncRef '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@=' contains=erlangComment syn match erlangGlobalFuncRef '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@=' contains=erlangComment,erlangVariable
" Variables, macros, records, maps " Variables, macros, records, maps
syn match erlangVariable '\<[A-Z_][[:alnum:]_@]*' syn match erlangVariable '\<[A-Z_][[:alnum:]_@]*'

41
syntax/fish.vim Normal file
View File

@@ -0,0 +1,41 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
if exists('b:current_syntax')
finish
endif
syntax case match
syntax keyword fishKeyword begin function end
syntax keyword fishConditional if else switch
syntax keyword fishRepeat while for in
syntax keyword fishLabel case
syntax match fishComment /#.*/
syntax match fishSpecial /\\$/
syntax match fishIdentifier /\$[[:alnum:]_]\+/
syntax region fishString start=/'/ skip=/\\'/ end=/'/
syntax region fishString start=/"/ skip=/\\"/ end=/"/ contains=fishIdentifier
syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/
syntax match fishStatement /\v;\s*\zs\k+>/
syntax match fishCommandSub /\v\(\s*\zs\k+>/
syntax region fishLineContinuation matchgroup=fishStatement
\ start='\v^\s*\zs\k+>' skip='\\$' end='$'
\ contains=fishSpecial,fishIdentifier,fishString,fishCharacter,fishStatement,fishCommandSub
highlight default link fishKeyword Keyword
highlight default link fishConditional Conditional
highlight default link fishRepeat Repeat
highlight default link fishLabel Label
highlight default link fishComment Comment
highlight default link fishSpecial Special
highlight default link fishIdentifier Identifier
highlight default link fishString String
highlight default link fishCharacter Character
highlight default link fishStatement Statement
highlight default link fishCommandSub fishStatement
let b:current_syntax = 'fish'
endif

View File

@@ -14,7 +14,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
" let OPTION_NAME = 1 " let OPTION_NAME = 1
" to enable particular options. " to enable particular options.
" At present, all options default to on, except highlight of: " At present, all options default to on, except highlight of:
" functions, methods and structs. " functions, methods, structs, operators, build constraints and interfaces.
" "
" - go_highlight_array_whitespace_error " - go_highlight_array_whitespace_error
" Highlights white space after "[]". " Highlights white space after "[]".
@@ -29,6 +29,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
" Highlights trailing white space. " Highlights trailing white space.
" - go_highlight_string_spellcheck " - go_highlight_string_spellcheck
" Specifies that strings should be spell checked " Specifies that strings should be spell checked
" - go_highlight_format_strings
" Highlights printf-style operators inside string literals.
" Quit when a (custom) syntax file was already loaded " Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax") if exists("b:current_syntax")
@@ -71,6 +73,10 @@ if !exists("g:go_highlight_structs")
let g:go_highlight_structs = 0 let g:go_highlight_structs = 0
endif endif
if !exists("g:go_highlight_interfaces")
let g:go_highlight_interfaces = 0
endif
if !exists("g:go_highlight_build_constraints") if !exists("g:go_highlight_build_constraints")
let g:go_highlight_build_constraints = 0 let g:go_highlight_build_constraints = 0
endif endif
@@ -79,6 +85,14 @@ if !exists("g:go_highlight_string_spellcheck")
let g:go_highlight_string_spellcheck = 1 let g:go_highlight_string_spellcheck = 1
endif endif
if !exists("g:go_highlight_format_strings")
let g:go_highlight_format_strings = 1
endif
if !exists("g:go_highlight_generate_tags")
let g:go_highlight_generate_tags = 0
endif
syn case match syn case match
syn keyword goDirective package import syn keyword goDirective package import
@@ -130,11 +144,18 @@ hi def link goBoolean Boolean
syn keyword goTodo contained TODO FIXME XXX BUG syn keyword goTodo contained TODO FIXME XXX BUG
syn cluster goCommentGroup contains=goTodo syn cluster goCommentGroup contains=goTodo
syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell
hi def link goComment Comment hi def link goComment Comment
hi def link goTodo Todo hi def link goTodo Todo
if g:go_highlight_generate_tags != 0
syn match goGenerateVariables contained /\(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/
syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables
hi def link goGenerate PreProc
hi def link goGenerateVariables Special
endif
" Go escapes " Go escapes
syn match goEscapeOctal display contained "\\[0-7]\{3}" syn match goEscapeOctal display contained "\\[0-7]\{3}"
syn match goEscapeC display contained +\\[abfnrtv\\'"]+ syn match goEscapeC display contained +\\[abfnrtv\\'"]+
@@ -160,11 +181,14 @@ else
syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
syn region goRawString start=+`+ end=+`+ syn region goRawString start=+`+ end=+`+
endif endif
syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString
if g:go_highlight_format_strings != 0
syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString
hi def link goFormatSpecifier goSpecialString
endif
hi def link goString String hi def link goString String
hi def link goRawString String hi def link goRawString String
hi def link goFormatSpecifier goSpecialString
" Characters; their contents " Characters; their contents
syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU
@@ -177,30 +201,31 @@ syn region goBlock start="{" end="}" transparent fold
syn region goParen start='(' end=')' transparent syn region goParen start='(' end=')' transparent
" Integers " Integers
syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>" syn match goDecimalInt "\<-\=\d\+\%([Ee][-+]\=\d\+\)\=\>"
syn match goHexadecimalInt "\<0x\x\+\>" syn match goHexadecimalInt "\<-\=0[xX]\x\+\>"
syn match goOctalInt "\<0\o\+\>" syn match goOctalInt "\<-\=0\o\+\>"
syn match goOctalError "\<0\o*[89]\d*\>" syn match goOctalError "\<-\=0\o*[89]\d*\>"
hi def link goDecimalInt Integer hi def link goDecimalInt Integer
hi def link goHexadecimalInt Integer hi def link goHexadecimalInt Integer
hi def link goOctalInt Integer hi def link goOctalInt Integer
hi def link goOctalError Error
hi def link Integer Number hi def link Integer Number
" Floating point " Floating point
syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" syn match goFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>"
syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" syn match goFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>"
syn match goFloat "\<\d\+[Ee][-+]\d\+\>"
hi def link goFloat Float hi def link goFloat Float
" Imaginary literals " Imaginary literals
syn match goImaginary "\<\d\+i\>" syn match goImaginary "\<-\=\d\+i\>"
syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" syn match goImaginary "\<-\=\d\+[Ee][-+]\=\d\+i\>"
syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" syn match goImaginaryFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=i\>"
syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>" syn match goImaginaryFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=i\>"
hi def link goImaginary Number hi def link goImaginary Number
hi def link goImaginaryFloat Float
" Spaces after "[]" " Spaces after "[]"
if g:go_highlight_array_whitespace_error != 0 if g:go_highlight_array_whitespace_error != 0
@@ -210,9 +235,17 @@ endif
" Spacing errors around the 'chan' keyword " Spacing errors around the 'chan' keyword
if g:go_highlight_chan_whitespace_error != 0 if g:go_highlight_chan_whitespace_error != 0
" receive-only annotation on chan type " receive-only annotation on chan type
syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@=" "
" \(\<chan\>\)\@<!<- (only pick arrow when it doesn't come after a chan)
" this prevents picking up 'chan<- chan<-' but not '<- chan'
syn match goSpaceError display "\(\(\<chan\>\)\@<!<-\)\@<=\s\+\(\<chan\>\)\@="
" send-only annotation on chan type " send-only annotation on chan type
syn match goSpaceError display "\(\<chan\)\@<=\s\+\(<-\)\@=" "
" \(<-\)\@<!\<chan\> (only pick chan when it doesn't come after an arrow)
" this prevents picking up '<-chan <-chan' but not 'chan <-'
syn match goSpaceError display "\(\(<-\)\@<!\<chan\>\)\@<=\s\+\(<-\)\@="
" value-ignoring receives in a few contexts " value-ignoring receives in a few contexts
syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+" syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
endif endif
@@ -285,6 +318,14 @@ endif
hi def link goStruct Function hi def link goStruct Function
hi def link goStructDef Function hi def link goStructDef Function
" Interfaces;
if g:go_highlight_interfaces != 0
syn match goInterface /\(.\)\@<=\w\+\({\)\@=/
syn match goInterfaceDef /\(type\s\+\)\@<=\w\+\(\s\+interface\s\+{\)\@=/
endif
hi def link goInterface Function
hi def link goInterfaceDef Function
" Build Constraints " Build Constraints
if g:go_highlight_build_constraints != 0 if g:go_highlight_build_constraints != 0
syn match goBuildKeyword display contained "+build" syn match goBuildKeyword display contained "+build"

22
syntax/godefstack.vim Normal file
View File

@@ -0,0 +1,22 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
if exists("b:current_syntax")
finish
endif
syn match godefStackComment '^".*'
syn match godefLinePrefix '^[>\s]\s' nextgroup=godefStackEntryNumber contains=godefStackCurrentPosition
syn match godefStackEntryNumber '\d\+' nextgroup=godefStackFilename skipwhite
syn match godefStackCurrentPosition '>' contained
syn match godefStackFilename '[^|]\+' contained nextgroup=godefStackEntryLocation
syn region godefStackEntryLocation oneline start='|' end='|' contained contains=godefStackEntryLocationNumber
syn match godefStackEntryLocationNumber '\d\+' contained display
let b:current_syntax = "godefstack"
hi def link godefStackComment Comment
hi def link godefStackCurrentPosition Special
hi def link godefStackFilename Directory
hi def link godefStackEntryLocationNumber LineNr
endif

View File

@@ -1,51 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
if exists("b:current_syntax")
finish
endif
syn case match
syn match godocTitle "^\([A-Z][A-Z ]*\)$"
hi def link godocTitle Title
" Single Line Definitions
syn match godocMethodRec /\i\+\ze)/ contained
syn match godocMethodName /) \zs\i\+\ze(/ contained
syn match godocMethod /^func \((\i\+ [^)]*)\) \i\+(/ contains=godocMethodRec,godocMethodName
syn match godocFunction /^func \zs\i\+\ze(/
syn match godocType /^type \zs\i\+\ze.*/
syn match godocVar /^var \zs\i\+\ze.*/
syn match godocConst /^const \zs\i\+\ze.*/
hi def link godocMethodRec Type
hi def link godocType Type
hi def link godocMethodName Function
hi def link godocFunction Function
hi def link godocVar Identifier
hi def link godocConst Identifier
" Definition Blocks
syn region godocComment start="/\*" end="\*/" contained
syn region godocComment start="//" end="$" contained
syn match godocDefinition /^\s\+\i\+/ contained
syn region godocVarBlock start=/^var (/ end=/^)/ contains=godocComment,godocDefinition
syn region godocConstBlock start=/^const (/ end=/^)/ contains=godocComment,godocDefinition
syn region godocTypeBlock start=/^type \i\+ \(interface\|struct\) {/ end=/^}/ matchgroup=godocType contains=godocComment,godocType
hi def link godocComment Comment
hi def link godocDefinition Identifier
syn sync minlines=500
let b:current_syntax = "godoc"
" vim:ts=4 sts=2 sw=2:
endif

View File

@@ -68,7 +68,7 @@ syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goIn
syn keyword gotplControl contained if else end range with template syn keyword gotplControl contained if else end range with template
syn keyword gotplFunctions contained and html index js len not or print printf println urlquery eq ne lt le gt ge syn keyword gotplFunctions contained and html index js len not or print printf println urlquery eq ne lt le gt ge
syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/ syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/
syn match goTplIdentifier contained /\.[^\s}]*\>/ syn match goTplIdentifier contained /\.[^\s}]+\>/
hi def link gotplControl Keyword hi def link gotplControl Keyword
hi def link gotplFunctions Function hi def link gotplFunctions Function

View File

@@ -19,16 +19,17 @@ syn match haskellRecordField contained containedin=haskellBlock
\ haskellIdentifier, \ haskellIdentifier,
\ haskellOperators, \ haskellOperators,
\ haskellSeparator, \ haskellSeparator,
\ haskellParens, \ haskellParens
syn match haskellTypeSig syn match haskellTypeSig
\ "^\s*\(where\s\+\|let\s\+\|default\s\+\)\?[_a-z][a-zA-Z0-9_']*\(,\s*[_a-z][a-zA-Z0-9_']*\)*\(\s*::\|\n\s\+::\)" \ "^\s*\(where\s\+\|let\s\+\|default\s\+\)\?[_a-z][a-zA-Z0-9_']*\(,\s*[_a-z][a-zA-Z0-9_']*\)*\(\s*::\|\n\s\+::\)"
\ contains= \ contains=
\ haskellWhere, \ haskellWhere,
\ haskellLet, \ haskellLet,
\ haskellDefault,
\ haskellIdentifier, \ haskellIdentifier,
\ haskellOperators, \ haskellOperators,
\ haskellSeparator, \ haskellSeparator,
\ haskellParens, \ haskellParens
syn keyword haskelLWhere where syn keyword haskelLWhere where
syn keyword haskellLet let syn keyword haskellLet let
syn keyword haskellDeclKeyword module class instance newtype deriving in syn keyword haskellDeclKeyword module class instance newtype deriving in
@@ -50,8 +51,8 @@ syn match haskellImport "^\<import\>\s\+\(\<safe\>\s\+\)\?\(\<qualified\>\s\+\)\
\ haskellType, \ haskellType,
\ haskellLineComment, \ haskellLineComment,
\ haskellBlockComment, \ haskellBlockComment,
\ haskellPragma, \ haskellPragma
syn keyword haskellStatement do case of syn keyword haskellKeyword do case of
if exists('g:haskell_enable_static_pointers') && g:haskell_enable_static_pointers == 1 if exists('g:haskell_enable_static_pointers') && g:haskell_enable_static_pointers == 1
syn keyword haskellStatic static syn keyword haskellStatic static
endif endif
@@ -122,22 +123,18 @@ endif
highlight def link haskellBottom Macro highlight def link haskellBottom Macro
highlight def link haskellTH Boolean highlight def link haskellTH Boolean
highlight def link haskellBlockKeywords Structure
highlight def link haskellIdentifier Identifier highlight def link haskellIdentifier Identifier
highlight def link haskellForeignKeywords Structure highlight def link haskellForeignKeywords Structure
highlight def link haskellDeriving Structure highlight def link haskellKeyword Keyword
highlight def link haskellStatement Statement highlight def link haskellDefault Keyword
highlight def link haskellDefault Statement
highlight def link haskellConditional Conditional highlight def link haskellConditional Conditional
highlight def link haskellNumber Number highlight def link haskellNumber Number
highlight def link haskellFloat Float highlight def link haskellFloat Float
highlight def link haskellSeparator Delimiter highlight def link haskellSeparator Delimiter
highlight def link haskellDelimiter Delimiter highlight def link haskellDelimiter Delimiter
highlight def link haskellInfix PreProc highlight def link haskellInfix Keyword
highlight def link haskellOperators Operator highlight def link haskellOperators Operator
highlight def link haskellQuote Operator highlight def link haskellQuote Operator
highlight def link haskellQuotedType Include
highlight def link haskellType Include
highlight def link haskellShebang Comment highlight def link haskellShebang Comment
highlight def link haskellLineComment Comment highlight def link haskellLineComment Comment
highlight def link haskellBlockComment Comment highlight def link haskellBlockComment Comment
@@ -145,34 +142,56 @@ highlight def link haskellPragma SpecialComment
highlight def link haskellString String highlight def link haskellString String
highlight def link haskellChar String highlight def link haskellChar String
highlight def link haskellBacktick Operator highlight def link haskellBacktick Operator
highlight def link haskellPreProc Macro
highlight def link haskellTodo Todo
highlight def link haskellAssocType Structure
highlight def link haskellImportBlock Delimiter
highlight def link haskellImportKeywords Structure
highlight def link haskellDeclKeyword Structure
highlight def link haskellDecl Structure
highlight def link haskellWhere Structure
highlight def link haskellLet Structure
highlight def link haskellQuasiQuoted String highlight def link haskellQuasiQuoted String
highlight def link haskellTodo Todo
if exists('g:haskell_classic_highlighting') && g:haskell_classic_highlighting == 1
highlight def link haskellPreProc PreProc
highlight def link haskellAssocType Type
highlight def link haskellImportKeywords Include
highlight def link haskellDeclKeyword Keyword
highlight def link haskellDecl Keyword
highlight def link haskellWhere Keyword
highlight def link haskellLet Keyword
highlight def link haskellQuotedType Type
highlight def link haskellType Type
else
highlight def link haskellPreProc Macro
highlight def link haskellAssocType Structure
highlight def link haskellImportKeywords Structure
highlight def link haskellDeclKeyword Structure
highlight def link haskellDecl Structure
highlight def link haskellWhere Structure
highlight def link haskellLet Structure
highlight def link haskellQuotedType Include
highlight def link haskellType Include
endif
if exists('g:haskell_enable_quantification') && g:haskell_enable_quantification == 1 if exists('g:haskell_enable_quantification') && g:haskell_enable_quantification == 1
highlight def link haskellForall Operator highlight def link haskellForall Operator
endif endif
if exists('g:haskell_enable_recursivedo') && g:haskell_enable_recursivedo == 1 if exists('g:haskell_enable_recursivedo') && g:haskell_enable_recursivedo == 1
highlight def link haskellRecursiveDo Operator highlight def link haskellRecursiveDo Keyword
endif endif
if exists('g:haskell_enable_arrowsyntax') && g:haskell_enable_arrowsyntax == 1 if exists('g:haskell_enable_arrowsyntax') && g:haskell_enable_arrowsyntax == 1
highlight def link haskellArrowSyntax Operator highlight def link haskellArrowSyntax Keyword
endif
if exists('g:haskell_enable_pattern_synonyms') && g:haskell_enable_pattern_synonyms == 1
highlight def link haskellPatternKeyword Structure
endif
if exists('g:haskell_enable_typeroles') && g:haskell_enable_typeroles == 1
highlight def link haskellTypeRoles Structure
endif endif
if exists('g:haskell_enable_static_pointers') && g:haskell_enable_static_pointers == 1 if exists('g:haskell_enable_static_pointers') && g:haskell_enable_static_pointers == 1
highlight def link haskellStatic Statement highlight def link haskellStatic Keyword
endif
if exists('g:haskell_classic_highlighting') && g:haskell_classic_highlighting == 1
if exists('g:haskell_enable_pattern_synonyms') && g:haskell_enable_pattern_synonyms == 1
highlight def link haskellPatternKeyword Keyword
endif
if exists('g:haskell_enable_typeroles') && g:haskell_enable_typeroles == 1
highlight def link haskellTypeRoles Keyword
endif
else
if exists('g:haskell_enable_pattern_synonyms') && g:haskell_enable_pattern_synonyms == 1
highlight def link haskellPatternKeyword Structure
endif
if exists('g:haskell_enable_typeroles') && g:haskell_enable_typeroles == 1
highlight def link haskellTypeRoles Structure
endif
endif endif
let b:current_syntax = "haskell" let b:current_syntax = "haskell"

View File

@@ -1,28 +1,27 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1
" Vim syntax file " Vim syntax file
" Language: HTML (version 5) " Language: HTML (version 5.1)
" Maintainer: Rodrigo Machado <rcmachado@gmail.com> " SVG (SVG 1.1 (Second Edition) )
" URL: http://rm.blog.br/vim/syntax/html.vim " Last Change: 2016 Jan 20
" Last Change: 2009 Aug 19
" License: Public domain " License: Public domain
" (but let me know if you like :) ) " (but let me know if you like :) )
" "
" Note: This file just adds the new tags from HTML 5 " Note: This file just add new tags from HTML 5
" and don't replace default html.vim syntax file " and don't replace default html.vim syntax file
" "
" Modified: othree <othree@gmail.com> " Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com )
" Changes: update to Draft 13 January 2011 " Changes: update to Draft 2016 Jan 13
" add complete new attributes
" add microdata Attributes " add microdata Attributes
" add bdi element " Maintainer: Rodrigo Machado <rcmachado@gmail.com>
" URL: http://rm.blog.br/vim/syntax/html.vim
" Modified: htdebeer <H.T.de.Beer@gmail.com> " Modified: htdebeer <H.T.de.Beer@gmail.com>
" Changes: add common SVG elements and attributes for inline SVG " Changes: add common SVG elements and attributes for inline SVG
" HTML 5 tags " HTML 5 tags
syn keyword htmlTagName contained article aside audio canvas command syn keyword htmlTagName contained article aside audio canvas command
syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer syn keyword htmlTagName contained datalist details dialog embed figcaption figure footer
syn keyword htmlTagName contained header hgroup keygen main mark meter menu nav output syn keyword htmlTagName contained header hgroup keygen main mark meter menu menuitem nav output
syn keyword htmlTagName contained progress ruby rt rp rb rtc section source summary time track video data syn keyword htmlTagName contained progress ruby rt rp rb rtc section source summary time track video data
syn keyword htmlTagName contained template content shadow syn keyword htmlTagName contained template content shadow
syn keyword htmlTagName contained wbr bdi syn keyword htmlTagName contained wbr bdi
@@ -43,6 +42,7 @@ syn keyword htmlTagName contained glyph glyphRef hkern
syn keyword htmlTagName contained linearGradient marker mask pattern radialGradient set stop syn keyword htmlTagName contained linearGradient marker mask pattern radialGradient set stop
syn keyword htmlTagName contained missing-glyph mpath syn keyword htmlTagName contained missing-glyph mpath
syn keyword htmlTagName contained text textPath tref tspan vkern syn keyword htmlTagName contained text textPath tref tspan vkern
syn keyword htmlTagName contained metadata title
" Custom Element " Custom Element
syn match htmlTagName contained "\<[a-z_]\([a-z0-9_.]\+\)\?\(\-[a-z0-9_.]\+\)\+\>" syn match htmlTagName contained "\<[a-z_]\([a-z0-9_.]\+\)\?\(\-[a-z0-9_.]\+\)\+\>"
@@ -101,21 +101,21 @@ syn keyword htmlArg contained d descent diffuseConstant divisor dur dx dy
syn keyword htmlArg contained edgeMode elevation end exponent externalResourcesRequired syn keyword htmlArg contained edgeMode elevation end exponent externalResourcesRequired
syn keyword htmlArg contained fill filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight format format from fx fy syn keyword htmlArg contained fill filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight format format from fx fy
syn keyword htmlArg contained g1 g2 glyph-name glyphRef gradientTransform gradientUnits syn keyword htmlArg contained g1 g2 glyph-name glyphRef gradientTransform gradientUnits
syn keyword htmlArg contained hanging height horiz-adv-x horiz-origin-y syn keyword htmlArg contained hanging height horiz-adv-x horiz-origin-x horiz-origin-y
syn keyword htmlArg contained id ideographic in in2 intercept syn keyword htmlArg contained id ideographic in in2 intercept
syn keyword htmlArg contained k k1 k2 k3 k4 kernelMatrix kernelUnitLength keyPoints keySplines keyTimes syn keyword htmlArg contained k k1 k2 k3 k4 kernelMatrix kernelUnitLength keyPoints keySplines keyTimes
syn keyword htmlArg contained lang lengthAdjust limitingConeAngle local syn keyword htmlArg contained lang lengthAdjust limitingConeAngle local
syn keyword htmlArg contained markerHeight markerUnits markerWidth maskContentUnits maskUnits mathematical max media method min mode name syn keyword htmlArg contained markerHeight markerUnits markerWidth maskContentUnits maskUnits mathematical max media method min mode name
syn keyword htmlArg contained numOctaves syn keyword htmlArg contained numOctaves
syn keyword htmlArg contained offset offset onabort onactivate onbegin onclick onend onerror onfocusin onfocusout onload onload onmousedown onmousemove onmouseout onmouseover onmouseup onrepeat onresize onscroll onunload onzoom operator order orient orientation origin overline-position overline-thickness syn keyword htmlArg contained offset onabort onactivate onbegin onclick onend onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onrepeat onresize onscroll onunload onzoom operator order orient orientation origin overline-position overline-thickness
syn keyword htmlArg contained panose-1 path pathLength patternContentUnits patternTransform patternUnits points pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits syn keyword htmlArg contained panose-1 path pathLength patternContentUnits patternTransform patternUnits points pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits
syn keyword htmlArg contained r radius refX refY rendering-intent repeatCount repeatDur requiredExtensions requiredFeatures restart result rotate rx ry syn keyword htmlArg contained r radius refX refY rendering-intent repeatCount repeatDur requiredExtensions requiredFeatures restart result rotate rx ry
syn keyword htmlArg contained scale seed slope spacing specularConstant specularExponent spreadMethod startOffset stdDeviation stemh stemv stitchTiles strikethrough-position strikethrough-thickness string surfaceScale systemLanguage syn keyword htmlArg contained scale seed slope spacing specularConstant specularExponent spreadMethod startOffset stdDeviation stemh stemv stitchTiles strikethrough-position strikethrough-thickness string surfaceScale systemLanguage
syn keyword htmlArg contained tableValues target targetX targetY textLength title to transform type u syn keyword htmlArg contained tableValues target targetX targetY textLength title to transform type
syn keyword htmlArg contained 1 u2 underline-position underline-thickness unicode unicode-range units-per-em syn keyword htmlArg contained u1 u2 underline-position underline-thickness unicode unicode-range units-per-em
syn keyword htmlArg contained v-alphabetic v-hanging v-ideographic v-mathematical values version vert-adv-y vert-origin-x vert-origin-y viewBox viewTarget syn keyword htmlArg contained v-alphabetic v-hanging v-ideographic v-mathematical values version vert-adv-y vert-origin-x vert-origin-y viewBox viewTarget
syn keyword htmlArg contained width widths syn keyword htmlArg contained width widths
syn keyword htmlArg contained x x-height x1 x2 xChannelSelector xlink:actuate xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:show xlink:title xlink:type xml:base xml:lang xml:space syn keyword htmlArg contained x x-height x1 x2 xChannelSelector xlink:actuate xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space
syn keyword htmlArg contained y y1 y2 yChannelSelector syn keyword htmlArg contained y y1 y2 yChannelSelector
syn keyword htmlArg contained z zoomAndPan syn keyword htmlArg contained z zoomAndPan
syn keyword htmlArg contained alignment-baseline baseline-shift clip-path clip-rule clip color-interpolation-filters color-interpolation color-profile color-rendering color cursor direction display dominant-baseline enable-background fill-opacity fill-rule fill filter flood-color flood-opacity font-family font-size-adjust font-size font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width stroke text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode syn keyword htmlArg contained alignment-baseline baseline-shift clip-path clip-rule clip color-interpolation-filters color-interpolation color-profile color-rendering color cursor direction display dominant-baseline enable-background fill-opacity fill-rule fill filter flood-color flood-opacity font-family font-size-adjust font-size font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width stroke text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode

View File

@@ -1,108 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1
" Vim syntax file
" Language: Jade
" Maintainer: Joshua Borton
" Credits: Tim Pope
" Filenames: *.jade
if exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = 'jade'
endif
silent! syntax include @htmlCoffeescript syntax/coffee.vim
unlet! b:current_syntax
silent! syntax include @htmlStylus syntax/stylus.vim
unlet! b:current_syntax
silent! syntax include @htmlCss syntax/css.vim
unlet! b:current_syntax
silent! syntax include @htmlMarkdown syntax/markdown.vim
unlet! b:current_syntax
syn case match
syn region javascriptParenthesisBlock start="(" end=")" contains=@htmlJavascript contained keepend
syn cluster htmlJavascript add=javascriptParenthesisBlock
syn region jadeJavascript matchgroup=jadeJavascriptOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
syn region jadeJavascript matchgroup=jadeJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
syn cluster jadeTop contains=jadeBegin,jadeComment,jadeHtmlComment,jadeJavascript
syn match jadeBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=jadeTag,jadeClassChar,jadeIdChar,jadePlainChar,jadeJavascript,jadeScriptConditional,jadeScriptStatement,jadePipedText
syn match jadeTag "+\?\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@jadeComponent
syn cluster jadeComponent contains=jadeAttributes,jadeIdChar,jadeBlockExpansionChar,jadeClassChar,jadePlainChar,jadeJavascript,jadeTagBlockChar,jadeTagInlineText
syn match jadeComment '\s*\/\/.*$'
syn region jadeCommentBlock start="\z(\s*\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" keepend
syn region jadeHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->"
syn region jadeAttributes matchgroup=jadeAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,jadeHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@jadeComponent
syn match jadeClassChar "\." contained nextgroup=jadeClass
syn match jadeBlockExpansionChar ":\s\+" contained nextgroup=jadeTag,jadeClassChar,jadeIdChar
syn match jadeIdChar "#[[{]\@!" contained nextgroup=jadeId
syn match jadeClass "\%(\w\|-\)\+" contained nextgroup=@jadeComponent
syn match jadeId "\%(\w\|-\)\+" contained nextgroup=@jadeComponent
syn region jadeDocType start="^\s*\(!!!\|doctype\)" end="$"
" Unless I'm mistaken, syntax/html.vim requires
" that the = sign be present for these matches.
" This adds the matches back for jade.
syn keyword jadeHtmlArg contained href title
syn match jadePlainChar "\\" contained
syn region jadeInterpolation matchgroup=jadeInterpolationDelimiter start="[#!]{" end="}" contains=@htmlJavascript
syn match jadeInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
syn match jadeTagInlineText "\s.*$" contained contains=jadeInterpolation,jadeTextInlineJade
syn region jadePipedText matchgroup=jadePipeChar start="|" end="$" contained contains=jadeInterpolation,jadeTextInlineJade nextgroup=jadePipedText skipnl
syn match jadeTagBlockChar "\.$" contained nextgroup=jadeTagBlockText,jadeTagBlockEnd skipnl
syn region jadeTagBlockText start="\%(\s*\)\S" end="\ze\n" contained contains=jadeInterpolation,jadeTextInlineJade nextgroup=jadeTagBlockText,jadeTagBlockEnd skipnl
syn region jadeTagBlockEnd start="\s*\S" end="$" contained contains=jadeInterpolation,jadeTextInlineJade nextgroup=jadeBegin skipnl
syn region jadeTextInlineJade matchgroup=jadeInlineDelimiter start="#\[" end="]" contains=jadeTag keepend
syn region jadeJavascriptFilter matchgroup=jadeFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript
syn region jadeMarkdownFilter matchgroup=jadeFilter start=/^\z(\s*\):\%(markdown\|marked\)\s*$/ end=/^\%(\z1\s\|\s*$\)\@!/ contains=@htmlMarkdown
syn region jadeStylusFilter matchgroup=jadeFilter start="^\z(\s*\):stylus\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlStylus
syn region jadePlainFilter matchgroup=jadeFilter start="^\z(\s*\):\%(sass\|less\|cdata\)\s*$" end="^\%(\z1\s\|\s*$\)\@!"
syn match jadeScriptConditional "^\s*\<\%(if\|else\|unless\|while\|until\|case\|when\|default\)\>[?!]\@!"
syn match jadeScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!"
syn region jadeScriptLoopRegion start="^\s*\(for \)" end="$" contains=jadeScriptLoopKeywords
syn keyword jadeScriptLoopKeywords for in contained
syn region jadeJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,jadeJavascriptTag,jadeCoffeescriptFilter keepend
syn region jadeCoffeescriptFilter matchgroup=jadeFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained
syn region jadeJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=jadeBegin,jadeTag
syn region jadeCssBlock start="^\z(\s*\)style" nextgroup=@jadeComponent,jadeError end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCss keepend
syn match jadeError "\$" contained
hi def link jadePlainChar Special
hi def link jadeScriptConditional PreProc
hi def link jadeScriptLoopKeywords PreProc
hi def link jadeScriptStatement PreProc
hi def link jadeHtmlArg htmlArg
hi def link jadeAttributeString String
hi def link jadeAttributesDelimiter Identifier
hi def link jadeIdChar Special
hi def link jadeClassChar Special
hi def link jadeBlockExpansionChar Special
hi def link jadePipeChar Special
hi def link jadeTagBlockChar Special
hi def link jadeId Identifier
hi def link jadeClass Type
hi def link jadeInterpolationDelimiter Delimiter
hi def link jadeInlineDelimiter Delimiter
hi def link jadeFilter PreProc
hi def link jadeDocType PreProc
hi def link jadeComment Comment
hi def link jadeCommentBlock Comment
hi def link jadeHtmlConditionalComment jadeComment
let b:current_syntax = "jade"
if main_syntax == "jade"
unlet main_syntax
endif
endif

View File

@@ -2,21 +2,9 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') ==
" Vim syntax file " Vim syntax file
" Language: JavaScript " Language: JavaScript
" Maintainer: Kao Wei-Ko(othree) <othree@gmail.com> " Maintainer: vim-javascript community
" Last Change: 2015-05-11 " URL: https://github.com/pangloss/vim-javascript
" Version: 1.5
" Changes: Go to https://github.com/othree/yajs.vim for recent changes.
" Origin: https://github.com/jelera/vim-javascript-syntax
" Credits: Jose Elera Campana, Zhao Yi, Claudio Fleiner, Scott Shattuck
" (This file is based on their hard work), gumnos (From the #vim
" IRC Channel in Freenode)
" if exists("b:yajs_loaded")
" finish
" else
" let b:yajs_loaded = 1
" endif
if !exists("main_syntax") if !exists("main_syntax")
if version < 600 if version < 600
syntax clear syntax clear
@@ -26,371 +14,331 @@ if !exists("main_syntax")
let main_syntax = 'javascript' let main_syntax = 'javascript'
endif endif
if !exists('g:javascript_conceal')
let g:javascript_conceal = 0
endif
"" dollar sign is permittd anywhere in an identifier
setlocal iskeyword+=$
syntax sync fromstart
syntax match jsNoise /[:,\;\.]\{1}/
"" Program Keywords
syntax keyword jsStorageClass const var let
syntax keyword jsOperator delete instanceof typeof void new in
syntax match jsOperator /[\!\|\&\+\-\<\>\=\%\/\*\~\^]\{1}/
syntax keyword jsBooleanTrue true
syntax keyword jsBooleanFalse false
syntax keyword jsModules import export contained
syntax keyword jsModuleWords default from as contained
syntax keyword jsOf of contained
syntax keyword jsArgsObj arguments
syntax region jsImportContainer start="^\s\?import \?" end=";\|$" contains=jsModules,jsModuleWords,jsLineComment,jsComment,jsStringS,jsStringD,jsTemplateString,jsNoise,jsBlock
syntax region jsExportContainer start="^\s\?export \?" end="$" contains=jsModules,jsModuleWords,jsComment,jsTemplateString,jsStringD,jsStringS,jsRegexpString,jsNumber,jsFloat,jsThis,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsDotNotation,jsBracket,jsParen,jsFuncCall,jsUndefined,jsNan,jsKeyword,jsStorageClass,jsPrototype,jsBuiltins,jsNoise,jsArgsObj,jsBlock,jsClassDefinition
"" JavaScript comments
syntax keyword jsCommentTodo TODO FIXME XXX TBD contained
syntax region jsLineComment start=+\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell extend
syntax region jsEnvComment start="\%^#!" end="$" display
syntax region jsLineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell fold
syntax region jsCvsTag start="\$\cid:" end="\$" oneline contained
syntax region jsComment start="/\*" end="\*/" contains=jsCommentTodo,jsCvsTag,@Spell fold extend
"" JSDoc / JSDoc Toolkit
if !exists("javascript_ignore_javaScriptdoc")
syntax case ignore
"" syntax coloring for javadoc comments (HTML)
"syntax include @javaHtml <sfile>:p:h/html.vim
"unlet b:current_syntax
syntax region jsBlockComment matchgroup=jsComment start="/\*\s*" end="\*/" contains=jsDocTags,jsCommentTodo,jsCvsTag,@jsHtml,@Spell fold
" tags containing a param
syntax match jsDocTags contained "@\(alias\|api\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|fires\|kind\|link\|listens\|member\|member[oO]f\|mixes\|module\|name\|namespace\|requires\|template\|throws\|var\|variation\|version\)\>" nextgroup=jsDocParam skipwhite
" tags containing type and param
syntax match jsDocTags contained "@\(arg\|argument\|cfg\|param\|property\|prop\)\>" nextgroup=jsDocType skipwhite
" tags containing type but no param
syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|implements\|this\|type\|typedef\|return\|returns\)\>" nextgroup=jsDocTypeNoParam skipwhite
" tags containing references
syntax match jsDocTags contained "@\(lends\|see\|tutorial\)\>" nextgroup=jsDocSeeTag skipwhite
" other tags (no extra syntax)
syntax match jsDocTags contained "@\(abstract\|access\|accessor\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|dict\|event\|example\|file\|file[oO]verview\|final\|function\|global\|ignore\|inheritDoc\|inner\|instance\|interface\|license\|localdoc\|method\|mixin\|nosideeffects\|override\|overview\|preserve\|private\|protected\|public\|readonly\|since\|static\|struct\|todo\|summary\|undocumented\|virtual\)\>"
syntax region jsDocType matchgroup=jsDocTypeBrackets start="{" end="}" oneline contained nextgroup=jsDocParam skipwhite contains=jsDocTypeRecord
syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite
syntax region jsDocTypeRecord start=/{/ end=/}/ contained extend contains=jsDocTypeRecord
syntax region jsDocTypeRecord start=/\[/ end=/\]/ contained extend contains=jsDocTypeRecord
syntax region jsDocTypeNoParam start="{" end="}" oneline contained
syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+"
syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\.\|:\|\/\|\[.{-}]\|=\)\+"
syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags
syntax case match
endif "" JSDoc end
syntax case match
"" Syntax in the JavaScript code
syntax match jsFuncCall /\k\+\%(\s*(\)\@=/
syntax match jsSpecial "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)" contained
syntax region jsTemplateVar matchgroup=jsTemplateBraces start=+${+ end=+}+ contained contains=@jsExpression
syntax region jsStringD start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@htmlPreproc,@Spell
syntax region jsStringS start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@htmlPreproc,@Spell
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateVar,jsSpecial,@htmlPreproc
syntax region jsTaggedTemplate start=/\k\+\%([\n\s]\+\)\?`/ end=+`+ contains=jsTemplateString keepend
syntax region jsRegexpCharClass start=+\[+ skip=+\\.+ end=+\]+ contained
syntax match jsRegexpBoundary "\v%(\<@![\^$]|\\[bB])" contained
syntax match jsRegexpBackRef "\v\\[1-9][0-9]*" contained
syntax match jsRegexpQuantifier "\v\\@<!%([?*+]|\{\d+%(,|,\d+)?})\??" contained
syntax match jsRegexpOr "\v\<@!\|" contained
syntax match jsRegexpMod "\v\(@<=\?[:=!>]" contained
syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod
syntax region jsRegexpGroup start="\\\@<!(" skip="\\.\|\[\(\\.\|[^]]\)*\]" end="\\\@<!)" contained contains=jsRegexpCharClass,@jsRegexpSpecial keepend
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@50<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@50<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimy]\{,4}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial,@htmlPreproc oneline keepend
syntax match jsNumber /\<-\=\d\+\(L\|[eE][+-]\=\d\+\)\=\>\|\<0[xX]\x\+\>/
syntax keyword jsNumber Infinity
syntax match jsFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
syntax match jsObjectKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\)\@=/ contains=jsFunctionKey contained
syntax match jsFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function\s*\)\@=/ contained
syntax match jsDecorator "@" display contains=jsDecoratorFunction nextgroup=jsDecoratorFunction skipwhite
syntax match jsDecoratorFunction "[a-zA-Z_][a-zA-Z0-9_.]*" display contained nextgroup=jsFunc skipwhite
exe 'syntax keyword jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '')
exe 'syntax keyword jsReturn return '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '')
exe 'syntax keyword jsUndefined undefined '.(exists('g:javascript_conceal_undefined') ? 'conceal cchar='.g:javascript_conceal_undefined : '')
exe 'syntax keyword jsNan NaN '.(exists('g:javascript_conceal_NaN') ? 'conceal cchar='.g:javascript_conceal_NaN : '')
exe 'syntax keyword jsPrototype prototype '.(exists('g:javascript_conceal_prototype') ? 'conceal cchar='.g:javascript_conceal_prototype : '')
exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal_this') ? 'conceal cchar='.g:javascript_conceal_this : '')
exe 'syntax keyword jsStatic static '.(exists('g:javascript_conceal_static') ? 'conceal cchar='.g:javascript_conceal_static : '')
exe 'syntax keyword jsSuper super '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
"" Statement Keywords
syntax keyword jsStatement break continue with
syntax keyword jsConditional if else switch
syntax keyword jsRepeat do while for
syntax keyword jsLabel case default
syntax keyword jsKeyword yield
syntax keyword jsException try catch throw finally
syntax keyword jsAsyncKeyword async await
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray JSON Math console document window Intl Collator DateTimeFormat NumberFormat
syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError
syntax keyword jsBuiltins decodeURI decodeURIComponent encodeURI encodeURIComponent eval isFinite isNaN parseFloat parseInt uneval
syntax keyword jsFutureKeys abstract enum int short boolean interface byte long char final native synchronized float package throws goto private transient debugger implements protected volatile double public
"" DOM/HTML/CSS specified things
" DOM2 Objects
syntax keyword jsGlobalObjects DOMImplementation DocumentFragment Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction
syntax keyword jsExceptions DOMException
" DOM2 CONSTANT
syntax keyword jsDomErrNo INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR
syntax keyword jsDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE
" HTML events and internal variables
syntax case ignore
syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize
syntax case match
" Follow stuff should be highligh within a special context
" While it can't be handled with context depended with Regex based highlight
" So, turn it off by default
if exists("javascript_enable_domhtmlcss")
" DOM2 things
syntax match jsDomElemAttrs contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/
syntax match jsDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementById\|getElementsByClassName\|getElementsByTagName\|querySelector\|querySelectorAll\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=jsParen skipwhite
" HTML things
syntax match jsHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/
syntax match jsHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=jsParen skipwhite
" CSS Styles in JavaScript
syntax keyword jsCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition
syntax keyword jsCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition
syntax keyword jsCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode
syntax keyword jsCssStyles contained bottom height left position right top width zIndex
syntax keyword jsCssStyles contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout
syntax keyword jsCssStyles contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop
syntax keyword jsCssStyles contained listStyle listStyleImage listStylePosition listStyleType
syntax keyword jsCssStyles contained background backgroundAttachment backgroundColor backgroundImage backgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat
syntax keyword jsCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType
syntax keyword jsCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText
syntax keyword jsCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor
" Highlight ways
syntax match jsDotNotation "\." nextgroup=jsPrototype,jsDomElemAttrs,jsDomElemFuncs,jsHtmlElemAttrs,jsHtmlElemFuncs
syntax match jsDotNotation "\.style\." nextgroup=jsCssStyles
endif "DOM/HTML/CSS
"" end DOM/HTML/CSS specified things
"" Code blocks
syntax cluster jsExpression contains=jsComment,jsLineComment,jsBlockComment,jsTaggedTemplate,jsTemplateString,jsStringD,jsStringS,jsRegexpString,jsNumber,jsFloat,jsThis,jsStatic,jsSuper,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsDotNotation,jsBracket,jsParen,jsBlock,jsFuncCall,jsUndefined,jsNan,jsKeyword,jsStorageClass,jsPrototype,jsBuiltins,jsNoise,jsCommonJS,jsImportContainer,jsExportContainer,jsArgsObj,jsDecorator,jsAsyncKeyword,jsClassDefinition,jsArrowFunction,jsArrowFuncArgs
syntax cluster jsAll contains=@jsExpression,jsLabel,jsConditional,jsRepeat,jsReturn,jsStatement,jsTernaryIf,jsException
syntax region jsBracket matchgroup=jsBrackets start="\[" end="\]" contains=@jsAll,jsParensErrB,jsParensErrC,jsBracket,jsParen,jsBlock,@htmlPreproc fold
syntax region jsParen matchgroup=jsParens start="(" end=")" contains=@jsAll,jsOf,jsParensErrA,jsParensErrC,jsParen,jsBracket,jsBlock,@htmlPreproc fold extend
syntax region jsClassBlock matchgroup=jsClassBraces start="{" end="}" contains=jsFuncName,jsClassMethodDefinitions,jsOperator,jsArrowFunction,jsArrowFuncArgs,jsComment,jsBlockComment,jsLineComment contained fold
syntax region jsFuncBlock matchgroup=jsFuncBraces start="{" end="}" contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,@htmlPreproc,jsClassDefinition fold extend
syntax region jsBlock matchgroup=jsBraces start="{" end="}" contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,jsObjectKey,@htmlPreproc,jsClassDefinition fold extend
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=+?+ end=+:+ contains=@jsExpression,jsTernaryIf
"" catch errors caused by wrong parenthesis
syntax match jsParensError ")\|}\|\]"
syntax match jsParensErrA contained "\]"
syntax match jsParensErrB contained ")"
syntax match jsParensErrC contained "}"
syntax match jsFuncArgDestructuring contained /\({\|}\|=\|:\|\[\|\]\)/ extend
exe 'syntax match jsFunction /\<function\>/ nextgroup=jsGenerator,jsFuncName,jsFuncArgs skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '')
exe 'syntax match jsArrowFunction /=>/ skipwhite nextgroup=jsFuncBlock contains=jsFuncBraces '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '')
syntax match jsGenerator contained '\*' nextgroup=jsFuncName,jsFuncArgs skipwhite
syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=jsFuncArgs skipwhite
syntax region jsFuncArgs contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas,jsFuncArgRest,jsComment,jsLineComment,jsStringS,jsStringD,jsNumber,jsFuncArgDestructuring,jsArrowFunction,jsParen,jsArrowFuncArgs nextgroup=jsFuncBlock keepend skipwhite skipempty
syntax match jsFuncArgCommas contained ','
syntax match jsFuncArgRest contained /\%(\.\.\.[a-zA-Z_$][0-9a-zA-Z_$]*\))/ contains=jsFuncArgRestDots
syntax match jsFuncArgRestDots contained /\.\.\./
" Matches a single keyword argument with no parens
syntax match jsArrowFuncArgs /\k\+\s*\%(=>\)\@=/ skipwhite contains=jsFuncArgs nextgroup=jsArrowFunction extend
" Matches a series of arguments surrounded in parens
syntax match jsArrowFuncArgs /([^()]*)\s*\(=>\)\@=/ skipempty skipwhite contains=jsFuncArgs nextgroup=jsArrowFunction extend
syntax keyword jsClassKeywords extends class contained
syntax match jsClassNoise /\./ contained
syntax keyword jsClassMethodDefinitions get set static contained nextgroup=jsFuncName skipwhite skipempty
syntax match jsClassDefinition /class [a-zA-Z_$][0-9a-zA-Z_$ \n.]*/ contains=jsClassKeywords,jsClassNoise nextgroup=jsClassBlock skipwhite skipempty
" Define the default highlighting. " Define the default highlighting.
" For version 5.7 and earlier: only when not done already " For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet " For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_javascript_syn_inits") if version >= 508 || !exists("did_javascript_syn_inits")
let did_javascript_hilink = 1
if version < 508 if version < 508
let did_javascript_syn_inits = 1 let did_javascript_syn_inits = 1
command -nargs=+ HiLink hi link <args> command -nargs=+ HiLink hi link <args>
else else
command -nargs=+ HiLink hi def link <args> command -nargs=+ HiLink hi def link <args>
endif endif
else HiLink jsFuncArgRest Special
finish HiLink jsComment Comment
endif HiLink jsLineComment Comment
HiLink jsEnvComment PreProc
HiLink jsBlockComment Comment
HiLink jsCommentTodo Todo
HiLink jsCvsTag Function
HiLink jsDocTags Special
HiLink jsDocSeeTag Function
HiLink jsDocType Type
HiLink jsDocTypeBrackets jsDocType
HiLink jsDocTypeRecord jsDocType
HiLink jsDocTypeNoParam Type
HiLink jsDocParam Label
HiLink jsStringS String
HiLink jsStringD String
HiLink jsTemplateString String
HiLink jsTaggedTemplate StorageClass
HiLink jsTernaryIfOperator Conditional
HiLink jsRegexpString String
HiLink jsRegexpBoundary SpecialChar
HiLink jsRegexpQuantifier SpecialChar
HiLink jsRegexpOr Conditional
HiLink jsRegexpMod SpecialChar
HiLink jsRegexpBackRef SpecialChar
HiLink jsRegexpGroup jsRegexpString
HiLink jsRegexpCharClass Character
HiLink jsCharacter Character
HiLink jsPrototype Special
HiLink jsConditional Conditional
HiLink jsBranch Conditional
HiLink jsLabel Label
HiLink jsReturn Statement
HiLink jsRepeat Repeat
HiLink jsStatement Statement
HiLink jsException Exception
HiLink jsKeyword Keyword
HiLink jsAsyncKeyword Keyword
HiLink jsArrowFunction Type
HiLink jsFunction Type
HiLink jsGenerator jsFunction
HiLink jsArrowFuncArgs jsFuncArgs
HiLink jsFuncName Function
HiLink jsArgsObj Special
HiLink jsError Error
HiLink jsParensError Error
HiLink jsParensErrA Error
HiLink jsParensErrB Error
HiLink jsParensErrC Error
HiLink jsOperator Operator
HiLink jsOf Operator
HiLink jsStorageClass StorageClass
HiLink jsClassKeywords Structure
HiLink jsThis Special
HiLink jsStatic Special
HiLink jsSuper Special
HiLink jsNan Number
HiLink jsNull Type
HiLink jsUndefined Type
HiLink jsNumber Number
HiLink jsFloat Float
HiLink jsBooleanTrue Boolean
HiLink jsBooleanFalse Boolean
HiLink jsNoise Noise
HiLink jsBrackets Noise
HiLink jsParens Noise
HiLink jsBraces Noise
HiLink jsFuncBraces Noise
HiLink jsFuncParens Noise
HiLink jsClassBraces Noise
HiLink jsClassNoise Noise
HiLink jsSpecial Special
HiLink jsTemplateVar Special
HiLink jsTemplateBraces jsBraces
HiLink jsGlobalObjects Special
HiLink jsExceptions Special
HiLink jsFutureKeys Special
HiLink jsBuiltins Special
HiLink jsModules Include
HiLink jsModuleWords Include
HiLink jsDecorator Special
HiLink jsFuncArgRestDots Noise
HiLink jsFuncArgDestructuring Noise
"Dollar sign is permitted anywhere in an identifier HiLink jsDomErrNo Constant
setlocal iskeyword-=$ HiLink jsDomNodeConsts Constant
if &filetype =~ 'javascript' HiLink jsDomElemAttrs Label
setlocal iskeyword+=$ HiLink jsDomElemFuncs PreProc
syntax cluster htmlJavaScript contains=TOP
endif
syntax sync fromstart HiLink jsHtmlEvents Special
HiLink jsHtmlElemAttrs Label
HiLink jsHtmlElemFuncs PreProc
"Syntax coloring for Node.js shebang line HiLink jsCssStyles Label
syntax match shellbang "^#!.*node\>"
syntax match shellbang "^#!.*iojs\>"
syntax match javascriptOpSymbols /:\ze\_[^+\-*/%\^=!<>&|?:]/ nextgroup=@javascriptStatement,javascriptCase skipwhite skipempty HiLink jsClassMethodDefinitions Type
syntax match javascriptOpSymbols /[+\-*/%\^=!<>&|?:]\+/ contains=javascriptOpSymbol nextgroup=@javascriptExpression skipwhite skipempty
"JavaScript comments
syntax keyword javascriptCommentTodo contained TODO FIXME XXX TBD
syntax match javascriptLineComment "//.*" contains=@Spell,javascriptCommentTodo
syntax region javascriptComment start="/\*" end="\*/" contains=@Spell,javascriptCommentTodo extend
syntax cluster javascriptComments contains=javascriptDocComment,javascriptComment,javascriptLineComment
"JSDoc
syntax case ignore
syntax region javascriptDocComment start="/\*\*" end="\*/" contains=javascriptDocNotation,javascriptCommentTodo,@Spell fold keepend
syntax match javascriptDocNotation contained / @/ nextgroup=javascriptDocTags
syntax keyword javascriptDocTags contained constant constructor constructs function ignore inner private public readonly static
syntax keyword javascriptDocTags contained const dict expose inheritDoc interface nosideeffects override protected struct
syntax keyword javascriptDocTags contained example global
" syntax keyword javascriptDocTags contained ngdoc nextgroup=javascriptDocNGDirective
syntax keyword javascriptDocTags contained ngdoc scope priority animations
syntax keyword javascriptDocTags contained ngdoc restrict methodOf propertyOf eventOf eventType nextgroup=javascriptDocParam skipwhite
syntax keyword javascriptDocNGDirective contained overview service object function method property event directive filter inputType error
syntax keyword javascriptDocTags contained abstract virtual access augments
syntax keyword javascriptDocTags contained arguments callback lends memberOf name type kind link mixes mixin tutorial nextgroup=javascriptDocParam skipwhite
syntax keyword javascriptDocTags contained variation nextgroup=javascriptDocNumParam skipwhite
syntax keyword javascriptDocTags contained author class classdesc copyright default defaultvalue nextgroup=javascriptDocDesc skipwhite
syntax keyword javascriptDocTags contained deprecated description external host nextgroup=javascriptDocDesc skipwhite
syntax keyword javascriptDocTags contained file fileOverview overview namespace requires since version nextgroup=javascriptDocDesc skipwhite
syntax keyword javascriptDocTags contained summary todo license preserve nextgroup=javascriptDocDesc skipwhite
syntax keyword javascriptDocTags contained borrows exports nextgroup=javascriptDocA skipwhite
syntax keyword javascriptDocTags contained param arg argument property prop module nextgroup=javascriptDocNamedParamType,javascriptDocParamName skipwhite
syntax keyword javascriptDocTags contained type nextgroup=javascriptDocParamType skipwhite
syntax keyword javascriptDocTags contained define enum extends implements this typedef nextgroup=javascriptDocParamType skipwhite
syntax keyword javascriptDocTags contained return returns throws exception nextgroup=javascriptDocParamType,javascriptDocParamName skipwhite
syntax keyword javascriptDocTags contained see nextgroup=javascriptDocRef skipwhite
"syntax for event firing
syntax keyword javascriptDocTags contained emits fires nextgroup=javascriptDocEventRef skipwhite
syntax keyword javascriptDocTags contained function func method nextgroup=javascriptDocName skipwhite
syntax match javascriptDocName contained /\h\w*/
syntax keyword javascriptDocTags contained fires event nextgroup=javascriptDocEventRef skipwhite
syntax match javascriptDocEventRef contained /\h\w*#\(\h\w*\:\)\?\h\w*/
syntax match javascriptDocNamedParamType contained /{.\+}/ nextgroup=javascriptDocParamName skipwhite
syntax match javascriptDocParamName contained /\[\?[0-9a-zA-Z_\.]\+=\?[0-9a-zA-Z_\.]*\]\?/ nextgroup=javascriptDocDesc skipwhite
syntax match javascriptDocParamType contained /{.\+}/ nextgroup=javascriptDocDesc skipwhite
syntax match javascriptDocA contained /\%(#\|\w\|\.\|:\|\/\)\+/ nextgroup=javascriptDocAs skipwhite
syntax match javascriptDocAs contained /\s*as\s*/ nextgroup=javascriptDocB skipwhite
syntax match javascriptDocB contained /\%(#\|\w\|\.\|:\|\/\)\+/
syntax match javascriptDocParam contained /\%(#\|\w\|\.\|:\|\/\|-\)\+/
syntax match javascriptDocNumParam contained /\d\+/
syntax match javascriptDocRef contained /\%(#\|\w\|\.\|:\|\/\)\+/
syntax region javascriptDocLinkTag contained matchgroup=javascriptDocLinkTag start=/{/ end=/}/ contains=javascriptDocTags
syntax cluster javascriptDocs contains=javascriptDocParamType,javascriptDocNamedParamType,javascriptDocParam
if main_syntax == "javascript"
syntax sync clear
syntax sync ccomment javascriptComment minlines=200
endif
syntax case match
syntax cluster javascriptAfterIdentifier contains=javascriptDotNotation,javascriptFuncCallArg,javascriptComputedProperty,javascriptWSymbols,@javascriptSymbols
syntax match javascriptIdentifierName /\<[^=<>!?+\-*\/%|&,;:. ~@#`"'\[\]\(\)\{\}\^0-9][^=<>!?+\-*\/%|&,;:. ~@#`"'\[\]\(\)\{\}\^]*/ nextgroup=@javascriptAfterIdentifier contains=@_semantic
"Block VariableStatement EmptyStatement ExpressionStatement IfStatement IterationStatement ContinueStatement BreakStatement ReturnStatement WithStatement LabelledStatement SwitchStatement ThrowStatement TryStatement DebuggerStatement
syntax cluster javascriptStatement contains=javascriptBlock,javascriptVariable,@javascriptExpression,javascriptConditional,javascriptRepeat,javascriptBranch,javascriptLabel,javascriptStatementKeyword,javascriptTry,javascriptDebugger
"Syntax in the JavaScript code
" syntax match javascriptASCII contained /\\\d\d\d/
syntax region javascriptTemplateSubstitution contained matchgroup=javascriptTemplateSB start=/\${/ end=/}/ contains=javascriptTemplateSBlock,javascriptTemplateSString
syntax region javascriptTemplateSBlock contained start=/{/ end=/}/ contains=javascriptTemplateSBlock,javascriptTemplateSString transparent
syntax region javascriptTemplateSString contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/ extend contains=javascriptTemplateSStringRB transparent
syntax match javascriptTemplateSStringRB /}/ contained
syntax region javascriptString start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/ nextgroup=@javascriptSymbols skipwhite skipempty
syntax region javascriptTemplate start=/`/ skip=/\\\\\|\\`\|\n/ end=/`\|$/ contains=javascriptTemplateSubstitution nextgroup=@javascriptSymbols skipwhite skipempty
" syntax match javascriptTemplateTag /\k\+/ nextgroup=javascriptTemplate
syntax region javascriptArray matchgroup=javascriptBraces start=/\[/ end=/]/ contains=@javascriptValue,javascriptForComprehension,@javascriptComments nextgroup=@javascriptSymbols,@javascriptComments skipwhite skipempty
syntax match javascriptNumber /\<0[bB][01]\+\>/ nextgroup=@javascriptSymbols skipwhite skipempty
syntax match javascriptNumber /\<0[oO][0-7]\+\>/ nextgroup=@javascriptSymbols skipwhite skipempty
syntax match javascriptNumber /\<0[xX][0-9a-fA-F]\+\>/ nextgroup=@javascriptSymbols skipwhite skipempty
syntax match javascriptNumber /[+-]\=\%(\d\+\.\d\+\|\d\+\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ nextgroup=@javascriptSymbols skipwhite skipempty
syntax cluster javascriptTypes contains=javascriptString,javascriptTemplate,javascriptRegexpString,javascriptNumber,javascriptBoolean,javascriptNull,javascriptArray
syntax cluster javascriptValue contains=@javascriptTypes,@javascriptExpression,javascriptFuncKeyword,javascriptClassKeyword,javascriptObjectLiteral,javascriptIdentifier,javascriptIdentifierName,javascriptOperator,@javascriptSymbols
syntax match javascriptLabel /[a-zA-Z_$]\k*\_s*:/he=e-1 nextgroup=@javascriptValue,@javascriptStatement skipwhite skipempty
syntax match javascriptObjectLabel contained /\k\+\_s*:/he=e-1 contains=javascriptObjectLabelColon nextgroup=@javascriptValue,@javascriptStatement skipwhite skipempty
syntax match javascriptObjectLabelColon contained /:/ nextgroup=@javascriptValue,@javascriptStatement skipwhite skipempty
" syntax match javascriptPropertyName contained /"[^"]\+"\s*:/he=e-1 nextgroup=@javascriptValue skipwhite skipempty
" syntax match javascriptPropertyName contained /'[^']\+'\s*:/he=e-1 nextgroup=@javascriptValue skipwhite skipempty
syntax region javascriptPropertyName contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/ nextgroup=javascriptObjectLabelColon skipwhite skipempty
syntax region javascriptComputedPropertyName contained matchgroup=javascriptPropertyName start=/\[/rs=s+1 end=/]/ contains=@javascriptValue nextgroup=javascriptObjectLabelColon skipwhite skipempty
syntax region javascriptComputedProperty contained matchgroup=javascriptProperty start=/\[/rs=s+1 end=/]/ contains=@javascriptValue,@javascriptSymbols nextgroup=@javascriptAfterIdentifier skipwhite skipempty
" Value for object, statement for label statement
syntax cluster javascriptTemplates contains=javascriptTemplate,javascriptTemplateSubstitution,javascriptTemplateSBlock,javascriptTemplateSString,javascriptTemplateSStringRB,javascriptTemplateSB
syntax cluster javascriptStrings contains=javascriptProp,javascriptString,@javascriptTemplates,@javascriptComments,javascriptDocComment,javascriptRegexpString,javascriptPropertyName
"this
"JavaScript Prototype
syntax keyword javascriptPrototype prototype
"Program Keywords
syntax keyword javascriptIdentifier arguments this nextgroup=@javascriptAfterIdentifier
syntax keyword javascriptVariable let var const
syntax keyword javascriptOperator delete new instanceof typeof void in nextgroup=@javascriptValue,@javascriptTypes skipwhite skipempty
syntax keyword javascriptForOperator contained in of
syntax keyword javascriptBoolean true false nextgroup=@javascriptSymbols skipwhite skipempty
syntax keyword javascriptNull null undefined nextgroup=@javascriptSymbols skipwhite skipempty
syntax keyword javascriptMessage alert confirm prompt status
syntax keyword javascriptGlobal self top parent
"Statement Keywords
syntax keyword javascriptConditional if else switch
syntax keyword javascriptConditionalElse else
syntax keyword javascriptRepeat do while for nextgroup=javascriptLoopParen skipwhite skipempty
syntax keyword javascriptBranch break continue
syntax keyword javascriptCase case nextgroup=@javascriptTypes skipwhite
syntax keyword javascriptDefault default
syntax keyword javascriptStatementKeyword return with yield
syntax keyword javascriptReturn return nextgroup=@javascriptValue skipwhite
syntax keyword javascriptYield yield
syntax keyword javascriptTry try
syntax keyword javascriptExceptions catch throw finally
syntax keyword javascriptDebugger debugger
syntax match javascriptProp contained /[a-zA-Z_$][a-zA-Z0-9_$]*/ contains=@props,@_semantic transparent nextgroup=@javascriptAfterIdentifier
syntax match javascriptMethod contained /[a-zA-Z_$][a-zA-Z0-9_$]*\ze(/ contains=@props transparent nextgroup=javascriptFuncCallArg
syntax match javascriptDotNotation /\./ nextgroup=javascriptProp,javascriptMethod
syntax match javascriptDotStyleNotation /\.style\./ nextgroup=javascriptDOMStyle transparent
runtime syntax/yajs/javascript.vim
runtime syntax/yajs/es6-number.vim
runtime syntax/yajs/es6-string.vim
runtime syntax/yajs/es6-array.vim
runtime syntax/yajs/es6-object.vim
runtime syntax/yajs/es6-symbol.vim
runtime syntax/yajs/es6-function.vim
runtime syntax/yajs/es6-math.vim
runtime syntax/yajs/es6-date.vim
runtime syntax/yajs/es6-json.vim
runtime syntax/yajs/es6-regexp.vim
runtime syntax/yajs/es6-map.vim
runtime syntax/yajs/es6-set.vim
runtime syntax/yajs/es6-proxy.vim
runtime syntax/yajs/es6-promise.vim
runtime syntax/yajs/node.vim
runtime syntax/yajs/web.vim
let javascript_props = 1
runtime syntax/yajs/event.vim
syntax region javascriptEventString contained start=/\z(["']\)/ skip=/\\\\\|\\\z1\|\\\n/ end=/\z1\|$/ contains=javascriptASCII,@events
"Import
syntax region javascriptImportDef start=/import/ end=/;\|\n/ contains=javascriptImport,javascriptString,javascriptEndColons
syntax keyword javascriptImport contained from as import
syntax keyword javascriptExport export module
syntax region javascriptBlock matchgroup=javascriptBraces start=/\([\^:]\s\*\)\=\zs{/ end=/}/ contains=@htmlJavaScript
syntax region javascriptMethodDef contained start=/\(\(\(set\|get\)\_s\+\)\?\)[a-zA-Z_$]\k*\_s*(/ end=/)/ contains=javascriptMethodAccessor,javascriptMethodName,javascriptFuncArg nextgroup=javascriptBlock skipwhite keepend
syntax region javascriptMethodArgs contained start=/(/ end=/)/ contains=javascriptFuncArg,@javascriptComments nextgroup=javascriptBlock skipwhite keepend
syntax match javascriptMethodName contained /[a-zA-Z_$]\k*/ nextgroup=javascriptMethodArgs skipwhite skipempty
syntax match javascriptMethodAccessor contained /\(set\|get\)\s\+\ze\k/ contains=javascriptMethodAccessorWords
syntax keyword javascriptMethodAccessorWords contained get set
syntax region javascriptMethodName contained matchgroup=javascriptPropertyName start=/\[/ end=/]/ contains=@javascriptValue nextgroup=javascriptMethodArgs skipwhite skipempty
syntax keyword javascriptAsyncFuncKeyword async await
" syntax keyword javascriptFuncKeyword function nextgroup=javascriptFuncName,javascriptFuncArg skipwhite
syntax keyword javascriptFuncKeyword function nextgroup=javascriptAsyncFunc,javascriptSyncFunc
syntax match javascriptSyncFunc contained // nextgroup=javascriptFuncName,javascriptFuncArg skipwhite skipempty
syntax match javascriptAsyncFunc contained /\s*\*\s*/ nextgroup=javascriptFuncName,javascriptFuncArg skipwhite skipempty
syntax match javascriptFuncName contained /[a-zA-Z_$]\k*/ nextgroup=javascriptFuncArg skipwhite
syntax match javascriptFuncArg contained /(\_[^()]*)/ contains=javascriptParens,javascriptFuncKeyword,javascriptFuncComma nextgroup=javascriptBlock skipwhite skipwhite skipempty
syntax match javascriptFuncComma contained /,/
"Class
syntax keyword javascriptClassKeyword class nextgroup=javascriptClassName skipwhite
syntax keyword javascriptClassSuper super
syntax match javascriptClassName contained /\k\+/ nextgroup=javascriptClassBlock,javascriptClassExtends skipwhite
syntax match javascriptClassSuperName contained /[a-zA-Z_$][a-zA-Z_$\[\]\.]*/ nextgroup=javascriptClassBlock skipwhite
syntax keyword javascriptClassExtends contained extends nextgroup=javascriptClassSuperName skipwhite
syntax region javascriptClassBlock contained matchgroup=javascriptBraces start=/{/ end=/}/ contains=javascriptMethodName,javascriptMethodAccessor,javascriptClassStatic,@javascriptComments
syntax keyword javascriptClassStatic contained static nextgroup=javascriptMethodName,javascriptMethodAccessor skipwhite
syntax keyword javascriptForComprehension contained for nextgroup=javascriptForComprehensionTail skipwhite skipempty
syntax region javascriptForComprehensionTail contained matchgroup=javascriptParens start=/(/ end=/)/ contains=javascriptOfComprehension,@javascriptExpression nextgroup=javascriptForComprehension,javascriptIfComprehension,@javascriptExpression skipwhite skipempty
syntax keyword javascriptOfComprehension contained of
syntax keyword javascriptIfComprehension contained if nextgroup=javascriptIfComprehensionTail
syntax region javascriptIfComprehensionTail contained matchgroup=javascriptParens start=/(/ end=/)/ contains=javascriptExpression nextgroup=javascriptForComprehension,javascriptIfComprehension skipwhite skipempty
syntax region javascriptObjectLiteral contained matchgroup=javascriptBraces start=/{/ end=/}/ contains=@javascriptComments,javascriptObjectLabel,javascriptPropertyName,javascriptMethodDef,javascriptComputedPropertyName,@javascriptValue
" syntax match javascriptBraces /[\[\]]/
syntax match javascriptParens /[()]/
" syntax match javascriptOpSymbols /[^+\-*/%\^=!<>&|?]\@<=\(<\|>\|<=\|>=\|==\|!=\|===\|!==\|+\|-\|*\|%\|++\|--\|<<\|>>\|>>>\|&\||\|^\|!\|\~\|&&\|||\|?\|=\|+=\|-=\|*=\|%=\|<<=\|>>=\|>>>=\|&=\||=\|^=\|\/\|\/=\)\ze\_[^+\-*/%\^=!<>&|?]/ nextgroup=@javascriptExpression skipwhite
" syntax match javascriptInvalidOp contained /[+\-*/%\^=!<>&|?:]\+/
syntax match javascriptOpSymbol contained /\(<\|>\|<=\|>=\|==\|!=\|===\|!==\|+\|*\|%\|++\|--\|<<\|>>\|>>>\|&\||\|^\|!\|\~\|&&\|||\|?\|=\|+=\|-=\|*=\|%=\|<<=\|>>=\|>>>=\|&=\||=\|^=\|\/\|\/=\)\ze\_[^+\-*/%\^=!<>&|?:]/ nextgroup=javascriptInvalidOp skipwhite skipempty
syn region htmlScriptTag contained start=+<script+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
syntax match javascriptWOpSymbols contained /\_s\+/ nextgroup=javascriptOpSymbols
syntax match javascriptEndColons /[;,]/
syntax match javascriptLogicSymbols /[^&|]\@<=\(&&\|||\)\ze\_[^&|]/ nextgroup=@javascriptExpression skipwhite skipempty
syntax cluster javascriptSymbols contains=javascriptOpSymbols,javascriptLogicSymbols
syntax match javascriptWSymbols contained /\_s\+/ nextgroup=@javascriptSymbols
syntax region javascriptRegexpString start="\(^\|&\||\|=\|(\|{\|;\|:\|\[\|!\)\@<=\_s*/[^/*]"me=e-1 skip="\\\\\|[^\\]\@<=\\/" end="/[gimy]\{0,2\}" oneline
syntax cluster javascriptEventTypes contains=javascriptEventString,javascriptTemplate,javascriptNumber,javascriptBoolean,javascriptNull
syntax cluster javascriptOps contains=javascriptOpSymbols,javascriptLogicSymbols,javascriptOperator
syntax region javascriptParenExp matchgroup=javascriptParens start=/(/ end=/)/ contains=@javascriptExpression nextgroup=@javascriptSymbols skipwhite skipempty
syntax cluster javascriptExpression contains=javascriptArrowFuncDef,javascriptParenExp,@javascriptValue,javascriptObjectLiteral,javascriptFuncKeyword,javascriptYield,javascriptIdentifierName,javascriptRegexpString,@javascriptTypes,@javascriptOps,javascriptGlobal,jsxRegion
syntax cluster javascriptEventExpression contains=javascriptArrowFuncDef,javascriptParenExp,@javascriptValue,javascriptObjectLiteral,javascriptFuncKeyword,javascriptIdentifierName,javascriptRegexpString,@javascriptEventTypes,@javascriptOps,javascriptGlobal,jsxRegion
syntax region javascriptLoopParen contained matchgroup=javascriptParens start=/(/ end=/)/ contains=javascriptVariable,javascriptForOperator,javascriptEndColons,@javascriptExpression nextgroup=javascriptBlock skipwhite skipempty
" syntax match javascriptFuncCall contained /[a-zA-Z]\k*\ze(/ nextgroup=javascriptFuncCallArg
syntax region javascriptFuncCallArg contained matchgroup=javascriptParens start=/(/ end=/)/ contains=@javascriptExpression,@javascriptComments nextgroup=@javascriptAfterIdentifier
syntax cluster javascriptSymbols contains=javascriptOpSymbols,javascriptLogicSymbols
syntax match javascriptWSymbols contained /\_s\+/ nextgroup=@javascriptSymbols
syntax region javascriptEventFuncCallArg contained matchgroup=javascriptParens start=/(/ end=/)/ contains=@javascriptEventExpression,@javascriptComments
syntax match javascriptArrowFuncDef contained /([^)]*)\_s*=>/ contains=javascriptFuncArg,javascriptArrowFunc nextgroup=javascriptBlock skipwhite skipempty
syntax match javascriptArrowFuncDef contained /[a-zA-Z_$][a-zA-Z0-9_$]*\_s*=>/ contains=javascriptArrowFuncArg,javascriptArrowFunc nextgroup=javascriptBlock skipwhite skipempty
syntax match javascriptArrowFunc /=>/
syntax match javascriptArrowFuncArg contained /[a-zA-Z_$]\k*/
runtime syntax/semhl.vim
if exists("did_javascript_hilink")
HiLink javascriptEndColons Exception
HiLink javascriptOpSymbols Normal
HiLink javascriptLogicSymbols Boolean
HiLink javascriptBraces Function
HiLink javascriptParens Normal
HiLink javascriptComment Comment
HiLink javascriptLineComment Comment
HiLink javascriptDocComment Comment
HiLink javascriptCommentTodo Todo
HiLink javascriptDocNotation SpecialComment
HiLink javascriptDocTags SpecialComment
HiLink javascriptDocNGParam javascriptDocParam
HiLink javascriptDocParam Function
HiLink javascriptDocNumParam Function
HiLink javascriptDocEventRef Function
HiLink javascriptDocNamedParamType Type
HiLink javascriptDocParamName Type
HiLink javascriptDocParamType Type
HiLink javascriptString String
HiLink javascriptTemplate String
HiLink javascriptEventString String
HiLink javascriptASCII Label
HiLink javascriptTemplateSubstitution Label
" HiLink javascriptTemplateSBlock Label
" HiLink javascriptTemplateSString Label
HiLink javascriptTemplateSStringRB javascriptTemplateSubstitution
HiLink javascriptTemplateSB javascriptTemplateSubstitution
HiLink javascriptRegexpString String
HiLink javascriptGlobal Constant
HiLink javascriptCharacter Character
HiLink javascriptPrototype Type
HiLink javascriptConditional Conditional
HiLink javascriptConditionalElse Conditional
HiLink javascriptCase Conditional
HiLink javascriptDefault javascriptCase
HiLink javascriptBranch Conditional
HiLink javascriptIdentifier Structure
HiLink javascriptVariable Identifier
HiLink javascriptRepeat Repeat
HiLink javascriptForComprehension Repeat
HiLink javascriptIfComprehension Repeat
HiLink javascriptOfComprehension Repeat
HiLink javascriptForOperator Repeat
HiLink javascriptStatementKeyword Statement
HiLink javascriptReturn Statement
HiLink javascriptYield Statement
HiLink javascriptMessage Keyword
HiLink javascriptOperator Identifier
" HiLink javascriptType Type
HiLink javascriptNull Boolean
HiLink javascriptNumber Number
HiLink javascriptBoolean Boolean
HiLink javascriptObjectLabel javascriptLabel
HiLink javascriptLabel Label
HiLink javascriptPropertyName Label
HiLink javascriptImport Special
HiLink javascriptExport Special
HiLink javascriptTry Special
HiLink javascriptExceptions Special
HiLink javascriptMethodName Function
HiLink javascriptMethodAccessor Operator
HiLink javascriptAsyncFuncKeyword Keyword
HiLink javascriptFuncKeyword Keyword
HiLink javascriptAsyncFunc Keyword
HiLink javascriptArrowFunc Type
HiLink javascriptFuncName Function
HiLink javascriptFuncArg Special
HiLink javascriptArrowFuncArg javascriptFuncArg
HiLink javascriptFuncComma Operator
HiLink javascriptClassKeyword Keyword
HiLink javascriptClassExtends Keyword
HiLink javascriptClassName Function
HiLink javascriptClassSuperName Function
HiLink javascriptClassStatic StorageClass
HiLink javascriptClassSuper keyword
HiLink shellbang Comment
highlight link javaScript NONE
delcommand HiLink delcommand HiLink
unlet did_javascript_hilink
endif endif
" Define the htmlJavaScript for HTML syntax html.vim
syntax cluster htmlJavaScript contains=@jsAll,jsBracket,jsParen,jsBlock
syntax cluster javaScriptExpression contains=@jsAll,jsBracket,jsParen,jsBlock,@htmlPreproc
" Vim's default html.vim highlights all javascript as 'Special'
hi! def link javaScript NONE
let b:current_syntax = "javascript" let b:current_syntax = "javascript"
if main_syntax == 'javascript' if main_syntax == 'javascript'
unlet main_syntax unlet main_syntax
endif endif
endif endif

View File

@@ -1,139 +0,0 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jinja') == -1
" Vim syntax file
" Language: Jinja template
" Maintainer: Armin Ronacher <armin.ronacher@active-4.com>
" Last Change: 2008 May 9
" Version: 1.1
"
" Known Bugs:
" because of odd limitations dicts and the modulo operator
" appear wrong in the template.
"
" Changes:
"
" 2008 May 9: Added support for Jinja2 changes (new keyword rules)
" .vimrc variable to disable html highlighting
if !exists('g:jinja_syntax_html')
let g:jinja_syntax_html=1
endif
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'jinja'
endif
" Pull in the HTML syntax.
if g:jinja_syntax_html
if version < 600
so <sfile>:p:h/html.vim
else
runtime! syntax/html.vim
unlet b:current_syntax
endif
endif
syntax case match
" Jinja template built-in tags and parameters (without filter, macro, is and raw, they
" have special threatment)
syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained and if else in not or recursive as import
syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained is filter skipwhite nextgroup=jinjaFilter
syn keyword jinjaStatement containedin=jinjaTagBlock contained macro skipwhite nextgroup=jinjaFunction
syn keyword jinjaStatement containedin=jinjaTagBlock contained block skipwhite nextgroup=jinjaBlockName
" Variable Names
syn match jinjaVariable containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[a-zA-Z_][a-zA-Z0-9_]*/
syn keyword jinjaSpecial containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained false true none False True None loop super caller varargs kwargs
" Filters
syn match jinjaOperator "|" containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained skipwhite nextgroup=jinjaFilter
syn match jinjaFilter contained /[a-zA-Z_][a-zA-Z0-9_]*/
syn match jinjaFunction contained /[a-zA-Z_][a-zA-Z0-9_]*/
syn match jinjaBlockName contained /[a-zA-Z_][a-zA-Z0-9_]*/
" Jinja template constants
syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/"/ skip=/\(\\\)\@<!\(\(\\\\\)\@>\)*\\"/ end=/"/
syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/'/ skip=/\(\\\)\@<!\(\(\\\\\)\@>\)*\\'/ end=/'/
syn match jinjaNumber containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[0-9]\+\(\.[0-9]\+\)\?/
" Operators
syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[+\-*\/<>=!,:]/
syn match jinjaPunctuation containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[()\[\]]/
syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /\./ nextgroup=jinjaAttribute
syn match jinjaAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/
" Jinja template tag and variable blocks
syn region jinjaNested matchgroup=jinjaOperator start="(" end=")" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained
syn region jinjaNested matchgroup=jinjaOperator start="\[" end="\]" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained
syn region jinjaNested matchgroup=jinjaOperator start="{" end="}" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained
syn region jinjaTagBlock matchgroup=jinjaTagDelim start=/{%-\?/ end=/-\?%}/ containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment
syn region jinjaVarBlock matchgroup=jinjaVarDelim start=/{{-\?/ end=/-\?}}/ containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment
" Jinja template 'raw' tag
syn region jinjaRaw matchgroup=jinjaRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString,jinjaComment
" Jinja comments
syn region jinjaComment matchgroup=jinjaCommentDelim start="{#" end="#}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString
" Block start keywords. A bit tricker. We only highlight at the start of a
" tag block and only if the name is not followed by a comma or equals sign
" which usually means that we have to deal with an assignment.
syn match jinjaStatement containedin=jinjaTagBlock contained /\({%-\?\s*\)\@<=\<[a-zA-Z_][a-zA-Z0-9_]*\>\(\s*[,=]\)\@!/
" and context modifiers
syn match jinjaStatement containedin=jinjaTagBlock contained /\<with\(out\)\?\s\+context\>/
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_jinja_syn_inits")
if version < 508
let did_jinja_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink jinjaPunctuation jinjaOperator
HiLink jinjaAttribute jinjaVariable
HiLink jinjaFunction jinjaFilter
HiLink jinjaTagDelim jinjaTagBlock
HiLink jinjaVarDelim jinjaVarBlock
HiLink jinjaCommentDelim jinjaComment
HiLink jinjaRawDelim jinja
HiLink jinjaSpecial Special
HiLink jinjaOperator Normal
HiLink jinjaRaw Normal
HiLink jinjaTagBlock PreProc
HiLink jinjaVarBlock PreProc
HiLink jinjaStatement Statement
HiLink jinjaFilter Function
HiLink jinjaBlockName Function
HiLink jinjaVariable Identifier
HiLink jinjaString Constant
HiLink jinjaNumber Constant
HiLink jinjaComment Comment
delcommand HiLink
endif
let b:current_syntax = "jinja"
if main_syntax == 'jinja'
unlet main_syntax
endif
endif

View File

@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'kotlin') == -1
" Vim syntax file " Vim syntax file
" Language: Kotlin " Language: Kotlin
" Maintainer: Alexander Udalov " Maintainer: Alexander Udalov
" Latest Revision: 23 December 2015 " Latest Revision: 24 February 2016
if exists("b:current_syntax") if exists("b:current_syntax")
finish finish
@@ -32,7 +32,8 @@ syn keyword ktConstant null
syn keyword ktModifier data tailrec lateinit reified external inline noinline crossinline const operator infix syn keyword ktModifier data tailrec lateinit reified external inline noinline crossinline const operator infix
syn keyword ktTodo TODO FIXME XXX contained syn keyword ktTodo TODO FIXME XXX contained
syn match ktLineComment "//.*$" contains=ktTodo,@Spell syn match ktShebang "\v^#!.*$"
syn match ktLineComment "\v//.*$" contains=ktTodo,@Spell
syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contains=ktComment,ktTodo,@Spell syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contains=ktComment,ktTodo,@Spell
syn match ktSpecialCharError "\v\\." contained syn match ktSpecialCharError "\v\\." contained
@@ -81,6 +82,7 @@ hi link ktBoolean Boolean
hi link ktConstant Constant hi link ktConstant Constant
hi link ktTodo Todo hi link ktTodo Todo
hi link ktShebang Comment
hi link ktLineComment Comment hi link ktLineComment Comment
hi link ktComment Comment hi link ktComment Comment
hi link ktCommentMatchGroup Comment hi link ktCommentMatchGroup Comment

View File

@@ -20,14 +20,20 @@ unlet! b:current_syntax
if !exists('g:markdown_fenced_languages') if !exists('g:markdown_fenced_languages')
let g:markdown_fenced_languages = [] let g:markdown_fenced_languages = []
endif endif
let s:done_include = {}
for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")') for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")')
if has_key(s:done_include, matchstr(s:type,'[^.]*'))
continue
endif
if s:type =~ '\.' if s:type =~ '\.'
let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*')
endif endif
exe 'syn include @markdownHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim' exe 'syn include @markdownHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim'
unlet! b:current_syntax unlet! b:current_syntax
let s:done_include[matchstr(s:type,'[^.]*')] = 1
endfor endfor
unlet! s:type unlet! s:type
unlet! s:done_include
syn sync minlines=10 syn sync minlines=10
syn case ignore syn case ignore
@@ -93,10 +99,16 @@ syn match markdownFootnote "\[^[^\]]\+\]"
syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:" syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:"
if main_syntax ==# 'markdown' if main_syntax ==# 'markdown'
let s:done_include = {}
for s:type in g:markdown_fenced_languages for s:type in g:markdown_fenced_languages
if has_key(s:done_include, matchstr(s:type,'[^.]*'))
continue
endif
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```*\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```*\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```*\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```*\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
let s:done_include[matchstr(s:type,'[^.]*')] = 1
endfor endfor
unlet! s:type unlet! s:type
unlet! s:done_include
endif endif
syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]" syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]"

View File

@@ -59,6 +59,7 @@ syn keyword ngxDirectiveError post_action
syn keyword ngxDirectiveDeprecated connections syn keyword ngxDirectiveDeprecated connections
syn keyword ngxDirectiveDeprecated imap syn keyword ngxDirectiveDeprecated imap
syn keyword ngxDirectiveDeprecated limit_zone syn keyword ngxDirectiveDeprecated limit_zone
syn keyword ngxDirectiveDeprecated mysql_test
syn keyword ngxDirectiveDeprecated open_file_cache_retest syn keyword ngxDirectiveDeprecated open_file_cache_retest
syn keyword ngxDirectiveDeprecated optimize_server_names syn keyword ngxDirectiveDeprecated optimize_server_names
syn keyword ngxDirectiveDeprecated satisfy_any syn keyword ngxDirectiveDeprecated satisfy_any
@@ -248,7 +249,6 @@ syn keyword ngxDirective mp4_max_buffer_size
syn keyword ngxDirective msie_padding syn keyword ngxDirective msie_padding
syn keyword ngxDirective msie_refresh syn keyword ngxDirective msie_refresh
syn keyword ngxDirective multi_accept syn keyword ngxDirective multi_accept
syn keyword ngxDirective mysql_test
syn keyword ngxDirective open_file_cache syn keyword ngxDirective open_file_cache
syn keyword ngxDirective open_file_cache_errors syn keyword ngxDirective open_file_cache_errors
syn keyword ngxDirective open_file_cache_events syn keyword ngxDirective open_file_cache_events
@@ -606,7 +606,7 @@ syn keyword ngxDirectiveThirdParty echo_subrequest
syn keyword ngxDirectiveThirdParty echo_subrequest_async syn keyword ngxDirectiveThirdParty echo_subrequest_async
" Events Module <http://docs.dutov.org/nginx_modules_events_en.html> " Events Module <http://docs.dutov.org/nginx_modules_events_en.html>
" Privides options for start/stop events. " Provides options for start/stop events.
syn keyword ngxDirectiveThirdParty on_start syn keyword ngxDirectiveThirdParty on_start
syn keyword ngxDirectiveThirdParty on_stop syn keyword ngxDirectiveThirdParty on_stop

192
syntax/nim.vim Normal file
View File

@@ -0,0 +1,192 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Keep user-supplied options
if !exists("nim_highlight_numbers")
let nim_highlight_numbers = 1
endif
if !exists("nim_highlight_builtins")
let nim_highlight_builtins = 1
endif
if !exists("nim_highlight_exceptions")
let nim_highlight_exceptions = 1
endif
if !exists("nim_highlight_space_errors")
let nim_highlight_space_errors = 1
endif
if exists("nim_highlight_all")
let nim_highlight_numbers = 1
let nim_highlight_builtins = 1
let nim_highlight_exceptions = 1
let nim_highlight_space_errors = 1
endif
syn region nimBrackets contained extend keepend matchgroup=Bold start=+\(\\\)\@<!\[+ end=+]\|$+ skip=+\\\s*$\|\(\\\)\@<!\\]+ contains=@tclCommandCluster
syn keyword nimKeyword addr and as asm atomic
syn keyword nimKeyword bind block break
syn keyword nimKeyword case cast const continue converter
syn keyword nimKeyword discard distinct div do
syn keyword nimKeyword elif else end enum except export
syn keyword nimKeyword finally for from
syn keyword nimKeyword generic
syn keyword nimKeyword if import in include interface is isnot iterator
syn keyword nimKeyword lambda let
syn keyword nimKeyword mixin using mod
syn keyword nimKeyword nil not notin
syn keyword nimKeyword object of or out
syn keyword nimKeyword proc method macro template nextgroup=nimFunction skipwhite
syn keyword nimKeyword ptr
syn keyword nimKeyword raise ref return
syn keyword nimKeyword shared shl shr static
syn keyword nimKeyword try tuple type
syn keyword nimKeyword var
syn keyword nimKeyword when while with without
syn keyword nimKeyword xor
syn keyword nimKeyword yield
syn match nimFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn match nimClass "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn keyword nimRepeat for while
syn keyword nimConditional if elif else case of
syn keyword nimOperator and in is not or xor shl shr div
syn match nimComment "#.*$" contains=nimTodo,@Spell
syn keyword nimTodo TODO FIXME XXX contained
syn keyword nimBoolean true false
" Strings
syn region nimString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=nimEscape,nimEscapeError,@Spell
syn region nimString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=nimEscape,nimEscapeError,@Spell
syn region nimString start=+"""+ end=+"""+ keepend contains=nimEscape,nimEscapeError,@Spell
syn region nimRawString matchgroup=Normal start=+[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell
syn match nimEscape +\\[abfnrtv'"\\]+ contained
syn match nimEscape "\\\o\{1,3}" contained
syn match nimEscape "\\x\x\{2}" contained
syn match nimEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
syn match nimEscape "\\$"
syn match nimEscapeError "\\x\x\=\X" display contained
if nim_highlight_numbers == 1
" numbers (including longs and complex)
syn match nimNumber "\v<0x\x+(\'(i|I|f|F|u|U)(8|16|32|64))?>"
syn match nimNumber "\v<[0-9_]+(\'(i|I|f|F|u|U)(8|16|32|64))?>"
syn match nimNumber "\v[0-9]\.[0-9_]+([eE][+-]=[0-9_]+)=>"
syn match nimNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>"
endif
if nim_highlight_builtins == 1
" builtin functions, types and objects, not really part of the syntax
syn keyword nimBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool
syn keyword nimBuiltin char string cstring pointer range array openarray seq
syn keyword nimBuiltin set Byte Natural Positive TObject PObject Conversion TResult TAddress
syn keyword nimBuiltin BiggestInt BiggestFloat cchar cschar cshort cint csize cuchar cushort
syn keyword nimBuiltin clong clonglong cfloat cdouble clongdouble cuint culong culonglong cchar
syn keyword nimBuiltin cstringArray TEndian PFloat32 PFloat64 PInt64 PInt32
syn keyword nimBuiltin TGC_Strategy TFile TFileMode TFileHandle isMainModule
syn keyword nimBuiltin CompileDate CompileTime nimVersion nimMajor
syn keyword nimBuiltin nimMinor nimPatch cpuEndian hostOS hostCPU inf
syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbgLineHook stdin
syn keyword nimBuiltin stdout stderr defined new high low sizeof succ pred
syn keyword nimBuiltin inc dec newSeq len incl excl card ord chr ze ze64
syn keyword nimBuiltin toU8 toU16 toU32 abs min max add repr
syn match nimBuiltin "\<contains\>"
syn keyword nimBuiltin toFloat toBiggestFloat toInt toBiggestInt addQuitProc
syn keyword nimBuiltin copy setLen newString zeroMem copyMem moveMem
syn keyword nimBuiltin equalMem alloc alloc0 realloc dealloc setLen assert
syn keyword nimBuiltin swap getRefcount getCurrentException Msg
syn keyword nimBuiltin getOccupiedMem getFreeMem getTotalMem isNil seqToPtr
syn keyword nimBuiltin find pop GC_disable GC_enable GC_fullCollect
syn keyword nimBuiltin GC_setStrategy GC_enableMarkAnd Sweep
syn keyword nimBuiltin GC_disableMarkAnd Sweep GC_getStatistics GC_ref
syn keyword nimBuiltin GC_ref GC_ref GC_unref GC_unref GC_unref quit
syn keyword nimBuiltin OpenFile OpenFile CloseFile EndOfFile readChar
syn keyword nimBuiltin FlushFile readFile write readLine writeln writeln
syn keyword nimBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes
syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos
syn keyword nimBuiltin fileHandle countdown countup items lines
endif
if nim_highlight_exceptions == 1
" builtin exceptions and warnings
syn keyword nimException E_Base EAsynch ESynch ESystem EIO EOS
syn keyword nimException ERessourceExhausted EArithmetic EDivByZero
syn keyword nimException EOverflow EAccessViolation EAssertionFailed
syn keyword nimException EControlC EInvalidValue EOutOfMemory EInvalidIndex
syn keyword nimException EInvalidField EOutOfRange EStackOverflow
syn keyword nimException ENoExceptionToReraise EInvalidObjectAssignment
syn keyword nimException EInvalidObject EInvalidLibrary EInvalidKey
syn keyword nimException EInvalidObjectConversion EFloatingPoint
syn keyword nimException EFloatInvalidOp EFloatDivByZero EFloatOverflow
syn keyword nimException EFloatInexact EDeadThread EResourceExhausted
syn keyword nimException EFloatUnderflow
endif
if nim_highlight_space_errors == 1
" trailing whitespace
syn match nimSpaceError display excludenl "\S\s\+$"ms=s+1
" any tabs are illegal in nim
syn match nimSpaceError display "\t"
endif
syn sync match nimSync grouphere NONE "):$"
syn sync maxlines=200
syn sync minlines=2000
if version >= 508 || !exists("did_nim_syn_inits")
if version <= 508
let did_nim_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
" The default methods for highlighting. Can be overridden later
HiLink nimBrackets Operator
HiLink nimKeyword Keyword
HiLink nimFunction Function
HiLink nimConditional Conditional
HiLink nimRepeat Repeat
HiLink nimString String
HiLink nimRawString String
HiLink nimBoolean Boolean
HiLink nimEscape Special
HiLink nimOperator Operator
HiLink nimPreCondit PreCondit
HiLink nimComment Comment
HiLink nimTodo Todo
HiLink nimDecorator Define
if nim_highlight_numbers == 1
HiLink nimNumber Number
endif
if nim_highlight_builtins == 1
HiLink nimBuiltin Number
endif
if nim_highlight_exceptions == 1
HiLink nimException Exception
endif
if nim_highlight_space_errors == 1
HiLink nimSpaceError Error
endif
delcommand HiLink
endif
let b:current_syntax = "nim"
endif

View File

@@ -315,16 +315,16 @@ syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*{+ end=+}+ contains=@perlInterpSQ,perlBracesSQ keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qw\s*<+ end=+>+ contains=@perlInterpSQ,perlAnglesSQ keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\>\s*\z([^[:space:]#([{<'/]\)+ end=+\z1[imosx]*+ contains=@perlInterpMatch keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\>\s*\z([^[:space:]#([{<'/]\)+ end=+\z1[imosxdual]*+ contains=@perlInterpMatch keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*/+ end=+/[imosx]*+ contains=@perlInterpSlash keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*/+ end=+/[imosxdual]*+ contains=@perlInterpSlash keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr#+ end=+#[imosx]*+ contains=@perlInterpMatch keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr#+ end=+#[imosxdual]*+ contains=@perlInterpMatch keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*'+ end=+'[imosx]*+ contains=@perlInterpSQ keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*'+ end=+'[imosxdual]*+ contains=@perlInterpSQ keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*(+ end=+)[imosx]*+ contains=@perlInterpMatch,perlParensDQ keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*(+ end=+)[imosxdual]*+ contains=@perlInterpMatch,perlParensDQ keepend extend
" A special case for qr{}, qr<> and qr[] which allows for comments and extra whitespace in the pattern " A special case for qr{}, qr<> and qr[] which allows for comments and extra whitespace in the pattern
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*{+ end=+}[imosx]*+ contains=@perlInterpMatch,perlBracesDQ,perlComment keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*{+ end=+}[imosxdual]*+ contains=@perlInterpMatch,perlBracesDQ,perlComment keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*<+ end=+>[imosx]*+ contains=@perlInterpMatch,perlAnglesDQ,perlComment keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*<+ end=+>[imosxdual]*+ contains=@perlInterpMatch,perlAnglesDQ,perlComment keepend extend
syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*\[+ end=+\][imosx]*+ contains=@perlInterpMatch,perlBracketsDQ,perlComment keepend extend syn region perlQQ matchgroup=perlStringStartEnd start=+\<\%(::\|'\|->\)\@<!qr\s*\[+ end=+\][imosxdual]*+ contains=@perlInterpMatch,perlBracketsDQ,perlComment keepend extend
" Constructs such as print <<EOF [...] EOF, 'here' documents " Constructs such as print <<EOF [...] EOF, 'here' documents
" "

View File

@@ -87,8 +87,8 @@ let s:keywords = {
\ "for loop repeat while until gather given", \ "for loop repeat while until gather given",
\ ], \ ],
\ "p6FlowControl": [ \ "p6FlowControl": [
\ "take do when next last redo return contend maybe defer start", \ "take do when next last redo return return-rw contend maybe defer",
\ "default exit make continue break goto leave async lift", \ "start default exit make continue break goto leave async lift",
\ ], \ ],
\ "p6ClosureTrait": [ \ "p6ClosureTrait": [
\ "BEGIN CHECK INIT START FIRST ENTER LEAVE KEEP", \ "BEGIN CHECK INIT START FIRST ENTER LEAVE KEEP",
@@ -118,7 +118,7 @@ let s:types = [
\ "Object Any Junction Whatever Capture Match", \ "Object Any Junction Whatever Capture Match",
\ "Signature Proxy Matcher Package Module Class", \ "Signature Proxy Matcher Package Module Class",
\ "Grammar Scalar Array Hash KeyHash KeySet KeyBag", \ "Grammar Scalar Array Hash KeyHash KeySet KeyBag",
\ "Pair List Seq Range Set Bag Mapping Void Undef", \ "Pair List Seq Range Set Bag Map Mapping Void Undef",
\ "Failure Exception Code Block Routine Sub Macro", \ "Failure Exception Code Block Routine Sub Macro",
\ "Method Submethod Regex Str Blob Char Byte Parcel", \ "Method Submethod Regex Str Blob Char Byte Parcel",
\ "Codepoint Grapheme StrPos StrLen Version Num", \ "Codepoint Grapheme StrPos StrLen Version Num",
@@ -1951,7 +1951,7 @@ endif
if exists("perl6_fold") || exists("perl6_extended_all") if exists("perl6_fold") || exists("perl6_extended_all")
setl foldmethod=syntax setl foldmethod=syntax
syn region p6BlockFold syn region p6BlockFold
\ start="^\z(\s*\)\%(my\|our\|augment\|multi\|proto\|only\)\?\s*\%(\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\s\+\)\?\<\%(CATCH\|try\|ENTER\|LEAVE\|CHECK\|INIT\|BEGIN\|END\|KEEP\|UNDO\|PRE\|POST\|module\|package\|enum\|subset\|class\|sub\%(method\)\?\|multi\|method\|slang\|grammar\|regex\|token\|rule\)\>[^{]\+{\%(\s+\|#.*\)\?$" \ start="^\z(\s*\)\%(my\|our\|augment\|multi\|proto\|only\)\?\s*\%(\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\s\+\)\?\<\%(CATCH\|try\|ENTER\|LEAVE\|CHECK\|INIT\|BEGIN\|END\|KEEP\|UNDO\|PRE\|POST\|module\|package\|enum\|subset\|class\|sub\%(method\)\?\|multi\|method\|slang\|grammar\|regex\|token\|rule\)\>[^{]\+\%({\s*\%(#.*\)\?\)\?$"
\ end="^\z1}" \ end="^\z1}"
\ transparent fold keepend extend \ transparent fold keepend extend
endif endif

2284
syntax/pgsql.vim Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -539,6 +539,8 @@ syn match phpMemberSelector "->\|::" contained display
syn match phpVarSelector "\$" contained display syn match phpVarSelector "\$" contained display
" highlight static and object variables inside strings " highlight static and object variables inside strings
syn match phpMethodsVar "\%(->\|::$\?\)\h\w*" contained contains=phpMethods,phpMemberSelector,phpIdentifier display containedin=phpStringDouble syn match phpMethodsVar "\%(->\|::$\?\)\h\w*" contained contains=phpMethods,phpMemberSelector,phpIdentifier display containedin=phpStringDouble
syn match phpMethodsVar "\%(->\|::\%($\)\@!\)\s*\h\w*\s*("me=e-1 skipwhite skipempty contained contains=phpMemberSelector,phpMethod display containedin=phpStringDouble
syn match phpMethod /\h\w*/
syn match phpSplatOperator "\.\.\." contained display syn match phpSplatOperator "\.\.\." contained display
" Identifier " Identifier
@@ -597,7 +599,7 @@ syn match phpCommentStar contained "^\s*\*$"
if !exists("php_ignore_phpdoc") || !php_ignore_phpdoc if !exists("php_ignore_phpdoc") || !php_ignore_phpdoc
syn case ignore syn case ignore
SynFoldDoc syn region phpDocComment start="/\*\*" end="\*/" keepend contains=phpCommentTitle,phpDocTags,phpTodo,@Spell SynFoldDoc syn region phpDocComment start="/\*\*" end="\*/" keepend contains=phpCommentTitle,phpDocTags,phpTodo,@Spell extend
syn region phpCommentTitle contained matchgroup=phpDocComment start="/\*\*" matchgroup=phpCommentTitle keepend end="\.$" end="\.[ \t\r<&]"me=e-1 end="[^{]@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=phpCommentStar,phpTodo,phpDocTags,@Spell containedin=phpDocComment syn region phpCommentTitle contained matchgroup=phpDocComment start="/\*\*" matchgroup=phpCommentTitle keepend end="\.$" end="\.[ \t\r<&]"me=e-1 end="[^{]@"me=s-2,he=s-1 end="\*/"me=s-1,he=s-1 contains=phpCommentStar,phpTodo,phpDocTags,@Spell containedin=phpDocComment
syn region phpDocTags start="{@\(example\|id\|internal\|inheritdoc\|link\|source\|toc\|tutorial\)" end="}" containedin=phpDocComment syn region phpDocTags start="{@\(example\|id\|internal\|inheritdoc\|link\|source\|toc\|tutorial\)" end="}" containedin=phpDocComment
@@ -849,7 +851,7 @@ let b:current_syntax = "php"
let &iskeyword = s:iskeyword_save let &iskeyword = s:iskeyword_save
unlet s:iskeyword_save unlet s:iskeyword_save
if main_syntax == 'php' if (exists("main_syntax") && main_syntax == 'php')
unlet main_syntax unlet main_syntax
endif endif

173
syntax/plantuml.vim Normal file
View File

@@ -0,0 +1,173 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'plantuml') == -1
" Vim syntax file
" Language: PlantUML
" Maintainer: Anders Thøgersen <first name at bladre dot dk>
" Last Change: 03-Apr-2011
" Version: 0.2
" TODO: There are some bugs, add << >>
"
if exists("b:current_syntax")
finish
endif
if version < 600
syntax clear
endif
let s:cpo_orig=&cpo
set cpo&vim
let b:current_syntax = "plantuml"
syntax sync minlines=100
syntax match plantumlPreProc /\%(^@startuml\|^@enduml\)\|!\%(include\|ifdef\|define\|endif\)\s*.*/ contains=plantumlDir
syntax region plantumlDir start=/\s\+/ms=s+1 end=/$/ contained
syntax keyword plantumlTypeKeyword namespace component package interface class interface enum object participant activity skinparam abstract
syntax keyword plantumlKeyword actor boundary control entity database partition title activate as deactivate note left right top bottom of end destroy
syntax keyword plantumlKeyword if then else endif
syntax keyword plantumlCommentTODO XXX TODO FIXME NOTE contained
syntax match plantumlColor /#[0-9A-Fa-f]\{6\}\>/
" Arrows - Differentiate between horizontal and vertical arrows
syntax match plantumlHorizontalArrow /\%([-\.]\%(|>\|>\|\*\|o\>\|\\\\\|\\\|\/\/\|\/\|\.\|-\)\|\%(<|\|<\|\*\|\<o\|\\\\\|\\\|\/\/\|\/\)[\.-]\)\%(\[[^\]]*\]\)\?/ contains=plantumlLabel
syntax match plantumlDirectedOrVerticalArrowLR /[-\.]\%(le\?f\?t\?\|ri\?g\?h\?t\?\|up\?\|\do\?w\?n\?\)\?[-\.]\%(|>\|>>\|>\|\*\|o\>\|\\\\\|\\\|\/\/\|\/\|\.\|-\)\%(\[[^\]]*\]\)\?/ contains=plantumlLabel
syntax match plantumlDirectedOrVerticalArrowRL /\%(<|\|<<\|<\|\*\|\<o\|\\\\\|\\\|\/\/\|\/\)[-\.]\%(le\?f\?t\?\|ri\?g\?h\?t\?\|up\?\|\do\?w\?n\?\)\?[-\.]\%(\[[^\]]*\]\)\?/ contains=plantumlLabel
syntax region plantumlLabel start=/\[/ms=s+1 end=/\]/me=s-1 contained contains=plantumlText
syntax match plantumlText /\%([0-9A-Za-zÀ-ÿ]\|\s\|[\.,;_-]\)\+/ contained
" Class
syntax region plantumlClass start=/{/ end=/\s*}/ contains=plantumlClassArrows,
\ plantumlKeyword,
\ @plantumlClassOp
syntax match plantumlClassPublic /+\w\+/ contained
syntax match plantumlClassPrivate /-\w\+/ contained
syntax match plantumlClassProtected /#\w\+/ contained
syntax match plantumlClassPackPrivate /\~\w\+/ contained
syntax cluster plantumlClassOp contains=plantumlClassPublic,
\ plantumlClassPrivate,
\ plantumlClassProtected,
\ plantumlClassProtected,
\ plantumlClassPackPrivate
" Strings
syntax match plantumlSpecialString /\\n/ contained
syntax region plantumlString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=plantumlSpecialString
syntax region plantumlString start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=plantumlSpecialString
syntax match plantumlComment /'[^']*$/ contains=plantumlCommentTODO
syntax region plantumlMultilineComment start=/\/'/ end=/'\// contains=plantumlCommentTODO
" Labels with a colon
syntax match plantumlColonLine /:[^:]\+$/ contains=plantumlText
" Activity diagram
syntax match plantumlActivityThing /([^)]*)/
syntax match plantumlActivitySynch /===[^=]\+===/
" Skinparam keywords
syntax keyword plantumlSkinparamKeyword activityArrowColor activityArrowFontColor activityArrowFontName
syntax keyword plantumlSkinparamKeyword activityArrowFontSize activityArrowFontStyle activityBackgroundColor
syntax keyword plantumlSkinparamKeyword activityBarColor activityBorderColor activityEndColor activityFontColor
syntax keyword plantumlSkinparamKeyword activityFontName activityFontSize activityFontStyle activityStartColor
syntax keyword plantumlSkinparamKeyword backgroundColor circledCharacterFontColor circledCharacterFontName
syntax keyword plantumlSkinparamKeyword circledCharacterFontSize circledCharacterFontStyle circledCharacterRadius
syntax keyword plantumlSkinparamKeyword classArrowColor classArrowFontColor classArrowFontName classArrowFontSize
syntax keyword plantumlSkinparamKeyword classArrowFontStyle classAttributeFontColor classAttributeFontName
syntax keyword plantumlSkinparamKeyword classAttributeFontSize classAttributeFontStyle classAttributeIconSize
syntax keyword plantumlSkinparamKeyword classBackgroundColor classBorderColor classFontColor classFontName
syntax keyword plantumlSkinparamKeyword classFontSize classFontStyle classStereotypeFontColor classStereotypeFontName
syntax keyword plantumlSkinparamKeyword classStereotypeFontSize classStereotypeFontStyle componentArrowColor
syntax keyword plantumlSkinparamKeyword componentArrowFontColor componentArrowFontName componentArrowFontSize
syntax keyword plantumlSkinparamKeyword componentArrowFontStyle componentBackgroundColor componentBorderColor
syntax keyword plantumlSkinparamKeyword componentFontColor componentFontName componentFontSize componentFontStyle
syntax keyword plantumlSkinparamKeyword componentInterfaceBackgroundColor componentInterfaceBorderColor
syntax keyword plantumlSkinparamKeyword componentStereotypeFontColor componentStereotypeFontName
syntax keyword plantumlSkinparamKeyword componentStereotypeFontSize componentStereotypeFontStyle footerFontColor
syntax keyword plantumlSkinparamKeyword footerFontName footerFontSize footerFontStyle headerFontColor headerFontName
syntax keyword plantumlSkinparamKeyword headerFontSize headerFontStyle noteBackgroundColor noteBorderColor
syntax keyword plantumlSkinparamKeyword noteFontColor noteFontName noteFontSize noteFontStyle packageBackgroundColor
syntax keyword plantumlSkinparamKeyword packageBorderColor packageFontColor packageFontName packageFontSize
syntax keyword plantumlSkinparamKeyword packageFontStyle sequenceActorBackgroundColor sequenceActorBorderColor
syntax keyword plantumlSkinparamKeyword sequenceActorFontColor sequenceActorFontName sequenceActorFontSize
syntax keyword plantumlSkinparamKeyword sequenceActorFontStyle sequenceArrowColor sequenceArrowFontColor
syntax keyword plantumlSkinparamKeyword sequenceArrowFontName sequenceArrowFontSize sequenceArrowFontStyle
syntax keyword plantumlSkinparamKeyword sequenceDividerBackgroundColor sequenceDividerFontColor sequenceDividerFontName
syntax keyword plantumlSkinparamKeyword sequenceDividerFontSize sequenceDividerFontStyle sequenceGroupBackgroundColor
syntax keyword plantumlSkinparamKeyword sequenceGroupingFontColor sequenceGroupingFontName sequenceGroupingFontSize
syntax keyword plantumlSkinparamKeyword sequenceGroupingFontStyle sequenceGroupingHeaderFontColor
syntax keyword plantumlSkinparamKeyword sequenceGroupingHeaderFontName sequenceGroupingHeaderFontSize
syntax keyword plantumlSkinparamKeyword sequenceGroupingHeaderFontStyle sequenceLifeLineBackgroundColor
syntax keyword plantumlSkinparamKeyword sequenceLifeLineBorderColor sequenceParticipantBackgroundColor
syntax keyword plantumlSkinparamKeyword sequenceParticipantBorderColor sequenceParticipantFontColor
syntax keyword plantumlSkinparamKeyword sequenceParticipantFontName sequenceParticipantFontSize
syntax keyword plantumlSkinparamKeyword sequenceParticipantFontStyle sequenceTitleFontColor sequenceTitleFontName
syntax keyword plantumlSkinparamKeyword sequenceTitleFontSize sequenceTitleFontStyle stateArrowColor
syntax keyword plantumlSkinparamKeyword stateArrowFontColor stateArrowFontName stateArrowFontSize stateArrowFontStyle
syntax keyword plantumlSkinparamKeyword stateAttributeFontColor stateAttributeFontName stateAttributeFontSize
syntax keyword plantumlSkinparamKeyword stateAttributeFontStyle stateBackgroundColor stateBorderColor stateEndColor
syntax keyword plantumlSkinparamKeyword stateFontColor stateFontName stateFontSize stateFontStyle stateStartColor
syntax keyword plantumlSkinparamKeyword stereotypeABackgroundColor stereotypeCBackgroundColor
syntax keyword plantumlSkinparamKeyword stereotypeEBackgroundColor stereotypeIBackgroundColor titleFontColor
syntax keyword plantumlSkinparamKeyword titleFontName titleFontSize titleFontStyle usecaseActorBackgroundColor
syntax keyword plantumlSkinparamKeyword usecaseActorBorderColor usecaseActorFontColor usecaseActorFontName
syntax keyword plantumlSkinparamKeyword usecaseActorFontSize usecaseActorFontStyle usecaseActorStereotypeFontColor
syntax keyword plantumlSkinparamKeyword usecaseActorStereotypeFontName usecaseActorStereotypeFontSize
syntax keyword plantumlSkinparamKeyword usecaseActorStereotypeFontStyle usecaseArrowColor usecaseArrowFontColor
syntax keyword plantumlSkinparamKeyword usecaseArrowFontName usecaseArrowFontSize usecaseArrowFontStyle
syntax keyword plantumlSkinparamKeyword usecaseBackgroundColor usecaseBorderColor usecaseFontColor usecaseFontName
syntax keyword plantumlSkinparamKeyword usecaseFontSize usecaseFontStyle usecaseStereotypeFontColor
syntax keyword plantumlSkinparamKeyword usecaseStereotypeFontName usecaseStereotypeFontSize usecaseStereotypeFontStyle
syntax keyword plantumlSkinparamKeyword ActorBackgroundColor ActorBorderColor ActorFontColor ActorFontName
syntax keyword plantumlSkinparamKeyword ActorFontSize ActorFontStyle ActorStereotypeFontColor ActorStereotypeFontName
syntax keyword plantumlSkinparamKeyword ActorStereotypeFontSize ActorStereotypeFontStyle ArrowColor ArrowFontColor
syntax keyword plantumlSkinparamKeyword ArrowFontName ArrowFontSize ArrowFontStyle AttributeFontColor AttributeFontName
syntax keyword plantumlSkinparamKeyword AttributeFontSize AttributeFontStyle AttributeIconSize BackgroundColor BarColor
syntax keyword plantumlSkinparamKeyword BorderColor CharacterFontColor CharacterFontName CharacterFontSize
syntax keyword plantumlSkinparamKeyword CharacterFontStyle CharacterRadius Color DividerBackgroundColor
syntax keyword plantumlSkinparamKeyword DividerFontColor DividerFontName DividerFontSize DividerFontStyle EndColor
syntax keyword plantumlSkinparamKeyword FontColor FontName FontSize FontStyle GroupBackgroundColor GroupingFontColor
syntax keyword plantumlSkinparamKeyword GroupingFontName GroupingFontSize GroupingFontStyle GroupingHeaderFontColor
syntax keyword plantumlSkinparamKeyword GroupingHeaderFontName GroupingHeaderFontSize GroupingHeaderFontStyle
syntax keyword plantumlSkinparamKeyword InterfaceBackgroundColor InterfaceBorderColor LifeLineBackgroundColor
syntax keyword plantumlSkinparamKeyword LifeLineBorderColor ParticipantBackgroundColor ParticipantBorderColor
syntax keyword plantumlSkinparamKeyword ParticipantFontColor ParticipantFontName ParticipantFontSize
syntax keyword plantumlSkinparamKeyword ParticipantFontStyle StartColor stateArrowColor stereotypeABackgroundColor
syntax keyword plantumlSkinparamKeyword stereotypeCBackgroundColor stereotypeEBackgroundColor StereotypeFontColor
syntax keyword plantumlSkinparamKeyword StereotypeFontName StereotypeFontSize StereotypeFontStyle
syntax keyword plantumlSkinparamKeyword stereotypeIBackgroundColor TitleFontColor TitleFontName TitleFontSize TitleFontStyle
" Highlight
highlight default link plantumlCommentTODO Todo
highlight default link plantumlKeyword Keyword
highlight default link plantumlTypeKeyword Type
highlight default link plantumlPreProc PreProc
highlight default link plantumlDir Constant
highlight default link plantumlColor Constant
highlight default link plantumlHorizontalArrow Identifier
highlight default link plantumlDirectedOrVerticalArrowLR Special
highlight default link plantumlDirectedOrVerticalArrowRL Special
highlight default link plantumlLabel Special
highlight default link plantumlText Label
highlight default link plantumlClassPublic Structure
highlight default link plantumlClassPrivate Macro
highlight default link plantumlClassProtected Statement
highlight default link plantumlClassPackPrivate Function
highlight default link plantumlSpecialString Special
highlight default link plantumlString String
highlight default link plantumlComment Comment
highlight default link plantumlMultilineComment Comment
highlight default link plantumlColonLine Comment
highlight default link plantumlActivityThing Type
highlight default link plantumlActivitySynch Type
highlight default link plantumlSkinparamKeyword Identifier
let &cpo=s:cpo_orig
unlet s:cpo_orig
endif

View File

@@ -59,7 +59,7 @@ syn keyword pbSyntax syntax import option
syn keyword pbStructure package message group oneof syn keyword pbStructure package message group oneof
syn keyword pbRepeat optional required repeated syn keyword pbRepeat optional required repeated
syn keyword pbDefault default syn keyword pbDefault default
syn keyword pbExtend extend extensions to max syn keyword pbExtend extend extensions to max reserved
syn keyword pbRPC service rpc returns syn keyword pbRPC service rpc returns
syn keyword pbType int32 int64 uint32 uint64 sint32 sint64 syn keyword pbType int32 int64 uint32 uint64 sint32 sint64

108
syntax/pug.vim Normal file
View File

@@ -0,0 +1,108 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'pug') == -1
" Vim syntax file
" Language: Pug
" Maintainer: Joshua Borton
" Credits: Tim Pope
" Filenames: *.pug
if exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = 'pug'
endif
silent! syntax include @htmlCoffeescript syntax/coffee.vim
unlet! b:current_syntax
silent! syntax include @htmlStylus syntax/stylus.vim
unlet! b:current_syntax
silent! syntax include @htmlCss syntax/css.vim
unlet! b:current_syntax
silent! syntax include @htmlMarkdown syntax/markdown.vim
unlet! b:current_syntax
syn case match
syn region javascriptParenthesisBlock start="(" end=")" contains=@htmlJavascript contained keepend
syn cluster htmlJavascript add=javascriptParenthesisBlock
syn region pugJavascript matchgroup=pugJavascriptOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
syn region pugJavascript matchgroup=pugJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
syn cluster pugTop contains=pugBegin,pugComment,pugHtmlComment,pugJavascript
syn match pugBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=pugTag,pugClassChar,pugIdChar,pugPlainChar,pugJavascript,pugScriptConditional,pugScriptStatement,pugPipedText
syn match pugTag "+\?\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@pugComponent
syn cluster pugComponent contains=pugAttributes,pugIdChar,pugBlockExpansionChar,pugClassChar,pugPlainChar,pugJavascript,pugTagBlockChar,pugTagInlineText
syn match pugComment '\s*\/\/.*$'
syn region pugCommentBlock start="\z(\s*\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" keepend
syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->"
syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,pugHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent
syn match pugClassChar "\." contained nextgroup=pugClass
syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar
syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId
syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent
syn match pugId "\%(\w\|-\)\+" contained nextgroup=@pugComponent
syn region pugDocType start="^\s*\(!!!\|doctype\)" end="$"
" Unless I'm mistaken, syntax/html.vim requires
" that the = sign be present for these matches.
" This adds the matches back for pug.
syn keyword pugHtmlArg contained href title
syn match pugPlainChar "\\" contained
syn region pugInterpolation matchgroup=pugInterpolationDelimiter start="[#!]{" end="}" contains=@htmlJavascript
syn match pugInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
syn match pugTagInlineText "\s.*$" contained contains=pugInterpolation,pugTextInlinePug
syn region pugPipedText matchgroup=pugPipeChar start="|" end="$" contained contains=pugInterpolation,pugTextInlinePug nextgroup=pugPipedText skipnl
syn match pugTagBlockChar "\.$" contained nextgroup=pugTagBlockText,pugTagBlockEnd skipnl
syn region pugTagBlockText start="\%(\s*\)\S" end="\ze\n" contained contains=pugInterpolation,pugTextInlinePug nextgroup=pugTagBlockText,pugTagBlockEnd skipnl
syn region pugTagBlockEnd start="\s*\S" end="$" contained contains=pugInterpolation,pugTextInlinePug nextgroup=pugBegin skipnl
syn region pugTextInlinePug matchgroup=pugInlineDelimiter start="#\[" end="]" contains=pugTag keepend
syn region pugJavascriptFilter matchgroup=pugFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript
syn region pugMarkdownFilter matchgroup=pugFilter start=/^\z(\s*\):\%(markdown\|marked\)\s*$/ end=/^\%(\z1\s\|\s*$\)\@!/ contains=@htmlMarkdown
syn region pugStylusFilter matchgroup=pugFilter start="^\z(\s*\):stylus\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlStylus
syn region pugPlainFilter matchgroup=pugFilter start="^\z(\s*\):\%(sass\|less\|cdata\)\s*$" end="^\%(\z1\s\|\s*$\)\@!"
syn match pugScriptConditional "^\s*\<\%(if\|else\|else if\|elif\|unless\|while\|until\|case\|when\|default\)\>[?!]\@!"
syn match pugScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!"
syn region pugScriptLoopRegion start="^\s*\(for \)" end="$" contains=pugScriptLoopKeywords
syn keyword pugScriptLoopKeywords for in contained
syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend
syn region pugCoffeescriptFilter matchgroup=pugFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained
syn region pugJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=pugBegin,pugTag
syn region pugCssBlock start="^\z(\s*\)style" nextgroup=@pugComponent,pugError end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCss keepend
syn match pugError "\$" contained
hi def link pugPlainChar Special
hi def link pugScriptConditional PreProc
hi def link pugScriptLoopKeywords PreProc
hi def link pugScriptStatement PreProc
hi def link pugHtmlArg htmlArg
hi def link pugAttributeString String
hi def link pugAttributesDelimiter Identifier
hi def link pugIdChar Special
hi def link pugClassChar Special
hi def link pugBlockExpansionChar Special
hi def link pugPipeChar Special
hi def link pugTagBlockChar Special
hi def link pugId Identifier
hi def link pugClass Type
hi def link pugInterpolationDelimiter Delimiter
hi def link pugInlineDelimiter Delimiter
hi def link pugFilter PreProc
hi def link pugDocType PreProc
hi def link pugComment Comment
hi def link pugCommentBlock Comment
hi def link pugHtmlConditionalComment pugComment
let b:current_syntax = "pug"
if main_syntax == "pug"
unlet main_syntax
endif
endif

View File

@@ -18,16 +18,17 @@ elseif exists("b:current_syntax")
finish finish
endif endif
" match class/definition/node declarations " match class/definition/node declarations/application
syn region puppetDefine start="^\s*\(class\|define\|node\)\s" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments,puppetNodeRe,@NoSpell syn region puppetDefine start="^\s*\(class\|define\|node\|application\)\s" end="{" contains=puppetDefType,puppetDefName,puppetDefArguments,puppetNodeRe,@NoSpell
syn keyword puppetDefType class define node inherits contained syn keyword puppetDefType class define node inherits application contained
syn region puppetDefArguments start="(" end=")" contained contains=puppetArgument,puppetString,puppetComment,puppetMultilineComment syn region puppetDefArguments start="(" end=")" contained contains=puppetArgument,puppetString,puppetComment,puppetMultilineComment,puppetDataTypes
syn match puppetArgument "\w\+" contained syn match puppetArgument "\w\+" contained
syn match puppetArgument "\$\w\+" contained syn match puppetArgument "\$\w\+" contained
syn match puppetArgument "'[^']+'" contained syn match puppetArgument "'[^']+'" contained
syn match puppetArgument '"[^"]+"' contained syn match puppetArgument '"[^"]+"' contained
syn match puppetDefName "\w\+" contained syn match puppetDefName "\w\+" contained
syn match puppetNodeRe "/.*/" contained syn match puppetNodeRe "/.*/" contained
syn keyword puppetDataTypes String Integer Float Numeric Boolean Array Hash Regexp Undef Default Resource Class Scalar Collection Variant Data Pattern Enum Tuple Struct Optional Catalogentry Type Any Callable
" match 'foo' in 'class foo { ...' " match 'foo' in 'class foo { ...'
" match 'foo::bar' in 'class foo::bar { ...' " match 'foo::bar' in 'class foo::bar { ...'
@@ -42,7 +43,7 @@ syn match puppetTypeDefault "[A-Z]\w*" contained
syn match puppetParam "\w\+\s*\(=\|+\)>" contains=puppetTypeRArrow,puppetParamName syn match puppetParam "\w\+\s*\(=\|+\)>" contains=puppetTypeRArrow,puppetParamName
syn match puppetParamRArrow "\(=\|+\)>" contained syn match puppetParamRArrow "\(=\|+\)>" contained
syn match puppetParamName "\w\+" contained contains=@NoSpell syn match puppetParamName "\w\+" contained contains=@NoSpell
syn match puppetVariable "$\(\(\(::\)\?\w\+\)\+\|{\(\(::\)\?\w\+\)\+}\)" syn match puppetVariable "$\(\(::\)\?\w\+\|{\(::\)\?\w\+}\)"
syn match puppetParen "(" syn match puppetParen "("
syn match puppetParen ")" syn match puppetParen ")"
syn match puppetBrace "{" syn match puppetBrace "{"
@@ -57,7 +58,7 @@ syn match puppetBrack "|>"
" don't match 'bar' in 'foo => bar' " don't match 'bar' in 'foo => bar'
syn match puppetParam "\w\+\s*[=+]>\s*[a-z0-9]\+" contains=puppetParamString,puppetParamName syn match puppetParam "\w\+\s*[=+]>\s*[a-z0-9]\+" contains=puppetParamString,puppetParamName
syn match puppetParamString "[=+]>\s*\w\+" contains=puppetParamKeyword,puppetParamSpecial,puppetParamDigits contained syn match puppetParamString "[=+]>\s*\w\+" contains=puppetParamKeyword,puppetParamSpecial,puppetParamDigits contained
syn keyword puppetParamKeyword present absent purged latest installed running stopped mounted unmounted role configured file directory link contained syn keyword puppetParamKeyword present absent purged latest installed running stopped mounted unmounted role configured file directory link on_failure contained
syn keyword puppetParamSpecial true false undef contained syn keyword puppetParamSpecial true false undef contained
syn match puppetParamDigits "[0-9]\+" syn match puppetParamDigits "[0-9]\+"
@@ -78,8 +79,8 @@ syn region puppetString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pupp
syn match puppetNotVariable "\\$\w\+" contained syn match puppetNotVariable "\\$\w\+" contained
syn match puppetNotVariable "\\${\w\+}" contained syn match puppetNotVariable "\\${\w\+}" contained
syn keyword puppetKeyword import inherits include require contains syn keyword puppetKeyword import inherits include require contain produces
syn keyword puppetControl case default if else elsif syn keyword puppetControl case default if else elsif unless
syn keyword puppetSpecial true false undef syn keyword puppetSpecial true false undef
syn match puppetClass "[A-Za-z0-9_-]\+\(::[A-Za-z0-9_-]\+\)\+" contains=@NoSpell syn match puppetClass "[A-Za-z0-9_-]\+\(::[A-Za-z0-9_-]\+\)\+" contains=@NoSpell

56
syntax/purescript.vim Normal file
View File

@@ -0,0 +1,56 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'purescript') == -1
" syntax highlighting for purescript
"
" Heavily modified version of the purescript syntax
" highlighter to support purescript.
"
" author: raichoo (raichoo@googlemail.com)
if exists("b:current_syntax")
finish
endif
syn keyword purescriptModule module
syn keyword purescriptImport foreign import hiding
syn region purescriptQualifiedImport start="\<qualified\>" contains=purescriptType,purescriptDot end="\<as\>"
syn keyword purescriptStructure data newtype type class instance derive where
syn keyword purescriptStatement forall do case of let in
syn keyword purescriptConditional if then else
syn match purescriptNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
syn match purescriptFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
syn match purescriptDelimiter "[(),;[\]{}]"
syn keyword purescriptInfix infix infixl infixr
syn match purescriptOperators "\([-!#$%&\*\+/<=>\?@\\^|~:]\|\<_\>\)"
syn match purescriptDot "\."
syn match purescriptType "\<\([A-Z][a-zA-Z0-9_]*\|_|_\)\>"
syn match purescriptLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$"
syn match purescriptChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
syn match purescriptBacktick "`[A-Za-z][A-Za-z0-9_]*`"
syn region purescriptString start=+"+ skip=+\\\\\|\\"+ end=+"+
syn region purescriptMultilineString start=+"""+ end=+"""+
syn region purescriptBlockComment start="{-" end="-}" contains=purescriptBlockComment
highlight def link purescriptImport Structure
highlight def link purescriptQualifiedImport Structure
highlight def link purescriptModule Structure
highlight def link purescriptStructure Structure
highlight def link purescriptStatement Statement
highlight def link purescriptConditional Conditional
highlight def link purescriptNumber Number
highlight def link purescriptFloat Float
highlight def link purescriptDelimiter Delimiter
highlight def link purescriptInfix PreProc
highlight def link purescriptOperators Operator
highlight def link purescriptDot Operator
highlight def link purescriptType Include
highlight def link purescriptLineComment Comment
highlight def link purescriptBlockComment Comment
highlight def link purescriptString String
highlight def link purescriptMultilineString String
highlight def link purescriptChar String
highlight def link purescriptBacktick Operator
let b:current_syntax = "purescript"
endif

View File

@@ -179,20 +179,20 @@ syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I\[" end="\]" s
syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold syn region rubySymbol matchgroup=rubySymbolDelimiter start="%I(" end=")" skip="\\\\\|\\)" contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape fold
" Here Document " Here Document
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-"\z([^"]*\)"\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]"\z([^"]*\)"\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-'\z([^']*\)'\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart fold keepend
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+3 matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend
if exists('main_syntax') && main_syntax == 'eruby' if exists('main_syntax') && main_syntax == 'eruby'
let b:ruby_no_expensive = 1 let b:ruby_no_expensive = 1

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