mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17ad302c54 | ||
|
|
1541356fe1 | ||
|
|
f3556c1eca | ||
|
|
4855e5ee82 | ||
|
|
bb85059bac | ||
|
|
11f53253ad | ||
|
|
9fe009095a | ||
|
|
dce9e8dec5 | ||
|
|
30c87b73de | ||
|
|
1713d35f06 | ||
|
|
5ddfa1ac28 | ||
|
|
dbe9bc927f | ||
|
|
d219055bc8 | ||
|
|
0e9041f29a | ||
|
|
a0b8a6e77f | ||
|
|
a61ab44810 | ||
|
|
dd4b5cbdd6 | ||
|
|
27903c5b86 | ||
|
|
d5e38fa97b | ||
|
|
7673a61990 | ||
|
|
6a12aa87f4 | ||
|
|
5b77877888 | ||
|
|
8148255ef1 | ||
|
|
40ddf334c9 | ||
|
|
7e10428cd6 | ||
|
|
6a4fe34e61 | ||
|
|
4cd5566b40 | ||
|
|
8b3418cab8 | ||
|
|
9bfde7574a | ||
|
|
8eab5f5403 |
32
README.md
32
README.md
@@ -8,13 +8,13 @@ A collection of language packs for Vim.
|
||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||
|
||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||
- It **installs and updates 100+ times faster** than 100+ packages it consist of.
|
||||
- Solid syntax and indentation support. Only the best language packs.
|
||||
- It **installs and updates 100+ times faster** than 100+ packages it consists of.
|
||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
||||
- Each build is tested by automated vimrunner script on CI. See `spec` directory.
|
||||
|
||||
\*To be completely honest, concatenated `ftdetect` script takes around `3ms` to load.
|
||||
\*To be completely honest, concatenated `ftdetect` script takes up to `17ms` to load.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -41,31 +41,34 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [applescript](https://github.com/vim-scripts/applescript.vim) (syntax)
|
||||
- [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent)
|
||||
- [asciidoc](https://github.com/asciidoc/vim-asciidoc) (syntax)
|
||||
- [autohotkey](https://github.com/hnamikaw/vim-autohotkey) (indent)
|
||||
- [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftplugin)
|
||||
- [c++11](https://github.com/octol/vim-cpp-enhanced-highlight) (syntax)
|
||||
- [c/c++](https://github.com/vim-jp/vim-cpp) (syntax)
|
||||
- [caddyfile](https://github.com/joshglendenning/vim-caddyfile) (syntax, indent, ftplugin)
|
||||
- [caddyfile](https://github.com/isobit/vim-caddyfile) (syntax, indent, ftplugin)
|
||||
- [carp](https://github.com/hellerve/carp-vim) (syntax)
|
||||
- [cjsx](https://github.com/mtscout6/vim-cjsx) (syntax, ftplugin)
|
||||
- [clojure](https://github.com/guns/vim-clojure-static) (syntax, indent, autoload, ftplugin)
|
||||
- [cmake](https://github.com/pboettch/vim-cmake-syntax) (syntax, indent)
|
||||
- [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin)
|
||||
- [cql](https://github.com/elubow/cql-vim) (syntax)
|
||||
- [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim) (syntax, compiler, ftplugin)
|
||||
- [crystal](https://github.com/rhysd/vim-crystal) (syntax, indent, autoload, ftplugin)
|
||||
- [css](https://github.com/JulesWang/css.vim) (syntax)
|
||||
- [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin)
|
||||
- [dart](https://github.com/dart-lang/dart-vim-plugin) (syntax, indent, autoload, ftplugin)
|
||||
- [dockerfile](https://github.com/docker/docker) (syntax)
|
||||
- [elixir](https://github.com/elixir-lang/vim-elixir) (syntax, indent, compiler, autoload, ftplugin)
|
||||
- [elm](https://github.com/lambdatoast/elm.vim) (syntax, indent, autoload, ftplugin)
|
||||
- [elm](https://github.com/ElmCast/elm-vim) (syntax, indent, autoload, ftplugin)
|
||||
- [emberscript](https://github.com/yalesov/vim-ember-script) (syntax, indent, ftplugin)
|
||||
- [emblem](https://github.com/yalesov/vim-emblem) (syntax, indent, ftplugin)
|
||||
- [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent)
|
||||
- [fish](https://github.com/dag/vim-fish) (syntax, indent, compiler, autoload, ftplugin)
|
||||
- [fsharp](https://github.com/fsharp/vim-fsharp) (syntax, indent)
|
||||
- [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin)
|
||||
- [glsl](https://github.com/tikhomirov/vim-glsl) (syntax, indent)
|
||||
- [gmpl](https://github.com/maelvalais/gmpl.vim) (syntax)
|
||||
- [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) (syntax)
|
||||
- [go](https://github.com/fatih/vim-go) (syntax, compiler, indent)
|
||||
- [graphql](https://github.com/jparise/vim-graphql) (syntax, ftplugin)
|
||||
- [groovy](https://github.com/vim-scripts/groovy.vim) (syntax)
|
||||
- [haml](https://github.com/sheerun/vim-haml) (syntax, indent, compiler, ftplugin)
|
||||
- [handlebars](https://github.com/mustache/vim-mustache-handlebars) (syntax, indent, ftplugin)
|
||||
@@ -75,10 +78,12 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [i3](https://github.com/PotatoesMaster/i3-vim-syntax) (syntax, ftplugin)
|
||||
- [jasmine](https://github.com/glanotte/vim-jasmine) (syntax)
|
||||
- [javascript](https://github.com/pangloss/vim-javascript) (syntax, indent, compiler, ftplugin, extras)
|
||||
- [jenkins](https://github.com/martinda/Jenkinsfile-vim-syntax) (syntax, indent)
|
||||
- [json5](https://github.com/GutenYe/json5.vim) (syntax)
|
||||
- [json](https://github.com/elzr/vim-json) (syntax, indent, ftplugin)
|
||||
- [jst](https://github.com/briancollins/vim-jst) (syntax, indent)
|
||||
- [jsx](https://github.com/mxw/vim-jsx) (after)
|
||||
- [julia](https://github.com/dcjones/julia-minimalist-vim) (syntax, indent)
|
||||
- [julia](https://github.com/JuliaEditorSupport/julia-vim) (syntax, indent, autoload, ftplugin)
|
||||
- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent)
|
||||
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin)
|
||||
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
|
||||
@@ -90,7 +95,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [mathematica](https://github.com/rsmenon/vim-mathematica) (syntax, ftplugin)
|
||||
- [nginx](https://github.com/chr4/nginx.vim) (syntax, indent, ftplugin)
|
||||
- [nim](https://github.com/zah/nim.vim) (syntax, compiler, indent)
|
||||
- [nix](https://github.com/spwhitt/vim-nix) (syntax, ftplugin)
|
||||
- [nix](https://github.com/LnL7/vim-nix) (syntax, indent, ftplugin)
|
||||
- [objc](https://github.com/b4winckler/vim-objc) (ftplugin, syntax, indent)
|
||||
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
|
||||
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
|
||||
@@ -103,9 +108,10 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [protobuf](https://github.com/uarun/vim-protobuf) (syntax, indent)
|
||||
- [pug](https://github.com/digitaltoad/vim-pug) (syntax, indent, ftplugin)
|
||||
- [puppet](https://github.com/voxpupuli/vim-puppet) (syntax, indent, ftplugin)
|
||||
- [purescript](https://github.com/raichoo/purescript-vim) (syntax, indent, ftplugin)
|
||||
- [purescript](https://github.com/purescript-contrib/purescript-vim) (syntax, indent, ftplugin)
|
||||
- [python-compiler](https://github.com/aliev/vim-compiler-python) (compiler, autoload)
|
||||
- [python](https://github.com/mitsuhiko/vim-python-combined) (syntax, indent)
|
||||
- [python-ident](https://github.com/Vimjas/vim-python-pep8-indent) (indent)
|
||||
- [python](https://github.com/vim-python/python-syntax) (syntax)
|
||||
- [qml](https://github.com/peterhoeg/vim-qml) (syntax, indent, ftplugin)
|
||||
- [r-lang](https://github.com/vim-scripts/R.vim) (syntax, ftplugin)
|
||||
- [racket](https://github.com/wlangstroth/vim-racket) (syntax, indent, autoload, ftplugin)
|
||||
@@ -118,7 +124,8 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [scala](https://github.com/derekwyatt/vim-scala) (syntax, indent, compiler, ftplugin)
|
||||
- [scss](https://github.com/cakebaker/scss-syntax.vim) (syntax, autoload, ftplugin)
|
||||
- [slim](https://github.com/slim-template/vim-slim) (syntax, indent, ftplugin)
|
||||
- [solidity](https://github.com/ethereum/vim-solidity) (syntax, indent)
|
||||
- [slime](https://github.com/slime-lang/vim-slime-syntax) (syntax, indent)
|
||||
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
||||
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
||||
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
||||
- [sxhkd](https://github.com/baskerville/vim-sxhkdrc) (syntax)
|
||||
@@ -134,6 +141,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [vala](https://github.com/arrufat/vala.vim) (syntax, indent)
|
||||
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)
|
||||
- [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax)
|
||||
- [vifm](https://github.com/vifm/vifm.vim) (syntax, autoload, ftplugin)
|
||||
- [vm](https://github.com/lepture/vim-velocity) (syntax, indent)
|
||||
- [vue](https://github.com/posva/vim-vue) (syntax, indent, ftplugin)
|
||||
- [xls](https://github.com/vim-scripts/XSLT-syntax) (syntax)
|
||||
|
||||
@@ -12,7 +12,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
|
||||
if exists("loaded_matchit")
|
||||
let b:match_ignorecase = 0
|
||||
let b:match_words = '(:),\[:\],{:},<:>,' .
|
||||
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
|
||||
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
|
||||
endif
|
||||
|
||||
setlocal suffixesadd+=.jsx
|
||||
|
||||
@@ -4,6 +4,14 @@ if !exists('g:terraform_align')
|
||||
let g:terraform_align = 0
|
||||
endif
|
||||
|
||||
if !exists('g:terraform_remap_spacebar')
|
||||
let g:terraform_remap_spacebar = 0
|
||||
endif
|
||||
|
||||
if !exists('g:terraform_fold_sections')
|
||||
let g:terraform_fold_sections = 0
|
||||
endif
|
||||
|
||||
if g:terraform_align && exists(':Tabularize')
|
||||
inoremap <buffer> <silent> = =<Esc>:call <SID>terraformalign()<CR>a
|
||||
function! s:terraformalign()
|
||||
@@ -18,37 +26,47 @@ if g:terraform_align && exists(':Tabularize')
|
||||
endfunction
|
||||
endif
|
||||
|
||||
if g:terraform_fold_sections
|
||||
function! TerraformFolds()
|
||||
let thisline = getline(v:lnum)
|
||||
if match(thisline, '^resource') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^provider') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^module') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^variable') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^output') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^data') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^terraform') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^locals') >= 0
|
||||
return ">1"
|
||||
else
|
||||
return "="
|
||||
endif
|
||||
endfunction
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=TerraformFolds()
|
||||
setlocal foldlevel=1
|
||||
|
||||
function! TerraformFolds()
|
||||
let thisline = getline(v:lnum)
|
||||
if match(thisline, '^resource') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^provider') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^module') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^variable') >= 0
|
||||
return ">1"
|
||||
elseif match(thisline, '^output') >= 0
|
||||
return ">1"
|
||||
else
|
||||
return "="
|
||||
endif
|
||||
endfunction
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=TerraformFolds()
|
||||
setlocal foldlevel=1
|
||||
function! TerraformFoldText()
|
||||
let foldsize = (v:foldend-v:foldstart)
|
||||
return getline(v:foldstart).' ('.foldsize.' lines)'
|
||||
endfunction
|
||||
setlocal foldtext=TerraformFoldText()
|
||||
endif
|
||||
|
||||
function! TerraformFoldText()
|
||||
let foldsize = (v:foldend-v:foldstart)
|
||||
return getline(v:foldstart).' ('.foldsize.' lines)'
|
||||
endfunction
|
||||
setlocal foldtext=TerraformFoldText()
|
||||
|
||||
"inoremap <space> <C-O>za
|
||||
nnoremap <space> za
|
||||
onoremap <space> <C-C>za
|
||||
vnoremap <space> zf
|
||||
" Re-map the space bar to fold and unfold
|
||||
if get(g:, "terraform_remap_spacebar", 1)
|
||||
"inoremap <space> <C-O>za
|
||||
nnoremap <space> za
|
||||
onoremap <space> <C-C>za
|
||||
vnoremap <space> zf
|
||||
endif
|
||||
|
||||
" Match the identation put in place by Hashicorp and :TerraformFmt, https://github.com/hashivim/vim-terraform/issues/21
|
||||
if get(g:, "terraform_align", 1)
|
||||
@@ -57,5 +75,4 @@ if get(g:, "terraform_align", 1)
|
||||
setlocal shiftwidth=2
|
||||
endif
|
||||
|
||||
|
||||
endif
|
||||
|
||||
@@ -20,9 +20,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1
|
||||
" -----------------------------------------------------------------------------
|
||||
" Highlight function names.
|
||||
" -----------------------------------------------------------------------------
|
||||
syn match cCustomParen "(" contains=cParen contains=cCppParen
|
||||
syn match cCustomFunc "\w\+\s*(\@=" contains=cCustomParen
|
||||
hi def link cCustomFunc Function
|
||||
if !exists('g:cpp_no_function_highlight')
|
||||
syn match cCustomParen "(" contains=cParen contains=cCppParen
|
||||
syn match cCustomFunc "\w\+\s*(\@=" contains=cCustomParen
|
||||
hi def link cCustomFunc Function
|
||||
endif
|
||||
|
||||
" -----------------------------------------------------------------------------
|
||||
" Highlight member variable names.
|
||||
|
||||
@@ -36,9 +36,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c++11') == -1
|
||||
" -----------------------------------------------------------------------------
|
||||
|
||||
" Functions
|
||||
syn match cCustomParen "(" contains=cParen contains=cCppParen
|
||||
syn match cCustomFunc "\w\+\s*(\@="
|
||||
hi def link cCustomFunc Function
|
||||
if !exists('g:cpp_no_function_highlight')
|
||||
syn match cCustomParen "(" contains=cParen contains=cCppParen
|
||||
syn match cCustomFunc "\w\+\s*(\@="
|
||||
hi def link cCustomFunc Function
|
||||
endif
|
||||
|
||||
" Class and namespace scope
|
||||
if exists('g:cpp_class_scope_highlight') && g:cpp_class_scope_highlight
|
||||
@@ -48,6 +50,52 @@ if exists('g:cpp_class_scope_highlight') && g:cpp_class_scope_highlight
|
||||
hi def link cCustomClass Function
|
||||
endif
|
||||
|
||||
" Clear cppStructure and replace "class" and/or "template" with matches
|
||||
" based on user configuration
|
||||
let s:needs_cppstructure_match = 0
|
||||
if exists('g:cpp_class_decl_highlight') && g:cpp_class_decl_highlight
|
||||
let s:needs_cppstructure_match += 1
|
||||
endif
|
||||
if exists('g:cpp_experimental_template_highlight') && g:cpp_experimental_template_highlight
|
||||
let s:needs_cppstructure_match += 2
|
||||
endif
|
||||
|
||||
syn clear cppStructure
|
||||
if s:needs_cppstructure_match == 0
|
||||
syn keyword cppStructure typename namespace template class
|
||||
elseif s:needs_cppstructure_match == 1
|
||||
syn keyword cppStructure typename namespace template
|
||||
elseif s:needs_cppstructure_match == 2
|
||||
syn keyword cppStructure typename namespace class
|
||||
elseif s:needs_cppstructure_match == 3
|
||||
syn keyword cppStructure typename namespace
|
||||
endif
|
||||
unlet s:needs_cppstructure_match
|
||||
|
||||
|
||||
" Class name declaration
|
||||
if exists('g:cpp_class_decl_highlight') && g:cpp_class_decl_highlight
|
||||
syn match cCustomClassKey "\<class\>"
|
||||
hi def link cCustomClassKey cppStructure
|
||||
|
||||
" Clear cppAccess entirely and redefine as matches
|
||||
syn clear cppAccess
|
||||
syn match cCustomAccessKey "\<private\>"
|
||||
syn match cCustomAccessKey "\<public\>"
|
||||
syn match cCustomAccessKey "\<protected\>"
|
||||
hi def link cCustomAccessKey cppAccess
|
||||
|
||||
" Match the parts of a class declaration
|
||||
syn match cCustomClassName "\<class\_s\+\w\+\>"
|
||||
\ contains=cCustomClassKey
|
||||
syn match cCustomClassName "\<private\_s\+\w\+\>"
|
||||
\ contains=cCustomAccessKey
|
||||
syn match cCustomClassName "\<public\_s\+\w\+\>"
|
||||
\ contains=cCustomAccessKey
|
||||
syn match cCustomClassName "\<protected\_s\+\w\+\>"
|
||||
\ contains=cCustomAccessKey
|
||||
hi def link cCustomClassName Function
|
||||
endif
|
||||
" Template functions.
|
||||
" Naive implementation that sorta works in most cases. Should correctly
|
||||
" highlight everything in test/color2.cpp
|
||||
@@ -79,17 +127,12 @@ elseif exists('g:cpp_experimental_template_highlight') && g:cpp_experimental_tem
|
||||
\ 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
|
||||
\ contains=cppStructure,cCustomTemplate,cCustomClassKey,cCustomAngleBracketStart
|
||||
|
||||
" Remove 'operator' from cppStructure and use a custom match
|
||||
" Remove 'operator' from cppOperator 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
|
||||
@@ -106,7 +149,7 @@ endif
|
||||
"hi def link cCustomFunc Function
|
||||
|
||||
" Cluster for all the stdlib functions defined below
|
||||
syn cluster cppSTLgroup contains=cppSTLfunction,cppSTLfunctional,cppSTLconstant,cppSTLnamespace,cppSTLtype,cppSTLexception,cppSTLiterator,cppSTLiterator_tagcppSTLenumcppSTLioscppSTLcast
|
||||
syn cluster cppSTLgroup contains=cppSTLfunction,cppSTLfunctional,cppSTLconstant,cppSTLnamespace,cppSTLtype,cppSTLexception,cppSTLiterator,cppSTLiterator_tag,cppSTLenum,cppSTLios,cppSTLcast
|
||||
|
||||
|
||||
" -----------------------------------------------------------------------------
|
||||
@@ -184,6 +227,7 @@ syntax keyword cppSTLfunctional binary_negate
|
||||
syntax keyword cppSTLfunctional bit_and
|
||||
syntax keyword cppSTLfunctional bit_not
|
||||
syntax keyword cppSTLfunctional bit_or
|
||||
syntax keyword cppSTLfunctional bit_xor
|
||||
syntax keyword cppSTLfunctional divides
|
||||
syntax keyword cppSTLfunctional equal_to
|
||||
syntax keyword cppSTLfunctional greater
|
||||
@@ -699,6 +743,7 @@ syntax keyword cppSTLtype slice_array
|
||||
syntax keyword cppSTLtype stack
|
||||
syntax keyword cppSTLtype stream
|
||||
syntax keyword cppSTLtype streambuf
|
||||
syntax keyword cppSTLtype streamsize
|
||||
syntax keyword cppSTLtype string
|
||||
syntax keyword cppSTLtype stringbuf
|
||||
syntax keyword cppSTLtype stringstream
|
||||
|
||||
@@ -49,7 +49,7 @@ syn region jsxChild contained start=+{+ end=++ contains=jsBlock,javascriptBlock
|
||||
" and generic Flow type annotations (http://flowtype.org/).
|
||||
syn region jsxRegion
|
||||
\ contains=@Spell,@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=+<!--\_.\{-}-->+
|
||||
\ end=+</\z1\_\s\{-}>+
|
||||
\ end=+/>+
|
||||
|
||||
@@ -26,7 +26,7 @@ syn match yamlBlock "[\[\]\{\}\|\>]"
|
||||
syn region yamlComment start="\#" end="$"
|
||||
syn match yamlIndicator "#YAML:\S\+"
|
||||
|
||||
syn region yamlString start="'" end="'" skip="\\'"
|
||||
syn region yamlString start="\%(^\| \)\zs'" end="'\ze\%( \|$\)" skip="\\'"
|
||||
syn region yamlString start='"' end='"' skip='\\"' contains=yamlEscape
|
||||
syn match yamlEscape +\\[abfnrtv'"\\]+ contained
|
||||
syn match yamlEscape "\\\o\o\=\o\=" contained
|
||||
@@ -39,7 +39,7 @@ syn keyword yamlConstant TRUE True true YES Yes yes ON On on
|
||||
syn keyword yamlConstant FALSE False false NO No no OFF Off off
|
||||
|
||||
syn match yamlKey "^\s*\zs[^ \t\"]\+\ze\s*:"
|
||||
syn match yamlKey "^\s*-\s*\zs[^ \t\"]\+\ze\s*:"
|
||||
syn match yamlKey "^\s*-\s*\zs[^ \t\"\']\+\ze\s*:"
|
||||
syn match yamlAnchor "&\S\+"
|
||||
syn match yamlAlias "*\S\+"
|
||||
|
||||
|
||||
625
autoload/LaTeXtoUnicode.vim
Normal file
625
autoload/LaTeXtoUnicode.vim
Normal file
@@ -0,0 +1,625 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Support for LaTex-to-Unicode conversion as in the Julia REPL "
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
function! s:L2U_Setup()
|
||||
|
||||
call s:L2U_SetupGlobal()
|
||||
|
||||
" Keep track of whether LaTeX-to-Unicode is activated
|
||||
" (used when filetype changes)
|
||||
if !has_key(b:, "l2u_enabled")
|
||||
let b:l2u_enabled = 0
|
||||
endif
|
||||
|
||||
" Did we install the L2U tab mappings?
|
||||
if !has_key(b:, "l2u_tab_set")
|
||||
let b:l2u_tab_set = 0
|
||||
endif
|
||||
if !has_key(b:, "l2u_cmdtab_set")
|
||||
let b:l2u_cmdtab_set = 0
|
||||
endif
|
||||
|
||||
" Did we activate the L2U as-you-type substitutions?
|
||||
if !has_key(b:, "l2u_autosub_set")
|
||||
let b:l2u_autosub_set = 0
|
||||
endif
|
||||
|
||||
" Following are some flags used to pass information between the function which
|
||||
" attempts the LaTeX-to-Unicode completion and the fallback function
|
||||
|
||||
" Was a (possibly partial) completion found?
|
||||
let b:l2u_found_completion = 0
|
||||
" Is the cursor just after a single backslash
|
||||
let b:l2u_singlebslash = 0
|
||||
" Backup value of the completeopt settings
|
||||
" (since we temporarily add the 'longest' setting while
|
||||
" attempting LaTeX-to-Unicode)
|
||||
let b:l2u_backup_commpleteopt = &completeopt
|
||||
" Are we in the middle of a L2U tab completion?
|
||||
let b:l2u_tab_completing = 0
|
||||
" Are we calling the tab fallback?
|
||||
let b:l2u_in_fallback = 0
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:L2U_SetupGlobal()
|
||||
|
||||
" Initialization of global and script-local variables
|
||||
" is only performed once
|
||||
if get(g:, "l2u_did_global_setup", 0)
|
||||
return
|
||||
endif
|
||||
|
||||
let g:l2u_did_global_setup = 1
|
||||
|
||||
let g:l2u_symbols_dict = julia_latex_symbols#get_dict()
|
||||
|
||||
call s:L2U_deprecated_options()
|
||||
|
||||
if v:version < 704
|
||||
let g:latex_to_unicode_tab = 0
|
||||
let g:latex_to_unicode_auto = 0
|
||||
endif
|
||||
|
||||
" YouCompleteMe and neocomplcache/neocomplete/deoplete plug-ins do not work well
|
||||
" with LaTeX symbols suggestions
|
||||
if exists("g:loaded_youcompleteme") ||
|
||||
\ exists("g:loaded_neocomplcache") ||
|
||||
\ exists("g:loaded_neocomplete") ||
|
||||
\ exists("g:loaded_deoplete")
|
||||
let g:latex_to_unicode_suggestions = 0
|
||||
endif
|
||||
|
||||
" A hack to forcibly get out of completion mode: feed
|
||||
" this string with feedkeys()
|
||||
if has("win32") || has("win64")
|
||||
if has("gui_running")
|
||||
let s:l2u_esc_sequence = "\u0006"
|
||||
else
|
||||
let s:l2u_esc_sequence = "\u0006\b"
|
||||
endif
|
||||
else
|
||||
let s:l2u_esc_sequence = "\u0091\b"
|
||||
end
|
||||
|
||||
" Trigger for the previous mapping of <Tab>
|
||||
let s:l2u_fallback_trigger = "\u0091L2UFallbackTab"
|
||||
|
||||
endfunction
|
||||
|
||||
" Each time the filetype changes, we may need to enable or
|
||||
" disable the LaTeX-to-Unicode functionality
|
||||
function! LaTeXtoUnicode#Refresh()
|
||||
|
||||
call s:L2U_Setup()
|
||||
|
||||
" by default, LaTeX-to-Unicode is only active on julia files
|
||||
let file_types = s:L2U_file_type_regex(get(g:, "latex_to_unicode_file_types", "julia"))
|
||||
let file_types_blacklist = s:L2U_file_type_regex(get(g:, "latex_to_unicode_file_types_blacklist", "$^"))
|
||||
|
||||
if match(&filetype, file_types) < 0 || match(&filetype, file_types_blacklist) >= 0
|
||||
if b:l2u_enabled
|
||||
call LaTeXtoUnicode#Disable()
|
||||
else
|
||||
return
|
||||
endif
|
||||
elseif !b:l2u_enabled
|
||||
call LaTeXtoUnicode#Enable()
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! LaTeXtoUnicode#Enable()
|
||||
|
||||
if b:l2u_enabled
|
||||
return
|
||||
end
|
||||
|
||||
call s:L2U_ResetLastCompletionInfo()
|
||||
|
||||
let b:l2u_enabled = 1
|
||||
|
||||
" If we're editing the first file upon opening vim, this will only init the
|
||||
" command line mode mapping, and the full initialization will be performed by
|
||||
" the autocmd triggered by InsertEnter, defined in /ftdetect.vim.
|
||||
" Otherwise, if we're opening a file from within a running vim session, this
|
||||
" will actually initialize all the LaTeX-to-Unicode substitutions.
|
||||
call LaTeXtoUnicode#Init()
|
||||
|
||||
return
|
||||
|
||||
endfunction
|
||||
|
||||
function! LaTeXtoUnicode#Disable()
|
||||
if !b:l2u_enabled
|
||||
return
|
||||
endif
|
||||
let b:l2u_enabled = 0
|
||||
call LaTeXtoUnicode#Init()
|
||||
return
|
||||
endfunction
|
||||
|
||||
" Translate old options to their new equivalents
|
||||
function! s:L2U_deprecated_options()
|
||||
for [new, old] in [["latex_to_unicode_tab", "julia_latex_to_unicode"],
|
||||
\ ["latex_to_unicode_auto", "julia_auto_latex_to_unicode"],
|
||||
\ ["latex_to_unicode_suggestions", "julia_latex_suggestions_enabled"],
|
||||
\ ["latex_to_unicode_eager", "julia_latex_to_unicode_eager"]]
|
||||
if !has_key(g:, new) && has_key(g:, old)
|
||||
exec "let g:" . new . " = g:" . old
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:L2U_file_type_regex(ft)
|
||||
if type(a:ft) == 3
|
||||
let file_types = "\\%(" . join(a:ft, "\\|") . "\\)"
|
||||
elseif type(a:ft) == 1
|
||||
let file_types = a:ft
|
||||
else
|
||||
echoerr "invalid file_type specification"
|
||||
endif
|
||||
return "^" . file_types . "$"
|
||||
endfunction
|
||||
|
||||
" Some data used to keep track of the previous completion attempt.
|
||||
" Used to detect
|
||||
" 1) if we just attempted the same completion, or
|
||||
" 2) if backspace was just pressed while completing
|
||||
" This function initializes and resets the required info
|
||||
|
||||
function! s:L2U_ResetLastCompletionInfo()
|
||||
let b:l2u_completed_once = 0
|
||||
let b:l2u_bs_while_completing = 0
|
||||
let b:l2u_last_compl = {
|
||||
\ 'line': '',
|
||||
\ 'col0': -1,
|
||||
\ 'col1': -1,
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
" This function only detects whether an exact match is found for a LaTeX
|
||||
" symbol in front of the cursor
|
||||
function! s:L2U_ismatch()
|
||||
let col1 = col('.')
|
||||
let l = getline('.')
|
||||
let col0 = match(l[0:col1-2], '\\[^[:space:]\\]\+$')
|
||||
if col0 == -1
|
||||
return 0
|
||||
endif
|
||||
let base = l[col0 : col1-1]
|
||||
return has_key(g:l2u_symbols_dict, base)
|
||||
endfunction
|
||||
|
||||
" Helper function to sort suggestion entries
|
||||
function! s:L2U_partmatches_sort(p1, p2)
|
||||
return a:p1.word > a:p2.word ? 1 : a:p1.word < a:p2.word ? -1 : 0
|
||||
endfunction
|
||||
|
||||
" Helper function to fix display of Unicode compose characters
|
||||
" in the suggestions menu (they are displayed on top of '◌')
|
||||
function! s:L2U_fix_compose_chars(uni)
|
||||
let u = matchstr(a:uni, '^.')
|
||||
let isc = ("\u0300" <= u && u <= "\u036F") ||
|
||||
\ ("\u1DC0" <= u && u <= "\u1DFF") ||
|
||||
\ ("\u20D0" <= u && u <= "\u20FF") ||
|
||||
\ ("\uFE20" <= u && u <= "\uFE2F")
|
||||
return isc ? "\u25CC" . a:uni : a:uni
|
||||
endfunction
|
||||
|
||||
" Helper function to find the longest common prefix among
|
||||
" partial completion matches (used when suggestions are disabled
|
||||
" and in command line mode)
|
||||
function! s:L2U_longest_common_prefix(partmatches)
|
||||
let common = a:partmatches[0]
|
||||
for i in range(1, len(a:partmatches)-1)
|
||||
let p = a:partmatches[i]
|
||||
if len(p) < len(common)
|
||||
let common = common[0 : len(p)-1]
|
||||
endif
|
||||
for j in range(1, len(common)-1)
|
||||
if p[j] != common[j]
|
||||
let common = common[0 : j-1]
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
return common
|
||||
endfunction
|
||||
|
||||
" Omnicompletion function. Besides the usual two-stage omnifunc behaviour,
|
||||
" it has the following peculiar features:
|
||||
" *) keeps track of the previous completion attempt
|
||||
" *) sets some info to be used by the fallback function
|
||||
" *) either returns a list of completions if a partial match is found, or a
|
||||
" Unicode char if an exact match is found
|
||||
" *) forces its way out of completion mode through a hack in some cases
|
||||
function! LaTeXtoUnicode#omnifunc(findstart, base)
|
||||
if a:findstart
|
||||
" first stage
|
||||
" avoid infinite loop if the fallback happens to call omnicompletion
|
||||
if b:l2u_in_fallback
|
||||
let b:l2u_in_fallback = 0
|
||||
return -3
|
||||
endif
|
||||
let b:l2u_in_fallback = 0
|
||||
" set info for the callback
|
||||
let b:l2u_tab_completing = 1
|
||||
let b:l2u_found_completion = 1
|
||||
" analyse current line
|
||||
let col1 = col('.')
|
||||
let l = getline('.')
|
||||
let col0 = match(l[0:col1-2], '\\[^[:space:]\\]\+$')
|
||||
" compare with previous completion attempt
|
||||
let b:l2u_bs_while_completing = 0
|
||||
let b:l2u_completed_once = 0
|
||||
if col0 == b:l2u_last_compl['col0']
|
||||
let prevl = b:l2u_last_compl['line']
|
||||
if col1 == b:l2u_last_compl['col1'] && l ==# prevl
|
||||
let b:l2u_completed_once = 1
|
||||
elseif col1 == b:l2u_last_compl['col1'] - 1 && l ==# prevl[0 : col1-2] . prevl[col1 : -1]
|
||||
let b:l2u_bs_while_completing = 1
|
||||
endif
|
||||
endif
|
||||
" store completion info for next attempt
|
||||
let b:l2u_last_compl['col0'] = col0
|
||||
let b:l2u_last_compl['col1'] = col1
|
||||
let b:l2u_last_compl['line'] = l
|
||||
" is the cursor right after a backslash?
|
||||
let b:l2u_singlebslash = (match(l[0:col1-2], '\\$') >= 0)
|
||||
" completion not found
|
||||
if col0 == -1
|
||||
let b:l2u_found_completion = 0
|
||||
call feedkeys(s:l2u_esc_sequence, 'n')
|
||||
let col0 = -2
|
||||
endif
|
||||
return col0
|
||||
else
|
||||
" read settings (eager mode is implicit when suggestions are disabled)
|
||||
let suggestions = get(g:, "latex_to_unicode_suggestions", 1)
|
||||
let eager = get(g:, "latex_to_unicode_eager", 1) || !suggestions
|
||||
" search for matches
|
||||
let partmatches = []
|
||||
let exact_match = 0
|
||||
for k in keys(g:l2u_symbols_dict)
|
||||
if k ==# a:base
|
||||
let exact_match = 1
|
||||
endif
|
||||
if len(k) >= len(a:base) && k[0 : len(a:base)-1] ==# a:base
|
||||
let menu = s:L2U_fix_compose_chars(g:l2u_symbols_dict[k])
|
||||
if suggestions
|
||||
call add(partmatches, {'word': k, 'menu': menu})
|
||||
else
|
||||
call add(partmatches, k)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
" exact matches are replaced with Unicode
|
||||
" exceptions:
|
||||
" *) we reached an exact match by pressing backspace while completing
|
||||
" *) the exact match is one among many, and the eager setting is
|
||||
" disabled, and it's the first time this completion is attempted
|
||||
if exact_match && !b:l2u_bs_while_completing && (len(partmatches) == 1 || eager || b:l2u_completed_once)
|
||||
" the completion is successful: reset the last completion info...
|
||||
call s:L2U_ResetLastCompletionInfo()
|
||||
" ...force our way out of completion mode...
|
||||
call feedkeys(s:l2u_esc_sequence, 'n')
|
||||
" ...return the Unicode symbol
|
||||
return [g:l2u_symbols_dict[a:base]]
|
||||
endif
|
||||
if !empty(partmatches)
|
||||
" here, only partial matches were found; either keep just the longest
|
||||
" common prefix, or pass them on
|
||||
if !suggestions
|
||||
let partmatches = [s:L2U_longest_common_prefix(partmatches)]
|
||||
else
|
||||
call sort(partmatches, "s:L2U_partmatches_sort")
|
||||
endif
|
||||
endif
|
||||
if empty(partmatches)
|
||||
call feedkeys(s:l2u_esc_sequence, 'n')
|
||||
let b:l2u_found_completion = 0
|
||||
endif
|
||||
return partmatches
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! LaTeXtoUnicode#PutLiteral(k)
|
||||
call feedkeys(a:k, 'ni')
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Function which saves the current insert-mode mapping of a key sequence `s`
|
||||
" and associates it with another key sequence `k` (e.g. stores the current
|
||||
" <Tab> mapping into the Fallback trigger)
|
||||
function! s:L2U_SetFallbackMapping(s, k)
|
||||
let mmdict = maparg(a:s, 'i', 0, 1)
|
||||
if empty(mmdict)
|
||||
exe 'inoremap <buffer> ' . a:k . ' ' . a:s
|
||||
return
|
||||
endif
|
||||
let rhs = mmdict["rhs"]
|
||||
if rhs =~# '^<Plug>L2U'
|
||||
return
|
||||
endif
|
||||
let pre = '<buffer>'
|
||||
if mmdict["silent"]
|
||||
let pre = pre . '<silent>'
|
||||
endif
|
||||
if mmdict["expr"]
|
||||
let pre = pre . '<expr>'
|
||||
endif
|
||||
if mmdict["noremap"]
|
||||
let cmd = 'inoremap '
|
||||
else
|
||||
let cmd = 'imap '
|
||||
" This is a nasty hack used to prevent infinite recursion. It's not a
|
||||
" general solution.
|
||||
if mmdict["expr"]
|
||||
let rhs = substitute(rhs, '\c' . a:s, "\<C-R>=LaTeXtoUnicode#PutLiteral('" . a:s . "')\<CR>", 'g')
|
||||
endif
|
||||
endif
|
||||
exe cmd . pre . ' ' . a:k . ' ' . rhs
|
||||
endfunction
|
||||
|
||||
" This is the function which is mapped to <Tab>
|
||||
function! LaTeXtoUnicode#Tab()
|
||||
" the <Tab> is passed through to the fallback mapping if the completion
|
||||
" menu is present, and it hasn't been raised by the L2U tab, and there
|
||||
" isn't an exact match before the cursor when suggestions are disabled
|
||||
if pumvisible() && !b:l2u_tab_completing && (get(g:, "latex_to_unicode_suggestions", 1) || !s:L2U_ismatch())
|
||||
call feedkeys(s:l2u_fallback_trigger)
|
||||
return ''
|
||||
endif
|
||||
" reset the in_fallback info
|
||||
let b:l2u_in_fallback = 0
|
||||
" temporary change to completeopt to use the `longest` setting, which is
|
||||
" probably the only one which makes sense given that the goal of the
|
||||
" completion is to substitute the final string
|
||||
let b:l2u_backup_commpleteopt = &completeopt
|
||||
set completeopt+=longest
|
||||
set completeopt-=noinsert
|
||||
" invoke omnicompletion; failure to perform LaTeX-to-Unicode completion is
|
||||
" handled by the CompleteDone autocommand.
|
||||
return "\<C-X>\<C-O>"
|
||||
endfunction
|
||||
|
||||
" This function is called at every CompleteDone event, and is meant to handle
|
||||
" the failures of LaTeX-to-Unicode completion by calling a fallback
|
||||
function! LaTeXtoUnicode#FallbackCallback()
|
||||
if !b:l2u_tab_completing
|
||||
" completion was not initiated by L2U, nothing to do
|
||||
return
|
||||
else
|
||||
" completion was initiated by L2U, restore completeopt
|
||||
let &completeopt = b:l2u_backup_commpleteopt
|
||||
endif
|
||||
" at this point L2U tab completion is over
|
||||
let b:l2u_tab_completing = 0
|
||||
" if the completion was successful do nothing
|
||||
if b:l2u_found_completion == 1 || b:l2u_singlebslash == 1
|
||||
return
|
||||
endif
|
||||
" fallback
|
||||
let b:l2u_in_fallback = 1
|
||||
call feedkeys(s:l2u_fallback_trigger)
|
||||
return
|
||||
endfunction
|
||||
|
||||
" This is the function which is mapped to <S-Tab> in command-line mode
|
||||
function! LaTeXtoUnicode#CmdTab()
|
||||
" first stage
|
||||
" analyse command line
|
||||
let col1 = getcmdpos() - 1
|
||||
let l = getcmdline()
|
||||
let col0 = match(l[0:col1-1], '\\[^[:space:]\\]\+$')
|
||||
let b:l2u_singlebslash = (match(l[0:col1-1], '\\$') >= 0)
|
||||
" completion not found
|
||||
if col0 == -1
|
||||
return l
|
||||
endif
|
||||
let base = l[col0 : col1-1]
|
||||
" search for matches
|
||||
let partmatches = []
|
||||
let exact_match = 0
|
||||
for k in keys(g:l2u_symbols_dict)
|
||||
if k ==# base
|
||||
let exact_match = 1
|
||||
endif
|
||||
if len(k) >= len(base) && k[0 : len(base)-1] ==# base
|
||||
call add(partmatches, k)
|
||||
endif
|
||||
endfor
|
||||
if len(partmatches) == 0
|
||||
return l
|
||||
endif
|
||||
" exact matches are replaced with Unicode
|
||||
if exact_match
|
||||
let unicode = g:l2u_symbols_dict[base]
|
||||
if col0 > 0
|
||||
let pre = l[0 : col0 - 1]
|
||||
else
|
||||
let pre = ''
|
||||
endif
|
||||
let posdiff = col1-col0 - len(unicode)
|
||||
call setcmdpos(col1 - posdiff + 1)
|
||||
return pre . unicode . l[col1 : -1]
|
||||
endif
|
||||
" no exact match: complete with the longest common prefix
|
||||
let common = s:L2U_longest_common_prefix(partmatches)
|
||||
if col0 > 0
|
||||
let pre = l[0 : col0 - 1]
|
||||
else
|
||||
let pre = ''
|
||||
endif
|
||||
let posdiff = col1-col0 - len(common)
|
||||
call setcmdpos(col1 - posdiff + 1)
|
||||
return pre . common . l[col1 : -1]
|
||||
endfunction
|
||||
|
||||
" Setup the L2U tab mapping
|
||||
function! s:L2U_SetTab(wait_insert_enter)
|
||||
if !b:l2u_cmdtab_set && get(g:, "latex_to_unicode_tab", 1) && b:l2u_enabled
|
||||
cmap <buffer> <S-Tab> <Plug>L2UCmdTab
|
||||
cnoremap <buffer> <Plug>L2UCmdTab <C-\>eLaTeXtoUnicode#CmdTab()<CR>
|
||||
let b:l2u_cmdtab_set = 1
|
||||
endif
|
||||
if b:l2u_tab_set
|
||||
return
|
||||
endif
|
||||
" g:did_insert_enter is set from an autocommand in ftdetect
|
||||
if a:wait_insert_enter && !get(g:, "did_insert_enter", 0)
|
||||
return
|
||||
endif
|
||||
if !get(g:, "latex_to_unicode_tab", 1) || !b:l2u_enabled
|
||||
return
|
||||
endif
|
||||
|
||||
" Backup the previous omnifunc (the check is probably not really needed)
|
||||
if get(b:, "prev_omnifunc", "") != "LaTeXtoUnicode#omnifunc"
|
||||
let b:prev_omnifunc = &omnifunc
|
||||
endif
|
||||
setlocal omnifunc=LaTeXtoUnicode#omnifunc
|
||||
|
||||
call s:L2U_SetFallbackMapping('<Tab>', s:l2u_fallback_trigger)
|
||||
imap <buffer> <Tab> <Plug>L2UTab
|
||||
inoremap <buffer><expr> <Plug>L2UTab LaTeXtoUnicode#Tab()
|
||||
|
||||
augroup L2UTab
|
||||
autocmd! * <buffer>
|
||||
" Every time a completion finishes, the fallback may be invoked
|
||||
autocmd CompleteDone <buffer> call LaTeXtoUnicode#FallbackCallback()
|
||||
augroup END
|
||||
|
||||
let b:l2u_tab_set = 1
|
||||
endfunction
|
||||
|
||||
" Revert the LaTeX-to-Unicode tab mapping settings
|
||||
function! s:L2U_UnsetTab()
|
||||
if b:l2u_cmdtab_set
|
||||
cunmap <buffer> <S-Tab>
|
||||
let b:l2u_cmdtab_set = 0
|
||||
endif
|
||||
if !b:l2u_tab_set
|
||||
return
|
||||
endif
|
||||
exec "setlocal omnifunc=" . get(b:, "prev_omnifunc", "")
|
||||
iunmap <buffer> <Tab>
|
||||
if empty(maparg("<Tab>", "i"))
|
||||
call s:L2U_SetFallbackMapping(s:l2u_fallback_trigger, '<Tab>')
|
||||
endif
|
||||
iunmap <buffer> <Plug>L2UTab
|
||||
exe 'iunmap <buffer> ' . s:l2u_fallback_trigger
|
||||
augroup L2UTab
|
||||
autocmd! * <buffer>
|
||||
augroup END
|
||||
let b:l2u_tab_set = 0
|
||||
endfunction
|
||||
|
||||
" Function which looks for viable LaTeX-to-Unicode supstitutions as you type
|
||||
function! LaTeXtoUnicode#AutoSub(...)
|
||||
let vc = a:0 == 0 ? v:char : a:1
|
||||
let col1 = col('.')
|
||||
let lnum = line('.')
|
||||
if col1 == 1
|
||||
if a:0 > 1
|
||||
call feedkeys(a:2, 'n')
|
||||
endif
|
||||
return ''
|
||||
endif
|
||||
let bs = (vc != "\n")
|
||||
let l = getline(lnum)[0 : col1-1-bs] . v:char
|
||||
let col0 = match(l, '\\\%([_^]\?[A-Za-z]\+\%' . col1 . 'c\%([^A-Za-z]\|$\)\|[_^]\%([0-9()=+-]\)\%' . col1 .'c\%(.\|$\)\)')
|
||||
if col0 == -1
|
||||
if a:0 > 1
|
||||
call feedkeys(a:2, 'n')
|
||||
endif
|
||||
return ''
|
||||
endif
|
||||
let base = l[col0 : -1-bs]
|
||||
let unicode = get(g:l2u_symbols_dict, base, '')
|
||||
if empty(unicode)
|
||||
if a:0 > 1
|
||||
call feedkeys(a:2, 'n')
|
||||
endif
|
||||
return ''
|
||||
endif
|
||||
call feedkeys("\<C-G>u", 'n')
|
||||
call feedkeys(repeat("\b", len(base) + bs) . unicode . vc . s:l2u_esc_sequence, 'nt')
|
||||
call feedkeys("\<C-G>u", 'n')
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Setup the auto as-you-type LaTeX-to-Unicode substitution
|
||||
function! s:L2U_SetAutoSub(wait_insert_enter)
|
||||
if b:l2u_autosub_set
|
||||
return
|
||||
endif
|
||||
" g:did_insert_enter is set from an autocommand in ftdetect
|
||||
if a:wait_insert_enter && !get(g:, "did_insert_enter", 0)
|
||||
return
|
||||
endif
|
||||
if !get(g:, "latex_to_unicode_auto", 0) || !b:l2u_enabled
|
||||
return
|
||||
endif
|
||||
" Viable substitutions are searched at every character insertion via the
|
||||
" autocmd InsertCharPre. The <Enter> key does not seem to be catched in
|
||||
" this way though, so we use a mapping for that case.
|
||||
imap <buffer> <CR> <Plug>L2UAutoSub
|
||||
inoremap <buffer><expr> <Plug>L2UAutoSub LaTeXtoUnicode#AutoSub("\n", "\<CR>")
|
||||
|
||||
augroup L2UAutoSub
|
||||
autocmd! * <buffer>
|
||||
autocmd InsertCharPre <buffer> call LaTeXtoUnicode#AutoSub()
|
||||
augroup END
|
||||
|
||||
let b:l2u_autosub_set = 1
|
||||
endfunction
|
||||
|
||||
" Revert the auto LaTeX-to-Unicode settings
|
||||
function! s:L2U_UnsetAutoSub()
|
||||
if !b:l2u_autosub_set
|
||||
return
|
||||
endif
|
||||
|
||||
iunmap <buffer> <CR>
|
||||
iunmap <buffer> <Plug>L2UAutoSub
|
||||
augroup L2UAutoSub
|
||||
autocmd! * <buffer>
|
||||
augroup END
|
||||
let b:l2u_autosub_set = 0
|
||||
endfunction
|
||||
|
||||
" Initialization. Can be used to re-init when global settings have changed.
|
||||
function! LaTeXtoUnicode#Init(...)
|
||||
let wait_insert_enter = a:0 > 0 ? a:1 : 1
|
||||
|
||||
if !wait_insert_enter
|
||||
augroup L2UInit
|
||||
autocmd!
|
||||
augroup END
|
||||
endif
|
||||
|
||||
call s:L2U_UnsetTab()
|
||||
call s:L2U_UnsetAutoSub()
|
||||
|
||||
call s:L2U_SetTab(wait_insert_enter)
|
||||
call s:L2U_SetAutoSub(wait_insert_enter)
|
||||
endfunction
|
||||
|
||||
function! LaTeXtoUnicode#Toggle()
|
||||
call s:L2U_Setup()
|
||||
if b:l2u_enabled
|
||||
call LaTeXtoUnicode#Disable()
|
||||
echo "LaTeX-to-Unicode disabled"
|
||||
else
|
||||
call LaTeXtoUnicode#Enable()
|
||||
echo "LaTeX-to-Unicode enabled"
|
||||
endif
|
||||
return
|
||||
endfunction
|
||||
|
||||
endif
|
||||
@@ -310,7 +310,7 @@ function! crystal_lang#format(option_str) abort
|
||||
|
||||
try
|
||||
call setreg('g', formatted, 'v')
|
||||
silent normal! ggvG$"gp
|
||||
silent normal! gg0vG$"gp
|
||||
finally
|
||||
call setreg('g', save_g_reg, save_g_regtype)
|
||||
let &l:selection = sel_save
|
||||
|
||||
@@ -24,9 +24,11 @@ function! dart#fmt(q_args) abort
|
||||
let joined_lines = system(printf('dartfmt %s', a:q_args), buffer_content)
|
||||
if 0 == v:shell_error
|
||||
let win_view = winsaveview()
|
||||
silent % delete _
|
||||
silent put=joined_lines
|
||||
silent 1 delete _
|
||||
let lines = split(joined_lines, "\n")
|
||||
silent keepjumps call setline(1, lines)
|
||||
if line('$') > len(lines)
|
||||
silent keepjumps execute string(len(lines)+1).',$ delete'
|
||||
endif
|
||||
call winrestview(win_view)
|
||||
else
|
||||
let errors = split(joined_lines, "\n")[2:]
|
||||
@@ -150,4 +152,13 @@ function! s:DotPackagesFile() abort
|
||||
return [v:false, '']
|
||||
endfunction
|
||||
|
||||
" Prevent writes to files in the pub cache.
|
||||
function! dart#setModifiable() abort
|
||||
let full_path = expand('%:p')
|
||||
if full_path =~# '.pub-cache' ||
|
||||
\ full_path =~# 'Pub\Cache'
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
endfunction
|
||||
|
||||
endif
|
||||
|
||||
@@ -1,6 +1,51 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
|
||||
|
||||
function! elixir#indent#debug(str)
|
||||
if !exists("g:elixir_indent_max_lookbehind")
|
||||
let g:elixir_indent_max_lookbehind = 30
|
||||
endif
|
||||
|
||||
" Return the effective value of 'shiftwidth'
|
||||
function! s:sw()
|
||||
return &shiftwidth == 0 ? &tabstop : &shiftwidth
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#indent(lnum)
|
||||
let lnum = a:lnum
|
||||
let text = getline(lnum)
|
||||
let prev_nb_lnum = prevnonblank(lnum-1)
|
||||
let prev_nb_text = getline(prev_nb_lnum)
|
||||
|
||||
call s:debug("==> Indenting line " . lnum)
|
||||
call s:debug("text = '" . text . "'")
|
||||
|
||||
let handlers = [
|
||||
\'top_of_file',
|
||||
\'starts_with_end',
|
||||
\'starts_with_mid_or_end_block_keyword',
|
||||
\'following_trailing_do',
|
||||
\'following_trailing_binary_operator',
|
||||
\'starts_with_pipe',
|
||||
\'starts_with_close_bracket',
|
||||
\'starts_with_binary_operator',
|
||||
\'inside_nested_construct',
|
||||
\'starts_with_comment',
|
||||
\'inside_generic_block',
|
||||
\'follow_prev_nb'
|
||||
\]
|
||||
for handler in handlers
|
||||
call s:debug('testing handler elixir#indent#handle_'.handler)
|
||||
let indent = function('elixir#indent#handle_'.handler)(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if indent != -1
|
||||
call s:debug('line '.lnum.': elixir#indent#handle_'.handler.' returned '.indent)
|
||||
return indent
|
||||
endif
|
||||
endfor
|
||||
|
||||
call s:debug("defaulting")
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:debug(str)
|
||||
if exists("g:elixir_indent_debug") && g:elixir_indent_debug
|
||||
echom a:str
|
||||
endif
|
||||
@@ -8,14 +53,14 @@ endfunction
|
||||
|
||||
" Returns 0 or 1 based on whether or not the text starts with the given
|
||||
" expression and is not a string or comment
|
||||
function! elixir#indent#starts_with(text, expr, lnum)
|
||||
function! s:starts_with(text, expr, lnum)
|
||||
let pos = match(a:text, '^\s*'.a:expr)
|
||||
if pos == -1
|
||||
return 0
|
||||
else
|
||||
" NOTE: @jbodah 2017-02-24: pos is the index of the match which is
|
||||
" zero-indexed. Add one to make it the column number
|
||||
if elixir#indent#is_string_or_comment(a:lnum, pos + 1)
|
||||
if s:is_string_or_comment(a:lnum, pos + 1)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@@ -25,12 +70,12 @@ endfunction
|
||||
|
||||
" Returns 0 or 1 based on whether or not the text ends with the given
|
||||
" expression and is not a string or comment
|
||||
function! elixir#indent#ends_with(text, expr, lnum)
|
||||
function! s:ends_with(text, expr, lnum)
|
||||
let pos = match(a:text, a:expr.'\s*$')
|
||||
if pos == -1
|
||||
return 0
|
||||
else
|
||||
if elixir#indent#is_string_or_comment(a:lnum, pos)
|
||||
if s:is_string_or_comment(a:lnum, pos)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
@@ -38,14 +83,9 @@ function! elixir#indent#ends_with(text, expr, lnum)
|
||||
end
|
||||
endfunction
|
||||
|
||||
" Returns 0 or 1 based on whether or not the text matches the given expression
|
||||
function! elixir#indent#contains(text, expr)
|
||||
return a:text =~ a:expr
|
||||
endfunction
|
||||
|
||||
" Returns 0 or 1 based on whether or not the given line number and column
|
||||
" number pair is a string or comment
|
||||
function! elixir#indent#is_string_or_comment(line, col)
|
||||
function! s:is_string_or_comment(line, col)
|
||||
return synIDattr(synID(a:line, a:col, 1), "name") =~ '\%(String\|Comment\)'
|
||||
endfunction
|
||||
|
||||
@@ -59,35 +99,19 @@ function! elixir#indent#searchpair_back_skip()
|
||||
if getline('.')[curr_col-1] == ''
|
||||
let curr_col = curr_col-1
|
||||
endif
|
||||
return elixir#indent#is_string_or_comment(line('.'), curr_col)
|
||||
endfunction
|
||||
|
||||
" DRY up searchpair calls
|
||||
function! elixir#indent#searchpair_back(start, mid, end)
|
||||
let line = line('.')
|
||||
return searchpair(a:start, a:mid, a:end, 'bnW', "line('.') == " . line . " || elixir#indent#searchpair_back_skip()")
|
||||
endfunction
|
||||
|
||||
" DRY up searchpairpos calls
|
||||
function! elixir#indent#searchpairpos_back(start, mid, end)
|
||||
let line = line('.')
|
||||
return searchpairpos(a:start, a:mid, a:end, 'bnW', "line('.') == " . line . " || elixir#indent#searchpair_back_skip()")
|
||||
return s:is_string_or_comment(line('.'), curr_col)
|
||||
endfunction
|
||||
|
||||
" DRY up regex for keywords that 1) makes sure we only look at complete words
|
||||
" and 2) ignores atoms
|
||||
function! elixir#indent#keyword(expr)
|
||||
function! s:keyword(expr)
|
||||
return ':\@<!\<\C\%('.a:expr.'\)\>:\@!'
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#starts_with_comment(text)
|
||||
return match(a:text, '^\s*#') != -1
|
||||
endfunction
|
||||
|
||||
" Start at the end of text and search backwards looking for a match. Also peek
|
||||
" ahead if we get a match to make sure we get a complete match. This means
|
||||
" that the result should be the position of the start of the right-most match
|
||||
function! elixir#indent#find_last_pos(lnum, text, match)
|
||||
function! s:find_last_pos(lnum, text, match)
|
||||
let last = len(a:text) - 1
|
||||
let c = last
|
||||
|
||||
@@ -118,13 +142,46 @@ function! elixir#indent#handle_top_of_file(_lnum, _text, prev_nb_lnum, _prev_nb_
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_follow_prev_nb(_lnum, _text, prev_nb_lnum, prev_nb_text)
|
||||
return s:get_base_indent(a:prev_nb_lnum, a:prev_nb_text)
|
||||
endfunction
|
||||
|
||||
" Given the line at `lnum`, returns the indent of the line that acts as the 'base indent'
|
||||
" for this line. In particular it traverses backwards up things like pipelines
|
||||
" to find the beginning of the expression
|
||||
function! s:get_base_indent(lnum, text)
|
||||
let prev_nb_lnum = prevnonblank(a:lnum - 1)
|
||||
let prev_nb_text = getline(prev_nb_lnum)
|
||||
|
||||
let binary_operator = '\%(=\|<>\|>>>\|<=\|||\|+\|\~\~\~\|-\|&&\|<<<\|/\|\^\^\^\|\*\)'
|
||||
let data_structure_close = '\%(\]\|}\|)\)'
|
||||
let pipe = '|>'
|
||||
|
||||
if s:starts_with(a:text, binary_operator, a:lnum)
|
||||
return s:get_base_indent(prev_nb_lnum, prev_nb_text)
|
||||
elseif s:starts_with(a:text, pipe, a:lnum)
|
||||
return s:get_base_indent(prev_nb_lnum, prev_nb_text)
|
||||
elseif s:ends_with(prev_nb_text, binary_operator, prev_nb_lnum)
|
||||
return s:get_base_indent(prev_nb_lnum, prev_nb_text)
|
||||
elseif s:ends_with(a:text, data_structure_close, a:lnum)
|
||||
let data_structure_open = '\%(\[\|{\|(\)'
|
||||
let close_match_idx = match(a:text, data_structure_close . '\s*$')
|
||||
let _move = cursor(a:lnum, close_match_idx + 1)
|
||||
let [open_match_lnum, open_match_col] = searchpairpos(data_structure_open, '', data_structure_close, 'bnW')
|
||||
let open_match_text = getline(open_match_lnum)
|
||||
return s:get_base_indent(open_match_lnum, open_match_text)
|
||||
else
|
||||
return indent(a:lnum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" TODO: @jbodah 2017-03-31: remove
|
||||
function! elixir#indent#handle_following_trailing_do(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if elixir#indent#ends_with(a:prev_nb_text, elixir#indent#keyword('do'), a:prev_nb_lnum)
|
||||
if elixir#indent#starts_with(a:text, elixir#indent#keyword('end'), a:lnum)
|
||||
if s:ends_with(a:prev_nb_text, s:keyword('do'), a:prev_nb_lnum)
|
||||
if s:starts_with(a:text, s:keyword('end'), a:lnum)
|
||||
return indent(a:prev_nb_lnum)
|
||||
else
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
end
|
||||
else
|
||||
return -1
|
||||
@@ -134,23 +191,31 @@ endfunction
|
||||
function! elixir#indent#handle_following_trailing_binary_operator(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
let binary_operator = '\%(=\|<>\|>>>\|<=\|||\|+\|\~\~\~\|-\|&&\|<<<\|/\|\^\^\^\|\*\)'
|
||||
|
||||
if elixir#indent#ends_with(a:prev_nb_text, binary_operator, a:prev_nb_lnum)
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
if s:ends_with(a:prev_nb_text, binary_operator, a:prev_nb_lnum)
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_following_prev_end(_lnum, _text, prev_nb_lnum, prev_nb_text)
|
||||
if s:ends_with(a:prev_nb_text, s:keyword('end'), a:prev_nb_lnum)
|
||||
return indent(a:prev_nb_lnum)
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_starts_with_pipe(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if elixir#indent#starts_with(a:text, '|>', a:lnum)
|
||||
if s:starts_with(a:text, '|>', a:lnum)
|
||||
let match_operator = '\%(!\|=\|<\|>\)\@<!=\%(=\|>\|\~\)\@!'
|
||||
let pos = elixir#indent#find_last_pos(a:prev_nb_lnum, a:prev_nb_text, match_operator)
|
||||
let pos = s:find_last_pos(a:prev_nb_lnum, a:prev_nb_text, match_operator)
|
||||
if pos == -1
|
||||
return indent(a:prev_nb_lnum)
|
||||
else
|
||||
let next_word_pos = match(strpart(a:prev_nb_text, pos+1, len(a:prev_nb_text)-1), '\S')
|
||||
if next_word_pos == -1
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
else
|
||||
return pos + 1 + next_word_pos
|
||||
end
|
||||
@@ -161,7 +226,7 @@ function! elixir#indent#handle_starts_with_pipe(lnum, text, prev_nb_lnum, prev_n
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_starts_with_comment(_lnum, text, prev_nb_lnum, _prev_nb_text)
|
||||
if elixir#indent#starts_with_comment(a:text)
|
||||
if match(a:text, '^\s*#') != -1
|
||||
return indent(a:prev_nb_lnum)
|
||||
else
|
||||
return -1
|
||||
@@ -169,8 +234,8 @@ function! elixir#indent#handle_starts_with_comment(_lnum, text, prev_nb_lnum, _p
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_starts_with_end(lnum, text, _prev_nb_lnum, _prev_nb_text)
|
||||
if elixir#indent#starts_with(a:text, elixir#indent#keyword('end'), a:lnum)
|
||||
let pair_lnum = elixir#indent#searchpair_back(elixir#indent#keyword('do\|fn'), '', elixir#indent#keyword('end').'\zs')
|
||||
if s:starts_with(a:text, s:keyword('end'), a:lnum)
|
||||
let pair_lnum = searchpair(s:keyword('do\|fn'), '', s:keyword('end').'\zs', 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()")
|
||||
return indent(pair_lnum)
|
||||
else
|
||||
return -1
|
||||
@@ -178,8 +243,8 @@ function! elixir#indent#handle_starts_with_end(lnum, text, _prev_nb_lnum, _prev_
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_starts_with_mid_or_end_block_keyword(lnum, text, _prev_nb_lnum, _prev_nb_text)
|
||||
if elixir#indent#starts_with(a:text, elixir#indent#keyword('catch\|rescue\|after\|else'), a:lnum)
|
||||
let pair_lnum = elixir#indent#searchpair_back(elixir#indent#keyword('with\|receive\|try\|if\|fn'), elixir#indent#keyword('catch\|rescue\|after\|else').'\zs', elixir#indent#keyword('end'))
|
||||
if s:starts_with(a:text, s:keyword('catch\|rescue\|after\|else'), a:lnum)
|
||||
let pair_lnum = searchpair(s:keyword('with\|receive\|try\|if\|fn'), s:keyword('catch\|rescue\|after\|else').'\zs', s:keyword('end'), 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()")
|
||||
return indent(pair_lnum)
|
||||
else
|
||||
return -1
|
||||
@@ -187,8 +252,8 @@ function! elixir#indent#handle_starts_with_mid_or_end_block_keyword(lnum, text,
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_starts_with_close_bracket(lnum, text, _prev_nb_lnum, _prev_nb_text)
|
||||
if elixir#indent#starts_with(a:text, '\%(\]\|}\|)\)', a:lnum)
|
||||
let pair_lnum = elixir#indent#searchpair_back('\%(\[\|{\|(\)', '', '\%(\]\|}\|)\)')
|
||||
if s:starts_with(a:text, '\%(\]\|}\|)\)', a:lnum)
|
||||
let pair_lnum = searchpair('\%(\[\|{\|(\)', '', '\%(\]\|}\|)\)', 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()")
|
||||
return indent(pair_lnum)
|
||||
else
|
||||
return -1
|
||||
@@ -198,15 +263,15 @@ endfunction
|
||||
function! elixir#indent#handle_starts_with_binary_operator(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
let binary_operator = '\%(=\|<>\|>>>\|<=\|||\|+\|\~\~\~\|-\|&&\|<<<\|/\|\^\^\^\|\*\)'
|
||||
|
||||
if elixir#indent#starts_with(a:text, binary_operator, a:lnum)
|
||||
if s:starts_with(a:text, binary_operator, a:lnum)
|
||||
let match_operator = '\%(!\|=\|<\|>\)\@<!=\%(=\|>\|\~\)\@!'
|
||||
let pos = elixir#indent#find_last_pos(a:prev_nb_lnum, a:prev_nb_text, match_operator)
|
||||
let pos = s:find_last_pos(a:prev_nb_lnum, a:prev_nb_text, match_operator)
|
||||
if pos == -1
|
||||
return indent(a:prev_nb_lnum)
|
||||
else
|
||||
let next_word_pos = match(strpart(a:prev_nb_text, pos+1, len(a:prev_nb_text)-1), '\S')
|
||||
if next_word_pos == -1
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
else
|
||||
return pos + 1 + next_word_pos
|
||||
end
|
||||
@@ -221,75 +286,116 @@ endfunction
|
||||
" function, etc... so we need to first figure out what the innermost structure
|
||||
" is then forward execution to the proper handler
|
||||
function! elixir#indent#handle_inside_nested_construct(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
let start_pattern = '\C\%(\<if\>\|\<case\>\|\<cond\>\|\<try\>\|\<receive\>\|\<fn\>\|{\|\[\|(\)'
|
||||
let start_pattern = '\C\%(\<with\>\|\<if\>\|\<case\>\|\<cond\>\|\<try\>\|\<receive\>\|\<fn\>\|{\|\[\|(\)'
|
||||
let end_pattern = '\C\%(\<end\>\|\]\|}\|)\)'
|
||||
let pair_info = elixir#indent#searchpairpos_back(start_pattern, '', end_pattern)
|
||||
let pair_info = searchpairpos(start_pattern, '', end_pattern, 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()", max([0, a:lnum - g:elixir_indent_max_lookbehind]))
|
||||
let pair_lnum = pair_info[0]
|
||||
let pair_col = pair_info[1]
|
||||
if pair_lnum != 0 || pair_col != 0
|
||||
let pair_text = getline(pair_lnum)
|
||||
let pair_char = pair_text[pair_col - 1]
|
||||
if pair_char == 'f'
|
||||
call elixir#indent#debug("testing elixir#indent#do_handle_inside_fn")
|
||||
return elixir#indent#do_handle_inside_fn(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
call s:debug("testing s:do_handle_inside_fn")
|
||||
return s:do_handle_inside_fn(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
elseif pair_char == '['
|
||||
call elixir#indent#debug("testing elixir#indent#do_handle_inside_square_brace")
|
||||
return elixir#indent#do_handle_inside_square_brace(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
call s:debug("testing s:do_handle_inside_square_brace")
|
||||
return s:do_handle_inside_square_brace(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
elseif pair_char == '{'
|
||||
call elixir#indent#debug("testing elixir#indent#do_handle_inside_curly_brace")
|
||||
return elixir#indent#do_handle_inside_curly_brace(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
call s:debug("testing s:do_handle_inside_curly_brace")
|
||||
return s:do_handle_inside_curly_brace(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
elseif pair_char == '('
|
||||
call elixir#indent#debug("testing elixir#indent#do_handle_inside_parens")
|
||||
return elixir#indent#do_handle_inside_parens(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
call s:debug("testing s:do_handle_inside_parens")
|
||||
return s:do_handle_inside_parens(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
elseif pair_char == 'w'
|
||||
call s:debug("testing s:do_handle_inside_with")
|
||||
return s:do_handle_inside_with(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
else
|
||||
call elixir#indent#debug("testing elixir#indent#do_handle_inside_keyword_block")
|
||||
return elixir#indent#do_handle_inside_keyword_block(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
call s:debug("testing s:do_handle_inside_keyword_block")
|
||||
return s:do_handle_inside_keyword_block(pair_lnum, pair_col, a:lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
end
|
||||
else
|
||||
return -1
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#do_handle_inside_keyword_block(pair_lnum, _pair_col, _lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
function! s:do_handle_inside_with(pair_lnum, pair_col, lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if a:pair_lnum == a:lnum
|
||||
" This is the `with` line or an inline `with`/`do`
|
||||
call s:debug("current line is `with`")
|
||||
return -1
|
||||
else
|
||||
" Determine if in with/do, do/else|end, or else/end
|
||||
let start_pattern = '\C\%(\<with\>\|\<else\>\|\<do\>\)'
|
||||
let end_pattern = '\C\%(\<end\>\)'
|
||||
let pair_info = searchpairpos(start_pattern, '', end_pattern, 'bnW', "line('.') == " . line('.') . " || elixir#indent#searchpair_back_skip()")
|
||||
let pair_lnum = pair_info[0]
|
||||
let pair_col = pair_info[1]
|
||||
|
||||
let pair_text = getline(pair_lnum)
|
||||
let pair_char = pair_text[pair_col - 1]
|
||||
|
||||
if s:starts_with(a:text, '\Cdo:', a:lnum)
|
||||
call s:debug("current line is do:")
|
||||
return pair_col - 1 + s:sw()
|
||||
elseif s:starts_with(a:text, '\Celse:', a:lnum)
|
||||
call s:debug("current line is else:")
|
||||
return pair_col - 1
|
||||
elseif s:starts_with(a:text, '\C\(\<do\>\|\<else\>\)', a:lnum)
|
||||
call s:debug("current line is do/else")
|
||||
return pair_col - 1
|
||||
elseif s:starts_with(pair_text, '\C\(do\|else\):', pair_lnum)
|
||||
call s:debug("inside do:/else:")
|
||||
return pair_col - 1 + s:sw()
|
||||
elseif pair_char == 'w'
|
||||
call s:debug("inside with/do")
|
||||
return pair_col + 4
|
||||
elseif pair_char == 'd'
|
||||
call s:debug("inside do/else|end")
|
||||
return pair_col - 1 + s:sw()
|
||||
else
|
||||
call s:debug("inside else/end")
|
||||
return s:do_handle_inside_pattern_match_block(pair_lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
end
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! s:do_handle_inside_keyword_block(pair_lnum, _pair_col, _lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
let keyword_pattern = '\C\%(\<case\>\|\<cond\>\|\<try\>\|\<receive\>\|\<after\>\|\<catch\>\|\<rescue\>\|\<else\>\)'
|
||||
if a:pair_lnum
|
||||
" last line is a "receive" or something
|
||||
if elixir#indent#starts_with(a:prev_nb_text, keyword_pattern, a:prev_nb_lnum)
|
||||
call elixir#indent#debug("prev nb line is keyword")
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
elseif elixir#indent#contains(a:text, '->')
|
||||
call elixir#indent#debug("contains ->")
|
||||
" TODO: @jbodah 2017-03-31: test contains ignores str + comments
|
||||
return indent(a:pair_lnum) + &sw
|
||||
elseif elixir#indent#contains(a:prev_nb_text, '->')
|
||||
call elixir#indent#debug("prev nb line contains ->")
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
" last line is a "receive" or something
|
||||
if s:starts_with(a:prev_nb_text, keyword_pattern, a:prev_nb_lnum)
|
||||
call s:debug("prev nb line is keyword")
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
else
|
||||
call elixir#indent#debug("doesnt start with comment or contain ->")
|
||||
return indent(a:prev_nb_lnum)
|
||||
return s:do_handle_inside_pattern_match_block(a:pair_lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
end
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#do_handle_inside_fn(pair_lnum, _pair_col, lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
" Implements indent for pattern-matching blocks (e.g. case, fn, with/else)
|
||||
function! s:do_handle_inside_pattern_match_block(block_start_lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if a:text =~ '->'
|
||||
call s:debug("current line contains ->")
|
||||
return indent(a:block_start_lnum) + s:sw()
|
||||
elseif a:prev_nb_text =~ '->'
|
||||
call s:debug("prev nb line contains ->")
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
else
|
||||
return indent(a:prev_nb_lnum)
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! s:do_handle_inside_fn(pair_lnum, _pair_col, lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if a:pair_lnum && a:pair_lnum != a:lnum
|
||||
if elixir#indent#contains(a:text, '->')
|
||||
return indent(a:pair_lnum) + &sw
|
||||
else
|
||||
if elixir#indent#ends_with(a:prev_nb_text, '->', a:prev_nb_lnum)
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
else
|
||||
return indent(a:prev_nb_lnum)
|
||||
end
|
||||
end
|
||||
return s:do_handle_inside_pattern_match_block(a:pair_lnum, a:text, a:prev_nb_lnum, a:prev_nb_text)
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#do_handle_inside_square_brace(pair_lnum, pair_col, _lnum, _text, _prev_nb_lnum, _prev_nb_text)
|
||||
function! s:do_handle_inside_square_brace(pair_lnum, pair_col, _lnum, _text, _prev_nb_lnum, _prev_nb_text)
|
||||
" If in list...
|
||||
if a:pair_lnum != 0 || a:pair_col != 0
|
||||
let pair_text = getline(a:pair_lnum)
|
||||
@@ -298,24 +404,24 @@ function! elixir#indent#do_handle_inside_square_brace(pair_lnum, pair_col, _lnum
|
||||
if indent_pos != -1
|
||||
return indent_pos + a:pair_col
|
||||
else
|
||||
return indent(a:pair_lnum) + &sw
|
||||
return indent(a:pair_lnum) + s:sw()
|
||||
endif
|
||||
else
|
||||
return -1
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#do_handle_inside_curly_brace(pair_lnum, _pair_col, _lnum, _text, _prev_nb_lnum, _prev_nb_text)
|
||||
return indent(a:pair_lnum) + &sw
|
||||
function! s:do_handle_inside_curly_brace(pair_lnum, _pair_col, _lnum, _text, _prev_nb_lnum, _prev_nb_text)
|
||||
return indent(a:pair_lnum) + s:sw()
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#do_handle_inside_parens(pair_lnum, pair_col, _lnum, _text, prev_nb_lnum, prev_nb_text)
|
||||
function! s:do_handle_inside_parens(pair_lnum, pair_col, _lnum, _text, prev_nb_lnum, prev_nb_text)
|
||||
if a:pair_lnum
|
||||
if elixir#indent#ends_with(a:prev_nb_text, '(', a:prev_nb_lnum)
|
||||
return indent(a:prev_nb_lnum) + &sw
|
||||
if s:ends_with(a:prev_nb_text, '(', a:prev_nb_lnum)
|
||||
return indent(a:prev_nb_lnum) + s:sw()
|
||||
elseif a:pair_lnum == a:prev_nb_lnum
|
||||
" Align indent (e.g. "def add(a,")
|
||||
let pos = elixir#indent#find_last_pos(a:prev_nb_lnum, a:prev_nb_text, '[^(]\+,')
|
||||
let pos = s:find_last_pos(a:prev_nb_lnum, a:prev_nb_text, '[^(]\+,')
|
||||
if pos == -1
|
||||
return 0
|
||||
else
|
||||
@@ -330,14 +436,14 @@ function! elixir#indent#do_handle_inside_parens(pair_lnum, pair_col, _lnum, _tex
|
||||
endfunction
|
||||
|
||||
function! elixir#indent#handle_inside_generic_block(lnum, _text, prev_nb_lnum, prev_nb_text)
|
||||
let pair_lnum = searchpair(elixir#indent#keyword('do\|fn'), '', elixir#indent#keyword('end'), 'bW', "line('.') == ".a:lnum." || elixir#indent#is_string_or_comment(line('.'), col('.'))")
|
||||
let pair_lnum = searchpair(s:keyword('do\|fn'), '', s:keyword('end'), 'bW', "line('.') == ".a:lnum." || s:is_string_or_comment(line('.'), col('.'))", max([0, a:lnum - g:elixir_indent_max_lookbehind]))
|
||||
if pair_lnum
|
||||
" TODO: @jbodah 2017-03-29: this should probably be the case in *all*
|
||||
" blocks
|
||||
if elixir#indent#ends_with(a:prev_nb_text, ',', a:prev_nb_lnum)
|
||||
return indent(pair_lnum) + 2 * &sw
|
||||
if s:ends_with(a:prev_nb_text, ',', a:prev_nb_lnum)
|
||||
return indent(pair_lnum) + 2 * s:sw()
|
||||
else
|
||||
return indent(pair_lnum) + &sw
|
||||
return indent(pair_lnum) + s:sw()
|
||||
endif
|
||||
else
|
||||
return -1
|
||||
|
||||
382
autoload/elm.vim
Normal file
382
autoload/elm.vim
Normal file
@@ -0,0 +1,382 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
let s:errors = []
|
||||
|
||||
function! s:elmOracle(...) abort
|
||||
let l:project = finddir('elm-stuff/..', '.;')
|
||||
if len(l:project) == 0
|
||||
echoerr '`elm-stuff` not found! run `elm-package install` for autocomplete.'
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:filename = expand('%:p')
|
||||
|
||||
if a:0 == 0
|
||||
let l:oldiskeyword = &iskeyword
|
||||
" Some non obvious values used in 'iskeyword':
|
||||
" @ = all alpha
|
||||
" 48-57 = numbers 0 to 9
|
||||
" @-@ = character @
|
||||
" 124 = |
|
||||
setlocal iskeyword=@,48-57,@-@,_,-,~,!,#,$,%,&,*,+,=,<,>,/,?,.,\\,124,^
|
||||
let l:word = expand('<cword>')
|
||||
let &iskeyword = l:oldiskeyword
|
||||
else
|
||||
let l:word = a:1
|
||||
endif
|
||||
|
||||
let l:infos = elm#Oracle(l:filename, l:word)
|
||||
if v:shell_error != 0
|
||||
call elm#util#EchoError("elm-oracle failed:\n\n", l:infos)
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:d = split(l:infos, '\n')
|
||||
if len(l:d) > 0
|
||||
return elm#util#DecodeJSON(l:d[0])
|
||||
endif
|
||||
|
||||
return []
|
||||
endf
|
||||
|
||||
" Vim command to format Elm files with elm-format
|
||||
function! elm#Format() abort
|
||||
" check for elm-format
|
||||
if elm#util#CheckBin('elm-format', 'https://github.com/avh4/elm-format') ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
" save cursor position, folds and many other things
|
||||
let l:curw = {}
|
||||
try
|
||||
mkview!
|
||||
catch
|
||||
let l:curw = winsaveview()
|
||||
endtry
|
||||
|
||||
" save our undo file to be restored after we are done.
|
||||
let l:tmpundofile = tempname()
|
||||
exe 'wundo! ' . l:tmpundofile
|
||||
|
||||
" write current unsaved buffer to a temporary file
|
||||
let l:tmpname = tempname() . '.elm'
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
|
||||
" call elm-format on the temporary file
|
||||
let l:out = system('elm-format ' . l:tmpname . ' --output ' . l:tmpname)
|
||||
|
||||
" if there is no error
|
||||
if v:shell_error == 0
|
||||
try | silent undojoin | catch | endtry
|
||||
|
||||
" replace current file with temp file, then reload buffer
|
||||
let l:old_fileformat = &fileformat
|
||||
call rename(l:tmpname, expand('%'))
|
||||
silent edit!
|
||||
let &fileformat = l:old_fileformat
|
||||
let &syntax = &syntax
|
||||
elseif g:elm_format_fail_silently == 0
|
||||
call elm#util#EchoLater('EchoError', 'elm-format:', l:out)
|
||||
endif
|
||||
|
||||
" save our undo history
|
||||
silent! exe 'rundo ' . l:tmpundofile
|
||||
call delete(l:tmpundofile)
|
||||
|
||||
" restore our cursor/windows positions, folds, etc..
|
||||
if empty(l:curw)
|
||||
silent! loadview
|
||||
else
|
||||
call winrestview(l:curw)
|
||||
endif
|
||||
endf
|
||||
|
||||
" Query elm-oracle and echo the type and docs for the word under the cursor.
|
||||
function! elm#ShowDocs() abort
|
||||
" check for the elm-oracle binary
|
||||
if elm#util#CheckBin('elm-oracle', 'https://github.com/elmcast/elm-oracle') ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
let l:response = s:elmOracle()
|
||||
|
||||
if len(l:response) > 0
|
||||
let l:info = l:response[0]
|
||||
redraws! | echohl Identifier | echon l:info.fullName | echohl None | echon ' : ' | echohl Function | echon l:info.signature | echohl None | echon "\n\n" . l:info.comment
|
||||
else
|
||||
call elm#util#Echo('elm-oracle:', '...no match found')
|
||||
endif
|
||||
endf
|
||||
|
||||
" Query elm-oracle and open the docs for the word under the cursor.
|
||||
function! elm#BrowseDocs() abort
|
||||
" check for the elm-oracle binary
|
||||
if elm#util#CheckBin('elm-oracle', 'https://github.com/elmcast/elm-oracle') ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
let l:response = s:elmOracle()
|
||||
|
||||
if len(l:response) > 0
|
||||
let l:info = l:response[0]
|
||||
call elm#util#OpenBrowser(l:info.href)
|
||||
else
|
||||
call elm#util#Echo('elm-oracle:', '...no match found')
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! elm#Syntastic(input) abort
|
||||
let l:fixes = []
|
||||
|
||||
let l:bin = 'elm-make'
|
||||
let l:format = '--report=json'
|
||||
let l:input = shellescape(a:input)
|
||||
let l:output = '--output=' . shellescape(syntastic#util#DevNull())
|
||||
let l:command = l:bin . ' ' . l:format . ' ' . l:input . ' ' . l:output
|
||||
let l:reports = s:ExecuteInRoot(l:command)
|
||||
|
||||
for l:report in split(l:reports, '\n')
|
||||
if l:report[0] ==# '['
|
||||
for l:error in elm#util#DecodeJSON(l:report)
|
||||
if g:elm_syntastic_show_warnings == 0 && l:error.type ==? 'warning'
|
||||
else
|
||||
if a:input == l:error.file
|
||||
call add(s:errors, l:error)
|
||||
call add(l:fixes, {'filename': l:error.file,
|
||||
\'valid': 1,
|
||||
\'bufnr': bufnr('%'),
|
||||
\'type': (l:error.type ==? 'error') ? 'E' : 'W',
|
||||
\'lnum': l:error.region.start.line,
|
||||
\'col': l:error.region.start.column,
|
||||
\'text': l:error.overview})
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:fixes
|
||||
endf
|
||||
|
||||
function! elm#Build(input, output, show_warnings) abort
|
||||
let s:errors = []
|
||||
let l:fixes = []
|
||||
let l:rawlines = []
|
||||
|
||||
let l:bin = 'elm-make'
|
||||
let l:format = '--report=json'
|
||||
let l:input = shellescape(a:input)
|
||||
let l:output = '--output=' . shellescape(a:output)
|
||||
let l:command = l:bin . ' ' . l:format . ' ' . l:input . ' ' . l:output
|
||||
let l:reports = s:ExecuteInRoot(l:command)
|
||||
|
||||
for l:report in split(l:reports, '\n')
|
||||
if l:report[0] ==# '['
|
||||
for l:error in elm#util#DecodeJSON(l:report)
|
||||
if a:show_warnings == 0 && l:error.type ==? 'warning'
|
||||
else
|
||||
call add(s:errors, l:error)
|
||||
call add(l:fixes, {'filename': l:error.file,
|
||||
\'valid': 1,
|
||||
\'type': (l:error.type ==? 'error') ? 'E' : 'W',
|
||||
\'lnum': l:error.region.start.line,
|
||||
\'col': l:error.region.start.column,
|
||||
\'text': l:error.overview})
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
call add(l:rawlines, l:report)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let l:details = join(l:rawlines, "\n")
|
||||
let l:lines = split(l:details, "\n")
|
||||
if !empty(l:lines)
|
||||
let l:overview = l:lines[0]
|
||||
else
|
||||
let l:overview = ''
|
||||
endif
|
||||
|
||||
if l:details ==# '' || l:details =~? '^Successfully.*'
|
||||
else
|
||||
call add(s:errors, {'overview': l:details, 'details': l:details})
|
||||
call add(l:fixes, {'filename': expand('%', 1),
|
||||
\'valid': 1,
|
||||
\'type': 'E',
|
||||
\'lnum': 0,
|
||||
\'col': 0,
|
||||
\'text': l:overview})
|
||||
endif
|
||||
|
||||
return l:fixes
|
||||
endf
|
||||
|
||||
" Make the given file, or the current file if none is given.
|
||||
function! elm#Make(...) abort
|
||||
if elm#util#CheckBin('elm-make', 'http://elm-lang.org/install') ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
call elm#util#Echo('elm-make:', 'building...')
|
||||
|
||||
let l:input = (a:0 == 0) ? expand('%:p') : a:1
|
||||
let l:fixes = elm#Build(l:input, g:elm_make_output_file, g:elm_make_show_warnings)
|
||||
|
||||
if len(l:fixes) > 0
|
||||
call elm#util#EchoWarning('', 'found ' . len(l:fixes) . ' errors')
|
||||
|
||||
call setqflist(l:fixes, 'r')
|
||||
cwindow
|
||||
|
||||
if get(g:, 'elm_jump_to_error', 1)
|
||||
ll 1
|
||||
endif
|
||||
else
|
||||
call elm#util#EchoSuccess('', 'Sucessfully compiled')
|
||||
|
||||
call setqflist([])
|
||||
cwindow
|
||||
endif
|
||||
endf
|
||||
|
||||
" Show the detail of the current error in the quickfix window.
|
||||
function! elm#ErrorDetail() abort
|
||||
if !empty(filter(tabpagebuflist(), 'getbufvar(v:val, "&buftype") ==? "quickfix"'))
|
||||
exec ':copen'
|
||||
let l:linenr = line('.')
|
||||
exec ':wincmd p'
|
||||
if len(s:errors) > 0
|
||||
let l:detail = s:errors[l:linenr-1].details
|
||||
if l:detail ==# ''
|
||||
let l:detail = s:errors[l:linenr-1].overview
|
||||
endif
|
||||
echo l:detail
|
||||
endif
|
||||
endif
|
||||
endf
|
||||
|
||||
" Open the elm repl in a subprocess.
|
||||
function! elm#Repl() abort
|
||||
" check for the elm-repl binary
|
||||
if elm#util#CheckBin('elm-repl', 'http://elm-lang.org/install') ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
if has('nvim')
|
||||
term('elm-repl')
|
||||
else
|
||||
!elm-repl
|
||||
endif
|
||||
endf
|
||||
|
||||
function! elm#Oracle(filepath, word) abort
|
||||
let l:bin = 'elm-oracle'
|
||||
let l:filepath = shellescape(a:filepath)
|
||||
let l:word = shellescape(a:word)
|
||||
let l:command = l:bin . ' ' . l:filepath . ' ' . l:word
|
||||
return s:ExecuteInRoot(l:command)
|
||||
endfunction
|
||||
|
||||
let s:fullComplete = ''
|
||||
|
||||
" Complete the current token using elm-oracle
|
||||
function! elm#Complete(findstart, base) abort
|
||||
" a:base is unused, but the callback function for completion expects 2 arguments
|
||||
if a:findstart
|
||||
let l:line = getline('.')
|
||||
|
||||
let l:idx = col('.') - 1
|
||||
let l:start = 0
|
||||
while l:idx > 0 && l:line[l:idx - 1] =~# '[a-zA-Z0-9_\.]'
|
||||
if l:line[l:idx - 1] ==# '.' && l:start == 0
|
||||
let l:start = l:idx
|
||||
endif
|
||||
let l:idx -= 1
|
||||
endwhile
|
||||
|
||||
if l:start == 0
|
||||
let l:start = l:idx
|
||||
endif
|
||||
|
||||
let s:fullComplete = l:line[l:idx : col('.')-2]
|
||||
|
||||
return l:start
|
||||
else
|
||||
" check for the elm-oracle binary
|
||||
if elm#util#CheckBin('elm-oracle', 'https://github.com/elmcast/elm-oracle') ==# ''
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:res = []
|
||||
let l:response = s:elmOracle(s:fullComplete)
|
||||
|
||||
let l:detailed = get(g:, 'elm_detailed_complete', 0)
|
||||
|
||||
for l:r in l:response
|
||||
let l:menu = ''
|
||||
if l:detailed
|
||||
let l:menu = ': ' . l:r.signature
|
||||
endif
|
||||
call add(l:res, {'word': l:r.name, 'menu': l:menu})
|
||||
endfor
|
||||
|
||||
return l:res
|
||||
endif
|
||||
endf
|
||||
|
||||
" If the current buffer contains a consoleRunner, run elm-test with it.
|
||||
" Otherwise run elm-test in the root of your project which deafults to
|
||||
" running 'elm-test tests/TestRunner'.
|
||||
function! elm#Test() abort
|
||||
if elm#util#CheckBin('elm-test', 'https://github.com/rtfeldman/node-elm-test') ==# ''
|
||||
return
|
||||
endif
|
||||
|
||||
if match(getline(1, '$'), 'consoleRunner') < 0
|
||||
let l:out = s:ExecuteInRoot('elm-test')
|
||||
call elm#util#EchoSuccess('elm-test', l:out)
|
||||
else
|
||||
let l:filepath = shellescape(expand('%:p'))
|
||||
let l:out = s:ExecuteInRoot('elm-test ' . l:filepath)
|
||||
call elm#util#EchoSuccess('elm-test', l:out)
|
||||
endif
|
||||
endf
|
||||
|
||||
" Returns the closest parent with an elm-package.json file.
|
||||
function! elm#FindRootDirectory() abort
|
||||
let l:elm_root = getbufvar('%', 'elmRoot')
|
||||
if empty(l:elm_root)
|
||||
let l:current_file = expand('%:p')
|
||||
let l:dir_current_file = fnameescape(fnamemodify(l:current_file, ':h'))
|
||||
let l:match = findfile('elm-package.json', l:dir_current_file . ';')
|
||||
if empty(l:match)
|
||||
let l:elm_root = ''
|
||||
else
|
||||
let l:elm_root = fnamemodify(l:match, ':p:h')
|
||||
endif
|
||||
|
||||
if !empty(l:elm_root)
|
||||
call setbufvar('%', 'elmRoot', l:elm_root)
|
||||
endif
|
||||
endif
|
||||
return l:elm_root
|
||||
endfunction
|
||||
|
||||
" Executes a command in the project directory.
|
||||
function! s:ExecuteInRoot(cmd) abort
|
||||
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
let l:current_dir = getcwd()
|
||||
let l:root_dir = elm#FindRootDirectory()
|
||||
|
||||
try
|
||||
execute l:cd . fnameescape(l:root_dir)
|
||||
let l:out = system(a:cmd)
|
||||
finally
|
||||
execute l:cd . fnameescape(l:current_dir)
|
||||
endtry
|
||||
|
||||
return l:out
|
||||
endfunction
|
||||
|
||||
endif
|
||||
@@ -1,12 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
" System IO
|
||||
|
||||
" Craft a system command and run it, returning the output.
|
||||
function! elm#io#system(program, args)
|
||||
let cmd ="which " . a:program . " && " . a:program . " " . a:args
|
||||
return system(cmd)
|
||||
endfunction
|
||||
|
||||
|
||||
endif
|
||||
178
autoload/elm/util.vim
Normal file
178
autoload/elm/util.vim
Normal file
@@ -0,0 +1,178 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
" IsWin returns 1 if current OS is Windows or 0 otherwise
|
||||
fun! elm#util#IsWin() abort
|
||||
let l:win = ['win16', 'win32', 'win32unix', 'win64', 'win95']
|
||||
for l:w in l:win
|
||||
if (has(l:w))
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endf
|
||||
|
||||
fun! elm#util#CheckBin(bin, url) abort
|
||||
let l:binpath = substitute(a:bin, '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||
|
||||
if executable(l:binpath)
|
||||
return l:binpath
|
||||
endif
|
||||
|
||||
call elm#util#EchoWarning('elm-vim:', 'could not find ' . l:binpath . ' [' . a:url . ']')
|
||||
|
||||
return ''
|
||||
endf
|
||||
|
||||
" Determines the browser command to use
|
||||
fun! s:get_browser_command() abort
|
||||
let l:elm_browser_command = get(g:, 'elm_browser_command', '')
|
||||
if l:elm_browser_command ==? ''
|
||||
if elm#util#IsWin()
|
||||
let l:elm_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%'
|
||||
elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin'
|
||||
let l:elm_browser_command = 'open %URL%'
|
||||
elseif executable('xdg-open')
|
||||
let l:elm_browser_command = 'xdg-open %URL%'
|
||||
elseif executable('firefox')
|
||||
let l:elm_browser_command = 'firefox %URL% &'
|
||||
else
|
||||
let l:elm_browser_command = ''
|
||||
endif
|
||||
endif
|
||||
return l:elm_browser_command
|
||||
endf
|
||||
|
||||
" OpenBrowser opens a url in the default browser
|
||||
fun! elm#util#OpenBrowser(url) abort
|
||||
let l:cmd = s:get_browser_command()
|
||||
if len(l:cmd) == 0
|
||||
redraw
|
||||
echohl WarningMsg
|
||||
echo "It seems that you don't have general web browser. Open URL below."
|
||||
echohl None
|
||||
echo a:url
|
||||
return
|
||||
endif
|
||||
if l:cmd =~? '^!'
|
||||
let l:cmd = substitute(l:cmd, '%URL%', '\=shellescape(a:url)', 'g')
|
||||
silent! exec l:cmd
|
||||
elseif l:cmd =~# '^:[A-Z]'
|
||||
let l:cmd = substitute(l:cmd, '%URL%', '\=a:url', 'g')
|
||||
exec l:cmd
|
||||
else
|
||||
let l:cmd = substitute(l:cmd, '%URL%', '\=shellescape(a:url)', 'g')
|
||||
call system(l:cmd)
|
||||
endif
|
||||
endf
|
||||
|
||||
" DecodeJSON decodes a string of json into a viml object
|
||||
fun! elm#util#DecodeJSON(s) abort
|
||||
let l:true = 1
|
||||
let l:false = 0
|
||||
let l:null = 0
|
||||
return eval(a:s)
|
||||
endf
|
||||
|
||||
" Remove ANSI escape characters used for highlighting purposes
|
||||
fun! s:strip_color(msg) abort
|
||||
return substitute(a:msg, '\e\[[0-9;]\+[mK]', '', 'g')
|
||||
endf
|
||||
|
||||
" Print functions
|
||||
fun! elm#util#Echo(title, msg) abort
|
||||
redraws! | echon a:title . ' ' | echohl Identifier | echon s:strip_color(a:msg) | echohl None
|
||||
endf
|
||||
|
||||
fun! elm#util#EchoSuccess(title, msg) abort
|
||||
redraws! | echon a:title . ' ' | echohl Function | echon s:strip_color(a:msg) | echohl None
|
||||
endf
|
||||
|
||||
fun! elm#util#EchoWarning(title, msg) abort
|
||||
redraws! | echon a:title . ' ' | echohl WarningMsg | echon s:strip_color(a:msg) | echohl None
|
||||
endf
|
||||
|
||||
fun! elm#util#EchoError(title, msg) abort
|
||||
redraws! | echon a:title . ' ' | echohl ErrorMsg | echon s:strip_color(a:msg) | echohl None
|
||||
endf
|
||||
|
||||
fun! elm#util#EchoLater(func_name, title, msg) abort
|
||||
let s:echo_func_name = a:func_name
|
||||
let s:echo_title = a:title
|
||||
let s:echo_msg = a:msg
|
||||
endf
|
||||
|
||||
fun! elm#util#EchoStored() abort
|
||||
if exists('s:echo_func_name') && exists('s:echo_title') && exists('s:echo_msg')
|
||||
call elm#util#{s:echo_func_name}(s:echo_title, s:echo_msg)
|
||||
unlet s:echo_func_name
|
||||
unlet s:echo_title
|
||||
unlet s:echo_msg
|
||||
endif
|
||||
endf
|
||||
|
||||
function! elm#util#GoToModule(name)
|
||||
if empty(a:name) | return | endif
|
||||
if empty(matchstr(a:name, '^Native\.'))
|
||||
let l:extension = '.elm'
|
||||
else
|
||||
let l:extension = '.js'
|
||||
endif
|
||||
let l:rel_path = substitute(a:name, '\.', '/', 'g') . l:extension
|
||||
let l:root = elm#FindRootDirectory()
|
||||
|
||||
let l:module_file = s:findLocalModule(l:rel_path, l:root)
|
||||
if !filereadable(l:module_file)
|
||||
let l:module_file = s:findDependencyModule(l:rel_path, l:root)
|
||||
endif
|
||||
|
||||
if filereadable(l:module_file)
|
||||
exec 'edit ' . fnameescape(l:module_file)
|
||||
else
|
||||
return s:error("Can't find module \"" . a:name . "\"")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:findLocalModule(rel_path, root)
|
||||
let l:package_json = a:root . '/elm-package.json'
|
||||
if exists('*json_decode')
|
||||
let l:package = json_decode(readfile(l:package_json))
|
||||
let l:source_roots = l:package['source-directories']
|
||||
else
|
||||
" This is a fallback for vim's which do not support json_decode.
|
||||
" It simply only looks in the 'src' subdirectory and fails otherwise.
|
||||
let l:source_roots = ['src']
|
||||
end
|
||||
for l:source_root in l:source_roots
|
||||
let l:file_path = a:root . '/' . l:source_root . '/' . a:rel_path
|
||||
if !filereadable(l:file_path)
|
||||
continue
|
||||
endif
|
||||
return l:file_path
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:findDependencyModule(rel_path, root)
|
||||
" If we are a dependency ourselves, we need to check our siblings.
|
||||
" This is because elm package doesn't install dependencies recursively.
|
||||
let l:root = substitute(a:root, '\/elm-stuff/packages.\+$', '', '')
|
||||
|
||||
" We naively craws the dependencies dir for any fitting module name.
|
||||
" If it exists, we'll find it. If multiple filenames match,
|
||||
" there's a chance we return the wrong one.
|
||||
let l:module_paths = glob(l:root . '/elm-stuff/packages/**/' . a:rel_path, 0, 1)
|
||||
if len(l:module_paths) > 0
|
||||
return l:module_paths[0]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Using the built-in :echoerr prints a stacktrace, which isn't that nice.
|
||||
" From: https://github.com/moll/vim-node/blob/master/autoload/node.vim
|
||||
function! s:error(msg)
|
||||
echohl ErrorMsg
|
||||
echomsg a:msg
|
||||
echohl NONE
|
||||
let v:errmsg = a:msg
|
||||
endfunction
|
||||
|
||||
endif
|
||||
@@ -1,6 +1,7 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
|
||||
|
||||
function! fish#Indent()
|
||||
let l:shiftwidth = shiftwidth()
|
||||
let l:prevlnum = prevnonblank(v:lnum - 1)
|
||||
if l:prevlnum ==# 0
|
||||
return 0
|
||||
@@ -8,15 +9,15 @@ function! fish#Indent()
|
||||
let l:indent = 0
|
||||
let l:prevline = getline(l:prevlnum)
|
||||
if l:prevline =~# '\v^\s*switch>'
|
||||
let l:indent = &shiftwidth * 2
|
||||
let l:indent = l:shiftwidth * 2
|
||||
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
|
||||
let l:indent = &shiftwidth
|
||||
let l:indent = l:shiftwidth
|
||||
endif
|
||||
let l:line = getline(v:lnum)
|
||||
if l:line =~# '\v^\s*end>'
|
||||
return indent(v:lnum) - (l:indent ==# 0 ? &shiftwidth : l:indent)
|
||||
return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent)
|
||||
elseif l:line =~# '\v^\s*%(case|else)>'
|
||||
return indent(v:lnum) - &shiftwidth
|
||||
return indent(v:lnum) - l:shiftwidth
|
||||
endif
|
||||
return indent(l:prevlnum) + l:indent
|
||||
endfunction
|
||||
|
||||
188
autoload/julia.vim
Normal file
188
autoload/julia.vim
Normal file
@@ -0,0 +1,188 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
||||
|
||||
function! julia#set_syntax_version(jvers)
|
||||
if &filetype != "julia"
|
||||
echo "Not a Julia file"
|
||||
return
|
||||
endif
|
||||
syntax clear
|
||||
let b:julia_syntax_version = a:jvers
|
||||
set filetype=julia
|
||||
endfunction
|
||||
|
||||
function! julia#toggle_deprecated_syntax()
|
||||
if &filetype != "julia"
|
||||
echo "Not a Julia file"
|
||||
return
|
||||
endif
|
||||
syntax clear
|
||||
let hd = get(b:, "julia_syntax_highlight_deprecated",
|
||||
\ get(g:, "julia_syntax_highlight_deprecated", 0))
|
||||
let b:julia_syntax_highlight_deprecated = hd ? 0 : 1
|
||||
set filetype=julia
|
||||
if b:julia_syntax_highlight_deprecated
|
||||
echo "Highlighting of deprecated syntax enabled"
|
||||
else
|
||||
echo "Highlighting of deprecated syntax disabled"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if exists("loaded_matchit")
|
||||
|
||||
function! julia#toggle_function_blockassign()
|
||||
let sav_pos = getcurpos()
|
||||
let l = getline('.')
|
||||
let c = match(l, '\C\m\<function\s\+.\+(')
|
||||
if c != -1
|
||||
return julia#function_block2assign()
|
||||
endif
|
||||
let c = match(l, '\C\m)\%(::\S\+\)\?\%(\s\+where\s\+.*\)\?\s*=\s*')
|
||||
if c == -1
|
||||
echohl WarningMsg | echo "Not on a function definition or assignment line" | echohl None
|
||||
return
|
||||
endif
|
||||
return julia#function_assign2block()
|
||||
endfunction
|
||||
|
||||
function! julia#function_block2assign()
|
||||
let sav_pos = getcurpos()
|
||||
let l = getline('.')
|
||||
let c = match(l, '\C\m\<function\s\+.\+(')
|
||||
if c == -1
|
||||
echohl WarningMsg | echo "Not on a function definition line" | echohl None
|
||||
return
|
||||
endif
|
||||
let fpos = copy(sav_pos)
|
||||
let fpos[2] = c+1
|
||||
call setpos('.', fpos)
|
||||
normal %
|
||||
if line('.') != fpos[1]+2 || match(getline('.'), '\C\m^\s*end\s*$') == -1
|
||||
echohl WarningMsg | echo "Only works with 3-lines functions" | echohl None
|
||||
call setpos('.', sav_pos)
|
||||
return
|
||||
endif
|
||||
call setpos('.', fpos)
|
||||
normal! f(
|
||||
normal %
|
||||
while line('.') == fpos[1] && match(l[col('.')-1:], '\C\m)(') == 0
|
||||
normal! l
|
||||
normal %
|
||||
endwhile
|
||||
if line('.') != fpos[1] || match(l[(col('.')-1):], '\C\m)\%(::\S\+\)\?\%(\s\+where\s\+.*\)\?\s*$') != 0
|
||||
echohl WarningMsg | echo "Unrecognized function definition format" | echohl None
|
||||
call setpos('.', sav_pos)
|
||||
return
|
||||
endif
|
||||
|
||||
call setpos('.', fpos)
|
||||
normal! dwA = J
|
||||
if match(getline('.')[(col('.')-1):], '\C\mreturn\>') == 0
|
||||
normal! dw
|
||||
endif
|
||||
if match(getline('.')[(col('.')-1):], '\C\m\s*$') == 0
|
||||
normal! F=C= nothing
|
||||
endif
|
||||
normal! jddk^
|
||||
return
|
||||
endfunction
|
||||
|
||||
function! julia#function_assign2block()
|
||||
let sav_pos = getcurpos()
|
||||
let l = getline('.')
|
||||
let c = match(l, '\C\m)\%(::\S\+\)\?\%(\s\+where\s\+.*\)\?\s*=\s*')
|
||||
if c == -1
|
||||
echohl WarningMsg | echo "Not on a function assignment-definition line" | echohl None
|
||||
return
|
||||
endif
|
||||
normal ^
|
||||
while match(l[(col('.')-1):], '\%(\S\+\.\)*@') == 0
|
||||
normal! W
|
||||
endwhile
|
||||
normal! ifunction
|
||||
let l = getline('.')
|
||||
let c = match(l, '\C\m)\%(::\S\+\)\?\%(\s\+where\s\+.*\)\?\s*\zs=\s*')
|
||||
let eqpos = copy(sav_pos)
|
||||
let eqpos[2] = c+1
|
||||
call setpos('.', eqpos)
|
||||
normal! cw
|
||||
oend
|
||||
normal %
|
||||
s/\s*$// | noh
|
||||
return
|
||||
endfunction
|
||||
|
||||
|
||||
let s:nonid_chars = "\U01-\U07" . "\U0E-\U1F" .
|
||||
\ "\"#$'(,.:;=?@`\\U5B{" .
|
||||
\ "\U80-\UA1" . "\UA7\UA8\UAB\UAD\UAF\UB4" . "\UB6-\UB8" . "\UBB\UBF"
|
||||
|
||||
let s:nonidS_chars = "[:space:])\\U5D}" . s:nonid_chars
|
||||
|
||||
" the following excludes '!' since it can be used as an identifier,
|
||||
" and '$' since it can be used in interpolations
|
||||
" note that \U2D is '-'
|
||||
let s:uniop_chars = "+\\U2D~¬√∛∜"
|
||||
|
||||
let s:binop_chars = "=+\\U2D*/\\%÷^&|⊻<>≤≥≡≠≢∈∉⋅×∪∩⊆⊈⊂⊄⊊←→∋∌⊕⊖⊞⊟∘∧⊗⊘↑↓∨⊠±"
|
||||
|
||||
" the following is a list of all remainig valid operator chars,
|
||||
" but it's more efficient when expressed with ranges (see below)
|
||||
" let s:binop_chars_extra = "↔↚↛↠↣↦↮⇎⇏⇒⇔⇴⇶⇷⇸⇹⇺⇻⇼⇽⇾⇿⟵⟶⟷⟷⟹⟺⟻⟼⟽⟾⟿⤀⤁⤂⤃⤄⤅⤆⤇⤌⤍⤎⤏⤐⤑⤔⤕⤖⤗⤘⤝⤞⤟⤠⥄⥅⥆⥇⥈⥊⥋⥎⥐⥒⥓⥖⥗⥚⥛⥞⥟⥢⥤⥦⥧⥨⥩⥪⥫⥬⥭⥰⧴⬱⬰⬲⬳⬴⬵⬶⬷⬸⬹⬺⬻⬼⬽⬾⬿⭀⭁⭂⭃⭄⭇⭈⭉⭊⭋⭌←→" .
|
||||
" \ "∝∊∍∥∦∷∺∻∽∾≁≃≄≅≆≇≈≉≊≋≌≍≎≐≑≒≓≔≕≖≗≘≙≚≛≜≝≞≟≣≦≧≨≩≪≫≬≭≮≯≰≱≲≳≴≵≶≷≸≹≺≻≼≽≾≿⊀⊁⊃⊅⊇⊉⊋⊏⊐⊑⊒⊜⊩⊬⊮⊰⊱⊲⊳⊴⊵⊶⊷⋍⋐⋑⋕⋖⋗⋘⋙⋚⋛⋜⋝⋞⋟⋠⋡⋢⋣⋤⋥⋦⋧⋨⋩⋪⋫⋬⋭⋲⋳⋴⋵⋶⋷⋸⋹⋺⋻⋼⋽⋾⋿⟈⟉⟒⦷⧀⧁⧡⧣⧤⧥⩦⩧⩪⩫⩬⩭⩮⩯⩰⩱⩲⩳⩴⩵⩶⩷⩸⩹⩺⩻⩼⩽⩾⩿⪀⪁⪂⪃⪄⪅⪆⪇⪈⪉⪊⪋⪌⪍⪎⪏⪐⪑⪒⪓⪔⪕⪖⪗⪘⪙⪚⪛⪜⪝⪞⪟⪠⪡⪢⪣⪤⪥⪦⪧⪨⪩⪪⪫⪬⪭⪮⪯⪰⪱⪲⪳⪴⪵⪶⪷⪸⪹⪺⪻⪼⪽⪾⪿⫀⫁⫂⫃⫄⫅⫆⫇⫈⫉⫊⫋⫌⫍⫎⫏⫐⫑⫒⫓⫔⫕⫖⫗⫘⫙⫷⫸⫹⫺⊢⊣" .
|
||||
" \ "⊔∓∔∸≂≏⊎⊽⋎⋓⧺⧻⨈⨢⨣⨤⨥⨦⨧⨨⨩⨪⨫⨬⨭⨮⨹⨺⩁⩂⩅⩊⩌⩏⩐⩒⩔⩖⩗⩛⩝⩡⩢⩣" .
|
||||
" \ "⊙⊚⊛⊡⊓∗∙∤⅋≀⊼⋄⋆⋇⋉⋊⋋⋌⋏⋒⟑⦸⦼⦾⦿⧶⧷⨇⨰⨱⨲⨳⨴⨵⨶⨷⨸⨻⨼⨽⩀⩃⩄⩋⩍⩎⩑⩓⩕⩘⩚⩜⩞⩟⩠⫛⊍▷⨝⟕⟖⟗" .
|
||||
" \ "⇵⟰⟱⤈⤉⤊⤋⤒⤓⥉⥌⥍⥏⥑⥔⥕⥘⥙⥜⥝⥠⥡⥣⥥⥮⥯↑↓"
|
||||
|
||||
" same as above, but with character ranges, for performance
|
||||
let s:binop_chars_extra = "\\U214B\\U2190-\\U2194\\U219A\\U219B\\U21A0\\U21A3\\U21A6\\U21AE\\U21CE\\U21CF\\U21D2\\U21D4\\U21F4-\\U21FF\\U2208-\\U220D\\U2213\\U2214\\U2217-\\U2219\\U221D\\U2224-\\U222A\\U2237\\U2238\\U223A\\U223B\\U223D\\U223E\\U2240-\\U228B\\U228D-\\U229C\\U229E-\\U22A3\\U22A9\\U22AC\\U22AE\\U22B0-\\U22B7\\U22BB-\\U22BD\\U22C4-\\U22C7\\U22C9-\\U22D3\\U22D5-\\U22ED\\U22F2-\\U22FF\\U25B7\\U27C8\\U27C9\\U27D1\\U27D2\\U27D5-\\U27D7\\U27F0\\U27F1\\U27F5-\\U27F7\\U27F7\\U27F9-\\U27FF\\U2900-\\U2918\\U291D-\\U2920\\U2944-\\U2970\\U29B7\\U29B8\\U29BC\\U29BE-\\U29C1\\U29E1\\U29E3-\\U29E5\\U29F4\\U29F6\\U29F7\\U29FA\\U29FB\\U2A07\\U2A08\\U2A1D\\U2A22-\\U2A2E\\U2A30-\\U2A3D\\U2A40-\\U2A45\\U2A4A-\\U2A58\\U2A5A-\\U2A63\\U2A66\\U2A67\\U2A6A-\\U2AD9\\U2ADB\\U2AF7-\\U2AFA\\U2B30-\\U2B44\\U2B47-\\U2B4C\\UFFE9-\\UFFEC"
|
||||
|
||||
" a Julia identifier, sort of
|
||||
let s:idregex = '[^' . s:nonidS_chars . '0-9!' . s:uniop_chars . s:binop_chars . '][^' . s:nonidS_chars . s:uniop_chars . s:binop_chars . s:binop_chars_extra . ']*'
|
||||
|
||||
let s:operators = '\%(' . '\.\%([-+*/^÷%|&!]\|//\|\\\|<<\|>>>\?\)\?=' .
|
||||
\ '\|' . '[:$<>]=\|||\|&&\||>\|<|\|<:\|:>\|::\|<<\|>>>\?\|//\|[-=]>\|\.\{3\}' .
|
||||
\ '\|' . '[' . s:uniop_chars . '!$]' .
|
||||
\ '\|' . '\.\?[' . s:binop_chars . s:binop_chars_extra . ']' .
|
||||
\ '\)'
|
||||
|
||||
function! julia#idundercursor()
|
||||
" TODO...
|
||||
let w = expand('<cword>')
|
||||
" let [l,c] = [line('.'),col('.')]
|
||||
" let ll = getline(l)
|
||||
return w
|
||||
endfunction
|
||||
|
||||
function! julia#gotodefinition()
|
||||
let w = julia#idundercursor()
|
||||
if empty(w)
|
||||
return ''
|
||||
endif
|
||||
let [l,c] = [line('.'),col('.')]
|
||||
let st = map(synstack(l,c), 'synIDattr(v:val, "name")')
|
||||
let n = len(st)
|
||||
if n > 0 && st[-1] =~# '^julia\%(\%(Range\|Ternary\|CTrans\)\?Operator\|\%(Possible\)\?SymbolS\?\|\%(Bl\|Rep\)\?Keyword\|Conditional\|ParDelim\|Char\|Colon\|Typedef\|Number\|Float\|Const\%(Generic\|Bool\)\|ComplexUnit\|\%(Special\|\%(Octal\|Hex\)Escape\)Char\|UniChar\%(Small\|Large\)\|Comment[LM]\|Todo\|Semicolon\)$'
|
||||
return ''
|
||||
endif
|
||||
|
||||
let comprehension = 0
|
||||
let indollar = 0
|
||||
for i in range(n-1, 0, -1)
|
||||
if st[i] =~# '^juliaDollar\%(Var\|Par\|SqBra\)$'
|
||||
let indollar = 1
|
||||
endif
|
||||
if !indollar && st[i] =~# '^julia\%(\a*String\|QuotedParBlockS\?\)$'
|
||||
return ''
|
||||
endif
|
||||
if st[i] =~# '^julia\%(ParBlock\%(InRange\)\?\|SqBraBlock\|\%(Dollar\|StringVars\)\%(Par\|SqBra\)\)$'
|
||||
let comprehension = 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
let s1 = search('\C\<' . w . '\s*=[^=]', 'bcWzs')
|
||||
|
||||
return
|
||||
endfunction
|
||||
|
||||
endif
|
||||
|
||||
798
autoload/julia_blocks.vim
Normal file
798
autoload/julia_blocks.vim
Normal file
@@ -0,0 +1,798 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
||||
|
||||
" Facilities for moving around Julia blocks (e.g. if/end, function/end etc.)
|
||||
" (AKA a collection of horrible hacks)
|
||||
|
||||
let s:default_mappings = {
|
||||
\ "moveblock_n" : "]]",
|
||||
\ "moveblock_N" : "][",
|
||||
\ "moveblock_p" : "[[",
|
||||
\ "moveblock_P" : "[]",
|
||||
\
|
||||
\ "move_n" : "]j",
|
||||
\ "move_N" : "]J",
|
||||
\ "move_p" : "[j",
|
||||
\ "move_P" : "[J",
|
||||
\
|
||||
\ "select_a" : "aj",
|
||||
\ "select_i" : "ij",
|
||||
\
|
||||
\ "whereami" : "",
|
||||
\ }
|
||||
|
||||
function! s:getmapchars(function)
|
||||
if exists("g:julia_blocks_mappings") && has_key(g:julia_blocks_mappings, a:function)
|
||||
return s:escape(g:julia_blocks_mappings[a:function])
|
||||
else
|
||||
return s:escape(s:default_mappings[a:function])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:map_move(function, toend, backwards)
|
||||
let chars = s:getmapchars(a:function)
|
||||
if empty(chars)
|
||||
return
|
||||
endif
|
||||
let fn = "julia_blocks#" . a:function
|
||||
let lhs = "<buffer> <nowait> <silent> " . chars . " "
|
||||
let cnt = ":<C-U>let b:jlblk_count=v:count1"
|
||||
exe "nnoremap " . lhs . cnt
|
||||
\ . " <Bar> call " . fn . "()<CR>"
|
||||
exe "onoremap " . lhs . cnt
|
||||
\ . "<CR><Esc>:call julia_blocks#owrapper_move(v:operator, \"" . fn . "\", " . a:toend . ", " . a:backwards . ")<CR>"
|
||||
exe "xnoremap " . lhs . cnt
|
||||
\ . "<CR>gv<Esc>:call julia_blocks#vwrapper_move(\"" . fn . "\")<CR>"
|
||||
let b:jlblk_mapped[a:function] = 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#owrapper_move(oper, function, toend, backwards)
|
||||
let F = function(a:function)
|
||||
|
||||
let save_redraw = &lazyredraw
|
||||
let save_select = &selection
|
||||
|
||||
let restore_cmds = "\<Esc>"
|
||||
\ . ":let &l:selection = \"" . save_select . "\"\<CR>"
|
||||
\ . ":let &l:lazyredraw = " . save_redraw . "\<CR>"
|
||||
\ . ":\<BS>"
|
||||
|
||||
setlocal lazyredraw
|
||||
|
||||
let start_pos = getpos('.')
|
||||
let b:jlblk_abort_calls_esc = 0
|
||||
call F()
|
||||
let b:jlblk_abort_calls_esc = 1
|
||||
let end_pos = getpos('.')
|
||||
if start_pos == end_pos
|
||||
call feedkeys(restore_cmds, 'n')
|
||||
endif
|
||||
|
||||
let &l:selection = "inclusive"
|
||||
if a:backwards || !a:toend
|
||||
let &l:selection = "exclusive"
|
||||
endif
|
||||
if a:toend && a:backwards
|
||||
let end_pos[2] += 1
|
||||
endif
|
||||
|
||||
if s:compare_pos(start_pos, end_pos) > 0
|
||||
let [start_pos, end_pos] = [end_pos, start_pos]
|
||||
endif
|
||||
|
||||
call setpos("'<", start_pos)
|
||||
call setpos("'>", end_pos)
|
||||
|
||||
" NOTE: the 'c' operator behaves differently, for mysterious reasons. We
|
||||
" simulate it with 'd' followed by 'i' instead
|
||||
call feedkeys("gv" . (a:oper == "c" ? "d" : a:oper) . restore_cmds . (a:oper == "c" ? "i" : ""), 'n')
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#vwrapper_move(function)
|
||||
let F = function(a:function)
|
||||
|
||||
let s = getpos('.')
|
||||
let b1 = getpos("'<")
|
||||
let b2 = getpos("'>")
|
||||
|
||||
let b = b1 == s ? b2 : b1
|
||||
call setpos('.', s)
|
||||
let b:jlblk_abort_calls_esc = 0
|
||||
call F()
|
||||
let b:jlblk_abort_calls_esc = 1
|
||||
let e = getpos('.')
|
||||
call setpos('.', b)
|
||||
exe "normal " . visualmode()
|
||||
call setpos('.', e)
|
||||
endfunction
|
||||
|
||||
function! s:unmap(function)
|
||||
if !get(b:jlblk_mapped, a:function, 0)
|
||||
return
|
||||
endif
|
||||
let chars = s:getmapchars(a:function)
|
||||
if empty(chars)
|
||||
" shouldn't happen
|
||||
return
|
||||
endif
|
||||
let mapids = a:function =~# "^move" ? ["n", "x", "o"] :
|
||||
\ a:function =~# "^select" ? ["x", "o"] :
|
||||
\ ["n"]
|
||||
let fn = "julia_blocks#" . a:function
|
||||
let cmd = "<buffer> " . chars
|
||||
for m in mapids
|
||||
exe m . "unmap " . cmd
|
||||
endfor
|
||||
let b:jlblk_mapped[a:function] = 0
|
||||
endfunction
|
||||
|
||||
function! s:escape(chars)
|
||||
let c = a:chars
|
||||
let c = substitute(c, '|', '<Bar>', 'g')
|
||||
return c
|
||||
endfunction
|
||||
|
||||
function! s:map_select(function)
|
||||
let chars = s:getmapchars(a:function)
|
||||
if empty(chars)
|
||||
return
|
||||
endif
|
||||
let fn = "julia_blocks#" . a:function
|
||||
let lhs = "<buffer> <nowait> <silent> " . chars . " "
|
||||
let cnt = ":<C-U>let b:jlblk_inwrapper=1<CR>:let b:jlblk_count=max([v:prevcount,1])<CR>"
|
||||
exe "onoremap " . lhs . "<Esc>" . cnt
|
||||
\ . ":call julia_blocks#owrapper_select(v:operator, \"" . fn . "\")<CR>"
|
||||
exe "xnoremap " . lhs . cnt
|
||||
\ . ":call julia_blocks#vwrapper_select(\"" . fn . "\")<CR>"
|
||||
let b:jlblk_mapped[a:function] = 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#owrapper_select(oper, function) ", toend, backwards)
|
||||
let F = function(a:function)
|
||||
|
||||
let save_redraw = &lazyredraw
|
||||
let save_select = &selection
|
||||
|
||||
let restore_cmds = "\<Esc>"
|
||||
\ . ":let &l:selection = \"" . save_select . "\"\<CR>"
|
||||
\ . ":let &l:lazyredraw = " . save_redraw . "\<CR>"
|
||||
\ . ":\<BS>"
|
||||
|
||||
setlocal lazyredraw
|
||||
|
||||
let b:jlblk_abort_calls_esc = 0
|
||||
let retF = F()
|
||||
let b:jlblk_abort_calls_esc = 1
|
||||
if empty(retF)
|
||||
let b:jlblk_inwrapper = 0
|
||||
call feedkeys(restore_cmds, 'n')
|
||||
return
|
||||
end
|
||||
let [start_pos, end_pos] = retF
|
||||
|
||||
if start_pos == end_pos
|
||||
call feedkeys(restore_cmds, 'n')
|
||||
endif
|
||||
|
||||
let &l:selection = "inclusive"
|
||||
|
||||
call setpos("'<", start_pos)
|
||||
call setpos("'>", end_pos)
|
||||
|
||||
let b:jlblk_inwrapper = 0
|
||||
" NOTE: the 'c' operator behaves differently, for mysterious reasons. We
|
||||
" simulate it with 'd' followed by 'i' instead
|
||||
call feedkeys("gv" . (a:oper == "c" ? "d" : a:oper) . restore_cmds . (a:oper == "c" ? "i" : ""), 'n')
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#vwrapper_select(function)
|
||||
let F = function(a:function)
|
||||
|
||||
let b:jlblk_abort_calls_esc = 0
|
||||
let retF = F()
|
||||
let b:jlblk_abort_calls_esc = 1
|
||||
if empty(retF)
|
||||
let b:jlblk_inwrapper = 0
|
||||
return
|
||||
end
|
||||
let [start_pos, end_pos] = retF
|
||||
call setpos("'<", start_pos)
|
||||
call setpos("'>", end_pos)
|
||||
normal! gv
|
||||
let b:jlblk_inwrapper = 0
|
||||
endfunction
|
||||
|
||||
function! s:map_aux(function)
|
||||
let chars = s:getmapchars(a:function)
|
||||
if empty(chars)
|
||||
return
|
||||
endif
|
||||
let fn = "julia_blocks#" . a:function
|
||||
let lhs = "<buffer> <nowait> <silent> " . chars . " "
|
||||
exe "nnoremap " . lhs . ":<C-U>echo " . fn . "()<CR>"
|
||||
let b:jlblk_mapped[a:function] = 1
|
||||
endfunction
|
||||
|
||||
let s:julia_blocks_functions = {
|
||||
\ "moveblock_N": [1, 0],
|
||||
\ "moveblock_n": [0, 0],
|
||||
\ "moveblock_p": [0, 1],
|
||||
\ "moveblock_P": [1, 1],
|
||||
\
|
||||
\ "move_N": [1, 0],
|
||||
\ "move_n": [0, 0],
|
||||
\ "move_p": [0, 1],
|
||||
\ "move_P": [1, 1],
|
||||
\
|
||||
\ "select_a": [],
|
||||
\ "select_i": [],
|
||||
\
|
||||
\ "whereami": [],
|
||||
\ }
|
||||
|
||||
function! julia_blocks#init_mappings()
|
||||
let b:jlblk_mapped = {}
|
||||
for f in keys(s:julia_blocks_functions)
|
||||
if f =~# "^move"
|
||||
let [te, bw] = s:julia_blocks_functions[f]
|
||||
call s:map_move(f, te, bw)
|
||||
elseif f =~# "^select"
|
||||
call s:map_select(f)
|
||||
else
|
||||
call s:map_aux(f)
|
||||
endif
|
||||
endfor
|
||||
call julia_blocks#select_reset()
|
||||
augroup JuliaBlocks
|
||||
au!
|
||||
au InsertEnter *.jl call julia_blocks#select_reset()
|
||||
au CursorMoved *.jl call s:cursor_moved()
|
||||
augroup END
|
||||
|
||||
" we would need some autocmd event associated with exiting from
|
||||
" visual mode, but there isn't any, so we resort to this crude
|
||||
" hack
|
||||
" ACTUALLY this creates more problems than it solves, so the crude hack
|
||||
" is just disabled
|
||||
"vnoremap <buffer><silent><unique> <Esc> <Esc>:call julia_blocks#select_reset()<CR>
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#remove_mappings()
|
||||
if exists("b:jlblk_mapped")
|
||||
for f in keys(s:julia_blocks_functions)
|
||||
call s:unmap(f)
|
||||
endfor
|
||||
endif
|
||||
unlet! b:jlblk_save_pos b:jlblk_view b:jlblk_count b:jlblk_abort_calls_esc
|
||||
unlet! b:jlblk_inwrapper b:jlblk_did_select b:jlblk_doing_select
|
||||
unlet! b:jlblk_last_start_pos b:jlblk_last_end_pos b:jlblk_last_mode
|
||||
augroup JuliaBlocks
|
||||
au!
|
||||
augroup END
|
||||
augroup! JuliaBlocks
|
||||
let md = maparg("<Esc>", "x", 0, 1)
|
||||
if !empty(md) && md["buffer"]
|
||||
vunmap <buffer> <Esc>
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:restore_view()
|
||||
"redraw! " would ensure correct behaviour, but is annoying
|
||||
let pos = getpos('.')
|
||||
if pos == b:jlblk_save_pos
|
||||
call winrestview(b:jlblk_view)
|
||||
return
|
||||
endif
|
||||
let oldtopline = b:jlblk_view["topline"]
|
||||
let newtopline = winsaveview()["topline"]
|
||||
let l = pos[1]
|
||||
if l >= oldtopline + &l:scrolloff && l <= oldtopline + winheight(0) - 1 - &l:scrolloff
|
||||
if newtopline > oldtopline
|
||||
exe ":normal! " . (newtopline - oldtopline) . "\<C-Y>"
|
||||
elseif newtopline < oldtopline
|
||||
exe ":normal! " . (oldtopline - newtopline) . "\<C-E>"
|
||||
endif
|
||||
" these reduce the scrolling to the minimum (which is maybe not
|
||||
" standard ViM behaviour?)
|
||||
elseif newtopline < oldtopline && (l - newtopline - &l:scrolloff) > 0
|
||||
exe ":normal! " . (l - newtopline - &l:scrolloff) . "\<C-E>"
|
||||
elseif newtopline > oldtopline && (newtopline + &l:scrolloff - l) > 0
|
||||
exe ":normal! " . (l - newtopline - &l:scrolloff) . "\<C-E>"
|
||||
endif
|
||||
call setpos('.', pos) " make sure we didn't screw up
|
||||
" (since winsaveview may not be up to date)
|
||||
endfunction
|
||||
|
||||
function! s:abort()
|
||||
call setpos('.', b:jlblk_save_pos)
|
||||
call s:restore_view()
|
||||
if get(b:, "jlblk_abort_calls_esc", 1)
|
||||
call feedkeys("\<Esc>", 'n')
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:set_mark_tick(...)
|
||||
" This could be a one-liner:
|
||||
" call setpos("''", b:jlblk_save_pos)
|
||||
" but we want to append to the jumplist,
|
||||
" which setpos doesn't do
|
||||
let p = getpos('.')
|
||||
call setpos('.', b:jlblk_save_pos)
|
||||
normal! m'
|
||||
call setpos('.', p)
|
||||
endfunction
|
||||
|
||||
function! s:get_save_pos(...)
|
||||
if !exists("b:jlblk_save_pos") || (a:0 == 0) || (a:0 > 0 && a:1)
|
||||
let b:jlblk_save_pos = getpos('.')
|
||||
endif
|
||||
let b:jlblk_view = winsaveview()
|
||||
endfunction
|
||||
|
||||
function! s:on_end()
|
||||
return getline('.')[col('.')-1] =~# '\k' && expand("<cword>") =~# b:julia_end_keywords
|
||||
endfunction
|
||||
|
||||
function! s:on_begin()
|
||||
let [l,c] = [line('.'), col('.')]
|
||||
normal! ^
|
||||
let patt = '\%<'.(c+1).'c\(' . b:julia_begin_keywordsm . '\)\%>'.(c-1).'c'
|
||||
let n = search(patt, 'Wnc', l)
|
||||
call cursor(l, c)
|
||||
return n > 0
|
||||
endfunction
|
||||
|
||||
function! s:matchit()
|
||||
let lkj = exists(":lockjumps") == 2 ? "lockjumps " : ""
|
||||
exe lkj . "normal %"
|
||||
endfunction
|
||||
|
||||
function! s:move_before_begin()
|
||||
call search(b:julia_begin_keywordsm, 'Wbc')
|
||||
normal! h
|
||||
endfunction
|
||||
|
||||
function! s:cycle_until_end()
|
||||
let pos = getpos('.')
|
||||
while !s:on_end()
|
||||
call s:matchit()
|
||||
let c = 0
|
||||
if getpos('.') == pos || c > 1000
|
||||
" shouldn't happen, but let's avoid infinite loops anyway
|
||||
return 0
|
||||
endif
|
||||
let c += 1
|
||||
endwhile
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:moveto_block_delim(toend, backwards, ...)
|
||||
let pattern = a:toend ? b:julia_end_keywords : b:julia_begin_keywordsm
|
||||
let flags = a:backwards ? 'Wb' : 'W'
|
||||
let cnt = a:0 > 0 ? a:1 : b:jlblk_count
|
||||
if !a:toend && a:backwards && s:on_begin()
|
||||
call s:move_before_begin()
|
||||
endif
|
||||
let ret = 0
|
||||
for c in range(cnt)
|
||||
if a:toend && a:backwards && s:on_end()
|
||||
normal! l
|
||||
normal! bh
|
||||
endif
|
||||
while 1
|
||||
let searchret = search(pattern, flags)
|
||||
if !searchret
|
||||
return ret
|
||||
endif
|
||||
exe "let skip = " . b:match_skip
|
||||
if !skip
|
||||
let ret = 1
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
endfor
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! s:compare_pos(pos1, pos2)
|
||||
if a:pos1[1] < a:pos2[1]
|
||||
return -1
|
||||
elseif a:pos1[1] > a:pos2[1]
|
||||
return 1
|
||||
elseif a:pos1[2] < a:pos2[2]
|
||||
return -1
|
||||
elseif a:pos1[2] > a:pos2[2]
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#move_N()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = s:moveto_block_delim(1, 0)
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
normal! e
|
||||
call s:set_mark_tick()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#move_n()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = s:moveto_block_delim(0, 0)
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#move_p()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = s:moveto_block_delim(0, 1)
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#move_P()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = s:moveto_block_delim(1, 1)
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
normal! e
|
||||
call s:set_mark_tick()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:moveto_currentblock_end()
|
||||
let flags = 'W'
|
||||
if s:on_end()
|
||||
let flags .= 'c'
|
||||
" NOTE: using "normal! lb" fails at the end of the file (?!)
|
||||
normal! l
|
||||
normal! b
|
||||
endif
|
||||
|
||||
let ret = searchpair(b:julia_begin_keywordsm, '', b:julia_end_keywords, flags, b:match_skip)
|
||||
if ret <= 0
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
normal! e
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#moveblock_N()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = 0
|
||||
for c in range(b:jlblk_count)
|
||||
let last_seen_pos = getpos('.')
|
||||
if s:on_end()
|
||||
normal! hel
|
||||
let save_pos = getpos('.')
|
||||
let ret_start = s:moveto_block_delim(0, 0, 1)
|
||||
let start1_pos = ret_start ? getpos('.') : [0,0,0,0]
|
||||
call setpos('.', save_pos)
|
||||
if s:on_end()
|
||||
normal! h
|
||||
endif
|
||||
let ret_end = s:moveto_block_delim(1, 0, 1)
|
||||
let end1_pos = ret_end ? getpos('.') : [0,0,0,0]
|
||||
|
||||
if ret_start && (!ret_end || s:compare_pos(start1_pos, end1_pos) < 0)
|
||||
call setpos('.', start1_pos)
|
||||
else
|
||||
call setpos('.', save_pos)
|
||||
endif
|
||||
endif
|
||||
|
||||
let moveret = s:moveto_currentblock_end()
|
||||
if !moveret && c == 0
|
||||
let moveret = s:moveto_block_delim(0, 0, 1) && s:cycle_until_end()
|
||||
if moveret
|
||||
normal! e
|
||||
endif
|
||||
endif
|
||||
if !moveret
|
||||
call setpos('.', last_seen_pos)
|
||||
break
|
||||
endif
|
||||
|
||||
let ret = 1
|
||||
endfor
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#moveblock_n()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = 0
|
||||
for c in range(b:jlblk_count)
|
||||
let last_seen_pos = getpos('.')
|
||||
|
||||
call s:moveto_currentblock_end()
|
||||
if s:moveto_block_delim(0, 0, 1)
|
||||
let ret = 1
|
||||
else
|
||||
call setpos('.', last_seen_pos)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#moveblock_p()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = 0
|
||||
for c in range(b:jlblk_count)
|
||||
let last_seen_pos = getpos('.')
|
||||
if s:on_begin()
|
||||
call s:move_before_begin()
|
||||
if s:on_end()
|
||||
normal! l
|
||||
endif
|
||||
let save_pos = getpos('.')
|
||||
let ret_start = s:moveto_block_delim(0, 1, 1)
|
||||
let start1_pos = ret_start ? getpos('.') : [0,0,0,0]
|
||||
call setpos('.', save_pos)
|
||||
let ret_end = s:moveto_block_delim(1, 1, 1)
|
||||
let end1_pos = ret_end ? getpos('.') : [0,0,0,0]
|
||||
|
||||
if ret_end && (!ret_start || s:compare_pos(start1_pos, end1_pos) < 0)
|
||||
call setpos('.', end1_pos)
|
||||
else
|
||||
call setpos('.', save_pos)
|
||||
endif
|
||||
endif
|
||||
|
||||
let moveret = s:moveto_currentblock_end()
|
||||
if !moveret && c == 0
|
||||
let moveret = s:moveto_block_delim(1, 1, 1)
|
||||
endif
|
||||
if !moveret
|
||||
call setpos('.', last_seen_pos)
|
||||
break
|
||||
endif
|
||||
|
||||
call s:matchit()
|
||||
let ret = 1
|
||||
endfor
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
call s:restore_view()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#moveblock_P()
|
||||
call s:get_save_pos()
|
||||
|
||||
let ret = 0
|
||||
for c in range(b:jlblk_count)
|
||||
let last_seen_pos = getpos('.')
|
||||
|
||||
call s:moveto_currentblock_end()
|
||||
if s:on_end()
|
||||
call s:matchit()
|
||||
endif
|
||||
|
||||
if s:moveto_block_delim(1, 1, 1)
|
||||
" NOTE: normal! he does not work unless &whichwrap inlcudes h
|
||||
normal! h
|
||||
normal! e
|
||||
let ret = 1
|
||||
else
|
||||
call setpos('.', last_seen_pos)
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !ret
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
call s:restore_view()
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#whereami()
|
||||
let b:jlblk_count = v:count1
|
||||
let save_redraw = &lazyredraw
|
||||
setlocal lazyredraw
|
||||
let pos = getpos('.')
|
||||
let ret = julia_blocks#select_a('w')
|
||||
if empty(ret)
|
||||
call setpos('.', pos)
|
||||
let &l:lazyredraw = save_redraw
|
||||
return ""
|
||||
end
|
||||
let [start_pos, end_pos] = ret
|
||||
let m = getline(start_pos[1])[start_pos[2]-1:]
|
||||
|
||||
" If cursor_moved was not forced from select_a, we force it now
|
||||
" (TODO: this is *really* ugly)
|
||||
if end_pos != pos
|
||||
call s:cursor_moved(1)
|
||||
endif
|
||||
call setpos('.', pos)
|
||||
call s:restore_view()
|
||||
let &l:lazyredraw = save_redraw
|
||||
return m
|
||||
endfunction
|
||||
|
||||
" Block text objects
|
||||
|
||||
function! s:find_block(current_mode)
|
||||
|
||||
let flags = 'W'
|
||||
|
||||
if b:jlblk_did_select
|
||||
call setpos('.', b:jlblk_last_start_pos)
|
||||
if !s:cycle_until_end()
|
||||
return s:abort()
|
||||
endif
|
||||
if !(a:current_mode[0] == 'a' && a:current_mode == b:jlblk_last_mode)
|
||||
let flags .= 'c'
|
||||
endif
|
||||
elseif s:on_end()
|
||||
let flags .= 'c'
|
||||
" NOTE: using "normal! lb" fails at the end of the file (?!)
|
||||
normal! l
|
||||
normal! b
|
||||
endif
|
||||
let searchret = searchpair(b:julia_begin_keywordsm, '', b:julia_end_keywords, flags, b:match_skip)
|
||||
if searchret <= 0
|
||||
if !b:jlblk_did_select
|
||||
return s:abort()
|
||||
else
|
||||
call setpos('.', b:jlblk_last_end_pos)
|
||||
endif
|
||||
endif
|
||||
|
||||
let end_pos = getpos('.')
|
||||
" Jump to match
|
||||
call s:matchit()
|
||||
let start_pos = getpos('.')
|
||||
|
||||
let b:jlblk_last_start_pos = copy(start_pos)
|
||||
let b:jlblk_last_end_pos = copy(end_pos)
|
||||
|
||||
return [start_pos, end_pos]
|
||||
endfunction
|
||||
|
||||
function! s:repeated_find(ai_mode)
|
||||
let repeat = b:jlblk_count + (a:ai_mode == 'i' && v:count1 > 1 ? 1 : 0)
|
||||
for c in range(repeat)
|
||||
let current_mode = (c < repeat - 1 ? 'a' : a:ai_mode)
|
||||
let ret_find_block = s:find_block(current_mode)
|
||||
if empty(ret_find_block)
|
||||
return 0
|
||||
endif
|
||||
let [start_pos, end_pos] = ret_find_block
|
||||
call setpos('.', end_pos)
|
||||
let b:jlblk_last_mode = current_mode
|
||||
if c < repeat - 1
|
||||
let b:jlblk_doing_select = 0
|
||||
let b:jlblk_did_select = 1
|
||||
endif
|
||||
endfor
|
||||
return [start_pos, end_pos]
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#select_a(...)
|
||||
let mode_flag = a:0 > 0 ? a:1 : ''
|
||||
call s:get_save_pos(!b:jlblk_did_select)
|
||||
let current_pos = getpos('.')
|
||||
let ret_find_block = s:repeated_find('a' . mode_flag)
|
||||
if empty(ret_find_block)
|
||||
return 0
|
||||
endif
|
||||
let [start_pos, end_pos] = ret_find_block
|
||||
|
||||
call setpos('.', end_pos)
|
||||
normal! e
|
||||
let end_pos = getpos('.')
|
||||
|
||||
let b:jlblk_doing_select = 1
|
||||
|
||||
" CursorMove is only triggered if end_pos
|
||||
" end_pos is different than the staring position;
|
||||
" so when starting from the 'd' in 'end' we need to
|
||||
" force it
|
||||
if current_pos == end_pos
|
||||
call s:cursor_moved(1)
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
return [start_pos, end_pos]
|
||||
endfunction
|
||||
|
||||
function! julia_blocks#select_i()
|
||||
call s:get_save_pos(!b:jlblk_did_select)
|
||||
let current_pos = getpos('.')
|
||||
let ret_find_block = s:repeated_find('i')
|
||||
if empty(ret_find_block)
|
||||
return 0
|
||||
endif
|
||||
let [start_pos, end_pos] = ret_find_block
|
||||
|
||||
if end_pos[1] <= start_pos[1]+1
|
||||
return s:abort()
|
||||
endif
|
||||
|
||||
call setpos('.', end_pos)
|
||||
|
||||
let b:jlblk_doing_select = 1
|
||||
|
||||
let start_pos[1] += 1
|
||||
call setpos('.', start_pos)
|
||||
normal! ^
|
||||
let start_pos = getpos('.')
|
||||
let end_pos[1] -= 1
|
||||
let end_pos[2] = len(getline(end_pos[1]))
|
||||
|
||||
" CursorMove is only triggered if end_pos
|
||||
" end_pos is different than the staring position;
|
||||
" so when starting from the 'd' in 'end' we need to
|
||||
" force it
|
||||
if current_pos == end_pos
|
||||
call s:cursor_moved(1)
|
||||
endif
|
||||
|
||||
call s:set_mark_tick()
|
||||
return [start_pos, end_pos]
|
||||
endfunction
|
||||
|
||||
function julia_blocks#select_reset()
|
||||
let b:jlblk_did_select = 0
|
||||
let b:jlblk_doing_select = 0
|
||||
let b:jlblk_inwrapper = 0
|
||||
let b:jlblk_last_mode = ""
|
||||
endfunction
|
||||
|
||||
function! s:cursor_moved(...)
|
||||
if b:jlblk_inwrapper && !(a:0 > 0 && a:1)
|
||||
return
|
||||
endif
|
||||
let b:jlblk_did_select = b:jlblk_doing_select
|
||||
let b:jlblk_doing_select = 0
|
||||
endfunction
|
||||
|
||||
endif
|
||||
3316
autoload/julia_latex_symbols.vim
Normal file
3316
autoload/julia_latex_symbols.vim
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
" Author: Kevin Ballard
|
||||
" Description: Helper functions for Rust commands/mappings
|
||||
" Last Modified: May 27, 2014
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
" Jump {{{1
|
||||
|
||||
@@ -366,53 +367,57 @@ endfunction
|
||||
" gist.vim available under the BSD license, available at
|
||||
" http://github.com/mattn/gist-vim
|
||||
function! s:has_webapi()
|
||||
if !exists("*webapi#http#post")
|
||||
try
|
||||
call webapi#http#post()
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
return exists("*webapi#http#post")
|
||||
if !exists("*webapi#http#post")
|
||||
try
|
||||
call webapi#http#post()
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
return exists("*webapi#http#post")
|
||||
endfunction
|
||||
|
||||
function! rust#Play(count, line1, line2, ...) abort
|
||||
redraw
|
||||
redraw
|
||||
|
||||
let l:rust_playpen_url = get(g:, 'rust_playpen_url', 'https://play.rust-lang.org/')
|
||||
let l:rust_shortener_url = get(g:, 'rust_shortener_url', 'https://is.gd/')
|
||||
let l:rust_playpen_url = get(g:, 'rust_playpen_url', 'https://play.rust-lang.org/')
|
||||
let l:rust_shortener_url = get(g:, 'rust_shortener_url', 'https://is.gd/')
|
||||
|
||||
if !s:has_webapi()
|
||||
echohl ErrorMsg | echomsg ':RustPlay depends on webapi.vim (https://github.com/mattn/webapi-vim)' | echohl None
|
||||
return
|
||||
endif
|
||||
if !s:has_webapi()
|
||||
echohl ErrorMsg | echomsg ':RustPlay depends on webapi.vim (https://github.com/mattn/webapi-vim)' | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
let bufname = bufname('%')
|
||||
if a:count < 1
|
||||
let content = join(getline(a:line1, a:line2), "\n")
|
||||
else
|
||||
let save_regcont = @"
|
||||
let save_regtype = getregtype('"')
|
||||
silent! normal! gvy
|
||||
let content = @"
|
||||
call setreg('"', save_regcont, save_regtype)
|
||||
endif
|
||||
let bufname = bufname('%')
|
||||
if a:count < 1
|
||||
let content = join(getline(a:line1, a:line2), "\n")
|
||||
else
|
||||
let save_regcont = @"
|
||||
let save_regtype = getregtype('"')
|
||||
silent! normal! gvy
|
||||
let content = @"
|
||||
call setreg('"', save_regcont, save_regtype)
|
||||
endif
|
||||
|
||||
let body = l:rust_playpen_url."?code=".webapi#http#encodeURI(content)
|
||||
let body = l:rust_playpen_url."?code=".webapi#http#encodeURI(content)
|
||||
|
||||
if strlen(body) > 5000
|
||||
echohl ErrorMsg | echomsg 'Buffer too large, max 5000 encoded characters ('.strlen(body).')' | echohl None
|
||||
return
|
||||
endif
|
||||
if strlen(body) > 5000
|
||||
echohl ErrorMsg | echomsg 'Buffer too large, max 5000 encoded characters ('.strlen(body).')' | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
let payload = "format=simple&url=".webapi#http#encodeURI(body)
|
||||
let res = webapi#http#post(l:rust_shortener_url.'create.php', payload, {})
|
||||
let url = res.content
|
||||
let payload = "format=simple&url=".webapi#http#encodeURI(body)
|
||||
let res = webapi#http#post(l:rust_shortener_url.'create.php', payload, {})
|
||||
let url = res.content
|
||||
|
||||
redraw | echomsg 'Done: '.url
|
||||
if exists('g:rust_clip_command')
|
||||
call system(g:rust_clip_command, url)
|
||||
endif
|
||||
|
||||
redraw | echomsg 'Done: '.url
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set noet sw=4 ts=4:
|
||||
" vim: set noet sw=8 ts=8:
|
||||
|
||||
endif
|
||||
|
||||
@@ -3,108 +3,109 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
" Author: Stephen Sugden <stephen@stephensugden.com>
|
||||
"
|
||||
" Adapted from https://github.com/fatih/vim-go
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
if !exists("g:rustfmt_autosave")
|
||||
let g:rustfmt_autosave = 0
|
||||
let g:rustfmt_autosave = 0
|
||||
endif
|
||||
|
||||
if !exists("g:rustfmt_command")
|
||||
let g:rustfmt_command = "rustfmt"
|
||||
let g:rustfmt_command = "rustfmt"
|
||||
endif
|
||||
|
||||
if !exists("g:rustfmt_options")
|
||||
let g:rustfmt_options = ""
|
||||
let g:rustfmt_options = ""
|
||||
endif
|
||||
|
||||
if !exists("g:rustfmt_fail_silently")
|
||||
let g:rustfmt_fail_silently = 0
|
||||
let g:rustfmt_fail_silently = 0
|
||||
endif
|
||||
|
||||
let s:got_fmt_error = 0
|
||||
|
||||
function! s:RustfmtCommandRange(filename, line1, line2)
|
||||
let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]}
|
||||
return printf("%s %s --write-mode=overwrite --file-lines '[%s]'", g:rustfmt_command, g:rustfmt_options, json_encode(l:arg))
|
||||
let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]}
|
||||
return printf("%s %s --write-mode=overwrite --file-lines '[%s]'", g:rustfmt_command, g:rustfmt_options, json_encode(l:arg))
|
||||
endfunction
|
||||
|
||||
function! s:RustfmtCommand(filename)
|
||||
return g:rustfmt_command . " --write-mode=overwrite " . g:rustfmt_options . " " . shellescape(a:filename)
|
||||
return g:rustfmt_command . " --write-mode=overwrite " . g:rustfmt_options . " " . shellescape(a:filename)
|
||||
endfunction
|
||||
|
||||
function! s:RunRustfmt(command, curw, tmpname)
|
||||
if exists("*systemlist")
|
||||
let out = systemlist(a:command)
|
||||
else
|
||||
let out = split(system(a:command), '\r\?\n')
|
||||
endif
|
||||
if exists("*systemlist")
|
||||
let out = systemlist(a:command)
|
||||
else
|
||||
let out = split(system(a:command), '\r\?\n')
|
||||
endif
|
||||
|
||||
if v:shell_error == 0 || v:shell_error == 3
|
||||
" remove undo point caused via BufWritePre
|
||||
try | silent undojoin | catch | endtry
|
||||
if v:shell_error == 0 || v:shell_error == 3
|
||||
" remove undo point caused via BufWritePre
|
||||
try | silent undojoin | catch | endtry
|
||||
|
||||
" Replace current file with temp file, then reload buffer
|
||||
call rename(a:tmpname, expand('%'))
|
||||
silent edit!
|
||||
let &syntax = &syntax
|
||||
" Replace current file with temp file, then reload buffer
|
||||
call rename(a:tmpname, expand('%'))
|
||||
silent edit!
|
||||
let &syntax = &syntax
|
||||
|
||||
" only clear location list if it was previously filled to prevent
|
||||
" clobbering other additions
|
||||
if s:got_fmt_error
|
||||
let s:got_fmt_error = 0
|
||||
call setloclist(0, [])
|
||||
lwindow
|
||||
endif
|
||||
elseif g:rustfmt_fail_silently == 0
|
||||
" otherwise get the errors and put them in the location list
|
||||
let errors = []
|
||||
" only clear location list if it was previously filled to prevent
|
||||
" clobbering other additions
|
||||
if s:got_fmt_error
|
||||
let s:got_fmt_error = 0
|
||||
call setloclist(0, [])
|
||||
lwindow
|
||||
endif
|
||||
elseif g:rustfmt_fail_silently == 0
|
||||
" otherwise get the errors and put them in the location list
|
||||
let errors = []
|
||||
|
||||
for line in out
|
||||
" src/lib.rs:13:5: 13:10 error: expected `,`, or `}`, found `value`
|
||||
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\):\s*\(\d\+:\d\+\s*\)\?\s*error: \(.*\)')
|
||||
if !empty(tokens)
|
||||
call add(errors, {"filename": @%,
|
||||
\"lnum": tokens[2],
|
||||
\"col": tokens[3],
|
||||
\"text": tokens[5]})
|
||||
endif
|
||||
endfor
|
||||
for line in out
|
||||
" src/lib.rs:13:5: 13:10 error: expected `,`, or `}`, found `value`
|
||||
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\):\s*\(\d\+:\d\+\s*\)\?\s*error: \(.*\)')
|
||||
if !empty(tokens)
|
||||
call add(errors, {"filename": @%,
|
||||
\"lnum": tokens[2],
|
||||
\"col": tokens[3],
|
||||
\"text": tokens[5]})
|
||||
endif
|
||||
endfor
|
||||
|
||||
if empty(errors)
|
||||
% | " Couldn't detect rustfmt error format, output errors
|
||||
endif
|
||||
if empty(errors)
|
||||
% | " Couldn't detect rustfmt error format, output errors
|
||||
endif
|
||||
|
||||
if !empty(errors)
|
||||
call setloclist(0, errors, 'r')
|
||||
echohl Error | echomsg "rustfmt returned error" | echohl None
|
||||
endif
|
||||
if !empty(errors)
|
||||
call setloclist(0, errors, 'r')
|
||||
echohl Error | echomsg "rustfmt returned error" | echohl None
|
||||
endif
|
||||
|
||||
let s:got_fmt_error = 1
|
||||
lwindow
|
||||
" We didn't use the temp file, so clean up
|
||||
call delete(a:tmpname)
|
||||
endif
|
||||
let s:got_fmt_error = 1
|
||||
lwindow
|
||||
" We didn't use the temp file, so clean up
|
||||
call delete(a:tmpname)
|
||||
endif
|
||||
|
||||
call winrestview(a:curw)
|
||||
call winrestview(a:curw)
|
||||
endfunction
|
||||
|
||||
function! rustfmt#FormatRange(line1, line2)
|
||||
let l:curw = winsaveview()
|
||||
let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt"
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
let l:curw = winsaveview()
|
||||
let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt"
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
|
||||
let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2)
|
||||
let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2)
|
||||
|
||||
call s:RunRustfmt(command, l:curw, l:tmpname)
|
||||
call s:RunRustfmt(command, l:curw, l:tmpname)
|
||||
endfunction
|
||||
|
||||
function! rustfmt#Format()
|
||||
let l:curw = winsaveview()
|
||||
let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt"
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
let l:curw = winsaveview()
|
||||
let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt"
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
|
||||
let command = s:RustfmtCommand(l:tmpname)
|
||||
let command = s:RustfmtCommand(l:tmpname)
|
||||
|
||||
call s:RunRustfmt(command, l:curw, l:tmpname)
|
||||
call s:RunRustfmt(command, l:curw, l:tmpname)
|
||||
endfunction
|
||||
|
||||
endif
|
||||
|
||||
18
autoload/vifm/edit.vim
Normal file
18
autoload/vifm/edit.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
|
||||
|
||||
" common functions for vifm command-line editing buffer filetype plugins
|
||||
" Maintainer: xaizek <xaizek@posteo.net>
|
||||
" Last Change: August 18, 2013
|
||||
|
||||
" Prepare buffer
|
||||
function! vifm#edit#Init()
|
||||
" Mappings for quick leaving the buffer (behavior similar to Command line
|
||||
" buffer in Vim)
|
||||
nnoremap <buffer> <cr> :copy 0 \| wq<cr>
|
||||
imap <buffer> <cr> <esc><cr>
|
||||
|
||||
" Start buffer editing in insert mode
|
||||
startinsert
|
||||
endfunction
|
||||
|
||||
endif
|
||||
10
autoload/vital/crystal.vital
Normal file
10
autoload/vital/crystal.vital
Normal file
@@ -0,0 +1,10 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
|
||||
|
||||
crystal
|
||||
a977489
|
||||
|
||||
Process
|
||||
Web.JSON
|
||||
ColorEcho
|
||||
|
||||
endif
|
||||
@@ -583,11 +583,11 @@ let g:xmldata_html5 = {
|
||||
\ ],
|
||||
\ 'img': [
|
||||
\ [],
|
||||
\ extend(copy(global_attributes), {'src': [], 'alt': [], 'height': [], 'width': [], 'usemap': [], 'ismap': ['ismap', ''], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url'], 'crossorigin': ['anonymous', 'use-credentials']})
|
||||
\ extend(copy(global_attributes), {'src': [], 'alt': [], 'height': [], 'width': [], 'decoding': ['async', 'sync', 'auto'], 'usemap': [], 'ismap': ['ismap', ''], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url'], 'crossorigin': ['anonymous', 'use-credentials']})
|
||||
\ ],
|
||||
\ 'input': [
|
||||
\ [],
|
||||
\ extend(copy(global_attributes), {'type': ['text', 'password', 'checkbox', 'radio', 'button', 'submit', 'reset', 'file', 'hidden', 'image', 'datetime', 'datetime-local', 'date', 'month', 'time', 'week', 'number', 'range', 'email', 'url', 'search', 'tel', 'color'], 'name': [], 'disabled': ['disabled', ''], 'form': [], 'maxlength': [], 'readonly': ['readonly', ''], 'size': [], 'value': [], 'autocomplete': autofill_tokens, 'autofocus': ['autofocus', ''], 'list': [], 'pattern': [], 'required': ['required', ''], 'placeholder': [], 'checked': ['checked'], 'accept': [], 'multiple': ['multiple', ''], 'alt': [], 'src': [], 'height': [], 'width': [], 'min': [], 'max': [], 'step': [], 'formenctype': ['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'], 'formmethod': ['get', 'post', 'put', 'delete'], 'formtarget': [], 'formnovalidate': ['formnovalidate', '']})
|
||||
\ extend(copy(global_attributes), {'type': ['text', 'password', 'checkbox', 'radio', 'button', 'submit', 'reset', 'file', 'hidden', 'image', 'datetime-local', 'date', 'month', 'time', 'week', 'number', 'range', 'email', 'url', 'search', 'tel', 'color'], 'name': [], 'disabled': ['disabled', ''], 'form': [], 'maxlength': [], 'readonly': ['readonly', ''], 'size': [], 'value': [], 'autocomplete': autofill_tokens, 'autofocus': ['autofocus', ''], 'list': [], 'pattern': [], 'required': ['required', ''], 'placeholder': [], 'checked': ['checked'], 'accept': [], 'multiple': ['multiple', ''], 'alt': [], 'src': [], 'height': [], 'width': [], 'min': [], 'max': [], 'step': [], 'formenctype': ['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'], 'formmethod': ['get', 'post', 'put', 'delete'], 'formtarget': [], 'formnovalidate': ['formnovalidate', '']})
|
||||
\ ],
|
||||
\ 'ins': [
|
||||
\ flow_elements,
|
||||
|
||||
28
build
28
build
@@ -80,7 +80,7 @@ extract() {
|
||||
}
|
||||
|
||||
copy_dir() {
|
||||
for file in $(find "$1/$2" -name '*.vim'); do
|
||||
for file in $(find "$1/$2" -name '*.vim' -o -name '*.vital'); do
|
||||
file_path="$(dirname "${file##$1/}")"
|
||||
mkdir -p "$file_path"
|
||||
touch "$file_path/$(basename "$file")"
|
||||
@@ -113,31 +113,34 @@ PACKS="
|
||||
yaml:stephpy/vim-yaml
|
||||
ansible:pearofducks/ansible-vim
|
||||
arduino:sudar/vim-arduino-syntax
|
||||
autohotkey:hnamikaw/vim-autohotkey
|
||||
blade:jwalton512/vim-blade
|
||||
c++11:octol/vim-cpp-enhanced-highlight
|
||||
c/c++:vim-jp/vim-cpp
|
||||
caddyfile:joshglendenning/vim-caddyfile
|
||||
caddyfile:isobit/vim-caddyfile
|
||||
carp:hellerve/carp-vim
|
||||
cjsx:mtscout6/vim-cjsx
|
||||
clojure:guns/vim-clojure-static
|
||||
cmake:pboettch/vim-cmake-syntax
|
||||
coffee-script:kchmck/vim-coffee-script
|
||||
cryptol:victoredwardocallaghan/cryptol.vim
|
||||
crystal:rhysd/vim-crystal
|
||||
cql:elubow/cql-vim
|
||||
css:JulesWang/css.vim
|
||||
cucumber:tpope/vim-cucumber
|
||||
dart:dart-lang/dart-vim-plugin
|
||||
dockerfile:docker/docker::/contrib/syntax/vim/
|
||||
elixir:elixir-lang/vim-elixir
|
||||
elm:lambdatoast/elm.vim
|
||||
elm:ElmCast/elm-vim
|
||||
emberscript:yalesov/vim-ember-script
|
||||
emblem:yalesov/vim-emblem
|
||||
erlang:vim-erlang/vim-erlang-runtime
|
||||
fish:dag/vim-fish
|
||||
fsharp:fsharp/vim-fsharp:_BASIC
|
||||
git:tpope/vim-git
|
||||
gmpl:maelvalais/gmpl.vim
|
||||
glsl:tikhomirov/vim-glsl
|
||||
gnuplot:vim-scripts/gnuplot-syntax-highlighting
|
||||
go:fatih/vim-go:_BASIC
|
||||
graphql:jparise/vim-graphql
|
||||
groovy:vim-scripts/groovy.vim
|
||||
haml:sheerun/vim-haml
|
||||
handlebars:mustache/vim-mustache-handlebars
|
||||
@@ -147,10 +150,12 @@ PACKS="
|
||||
i3:PotatoesMaster/i3-vim-syntax
|
||||
jasmine:glanotte/vim-jasmine
|
||||
javascript:pangloss/vim-javascript:_JAVASCRIPT
|
||||
jenkins:martinda/Jenkinsfile-vim-syntax
|
||||
json:elzr/vim-json
|
||||
json5:GutenYe/json5.vim
|
||||
jst:briancollins/vim-jst
|
||||
jsx:mxw/vim-jsx:_ALL
|
||||
julia:dcjones/julia-minimalist-vim
|
||||
julia:JuliaEditorSupport/julia-vim
|
||||
kotlin:udalov/kotlin-vim
|
||||
latex:LaTeX-Box-Team/LaTeX-Box
|
||||
less:groenewege/vim-less
|
||||
@@ -162,7 +167,7 @@ PACKS="
|
||||
mathematica:rsmenon/vim-mathematica
|
||||
nginx:chr4/nginx.vim
|
||||
nim:zah/nim.vim:_BASIC
|
||||
nix:spwhitt/vim-nix
|
||||
nix:LnL7/vim-nix
|
||||
objc:b4winckler/vim-objc
|
||||
ocaml:jrk/vim-ocaml
|
||||
octave:vim-scripts/octave.vim--
|
||||
@@ -175,9 +180,10 @@ PACKS="
|
||||
protobuf:uarun/vim-protobuf
|
||||
pug:digitaltoad/vim-pug
|
||||
puppet:voxpupuli/vim-puppet
|
||||
purescript:raichoo/purescript-vim
|
||||
python:mitsuhiko/vim-python-combined
|
||||
purescript:purescript-contrib/purescript-vim
|
||||
python:vim-python/python-syntax
|
||||
python-compiler:aliev/vim-compiler-python
|
||||
python-ident:Vimjas/vim-python-pep8-indent
|
||||
qml:peterhoeg/vim-qml
|
||||
r-lang:vim-scripts/R.vim
|
||||
racket:wlangstroth/vim-racket
|
||||
@@ -190,7 +196,8 @@ PACKS="
|
||||
scala:derekwyatt/vim-scala
|
||||
scss:cakebaker/scss-syntax.vim
|
||||
slim:slim-template/vim-slim
|
||||
solidity:ethereum/vim-solidity
|
||||
slime:slime-lang/vim-slime-syntax
|
||||
solidity:tomlion/vim-solidity
|
||||
stylus:wavded/vim-stylus
|
||||
swift:keith/swift.vim
|
||||
sxhkd:baskerville/vim-sxhkdrc
|
||||
@@ -206,6 +213,7 @@ PACKS="
|
||||
vala:arrufat/vala.vim
|
||||
vbnet:vim-scripts/vbnet.vim
|
||||
vcl:smerrill/vcl-vim-plugin
|
||||
vifm:vifm/vifm.vim
|
||||
vue:posva/vim-vue
|
||||
vm:lepture/vim-velocity
|
||||
xls:vim-scripts/XSLT-syntax
|
||||
|
||||
@@ -4,21 +4,25 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
" Compiler: Cargo Compiler
|
||||
" Maintainer: Damien Radtke <damienradtke@gmail.com>
|
||||
" Latest Revision: 2014 Sep 24
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
if exists('current_compiler')
|
||||
finish
|
||||
finish
|
||||
endif
|
||||
runtime compiler/rustc.vim
|
||||
let current_compiler = "cargo"
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if exists(':CompilerSet') != 2
|
||||
command -nargs=* CompilerSet setlocal <args>
|
||||
command -nargs=* CompilerSet setlocal <args>
|
||||
endif
|
||||
|
||||
if exists('g:cargo_makeprg_params')
|
||||
execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*'
|
||||
execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*'
|
||||
else
|
||||
CompilerSet makeprg=cargo\ $*
|
||||
CompilerSet makeprg=cargo\ $*
|
||||
endif
|
||||
|
||||
" Ignore general cargo progress messages
|
||||
@@ -27,6 +31,11 @@ CompilerSet errorformat+=
|
||||
\%-G%\\s%#Compiling%.%#,
|
||||
\%-G%\\s%#Finished%.%#,
|
||||
\%-G%\\s%#error:\ Could\ not\ compile\ %.%#,
|
||||
\%-G%\\s%#To\ learn\ more\\,%.%#
|
||||
\%-G%\\s%#To\ learn\ more\\,%.%#,
|
||||
\%-Gnote:\ Run\ with\ \`RUST_BACKTRACE=%.%#,
|
||||
\%.%#panicked\ at\ \\'%m\\'\\,\ %f:%l
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
endif
|
||||
|
||||
@@ -6,10 +6,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
|
||||
"
|
||||
" compiler/go.vim: Vim compiler file for Go.
|
||||
|
||||
if exists("current_compiler")
|
||||
if exists("g:current_compiler")
|
||||
finish
|
||||
endif
|
||||
let current_compiler = "go"
|
||||
let g:current_compiler = "go"
|
||||
|
||||
if exists(":CompilerSet") != 2
|
||||
command -nargs=* CompilerSet setlocal <args>
|
||||
|
||||
@@ -24,10 +24,10 @@ CompilerSet errorformat=
|
||||
\%D(in\ %f),
|
||||
\%\\s%#from\ %f:%l:%m,
|
||||
\%\\s%#from\ %f:%l:,
|
||||
\%\\s%##\ %f:%l:%m%\\&%.%#%\\D:%.%#,
|
||||
\%\\s%##\ %f:%l%\\&%.%#%\\D:%.%#,
|
||||
\%\\s%#[%f:%l:\ %#%m%\\&%.%#%\\D:%.%#,
|
||||
\%\\s%#%f:%l:\ %#%m%\\&%.%#%\\D:%.%#,
|
||||
\%\\s%##\ %f:%l:%m%\\&%.%#%\\D:%\\d%#:%.%#,
|
||||
\%\\s%##\ %f:%l%\\&%.%#%\\D:%\\d%#,
|
||||
\%\\s%#[%f:%l:\ %#%m%\\&%.%#%\\D:%\\d%#:%.%#,
|
||||
\%\\s%#%f:%l:\ %#%m%\\&%.%#%\\D:%\\d%#:%.%#,
|
||||
\%\\s%#%f:%l:,
|
||||
\%m\ [%f:%l]:,
|
||||
\%+Erake\ aborted!,
|
||||
|
||||
@@ -4,9 +4,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
" Compiler: Rust Compiler
|
||||
" Maintainer: Chris Morgan <me@chrismorgan.info>
|
||||
" Latest Revision: 2013 Jul 12
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
finish
|
||||
endif
|
||||
let current_compiler = "rustc"
|
||||
|
||||
|
||||
@@ -17,8 +17,18 @@ if exists(":CompilerSet") != 2
|
||||
command! -nargs=* CompilerSet setlocal <args>
|
||||
endif
|
||||
|
||||
let &l:makeprg = g:typescript_compiler_binary . ' ' . g:typescript_compiler_options . ' $* %'
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
|
||||
execute 'CompilerSet makeprg='
|
||||
\ . escape(g:typescript_compiler_binary, ' ')
|
||||
\ . '\ '
|
||||
\ . escape(g:typescript_compiler_options, ' ')
|
||||
\ . '\ $*\ %'
|
||||
|
||||
CompilerSet errorformat=%+A\ %#%f\ %#(%l\\\,%c):\ %m,%C%m
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
endif
|
||||
|
||||
@@ -9,3 +9,9 @@ if !exists('g:vim_json_syntax_conceal')
|
||||
endif
|
||||
|
||||
let g:filetype_euphoria = 'elixir'
|
||||
|
||||
augroup filetypedetect
|
||||
autocmd BufNewFile,BufReadPost *.vb setlocal filetype=vbnet
|
||||
augroup END
|
||||
|
||||
let g:python_highlight_all = 1
|
||||
|
||||
@@ -2,9 +2,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') ==
|
||||
|
||||
syntax region jsFlowDefinition contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster containedin=jsParen
|
||||
syntax region jsFlowArgumentDef contained start=/:/ end=/\%(\s*[,)]\|=>\@!\)\@=/ contains=@jsFlowCluster
|
||||
syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster
|
||||
syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster
|
||||
syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster
|
||||
syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster,jsComment fold
|
||||
syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster,jsComment fold
|
||||
syntax region jsFlowExactObject contained matchgroup=jsFlowNoise start=/{|/ end=/|}/ contains=@jsFlowCluster,jsComment fold
|
||||
syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster keepend fold
|
||||
syntax match jsFlowNoise contained /[:;,<>]/
|
||||
syntax keyword jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class
|
||||
syntax keyword jsFlowTypeof contained typeof skipempty skipempty nextgroup=jsFlowTypeCustom,jsFlowType
|
||||
@@ -12,18 +13,18 @@ syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipemp
|
||||
syntax region jsFlowGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster
|
||||
syntax region jsFlowArrowArguments contained matchgroup=jsFlowNoise start=/(/ end=/)\%(\s*=>\)\@=/ oneline skipwhite skipempty nextgroup=jsFlowArrow contains=@jsFlowCluster
|
||||
syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens
|
||||
syntax match jsFlowMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens,jsFlowArrowArguments,jsFlowObject,jsFlowReturnObject
|
||||
syntax match jsFlowObjectKey contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ contains=jsFunctionKey,jsFlowMaybe skipwhite skipempty nextgroup=jsObjectValue containedin=jsObject
|
||||
syntax match jsFlowOrOperator contained /|/ skipwhite skipempty nextgroup=@jsFlowCluster
|
||||
syntax keyword jsFlowImportType contained type skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup
|
||||
syntax match jsFlowWildcard contained /*/
|
||||
|
||||
syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster
|
||||
syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
|
||||
syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
|
||||
syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
|
||||
syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster,jsFlowArrow,jsFlowReturnParens
|
||||
syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold
|
||||
syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold
|
||||
syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArrow fold
|
||||
syntax match jsFlowReturnArrow contained /=>/ skipwhite skipempty nextgroup=@jsFlowReturnCluster
|
||||
syntax match jsFlowReturnKeyword contained /\k\+/ contains=jsFlowType,jsFlowTypeCustom skipwhite skipempty nextgroup=jsFlowReturnGroup,jsFuncBlock,jsFlowReturnOrOp
|
||||
syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword
|
||||
syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword,jsFlowReturnObject
|
||||
syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
|
||||
syntax match jsFlowReturnOrOp contained /\s*|\s*/ skipwhite skipempty nextgroup=@jsFlowReturnCluster
|
||||
syntax match jsFlowWildcardReturn contained /*/ skipwhite skipempty nextgroup=jsFuncBlock
|
||||
@@ -32,7 +33,8 @@ syntax region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=/</ e
|
||||
syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock
|
||||
|
||||
syntax region jsFlowTypeStatement start=/type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend
|
||||
syntax region jsFlowTypeValue contained start=/=/ end=/[;\n]/ contains=@jsExpression,jsFlowGroup,jsFlowMaybe
|
||||
syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/[\n;]/ contains=@jsFlowCluster,jsFlowGroup,jsFlowMaybe
|
||||
syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue
|
||||
syntax match jsFlowTypeOperator contained /=/
|
||||
syntax keyword jsFlowTypeKeyword contained type
|
||||
|
||||
@@ -42,12 +44,18 @@ syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)
|
||||
|
||||
syntax region jsFlowModule contained start=/module/ end=/{\@=/ skipempty skipempty nextgroup=jsFlowDeclareBlock contains=jsString
|
||||
syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipempty nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster
|
||||
syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise
|
||||
syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold
|
||||
|
||||
syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise keepend
|
||||
" NOTE: It appears the nextgroup was causing a ton of breakages... testing it
|
||||
" witout a nextgroup, but keeping this arround for reference incase something breaks
|
||||
" syntax match jsFlowMaybe contained /?/ nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens,jsFlowArrowArguments,jsFlowObject,jsFlowReturnObject extend keepend
|
||||
syntax match jsFlowMaybe contained /?/
|
||||
syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise keepend fold
|
||||
|
||||
syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn
|
||||
syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGroup,jsFlowArrowArguments,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard
|
||||
syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster
|
||||
|
||||
syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow
|
||||
syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGroup,jsFlowArrowArguments,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard
|
||||
|
||||
if version >= 508 || !exists("did_javascript_syn_inits")
|
||||
if version < 508
|
||||
@@ -64,9 +72,11 @@ if version >= 508 || !exists("did_javascript_syn_inits")
|
||||
HiLink jsFlowTypeof PreProc
|
||||
HiLink jsFlowArray PreProc
|
||||
HiLink jsFlowObject PreProc
|
||||
HiLink jsFlowExactObject PreProc
|
||||
HiLink jsFlowParens PreProc
|
||||
HiLink jsFlowGroup PreProc
|
||||
HiLink jsFlowReturn PreProc
|
||||
HiLink jsFlowParenAnnotation PreProc
|
||||
HiLink jsFlowReturnObject jsFlowReturn
|
||||
HiLink jsFlowReturnArray jsFlowArray
|
||||
HiLink jsFlowReturnParens jsFlowParens
|
||||
@@ -75,9 +85,10 @@ if version >= 508 || !exists("did_javascript_syn_inits")
|
||||
HiLink jsFlowClassGroup PreProc
|
||||
HiLink jsFlowArrowArguments PreProc
|
||||
HiLink jsFlowArrow PreProc
|
||||
HiLink jsFlowReturnArrow PreProc
|
||||
HiLink jsFlowTypeStatement PreProc
|
||||
HiLink jsFlowTypeKeyword PreProc
|
||||
HiLink jsFlowTypeOperator PreProc
|
||||
HiLink jsFlowTypeOperator Operator
|
||||
HiLink jsFlowMaybe PreProc
|
||||
HiLink jsFlowReturnMaybe PreProc
|
||||
HiLink jsFlowClassProperty jsClassProperty
|
||||
@@ -86,10 +97,12 @@ if version >= 508 || !exists("did_javascript_syn_inits")
|
||||
HiLink jsFlowInterface PreProc
|
||||
HiLink jsFlowNoise Noise
|
||||
HiLink jsFlowObjectKey jsObjectKey
|
||||
HiLink jsFlowOrOperator PreProc
|
||||
HiLink jsFlowOrOperator jsOperator
|
||||
HiLink jsFlowReturnOrOp jsFlowOrOperator
|
||||
HiLink jsFlowWildcard PreProc
|
||||
HiLink jsFlowWildcardReturn PreProc
|
||||
HiLink jsFlowImportType PreProc
|
||||
HiLink jsFlowTypeValue PreProc
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|
|
||||
" tags containing references
|
||||
syntax match jsDocTags contained "@\(lends\|see\|tutorial\)\>" skipwhite nextgroup=jsDocSeeTag
|
||||
" other tags (no extra syntax)
|
||||
syntax match jsDocTags contained "@\(abstract\|access\|accessor\|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 match jsDocTags contained "@\(abstract\|access\|accessor\|async\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|dict\|event\|example\|file\|file[oO]verview\|final\|function\|global\|ignore\|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 contained matchgroup=jsDocTypeBrackets start="{" end="}" contains=jsDocTypeRecord oneline skipwhite nextgroup=jsDocParam
|
||||
syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" skipwhite nextgroup=jsDocParam
|
||||
|
||||
@@ -9,6 +9,12 @@ if !exists('g:vim_json_syntax_conceal')
|
||||
endif
|
||||
|
||||
let g:filetype_euphoria = 'elixir'
|
||||
|
||||
augroup filetypedetect
|
||||
autocmd BufNewFile,BufReadPost *.vb setlocal filetype=vbnet
|
||||
augroup END
|
||||
|
||||
let g:python_highlight_all = 1
|
||||
augroup filetypedetect
|
||||
" apiblueprint:sheerun/apiblueprint.vim
|
||||
autocmd BufReadPost,BufNewFile *.apib set filetype=apiblueprint
|
||||
@@ -56,6 +62,10 @@ augroup filetypedetect
|
||||
au BufRead,BufNewFile *.ino,*.pde set filetype=arduino
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" autohotkey:hnamikaw/vim-autohotkey
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" blade:jwalton512/vim-blade
|
||||
autocmd BufNewFile,BufRead *.blade.php set filetype=blade
|
||||
@@ -70,10 +80,15 @@ augroup filetypedetect
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" caddyfile:joshglendenning/vim-caddyfile
|
||||
" caddyfile:isobit/vim-caddyfile
|
||||
au BufNewFile,BufRead Caddyfile set ft=caddyfile
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" carp:hellerve/carp-vim
|
||||
au BufRead,BufNewFile *.carp set filetype=carp
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" cjsx:mtscout6/vim-cjsx
|
||||
augroup CJSX
|
||||
@@ -87,6 +102,10 @@ augroup filetypedetect
|
||||
autocmd BufNewFile,BufRead *.clj,*.cljs,*.edn,*.cljx,*.cljc,{build,profile}.boot setlocal filetype=clojure
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" cmake:pboettch/vim-cmake-syntax
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" coffee-script:kchmck/vim-coffee-script
|
||||
" Language: CoffeeScript
|
||||
@@ -146,10 +165,6 @@ if has("autocmd")
|
||||
endif
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" css:JulesWang/css.vim
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" cucumber:tpope/vim-cucumber
|
||||
" Cucumber
|
||||
@@ -183,8 +198,10 @@ endfunction
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" elm:lambdatoast/elm.vim
|
||||
au BufNewFile,BufRead *.elm set filetype=elm
|
||||
" elm:ElmCast/elm-vim
|
||||
" detection for Elm (http://elm-lang.org/)
|
||||
|
||||
au BufRead,BufNewFile *.elm set filetype=elm
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -227,7 +244,7 @@ augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" erlang:vim-erlang/vim-erlang-runtime
|
||||
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,*.escript set ft=erlang
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -257,6 +274,12 @@ autocmd BufNewFile ~/.config/fish/functions/*.fish
|
||||
\ 2
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" fsharp:fsharp/vim-fsharp:_BASIC
|
||||
" F#, fsharp
|
||||
autocmd BufNewFile,BufRead *.fs,*.fsi,*.fsx set filetype=fsharp
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" git:tpope/vim-git
|
||||
" Git
|
||||
@@ -282,14 +305,19 @@ autocmd BufNewFile,BufRead *
|
||||
\ endif
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" gmpl:maelvalais/gmpl.vim
|
||||
au BufRead,BufNewFile *.mod set filetype=gmpl
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" glsl:tikhomirov/vim-glsl
|
||||
" Language: OpenGL Shading Language
|
||||
" Maintainer: Sergey Tikhomirov <sergey@tikhomirov.io>
|
||||
|
||||
" Extensions supported by Khronos reference compiler
|
||||
" Extensions supported by Khronos reference compiler (with one exception, ".glsl")
|
||||
" https://github.com/KhronosGroup/glslang
|
||||
autocmd! BufNewFile,BufRead *.vert,*.tesc,*.tese,*.geom,*.frag,*.comp set filetype=glsl
|
||||
autocmd! BufNewFile,BufRead *.vert,*.tesc,*.tese,*.glsl,*.geom,*.frag,*.comp set filetype=glsl
|
||||
|
||||
" vim:set sts=2 sw=2 :
|
||||
augroup END
|
||||
@@ -320,24 +348,22 @@ function! s:gofiletype_post()
|
||||
let &g:fileencodings = s:current_fileencodings
|
||||
endfunction
|
||||
|
||||
au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix
|
||||
au BufRead *.go call s:gofiletype_pre("go")
|
||||
au BufReadPost *.go call s:gofiletype_post()
|
||||
augroup vim-go-filetype
|
||||
autocmd!
|
||||
au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix
|
||||
au BufRead *.go call s:gofiletype_pre("go")
|
||||
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 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
|
||||
augroup end
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" graphql:jparise/vim-graphql
|
||||
au BufRead,BufNewFile *.graphql,*.gql setfiletype graphql
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" groovy:vim-scripts/groovy.vim
|
||||
augroup END
|
||||
@@ -376,7 +402,7 @@ augroup filetypedetect
|
||||
" i3:PotatoesMaster/i3-vim-syntax
|
||||
augroup i3_ftdetect
|
||||
au!
|
||||
au BufRead,BufNewFile *i3/config set ft=i3
|
||||
au BufRead,BufNewFile *i3/config,*sway/config set ft=i3
|
||||
augroup END
|
||||
augroup END
|
||||
|
||||
@@ -387,7 +413,7 @@ augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" javascript:pangloss/vim-javascript:_JAVASCRIPT
|
||||
au BufNewFile,BufRead *.{js,jsm,es,es6},Jakefile setf javascript
|
||||
au BufNewFile,BufRead *.{js,mjs,jsm,es,es6},Jakefile setf javascript
|
||||
|
||||
fun! s:SourceFlowSyntax()
|
||||
if !exists('javascript_plugin_flow') && !exists('b:flow_active') &&
|
||||
@@ -406,11 +432,26 @@ endfun
|
||||
au BufNewFile,BufRead * call s:SelectJavascript()
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" jenkins:martinda/Jenkinsfile-vim-syntax
|
||||
" Jenkinsfile
|
||||
autocmd BufRead,BufNewFile Jenkinsfile set ft=Jenkinsfile
|
||||
autocmd BufRead,BufNewFile Jenkinsfile* setf Jenkinsfile
|
||||
autocmd BufRead,BufNewFile *.jenkinsfile set ft=Jenkinsfile
|
||||
autocmd BufRead,BufNewFile *.jenkinsfile setf Jenkinsfile
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" json:elzr/vim-json
|
||||
autocmd BufNewFile,BufRead *.json setlocal filetype=json
|
||||
autocmd BufNewFile,BufRead *.jsonp setlocal filetype=json
|
||||
autocmd BufNewFile,BufRead *.geojson setlocal filetype=json
|
||||
autocmd BufNewFile,BufRead *.template setlocal filetype=json
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" json5:GutenYe/json5.vim
|
||||
au BufNewFile,BufRead *.json5 setfiletype json5
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -442,15 +483,16 @@ if !exists('g:jsx_pragma_required')
|
||||
let g:jsx_pragma_required = 0
|
||||
endif
|
||||
|
||||
if g:jsx_pragma_required
|
||||
" Look for the @jsx pragma. It must be included in a docblock comment before
|
||||
" anything else in the file (except whitespace).
|
||||
let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
|
||||
let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
|
||||
endif
|
||||
let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
|
||||
|
||||
" Whether to set the JSX filetype on *.js files.
|
||||
fu! <SID>EnableJSX()
|
||||
if g:jsx_pragma_required && !exists('b:jsx_ext_found')
|
||||
" Look for the @jsx pragma. It must be included in a docblock comment
|
||||
" before anything else in the file (except whitespace).
|
||||
let b:jsx_pragma_found = search(s:jsx_pragma_pattern, 'npw')
|
||||
endif
|
||||
|
||||
if g:jsx_pragma_required && !b:jsx_pragma_found | return 0 | endif
|
||||
if g:jsx_ext_required && !exists('b:jsx_ext_found') | return 0 | endif
|
||||
return 1
|
||||
@@ -463,13 +505,28 @@ autocmd BufNewFile,BufRead *.js
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" julia:dcjones/julia-minimalist-vim
|
||||
" NOTE: this line fixes an issue with the default system-wide lisp ftplugin
|
||||
" which doesn't define b:undo_ftplugin
|
||||
" (*.jt files are recognized as lisp)
|
||||
au BufRead,BufNewFile *.jl let b:undo_ftplugin = "setlocal comments< define< formatoptions< iskeyword< lisp<"
|
||||
" julia:JuliaEditorSupport/julia-vim
|
||||
if v:version < 704
|
||||
" NOTE: this line fixes an issue with the default system-wide lisp ftplugin
|
||||
" which didn't define b:undo_ftplugin on older Vim versions
|
||||
" (*.jl files are recognized as lisp)
|
||||
autocmd BufRead,BufNewFile *.jl let b:undo_ftplugin = "setlocal comments< define< formatoptions< iskeyword< lisp<"
|
||||
endif
|
||||
|
||||
au BufRead,BufNewFile *.jl set filetype=julia
|
||||
autocmd BufRead,BufNewFile *.jl set filetype=julia
|
||||
|
||||
autocmd FileType * call LaTeXtoUnicode#Refresh()
|
||||
autocmd BufEnter * call LaTeXtoUnicode#Refresh()
|
||||
|
||||
" This autocommand is used to postpone the first initialization of LaTeXtoUnicode as much as possible,
|
||||
" by calling LaTeXtoUnicode#SetTab amd LaTeXtoUnicode#SetAutoSub only at InsertEnter or later
|
||||
function! s:L2UTrigger()
|
||||
augroup L2UInit
|
||||
autocmd!
|
||||
autocmd InsertEnter * let g:did_insert_enter = 1 | call LaTeXtoUnicode#Init(0)
|
||||
augroup END
|
||||
endfunction
|
||||
autocmd BufEnter * call s:L2UTrigger()
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -524,6 +581,16 @@ augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" mako:sophacles/vim-bundle-mako
|
||||
if !exists("g:mako_detect_lang_from_ext")
|
||||
let g:mako_detect_lang_from_ext = 1
|
||||
endif
|
||||
if g:mako_detect_lang_from_ext
|
||||
au BufNewFile *.*.mako execute "do BufNewFile filetypedetect " . expand("<afile>:r") | let b:mako_outer_lang = &filetype
|
||||
" it's important to get this before any of the normal BufRead autocmds execute
|
||||
" for this file, otherwise a mako tag at the start of the file can cause the
|
||||
" filetype to be set to mason
|
||||
au BufReadPre *.*.mako execute "do BufRead filetypedetect " . expand("<afile>:r") | let b:mako_outer_lang = &filetype
|
||||
endif
|
||||
au BufRead,BufNewFile *.mako set filetype=mako
|
||||
augroup END
|
||||
|
||||
@@ -554,8 +621,14 @@ au BufNewFile,BufRead *.nim,*.nims set filetype=nim
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" nix:spwhitt/vim-nix
|
||||
autocmd BufNewFile,BufRead *.nix setfiletype nix
|
||||
" nix:LnL7/vim-nix
|
||||
" Vim filetype detect
|
||||
" Language: Nix
|
||||
" Maintainer: Daiderd Jordan <daiderd@gmail.com>
|
||||
" URL: https://github.com/LnL7/vim-nix
|
||||
|
||||
au BufRead,BufNewFile *.nix set filetype=nix
|
||||
au FileType nix setl sw=2 sts=2 et iskeyword+=-
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -703,13 +776,13 @@ au! BufRead,BufNewFile Puppetfile setfiletype ruby
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" purescript:raichoo/purescript-vim
|
||||
" purescript:purescript-contrib/purescript-vim
|
||||
au BufNewFile,BufRead *.purs setf purescript
|
||||
au FileType purescript let &l:commentstring='{--%s--}'
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" python:mitsuhiko/vim-python-combined
|
||||
" python:vim-python/python-syntax
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -722,6 +795,10 @@ augroup filetypedetect
|
||||
autocmd FileType python compiler python
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" python-ident:Vimjas/vim-python-pep8-indent
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" qml:peterhoeg/vim-qml
|
||||
autocmd BufRead,BufNewFile *.qml setfiletype qml
|
||||
@@ -755,7 +832,7 @@ augroup filetypedetect
|
||||
|
||||
" Support functions {{{
|
||||
function! s:setf(filetype) abort
|
||||
if &filetype !=# a:filetype
|
||||
if &filetype !~# '\<'.a:filetype.'\>'
|
||||
let &filetype = a:filetype
|
||||
endif
|
||||
endfunction
|
||||
@@ -885,7 +962,7 @@ fun! s:DetectScala()
|
||||
endif
|
||||
endfun
|
||||
|
||||
au BufRead,BufNewFile *.scala set filetype=scala
|
||||
au BufRead,BufNewFile *.scala,*.sc set filetype=scala
|
||||
au BufRead,BufNewFile * call s:DetectScala()
|
||||
|
||||
" Install vim-sbt for additional syntax highlighting.
|
||||
@@ -904,7 +981,12 @@ autocmd BufNewFile,BufRead *.slim setfiletype slim
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" solidity:ethereum/vim-solidity
|
||||
" slime:slime-lang/vim-slime-syntax
|
||||
autocmd BufNewFile,BufRead *.slime set filetype=slime
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" solidity:tomlion/vim-solidity
|
||||
au BufNewFile,BufRead *.sol setf solidity
|
||||
augroup END
|
||||
|
||||
@@ -987,8 +1069,8 @@ augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" toml:cespare/vim-toml
|
||||
" Rust uses several TOML config files that are not named with .toml.
|
||||
autocmd BufNewFile,BufRead *.toml,Cargo.lock,*/.cargo/config set filetype=toml
|
||||
" Go dep and Rust use several TOML config files that are not named with .toml.
|
||||
autocmd BufNewFile,BufRead *.toml,Gopkg.lock,Cargo.lock,*/.cargo/config set filetype=toml
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
@@ -1024,6 +1106,17 @@ augroup filetypedetect
|
||||
au BufRead,BufNewFile *.vcl set filetype=vcl
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" vifm:vifm/vifm.vim
|
||||
autocmd BufRead,BufNewFile vifm.rename* :set filetype=vifm-rename
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" vifm:vifm/vifm.vim
|
||||
autocmd BufRead,BufNewFile vifmrc :set filetype=vifm
|
||||
autocmd BufRead,BufNewFile *vifm/colors/* :set filetype=vifm
|
||||
augroup END
|
||||
|
||||
augroup filetypedetect
|
||||
" vue:posva/vim-vue
|
||||
au BufNewFile,BufRead *.vue setf vue
|
||||
|
||||
@@ -4,6 +4,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ansible') == -1
|
||||
if exists('+regexpengine') && ('®expengine' == 0)
|
||||
setlocal regexpengine=1
|
||||
endif
|
||||
set path+=./../templates,./../files
|
||||
set path+=./../templates,./../files,templates,files
|
||||
|
||||
endif
|
||||
|
||||
149
ftplugin/elm.vim
149
ftplugin/elm.vim
@@ -1,86 +1,101 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
" elm.vim - Plugin for the Elm programming language
|
||||
" Maintainer: Alexander Noriega <http://lambdatoast.com/>
|
||||
" Version: 0.4.3
|
||||
" plugin for Elm (http://elm-lang.org/)
|
||||
|
||||
" Plugin setup stuff
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" Compilation
|
||||
" Settings
|
||||
if !exists('g:elm_jump_to_error')
|
||||
let g:elm_jump_to_error = 0
|
||||
endif
|
||||
|
||||
function! ElmMake(file)
|
||||
let args = a:file
|
||||
return elm#io#system("elm-make", args)
|
||||
endfunction
|
||||
if !exists('g:elm_make_output_file')
|
||||
let g:elm_make_output_file = 'elm.js'
|
||||
endif
|
||||
|
||||
function! ElmMakeCurrentFile()
|
||||
echo ElmMake(expand("%"))
|
||||
endfunction
|
||||
if !exists('g:elm_make_show_warnings')
|
||||
let g:elm_make_show_warnings = 0
|
||||
endif
|
||||
|
||||
function! ElmMakeMain()
|
||||
echo ElmMake("Main.elm")
|
||||
endfunction
|
||||
if !exists('g:elm_syntastic_show_warnings')
|
||||
let g:elm_syntastic_show_warnings = 0
|
||||
endif
|
||||
|
||||
function! ElmMakeFile(file)
|
||||
echo ElmMake(a:file)
|
||||
endfunction
|
||||
if !exists('g:elm_format_autosave')
|
||||
let g:elm_format_autosave = 1
|
||||
endif
|
||||
|
||||
" REPL
|
||||
if !exists('g:elm_format_fail_silently')
|
||||
let g:elm_format_fail_silently = 0
|
||||
endif
|
||||
|
||||
function! ElmRepl()
|
||||
!elm-repl
|
||||
endfunction
|
||||
if !exists('g:elm_setup_keybindings')
|
||||
let g:elm_setup_keybindings = 1
|
||||
endif
|
||||
|
||||
" Evaluation
|
||||
|
||||
function! ElmEvalLine()
|
||||
return ElmEval(getline("."))
|
||||
endfunction
|
||||
|
||||
function! ElmEvalSelection()
|
||||
let savedReg = @z
|
||||
normal! `<v`>"zy
|
||||
let res = ElmEval(substitute(getreg("z"), "\n", "\\\n", "g"))
|
||||
let @z = savedReg
|
||||
normal! gv
|
||||
endfunction
|
||||
|
||||
function! ElmEval(sourceCode)
|
||||
let currentLine = a:sourceCode
|
||||
let args = "echo '" . currentLine . "' | elm-repl"
|
||||
let result = elm#io#system("echo", args)
|
||||
let cleanResult = "-- " . join(s:Filtered(function("s:IsUsefulReplOutput"), split(result, "\n")), "")
|
||||
put =cleanResult
|
||||
endfunction
|
||||
|
||||
function! s:IsUsefulReplOutput(str)
|
||||
return a:str !~ "^Elm REPL" && a:str !~ "Type :help" && a:str !~ ">\\s*$"
|
||||
endfunction
|
||||
|
||||
" List processing
|
||||
|
||||
function! s:Filtered(fn, l)
|
||||
let new_list = deepcopy(a:l)
|
||||
call filter(new_list, string(a:fn) . '(v:val)')
|
||||
return new_list
|
||||
endfunction
|
||||
|
||||
command -buffer ElmEvalLine call ElmEvalLine()
|
||||
command -buffer ElmEvalSelection call ElmEvalSelection()
|
||||
command -buffer ElmMakeMain call ElmMakeMain()
|
||||
command -buffer -nargs=1 ElmMakeFile call ElmMakeFile <args>
|
||||
command -buffer ElmMakeCurrentFile call ElmMakeCurrentFile()
|
||||
command -buffer ElmRepl call ElmRepl()
|
||||
|
||||
" Define comment convention
|
||||
setlocal omnifunc=elm#Complete
|
||||
|
||||
setlocal comments=:--
|
||||
setlocal commentstring=--%s
|
||||
setlocal commentstring=--\ %s
|
||||
|
||||
" Commands
|
||||
command -buffer -nargs=? -complete=file ElmMake call elm#Make(<f-args>)
|
||||
command -buffer ElmMakeMain call elm#Make("Main.elm")
|
||||
command -buffer -nargs=? -complete=file ElmTest call elm#Test(<f-args>)
|
||||
command -buffer ElmRepl call elm#Repl()
|
||||
command -buffer ElmErrorDetail call elm#ErrorDetail()
|
||||
command -buffer ElmShowDocs call elm#ShowDocs()
|
||||
command -buffer ElmBrowseDocs call elm#BrowseDocs()
|
||||
command -buffer ElmFormat call elm#Format()
|
||||
|
||||
if get(g:, 'elm_setup_keybindings', 1)
|
||||
nmap <buffer> <LocalLeader>m <Plug>(elm-make)
|
||||
nmap <buffer> <LocalLeader>b <Plug>(elm-make-main)
|
||||
nmap <buffer> <LocalLeader>t <Plug>(elm-test)
|
||||
nmap <buffer> <LocalLeader>r <Plug>(elm-repl)
|
||||
nmap <buffer> <LocalLeader>e <Plug>(elm-error-detail)
|
||||
nmap <buffer> <LocalLeader>d <Plug>(elm-show-docs)
|
||||
nmap <buffer> <LocalLeader>w <Plug>(elm-browse-docs)
|
||||
endif
|
||||
|
||||
" Better gf command
|
||||
nmap <buffer> gf :call elm#util#GoToModule(expand('<cfile>'))<CR>
|
||||
|
||||
" Elm code formatting on save
|
||||
if get(g:, 'elm_format_autosave', 1)
|
||||
augroup elmFormat
|
||||
autocmd!
|
||||
autocmd BufWritePre *.elm call elm#Format()
|
||||
autocmd BufWritePost *.elm call elm#util#EchoStored()
|
||||
augroup END
|
||||
endif
|
||||
if has('win32')
|
||||
set viewdir=$HOME/vimfiles/views/
|
||||
endif
|
||||
|
||||
" Enable go to file under cursor from module name
|
||||
" Based on: https://github.com/elixir-lang/vim-elixir/blob/bd66ed134319d1e390f3331e8c4d525109f762e8/ftplugin/elixir.vim#L22-L56
|
||||
function! GetElmFilename(word)
|
||||
let l:word = a:word
|
||||
|
||||
" replace module dots with slash
|
||||
let l:word = substitute(l:word,'\.','/','g')
|
||||
|
||||
return l:word
|
||||
endfunction
|
||||
|
||||
let &l:path =
|
||||
\ join([
|
||||
\ elm#FindRootDirectory().'/src',
|
||||
\ elm#FindRootDirectory().'/elm-stuff/packages/**/src',
|
||||
\ &g:path
|
||||
\ ], ',')
|
||||
setlocal includeexpr=GetElmFilename(v:fname)
|
||||
setlocal include=^\\s*import\\s\\+
|
||||
setlocal suffixesadd=.elm
|
||||
|
||||
endif
|
||||
|
||||
24
ftplugin/elm/tagbar.vim
Normal file
24
ftplugin/elm/tagbar.vim
Normal file
@@ -0,0 +1,24 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
if !executable('ctags')
|
||||
finish
|
||||
elseif globpath(&runtimepath, 'plugin/tagbar.vim') ==? ''
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:SetTagbar()
|
||||
if !exists('g:tagbar_type_elm')
|
||||
let g:tagbar_type_elm = {
|
||||
\ 'ctagstype' : 'elm',
|
||||
\ 'kinds' : [
|
||||
\ 'c:constants',
|
||||
\ 'f:functions',
|
||||
\ 'p:ports'
|
||||
\ ]
|
||||
\ }
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call s:SetTagbar()
|
||||
|
||||
endif
|
||||
@@ -29,7 +29,7 @@ elseif !exists("b:eruby_subtype")
|
||||
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
||||
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
||||
if b:eruby_subtype == ''
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
endif
|
||||
if b:eruby_subtype == 'rhtml'
|
||||
let b:eruby_subtype = 'html'
|
||||
@@ -47,7 +47,7 @@ elseif !exists("b:eruby_subtype")
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby'
|
||||
exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
|
||||
else
|
||||
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
||||
|
||||
@@ -31,7 +31,7 @@ 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'
|
||||
execute 'setlocal keywordprg=fish\ '.fnameescape(expand('<sfile>:p:h:h').'/bin/man.fish')
|
||||
|
||||
let b:match_words =
|
||||
\ escape('<%(begin|function|if|switch|while|for)>:<end>', '<>%|)')
|
||||
|
||||
@@ -28,11 +28,12 @@ function! s:cycle()
|
||||
call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick'))
|
||||
endfunction
|
||||
|
||||
command! -buffer -bar Pick :call s:choose('pick')
|
||||
command! -buffer -bar Squash :call s:choose('squash')
|
||||
command! -buffer -bar Edit :call s:choose('edit')
|
||||
command! -buffer -bar Reword :call s:choose('reword')
|
||||
command! -buffer -bar Fixup :call s:choose('fixup')
|
||||
command! -buffer -bar -range Pick :<line1>,<line2>call s:choose('pick')
|
||||
command! -buffer -bar -range Squash :<line1>,<line2>call s:choose('squash')
|
||||
command! -buffer -bar -range Edit :<line1>,<line2>call s:choose('edit')
|
||||
command! -buffer -bar -range Reword :<line1>,<line2>call s:choose('reword')
|
||||
command! -buffer -bar -range Fixup :<line1>,<line2>call s:choose('fixup')
|
||||
command! -buffer -bar -range Drop :<line1>,<line2>call s:choose('drop')
|
||||
command! -buffer -bar Cycle :call s:cycle()
|
||||
" The above are more useful when they are mapped; for example:
|
||||
"nnoremap <buffer> <silent> S :Cycle<CR>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'graphql') == -1
|
||||
|
||||
" Vim filetype plugin
|
||||
" Language: GraphQL
|
||||
" Maintainer: Jon Parise <jon@indelible.org>
|
||||
|
||||
if (exists("b:did_ftplugin"))
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal comments=:#
|
||||
setlocal commentstring=#\ %s
|
||||
setlocal formatoptions-=t
|
||||
setlocal iskeyword+=$,@-@
|
||||
|
||||
endif
|
||||
99
ftplugin/julia.vim
Normal file
99
ftplugin/julia.vim
Normal file
@@ -0,0 +1,99 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
||||
|
||||
" Vim filetype plugin file
|
||||
" Language: Julia
|
||||
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
|
||||
" Last Change: 2014 may 29
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo-=C
|
||||
|
||||
setlocal include=^\\s*\\%(reload\\\|include\\)\\>
|
||||
setlocal suffixesadd=.jl
|
||||
setlocal comments=:#
|
||||
setlocal commentstring=#=%s=#
|
||||
setlocal cinoptions+=#1
|
||||
setlocal define=^\\s*macro\\>
|
||||
|
||||
let b:julia_vim_loaded = 1
|
||||
|
||||
let b:undo_ftplugin = "setlocal include< suffixesadd< comments< commentstring<"
|
||||
\ . " define< shiftwidth< expandtab< indentexpr< indentkeys< cinoptions< omnifunc<"
|
||||
\ . " | unlet! b:julia_vim_loaded"
|
||||
|
||||
" MatchIt plugin support
|
||||
if exists("loaded_matchit")
|
||||
let b:match_ignorecase = 0
|
||||
|
||||
" note: begin_keywords must contain all blocks in order
|
||||
" for nested-structures-skipping to work properly
|
||||
let b:julia_begin_keywords = '\%(\%(\.\s*\)\@<!\|\%(@\s*.\s*\)\@<=\)\<\%(\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|\%(\(abstract\|primitive\)\s\+\)\@<!type\|immutable\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\>'
|
||||
let s:macro_regex = '@\%(#\@!\S\)\+\s\+'
|
||||
let s:nomacro = '\%(' . s:macro_regex . '\)\@<!'
|
||||
let s:yesmacro = s:nomacro . '\%('. s:macro_regex . '\)\+'
|
||||
let b:julia_begin_keywordsm = '\%(' . s:yesmacro . b:julia_begin_keywords . '\)\|'
|
||||
\ . '\%(' . s:nomacro . b:julia_begin_keywords . '\)'
|
||||
let b:julia_end_keywords = '\<end\>'
|
||||
|
||||
" note: this function relies heavily on the syntax file
|
||||
function! JuliaGetMatchWords()
|
||||
let [l,c] = [line('.'),col('.')]
|
||||
let attr = synIDattr(synID(l, c, 1),"name")
|
||||
let c1 = c
|
||||
while attr == 'juliaMacro'
|
||||
normal! W
|
||||
if line('.') > l || col('.') == c1
|
||||
call cursor(l, c)
|
||||
return ''
|
||||
endif
|
||||
let attr = synIDattr(synID(l, col('.'), 1),"name")
|
||||
let c1 = col('.')
|
||||
endwhile
|
||||
call cursor(l, c)
|
||||
if attr == 'juliaConditional'
|
||||
return b:julia_begin_keywordsm . ':\<\%(elseif\|else\)\>:' . b:julia_end_keywords
|
||||
elseif attr =~ '\<\%(juliaRepeat\|juliaRepKeyword\)\>'
|
||||
return b:julia_begin_keywordsm . ':\<\%(break\|continue\)\>:' . b:julia_end_keywords
|
||||
elseif attr == 'juliaBlKeyword'
|
||||
return b:julia_begin_keywordsm . ':' . b:julia_end_keywords
|
||||
elseif attr == 'juliaException'
|
||||
return b:julia_begin_keywordsm . ':\<\%(catch\|finally\)\>:' . b:julia_end_keywords
|
||||
endif
|
||||
return '\<\>:\<\>'
|
||||
endfunction
|
||||
|
||||
let b:match_words = 'JuliaGetMatchWords()'
|
||||
|
||||
" we need to skip everything within comments, strings and
|
||||
" the 'end' keyword when it is used as a range rather than as
|
||||
" the end of a block
|
||||
let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") =~ '
|
||||
\ . '"\\<julia\\%(Comprehension\\%(For\\|If\\)\\|RangeEnd\\|SymbolS\\?\\|Comment[LM]\\|\\%([bv]\\|ip\\|MIME\\|Shell\\|Doc\\)\\?String\\|RegEx\\)\\>"'
|
||||
|
||||
let b:undo_ftplugin = b:undo_ftplugin
|
||||
\ . " | unlet! b:match_words b:match_skip b:match_ignorecase"
|
||||
\ . " | unlet! b:julia_begin_keywords b:julia_end_keywords"
|
||||
\ . " | delfunction JuliaGetMatchWords"
|
||||
\ . " | call julia_blocks#remove_mappings()"
|
||||
|
||||
if get(g:, "julia_blocks", 1)
|
||||
call julia_blocks#init_mappings()
|
||||
let b:undo_ftplugin .= " | call julia_blocks#remove_mappings()"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if has("gui_win32")
|
||||
let b:browsefilter = "Julia Source Files (*.jl)\t*.jl\n"
|
||||
let b:undo_ftplugin = b:undo_ftplugin . " | unlet! b:browsefilter"
|
||||
endif
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
endif
|
||||
66
ftplugin/mail_vifm.vim
Normal file
66
ftplugin/mail_vifm.vim
Normal file
@@ -0,0 +1,66 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
|
||||
|
||||
" Mail file type extension to pick files for attachments via vifm
|
||||
" Maintainer: xaizek <xaizek@posteo.net>
|
||||
" Last Change: January 23, 2016
|
||||
|
||||
" Insert attachment picked via vifm after 'Subject' header
|
||||
function! s:AddMailAttacments()
|
||||
" TODO: reduce duplication between this file and plugins/vifm.vim
|
||||
let l:listf = tempname()
|
||||
|
||||
if !has('nvim')
|
||||
if has('gui_running')
|
||||
execute 'silent !' g:vifm_term g:vifm_exec
|
||||
\ '--choose-files' shellescape(l:listf, 1)
|
||||
\ g:vifm_exec_args
|
||||
else
|
||||
execute 'silent !' g:vifm_exec
|
||||
\ '--choose-files' shellescape(l:listf, 1)
|
||||
\ g:vifm_exec_args
|
||||
endif
|
||||
|
||||
redraw!
|
||||
|
||||
call s:HandleRunResults(v:shell_error, l:listf)
|
||||
else
|
||||
" Work around handicapped neovim...
|
||||
let callback = { 'listf': l:listf }
|
||||
function! callback.on_exit(id, code)
|
||||
buffer #
|
||||
silent! bdelete! #
|
||||
call s:HandleRunResults(a:code, self.listf)
|
||||
endfunction
|
||||
enew
|
||||
call termopen(g:vifm_exec . ' --choose-files ' . shellescape(l:listf, 1)
|
||||
\. ' ' . g:vifm_exec_args, callback)
|
||||
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:HandleRunResults(exitcode, listf)
|
||||
if a:exitcode != 0
|
||||
echohl WarningMsg
|
||||
echo 'Got non-zero code from vifm: ' . a:exitcode
|
||||
echohl None
|
||||
call delete(a:listf)
|
||||
return
|
||||
endif
|
||||
|
||||
let l:insert_pos = search('^Subject:', 'nw')
|
||||
|
||||
if filereadable(a:listf) && l:insert_pos != 0
|
||||
for line in readfile(a:listf)
|
||||
call append(l:insert_pos, 'Attach: '.line)
|
||||
let l:insert_pos += 1
|
||||
endfor
|
||||
endif
|
||||
call delete(a:listf)
|
||||
endfunction
|
||||
|
||||
nnoremap <buffer> <silent> <localleader>a :call <sid>AddMailAttacments()<cr>
|
||||
|
||||
" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 :
|
||||
|
||||
endif
|
||||
@@ -1,17 +1,17 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin=1
|
||||
" Vim filetype plugin
|
||||
" Language: Nix
|
||||
" Maintainer: Daiderd Jordan <daiderd@gmail.com>
|
||||
" URL: https://github.com/LnL7/vim-nix
|
||||
|
||||
setlocal comments=
|
||||
if (exists("b:did_ftplugin"))
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
|
||||
setlocal comments=:#
|
||||
setlocal commentstring=#\ %s
|
||||
|
||||
" Nixpkgs indent settings
|
||||
setlocal tabstop=2
|
||||
setlocal softtabstop=2
|
||||
setlocal shiftwidth=2
|
||||
setlocal expandtab
|
||||
|
||||
endif
|
||||
|
||||
@@ -19,8 +19,6 @@ setlocal formatoptions=tcqro
|
||||
" Enable autocompletion of hyphenated PowerShell commands,
|
||||
" e.g. Get-Content or Get-ADUser
|
||||
setlocal iskeyword+=-
|
||||
" MS applications (including PowerShell) require a Byte Order Mark (BOM) for UTF-8.
|
||||
setlocal bomb
|
||||
|
||||
" Change the browse dialog on Win32 to show mainly PowerShell-related files
|
||||
if has("gui_win32")
|
||||
|
||||
@@ -16,8 +16,6 @@ let b:did_ftplugin = 1
|
||||
setlocal tw=0
|
||||
setlocal commentstring=#%s
|
||||
setlocal formatoptions=tcqro
|
||||
" MS applications (including PowerShell) require a Byte Order Mark (BOM) for UTF-8.
|
||||
setlocal bomb
|
||||
|
||||
" Change the browse dialog on Win32 to show mainly PowerShell-related files
|
||||
if has("gui_win32")
|
||||
|
||||
@@ -1,5 +1,42 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'purescript') == -1
|
||||
|
||||
setlocal comments=s1fl:{-,mb:\ \ ,ex:-},:--
|
||||
setlocal include=^import
|
||||
setlocal includeexpr=printf('%s.purs',substitute(v:fname,'\\.','/','g'))
|
||||
|
||||
let s:PS = []
|
||||
fun! InitPureScript()
|
||||
let dirs = map(
|
||||
\ findfile("psc-package.json", expand("%:p:h") . ";/", -1),
|
||||
\ { idx, val -> fnamemodify(val, ":p:h") }
|
||||
\ )
|
||||
if empty(dirs)
|
||||
let dirs = map(
|
||||
\ findfile("bower.json", expand("%:p:h") . ";/", -1),
|
||||
\ { idx, val -> fnamemodify(val, ":p:h") }
|
||||
\ )
|
||||
if empty(dirs)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
let path = expand("%:p")
|
||||
for p in s:PS
|
||||
if stridx(path, p[0], 0) == 0
|
||||
let &l:path=p[1]
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
let dir = dirs[len(dirs) - 1]
|
||||
let gp = globpath(dir, "src/**/*.purs", v:true, v:true)
|
||||
if empty(gp)
|
||||
return
|
||||
endif
|
||||
|
||||
let &l:path=join([dir, dir . "/bower_components/**", dir . "/src/**"], ",")
|
||||
call add(s:PS, [dir, &l:path])
|
||||
endfun
|
||||
call InitPureScript()
|
||||
|
||||
endif
|
||||
|
||||
@@ -365,6 +365,7 @@ function! RubyCursorFile() abort
|
||||
let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''
|
||||
if s:synid() ==# hlID('rubyConstant')
|
||||
let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')
|
||||
let cfile = substitute(cfile,'^::','','')
|
||||
let cfile = substitute(cfile,'::','/','g')
|
||||
let cfile = substitute(cfile,'\(\u\+\)\(\u\l\)','\1_\2', 'g')
|
||||
let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
|
||||
" Language: Rust
|
||||
" Description: Vim syntax file for Rust
|
||||
" Description: Vim ftplugin for Rust
|
||||
" Maintainer: Chris Morgan <me@chrismorgan.info>
|
||||
" Maintainer: Kevin Ballard <kevin@sb.org>
|
||||
" Last Change: June 08, 2016
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
@@ -193,19 +194,13 @@ endif
|
||||
|
||||
augroup END
|
||||
|
||||
" %-matching. <:> is handy for generics.
|
||||
set matchpairs+=<:>
|
||||
" There are two minor issues with it; (a) comparison operators in expressions,
|
||||
" where a less-than may match a greater-than later on—this is deemed a trivial
|
||||
" issue—and (b) `Fn() -> X` syntax. This latter issue is irremediable from the
|
||||
" highlighting perspective (built into Vim), but the actual % functionality
|
||||
" can be fixed by this use of matchit.vim.
|
||||
" For matchit.vim (rustArrow stops `Fn() -> X` messing things up)
|
||||
let b:match_skip = 's:comment\|string\|rustArrow'
|
||||
source $VIMRUNTIME/macros/matchit.vim
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set noet sw=4 ts=4:
|
||||
" vim: set noet sw=8 ts=8:
|
||||
|
||||
endif
|
||||
|
||||
5
ftplugin/solidity.vim
Normal file
5
ftplugin/solidity.vim
Normal file
@@ -0,0 +1,5 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'solidity') == -1
|
||||
|
||||
setlocal commentstring=//\ %s
|
||||
|
||||
endif
|
||||
@@ -15,7 +15,7 @@ setlocal commentstring=//\ %s
|
||||
" " and insert the comment leader when hitting <CR> or using "o".
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
|
||||
setlocal suffixesadd+=.ts
|
||||
setlocal suffixesadd+=.ts,.tsx
|
||||
|
||||
let b:undo_ftplugin = "setl fo< ofu< com< cms<"
|
||||
|
||||
|
||||
23
ftplugin/vifm-cmdedit.vim
Normal file
23
ftplugin/vifm-cmdedit.vim
Normal file
@@ -0,0 +1,23 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
|
||||
|
||||
" vifm command-line editing buffer filetype plugin
|
||||
" Maintainer: xaizek <xaizek@posteo.net>
|
||||
" Last Change: August 18, 2013
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" Behave as vifm script file
|
||||
runtime! ftplugin/vifm.vim
|
||||
|
||||
" Use vifm script highlighting
|
||||
set syntax=vifm
|
||||
|
||||
call vifm#edit#Init()
|
||||
|
||||
" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 :
|
||||
|
||||
endif
|
||||
17
ftplugin/vifm-edit.vim
Normal file
17
ftplugin/vifm-edit.vim
Normal file
@@ -0,0 +1,17 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
|
||||
|
||||
" vifm command-line editing buffer filetype plugin
|
||||
" Maintainer: xaizek <xaizek@posteo.net>
|
||||
" Last Change: August 18, 2013
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
call vifm#edit#Init()
|
||||
|
||||
" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 :
|
||||
|
||||
endif
|
||||
62
ftplugin/vifm-rename.vim
Normal file
62
ftplugin/vifm-rename.vim
Normal file
@@ -0,0 +1,62 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
|
||||
|
||||
" Filetype plugin for vifm rename buffer
|
||||
" Maintainer: xaizek <xaizek@posteo.net>
|
||||
" Last Change: October 05, 2014
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
" Copy list of original file names
|
||||
let s:files = getline(1, '$')
|
||||
|
||||
" Closes window/tab/Vim when buffer is left alone in there
|
||||
function! s:QuitIfOnlyWindow()
|
||||
" Boil out if there is more than one window
|
||||
if winbufnr(2) != -1
|
||||
return
|
||||
endif
|
||||
|
||||
" Just close tab with this single window or quit Vim with last tab
|
||||
if tabpagenr('$') == 1
|
||||
bdelete
|
||||
quit
|
||||
else
|
||||
close
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Create a vertical split window for original file names and configure it
|
||||
belowright vsplit __VifmRenameOrig__
|
||||
enew
|
||||
call setline(1, s:files)
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=hide
|
||||
setlocal noswapfile
|
||||
setlocal nobuflisted
|
||||
setlocal cursorbind
|
||||
setlocal scrollbind
|
||||
setlocal nocursorline
|
||||
|
||||
" Free now useless list of file names
|
||||
unlet s:files
|
||||
|
||||
" Setup a hook in auxiliary local window to do not leave it alone, when it's
|
||||
" useless
|
||||
augroup VifmRenameAutoCmds
|
||||
autocmd! * <buffer>
|
||||
autocmd BufEnter <buffer> call s:QuitIfOnlyWindow()
|
||||
augroup END
|
||||
|
||||
" Go back to the original window and ensure it will remain synchronized with
|
||||
" the auxiliary one
|
||||
wincmd w
|
||||
setlocal cursorbind
|
||||
setlocal scrollbind
|
||||
|
||||
" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 :
|
||||
|
||||
endif
|
||||
50
ftplugin/vifm.vim
Normal file
50
ftplugin/vifm.vim
Normal file
@@ -0,0 +1,50 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1
|
||||
|
||||
" vifmrc filetype plugin
|
||||
" Maintainer: xaizek <xaizek@posteo.net>
|
||||
" Last Change: July 08, 2016
|
||||
" Based On: Vim file type file by Bram Moolenaar
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
|
||||
let b:undo_ftplugin = "setlocal formatoptions< comments< textwidth< commentstring<"
|
||||
|
||||
" Break comment lines but not other lines
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
|
||||
" Set comment character
|
||||
setlocal comments=:\"
|
||||
|
||||
" Format comments to be up to 78 characters long
|
||||
if &textwidth == 0
|
||||
setlocal textwidth=78
|
||||
endif
|
||||
|
||||
" Comments start with a double quote
|
||||
setlocal commentstring=\"%s
|
||||
|
||||
" Move around comments
|
||||
nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
|
||||
vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
|
||||
nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
|
||||
vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
|
||||
|
||||
" Let the matchit plugin know what items can be matched.
|
||||
if exists("loaded_matchit")
|
||||
let b:match_ignorecase = 0
|
||||
let b:match_words = '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>'
|
||||
endif
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 :
|
||||
|
||||
endif
|
||||
@@ -13,6 +13,13 @@ runtime! ftplugin/html.vim
|
||||
|
||||
setlocal suffixesadd+=.vue
|
||||
|
||||
if !exists('g:no_plugin_maps') && !exists('g:no_vue_maps')
|
||||
nnoremap <silent> <buffer> [[ :call search('^<\(template\<Bar>script\<Bar>style\)', 'bW')<CR>
|
||||
nnoremap <silent> <buffer> ]] :call search('^<\(template\<Bar>script\<Bar>style\)', 'W')<CR>
|
||||
nnoremap <silent> <buffer> [] :call search('^</\(template\<Bar>script\<Bar>style\)', 'bW')<CR>
|
||||
nnoremap <silent> <buffer> ][ :call search('^</\(template\<Bar>script\<Bar>style\)', 'W')<CR>
|
||||
endif
|
||||
|
||||
if exists('g:loaded_ale')
|
||||
let g:ale_linters = get(g:, 'ale_linters', {})
|
||||
let g:ale_linters.vue = get(g:ale_linters, 'vue', ['eslint'])
|
||||
|
||||
5
indent/Jenkinsfile.vim
Normal file
5
indent/Jenkinsfile.vim
Normal file
@@ -0,0 +1,5 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jenkins') == -1
|
||||
|
||||
runtime indent/groovy.vim
|
||||
|
||||
endif
|
||||
223
indent/autohotkey.vim
Normal file
223
indent/autohotkey.vim
Normal file
@@ -0,0 +1,223 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'autohotkey') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: AutoHotkey
|
||||
" Maintainer: Hirotoshi Namikawa <hnamikaw1@gmail.com>
|
||||
" URL: http://github.com/hnamikaw/vim-autohotkey
|
||||
" License: Same as Vim.
|
||||
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetAutoHotkeyIndent()
|
||||
setlocal indentkeys=!^F,o,O,0{,0},=if,=else,=return
|
||||
setlocal expandtab
|
||||
|
||||
let b:undo_indent = 'setlocal '.join([
|
||||
\ 'autoindent<',
|
||||
\ 'indentexpr<',
|
||||
\ 'indentkeys<',
|
||||
\ 'expandtab<',
|
||||
\ ])
|
||||
|
||||
let s:TRUE = !0
|
||||
let s:FALSE = 0
|
||||
|
||||
" Check BEGIN BLOCK
|
||||
" TRUE:
|
||||
" {
|
||||
" { ; with comment
|
||||
" if {
|
||||
" if { ; with comment
|
||||
"
|
||||
" FALSE:
|
||||
" ; if { comment
|
||||
" sleep 1000 ; {
|
||||
function! IsBeginBlockByStr(str)
|
||||
return a:str =~? '^[^;]*{\s*\(;.*\)\?$' ? s:TRUE : s:FALSE
|
||||
endfunction
|
||||
|
||||
" Check END BLOCK
|
||||
" TRUE:
|
||||
" }
|
||||
" } ; with comment
|
||||
" } else {
|
||||
" } else { ; with comment
|
||||
"
|
||||
" FALSE:
|
||||
" ; } else {
|
||||
function! IsEndBlockByStr(str)
|
||||
return a:str =~? '^\s*}.*\(;.*\)\?$' ? s:TRUE : s:FALSE
|
||||
endfunction
|
||||
|
||||
" Check DOUBLE CORON
|
||||
" TRUE:
|
||||
" LAlt up::
|
||||
" LAlt up:: ; with comment
|
||||
"
|
||||
" FALSE:
|
||||
" ; LAlt up::
|
||||
" sleep 1000 ; ::
|
||||
function! IsDoubleCoronByStr(str)
|
||||
return a:str =~? '^[^;]*::\s*\(;.*\)\?$' ? s:TRUE : s:FALSE
|
||||
endfunction
|
||||
|
||||
" Check RETURN
|
||||
" TRUE:
|
||||
" return
|
||||
" return 1
|
||||
" return ; with comment
|
||||
"
|
||||
" FALSE:
|
||||
" ; return
|
||||
function! IsReturnByStr(str)
|
||||
return a:str =~? '^\s*return.*\(;.*\)\?$' ? s:TRUE : s:FALSE
|
||||
endfunction
|
||||
|
||||
" Check IF STATEMENT(without BLOCK)
|
||||
" TRUE:
|
||||
" if
|
||||
" if ; with comment
|
||||
" else
|
||||
" else ; with comment
|
||||
"
|
||||
" FALSE:
|
||||
" if {
|
||||
" else {
|
||||
function! IsIfStatementByStr(str)
|
||||
return a:str =~? '^\s*\(if\|else\)[^{]*\(;.*\)\?$' ? s:TRUE : s:FALSE
|
||||
endfunction
|
||||
|
||||
" Check inside of BLOCK.
|
||||
" TRUE:
|
||||
" if {
|
||||
" hogehoge
|
||||
" fugafuga <--- line_num
|
||||
" }
|
||||
"
|
||||
" FALSE:
|
||||
" foobar <--- line_num
|
||||
function! IsInsideOfBlockByNum(line_num)
|
||||
let block_indent_level = 0
|
||||
|
||||
for scan_line_num in range(1, a:line_num)
|
||||
if IsBeginBlockByStr(getline(scan_line_num)) == s:TRUE
|
||||
let block_indent_level += 1
|
||||
endif
|
||||
|
||||
if IsEndBlockByStr(getline(scan_line_num)) == s:TRUE
|
||||
let block_indent_level -= 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return block_indent_level >= 1 ? s:TRUE : s:FALSE
|
||||
endfunction
|
||||
|
||||
function! AddIndentByInd(indent)
|
||||
return a:indent + &l:shiftwidth
|
||||
endfunction
|
||||
|
||||
function! UnIndentByInd(indent)
|
||||
return a:indent - &l:shiftwidth
|
||||
endfunction
|
||||
|
||||
function! GetAutoHotkeyIndent()
|
||||
let l0_num = v:lnum
|
||||
let l1_num = v:lnum - 1
|
||||
let pl1_num = prevnonblank(l1_num)
|
||||
let pl2_num = prevnonblank(pl1_num - 1)
|
||||
|
||||
let l0_str = getline(l0_num)
|
||||
let pl1_str = getline(pl1_num)
|
||||
let pl2_str = getline(pl2_num)
|
||||
let pl1_ind = indent(pl1_num)
|
||||
let pl2_ind = indent(pl2_num)
|
||||
|
||||
" Case: Next line of IF STATEMENT(without BLOCK)
|
||||
" if bar = 1
|
||||
" callFunc1() <--- AddIndent
|
||||
"
|
||||
" if bar = 1
|
||||
" { <--- No! AddIndent
|
||||
if IsIfStatementByStr(pl1_str) == s:TRUE && IsBeginBlockByStr(l0_str) == s:FALSE
|
||||
return AddIndentByInd(pl1_ind)
|
||||
endif
|
||||
|
||||
" Case: End of IF STATEMENT(without BLOCK)
|
||||
" if bar = 1
|
||||
" callFunc1()
|
||||
" if bar = 2 <--- UnIndent
|
||||
"
|
||||
" Case: End of IF STATEMENT(without BLOCK) and END BLOCK(of outer block)
|
||||
" if foo
|
||||
" {
|
||||
" if bar = 3
|
||||
" callFunc3()
|
||||
" } <--- UnIndent (2level)
|
||||
if IsIfStatementByStr(pl2_str) == s:TRUE && IsBeginBlockByStr(pl1_str) == s:FALSE
|
||||
if IsEndBlockByStr(l0_str) == s:FALSE
|
||||
return UnIndentByInd(pl1_ind)
|
||||
else
|
||||
return UnIndentByInd(pl2_ind)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Case: Next line of BEGIN BLOCK
|
||||
" Swap(ByRef Left, ByRef Right)
|
||||
" {
|
||||
" temp := Left <--- AddIndent
|
||||
" Left := Right
|
||||
" Right := temp
|
||||
" }
|
||||
if IsBeginBlockByStr(pl1_str) == s:TRUE
|
||||
return AddIndentByInd(pl1_ind)
|
||||
endif
|
||||
|
||||
" Case: END BLOCK
|
||||
" Swap(ByRef Left, ByRef Right)
|
||||
" {
|
||||
" temp := Left
|
||||
" Left := Right
|
||||
" Right := temp
|
||||
" } <--- UnIndent
|
||||
if IsEndBlockByStr(l0_str) == s:TRUE
|
||||
return UnIndentByInd(pl1_ind)
|
||||
endif
|
||||
|
||||
" Case: Next line of DOUBLE CORON
|
||||
" #n::
|
||||
" Run Notepad <--- AddIndent
|
||||
" return
|
||||
if IsDoubleCoronByStr(pl1_str) == s:TRUE
|
||||
return AddIndentByInd(pl1_ind)
|
||||
endif
|
||||
|
||||
" Case: RETURN
|
||||
" Note: It is not nothing if in the BLOCK.
|
||||
" #n::
|
||||
" Run Notepad
|
||||
" return <--- UnIndent
|
||||
" ~~~
|
||||
" if foo
|
||||
" {
|
||||
" callFunc1()
|
||||
" return <--- No! UnIndent
|
||||
" }
|
||||
if IsReturnByStr(l0_str) == s:TRUE && IsInsideOfBlockByNum(l0_num) == s:FALSE
|
||||
return UnIndentByInd(pl1_ind)
|
||||
endif
|
||||
|
||||
" Case: Top line.
|
||||
if pl1_num == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Case: It does not match anything.
|
||||
return pl1_ind
|
||||
endfunction
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
endif
|
||||
@@ -19,7 +19,7 @@ let b:did_indent = 1
|
||||
|
||||
" Doesn't include 'foreach' and 'forelse' because these already get matched by 'for'.
|
||||
let s:directives_start = 'if\|else\|unless\|for\|while\|empty\|push\|section\|can\|hasSection\|verbatim\|php\|' .
|
||||
\ 'component\|slot\|prepend'
|
||||
\ 'component\|slot\|prepend\|auth\|guest'
|
||||
let s:directives_end = 'else\|end\|empty\|show\|stop\|append\|overwrite'
|
||||
|
||||
if exists('g:blade_custom_directives_pairs')
|
||||
|
||||
@@ -192,11 +192,7 @@ if exists("*searchpairpos")
|
||||
" Check if form is a reader conditional, that is, it is prefixed by #?
|
||||
" or @#?
|
||||
function! s:is_reader_conditional_special_case(position)
|
||||
if getline(a:position[0])[a:position[1] - 3 : a:position[1] - 2] == "#?"
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
return getline(a:position[0])[a:position[1] - 3 : a:position[1] - 2] == "#?"
|
||||
endfunction
|
||||
|
||||
" Returns 1 for opening brackets, -1 for _anything else_.
|
||||
@@ -294,6 +290,19 @@ if exists("*searchpairpos")
|
||||
return paren
|
||||
endif
|
||||
|
||||
" If the keyword begins with #, check if it is an anonymous
|
||||
" function or set, in which case we indent by the shiftwidth
|
||||
" (minus one if g:clojure_align_subforms = 1), or if it is
|
||||
" ignored, in which case we use the ( position for indent.
|
||||
if w[0] == "#"
|
||||
" TODO: Handle #=() and other rare reader invocations?
|
||||
if w[1] == '(' || w[1] == '{'
|
||||
return [paren[0], paren[1] + (g:clojure_align_subforms ? 0 : &shiftwidth - 1)]
|
||||
elseif w[1] == '_'
|
||||
return paren
|
||||
endif
|
||||
endif
|
||||
|
||||
" Test words without namespace qualifiers and leading reader macro
|
||||
" metacharacters.
|
||||
"
|
||||
|
||||
93
indent/cmake.vim
Normal file
93
indent/cmake.vim
Normal file
@@ -0,0 +1,93 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cmake') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: CMake (ft=cmake)
|
||||
" Author: Andy Cedilnik <andy.cedilnik@kitware.com>
|
||||
" Maintainer: Dimitri Merejkowsky <d.merej@gmail.com>
|
||||
" Former Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
|
||||
" Last Change: 2017 Aug 30
|
||||
"
|
||||
" Licence: The CMake license applies to this file. See
|
||||
" https://cmake.org/licensing
|
||||
" This implies that distribution with Vim is allowed
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
let s:keepcpo= &cpo
|
||||
set cpo&vim
|
||||
|
||||
setlocal indentexpr=CMakeGetIndent(v:lnum)
|
||||
setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE(
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*CMakeGetIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
fun! CMakeGetIndent(lnum)
|
||||
let this_line = getline(a:lnum)
|
||||
|
||||
" Find a non-blank line above the current line.
|
||||
let lnum = a:lnum
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
let previous_line = getline(lnum)
|
||||
|
||||
" Hit the start of the file, use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(lnum)
|
||||
|
||||
let or = '\|'
|
||||
" Regular expressions used by line indentation function.
|
||||
let cmake_regex_comment = '#.*'
|
||||
let cmake_regex_identifier = '[A-Za-z][A-Za-z0-9_]*'
|
||||
let cmake_regex_quoted = '"\([^"\\]\|\\.\)*"'
|
||||
let cmake_regex_arguments = '\(' . cmake_regex_quoted .
|
||||
\ or . '\$(' . cmake_regex_identifier . ')' .
|
||||
\ or . '[^()\\#"]' . or . '\\.' . '\)*'
|
||||
|
||||
let cmake_indent_comment_line = '^\s*' . cmake_regex_comment
|
||||
let cmake_indent_blank_regex = '^\s*$'
|
||||
let cmake_indent_open_regex = '^\s*' . cmake_regex_identifier .
|
||||
\ '\s*(' . cmake_regex_arguments .
|
||||
\ '\(' . cmake_regex_comment . '\)\?$'
|
||||
|
||||
let cmake_indent_close_regex = '^' . cmake_regex_arguments .
|
||||
\ ')\s*' .
|
||||
\ '\(' . cmake_regex_comment . '\)\?$'
|
||||
|
||||
let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\|FUNCTION\)\s*('
|
||||
let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|ENDWHILE\|ENDFUNCTION\)\s*('
|
||||
|
||||
" Add
|
||||
if previous_line =~? cmake_indent_comment_line " Handle comments
|
||||
let ind = ind
|
||||
else
|
||||
if previous_line =~? cmake_indent_begin_regex
|
||||
let ind = ind + shiftwidth()
|
||||
endif
|
||||
if previous_line =~? cmake_indent_open_regex
|
||||
let ind = ind + shiftwidth()
|
||||
endif
|
||||
endif
|
||||
|
||||
" Subtract
|
||||
if this_line =~? cmake_indent_end_regex
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
if previous_line =~? cmake_indent_close_regex
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfun
|
||||
|
||||
let &cpo = s:keepcpo
|
||||
unlet s:keepcpo
|
||||
|
||||
endif
|
||||
433
indent/cython.vim
Normal file
433
indent/cython.vim
Normal file
@@ -0,0 +1,433 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'python-ident') == -1
|
||||
|
||||
" PEP8 compatible Python indent file
|
||||
" Language: Python
|
||||
" Maintainer: Daniel Hahler <https://daniel.hahler.de/>
|
||||
" Prev Maintainer: Hynek Schlawack <hs@ox.cx>
|
||||
" Prev Maintainer: Eric Mc Sween <em@tomcom.de> (address invalid)
|
||||
" Original Author: David Bustos <bustos@caltech.edu> (address invalid)
|
||||
" License: CC0
|
||||
"
|
||||
" vim-python-pep8-indent - A nicer Python indentation style for vim.
|
||||
" Written in 2004 by David Bustos <bustos@caltech.edu>
|
||||
" Maintained from 2004-2005 by Eric Mc Sween <em@tomcom.de>
|
||||
" Maintained from 2013 by Hynek Schlawack <hs@ox.cx>
|
||||
" Maintained from 2017 by Daniel Hahler <https://daniel.hahler.de/>
|
||||
"
|
||||
" To the extent possible under law, the author(s) have dedicated all copyright
|
||||
" and related and neighboring rights to this software to the public domain
|
||||
" worldwide. This software is distributed without any warranty.
|
||||
" You should have received a copy of the CC0 Public Domain Dedication along
|
||||
" with this software. If not, see
|
||||
" <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal nolisp
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetPythonPEPIndent(v:lnum)
|
||||
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except
|
||||
|
||||
if !exists('g:python_pep8_indent_multiline_string')
|
||||
let g:python_pep8_indent_multiline_string = 0
|
||||
endif
|
||||
|
||||
let s:block_rules = {
|
||||
\ '^\s*elif\>': ['if', 'elif'],
|
||||
\ '^\s*except\>': ['try', 'except'],
|
||||
\ '^\s*finally\>': ['try', 'except', 'else']
|
||||
\ }
|
||||
let s:block_rules_multiple = {
|
||||
\ '^\s*else\>': ['if', 'elif', 'for', 'try', 'except'],
|
||||
\ }
|
||||
" Pairs to look for when searching for opening parenthesis.
|
||||
" The value is the maximum offset in lines.
|
||||
let s:paren_pairs = {'()': 50, '[]': 100, '{}': 1000}
|
||||
|
||||
if &filetype ==# 'pyrex' || &filetype ==# 'cython'
|
||||
let b:control_statement = '\v^\s*(class|def|if|while|with|for|except|cdef|cpdef)>'
|
||||
else
|
||||
let b:control_statement = '\v^\s*(class|def|if|while|with|for|except)>'
|
||||
endif
|
||||
let s:stop_statement = '^\s*\(break\|continue\|raise\|return\|pass\)\>'
|
||||
|
||||
" Skip strings and comments. Return 1 for chars to skip.
|
||||
" jedi* refers to syntax definitions from jedi-vim for call signatures, which
|
||||
" are inserted temporarily into the buffer.
|
||||
let s:skip_special_chars = 'synIDattr(synID(line("."), col("."), 0), "name") ' .
|
||||
\ '=~? "\\vstring|comment|jedi\\S"'
|
||||
|
||||
let s:skip_after_opening_paren = 'synIDattr(synID(line("."), col("."), 0), "name") ' .
|
||||
\ '=~? "\\vcomment|jedi\\S"'
|
||||
|
||||
" Also ignore anything concealed.
|
||||
" Wrapper around synconcealed for older Vim (7.3.429, used on Travis CI).
|
||||
function! s:is_concealed(line, col)
|
||||
let concealed = synconcealed(a:line, a:col)
|
||||
return len(concealed) && concealed[0]
|
||||
endfunction
|
||||
if has('conceal')
|
||||
let s:skip_special_chars .= '|| s:is_concealed(line("."), col("."))'
|
||||
endif
|
||||
|
||||
|
||||
let s:skip_search = 'synIDattr(synID(line("."), col("."), 0), "name") ' .
|
||||
\ '=~? "comment"'
|
||||
|
||||
" Use 'shiftwidth()' instead of '&sw'.
|
||||
" (Since Vim patch 7.3.629, 'shiftwidth' can be set to 0 to follow 'tabstop').
|
||||
if exists('*shiftwidth')
|
||||
function! s:sw()
|
||||
return shiftwidth()
|
||||
endfunction
|
||||
else
|
||||
function! s:sw()
|
||||
return &shiftwidth
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:pair_sort(x, y)
|
||||
if a:x[0] == a:y[0]
|
||||
return a:x[1] == a:y[1] ? 0 : a:x[1] > a:y[1] ? 1 : -1
|
||||
else
|
||||
return a:x[0] > a:y[0] ? 1 : -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Find backwards the closest open parenthesis/bracket/brace.
|
||||
function! s:find_opening_paren(...)
|
||||
" optional arguments: line and column (defaults to 1) to search around
|
||||
if a:0 > 0
|
||||
let view = winsaveview()
|
||||
call cursor(a:1, a:0 > 1 ? a:2 : 1)
|
||||
let ret = s:find_opening_paren()
|
||||
call winrestview(view)
|
||||
return ret
|
||||
endif
|
||||
|
||||
" Return if cursor is in a comment.
|
||||
exe 'if' s:skip_search '| return [0, 0] | endif'
|
||||
|
||||
let nearest = [0, 0]
|
||||
for [p, maxoff] in items(s:paren_pairs)
|
||||
let stopline = max([0, line('.') - maxoff, nearest[0]])
|
||||
let next = searchpairpos(
|
||||
\ '\V'.p[0], '', '\V'.p[1], 'bnW', s:skip_special_chars, stopline)
|
||||
if next[0] && (next[0] > nearest[0] || (next[0] == nearest[0] && next[1] > nearest[1]))
|
||||
let nearest = next
|
||||
endif
|
||||
endfor
|
||||
return nearest
|
||||
endfunction
|
||||
|
||||
" Find the start of a multi-line statement
|
||||
function! s:find_start_of_multiline_statement(lnum)
|
||||
let lnum = a:lnum
|
||||
while lnum > 0
|
||||
if getline(lnum - 1) =~# '\\$'
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
else
|
||||
let [paren_lnum, _] = s:find_opening_paren(lnum)
|
||||
if paren_lnum < 1
|
||||
return lnum
|
||||
else
|
||||
let lnum = paren_lnum
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
" Find possible indent(s) of the block starter that matches the current line.
|
||||
function! s:find_start_of_block(lnum, types, multiple)
|
||||
let r = []
|
||||
let types = copy(a:types)
|
||||
let re = '\V\^\s\*\('.join(a:types, '\|').'\)\>'
|
||||
let lnum = a:lnum
|
||||
let last_indent = indent(lnum) + 1
|
||||
while lnum > 0 && last_indent > 0
|
||||
let indent = indent(lnum)
|
||||
if indent < last_indent
|
||||
for type in types
|
||||
let re = '\v^\s*'.type.'>'
|
||||
if getline(lnum) =~# re
|
||||
if !a:multiple
|
||||
return [indent]
|
||||
endif
|
||||
if index(r, indent) == -1
|
||||
let r += [indent]
|
||||
endif
|
||||
" Remove any handled type, e.g. 'if'.
|
||||
call remove(types, index(types, type))
|
||||
endif
|
||||
endfor
|
||||
let last_indent = indent(lnum)
|
||||
endif
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
endwhile
|
||||
return r
|
||||
endfunction
|
||||
|
||||
" Is "expr" true for every position in "lnum", beginning at "start"?
|
||||
" (optionally up to a:1 / 4th argument)
|
||||
function! s:match_expr_on_line(expr, lnum, start, ...)
|
||||
let text = getline(a:lnum)
|
||||
let end = a:0 ? a:1 : len(text)
|
||||
if a:start > end
|
||||
return 1
|
||||
endif
|
||||
let save_pos = getpos('.')
|
||||
let r = 1
|
||||
for i in range(a:start, end)
|
||||
call cursor(a:lnum, i)
|
||||
if !(eval(a:expr) || text[i-1] =~# '\s')
|
||||
let r = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
call setpos('.', save_pos)
|
||||
return r
|
||||
endfunction
|
||||
|
||||
" Line up with open parenthesis/bracket/brace.
|
||||
function! s:indent_like_opening_paren(lnum)
|
||||
let [paren_lnum, paren_col] = s:find_opening_paren(a:lnum)
|
||||
if paren_lnum <= 0
|
||||
return -2
|
||||
endif
|
||||
let text = getline(paren_lnum)
|
||||
let base = indent(paren_lnum)
|
||||
|
||||
let nothing_after_opening_paren = s:match_expr_on_line(
|
||||
\ s:skip_after_opening_paren, paren_lnum, paren_col+1)
|
||||
let starts_with_closing_paren = getline(a:lnum) =~# '^\s*[])}]'
|
||||
|
||||
if nothing_after_opening_paren
|
||||
if starts_with_closing_paren
|
||||
let res = base
|
||||
else
|
||||
let res = base + s:sw()
|
||||
endif
|
||||
else
|
||||
" Indent to match position of opening paren.
|
||||
let res = paren_col
|
||||
endif
|
||||
|
||||
" If this line is the continuation of a control statement
|
||||
" indent further to distinguish the continuation line
|
||||
" from the next logical line.
|
||||
if text =~# b:control_statement && res == base + s:sw()
|
||||
return base + s:sw() * 2
|
||||
else
|
||||
return res
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Match indent of first block of this type.
|
||||
function! s:indent_like_block(lnum)
|
||||
let text = getline(a:lnum)
|
||||
for [multiple, block_rules] in [
|
||||
\ [0, s:block_rules],
|
||||
\ [1, s:block_rules_multiple]]
|
||||
for [line_re, blocks] in items(block_rules)
|
||||
if text !~# line_re
|
||||
continue
|
||||
endif
|
||||
|
||||
let indents = s:find_start_of_block(a:lnum - 1, blocks, multiple)
|
||||
if !len(indents)
|
||||
return -1
|
||||
endif
|
||||
if len(indents) == 1
|
||||
return indents[0]
|
||||
endif
|
||||
|
||||
" Multiple valid indents, e.g. for 'else' with both try and if.
|
||||
let indent = indent(a:lnum)
|
||||
if index(indents, indent) != -1
|
||||
" The indent is valid, keep it.
|
||||
return indent
|
||||
endif
|
||||
" Fallback to the first/nearest one.
|
||||
return indents[0]
|
||||
endfor
|
||||
endfor
|
||||
return -2
|
||||
endfunction
|
||||
|
||||
function! s:indent_like_previous_line(lnum)
|
||||
let lnum = prevnonblank(a:lnum - 1)
|
||||
|
||||
" No previous line, keep current indent.
|
||||
if lnum < 1
|
||||
return -1
|
||||
endif
|
||||
|
||||
let text = getline(lnum)
|
||||
let start = s:find_start_of_multiline_statement(lnum)
|
||||
let base = indent(start)
|
||||
let current = indent(a:lnum)
|
||||
|
||||
" Jump to last character in previous line.
|
||||
call cursor(lnum, len(text))
|
||||
let ignore_last_char = eval(s:skip_special_chars)
|
||||
|
||||
" Search for final colon that is not inside something to be ignored.
|
||||
while 1
|
||||
let curpos = getpos('.')[2]
|
||||
if curpos == 1 | break | endif
|
||||
if eval(s:skip_special_chars) || text[curpos-1] =~# '\s'
|
||||
normal! h
|
||||
continue
|
||||
elseif text[curpos-1] ==# ':'
|
||||
return base + s:sw()
|
||||
endif
|
||||
break
|
||||
endwhile
|
||||
|
||||
if text =~# '\\$' && !ignore_last_char
|
||||
" If this line is the continuation of a control statement
|
||||
" indent further to distinguish the continuation line
|
||||
" from the next logical line.
|
||||
if getline(start) =~# b:control_statement
|
||||
return base + s:sw() * 2
|
||||
endif
|
||||
|
||||
" Nest (other) explicit continuations only one level deeper.
|
||||
return base + s:sw()
|
||||
endif
|
||||
|
||||
let empty = getline(a:lnum) =~# '^\s*$'
|
||||
|
||||
" Current and prev line are empty, next is not -> indent like next.
|
||||
if empty && a:lnum > 1 &&
|
||||
\ (getline(a:lnum - 1) =~# '^\s*$') &&
|
||||
\ !(getline(a:lnum + 1) =~# '^\s*$')
|
||||
return indent(a:lnum + 1)
|
||||
endif
|
||||
|
||||
" If the previous statement was a stop-execution statement or a pass
|
||||
if getline(start) =~# s:stop_statement
|
||||
" Remove one level of indentation if the user hasn't already dedented
|
||||
if empty || current > base - s:sw()
|
||||
return base - s:sw()
|
||||
endif
|
||||
" Otherwise, trust the user
|
||||
return -1
|
||||
endif
|
||||
|
||||
if !empty && s:is_dedented_already(current, base)
|
||||
return -1
|
||||
endif
|
||||
|
||||
" In all other cases, line up with the start of the previous statement.
|
||||
return base
|
||||
endfunction
|
||||
|
||||
" If this line is dedented and the number of indent spaces is valid
|
||||
" (multiple of the indentation size), trust the user.
|
||||
function! s:is_dedented_already(current, base)
|
||||
let dedent_size = a:current - a:base
|
||||
return (dedent_size < 0 && a:current % s:sw() == 0) ? 1 : 0
|
||||
endfunction
|
||||
|
||||
" Is the syntax at lnum (and optionally cnum) a python string?
|
||||
function! s:is_python_string(lnum, ...)
|
||||
let line = getline(a:lnum)
|
||||
let linelen = len(line)
|
||||
if linelen < 1
|
||||
let linelen = 1
|
||||
endif
|
||||
let cols = a:0 ? type(a:1) != type([]) ? [a:1] : a:1 : range(1, linelen)
|
||||
for cnum in cols
|
||||
if match(map(synstack(a:lnum, cnum),
|
||||
\ "synIDattr(v:val, 'name')"), 'python\S*String') == -1
|
||||
return 0
|
||||
end
|
||||
endfor
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! GetPythonPEPIndent(lnum)
|
||||
" First line has indent 0
|
||||
if a:lnum == 1
|
||||
return 0
|
||||
endif
|
||||
|
||||
let line = getline(a:lnum)
|
||||
let prevline = getline(a:lnum-1)
|
||||
|
||||
" Multilinestrings: continous, docstring or starting.
|
||||
if s:is_python_string(a:lnum-1, len(prevline))
|
||||
\ && (s:is_python_string(a:lnum, 1)
|
||||
\ || match(line, '^\%("""\|''''''\)') != -1)
|
||||
|
||||
" Indent closing quotes as the line with the opening ones.
|
||||
let match_quotes = match(line, '^\s*\zs\%("""\|''''''\)')
|
||||
if match_quotes != -1
|
||||
" closing multiline string
|
||||
let quotes = line[match_quotes:(match_quotes+2)]
|
||||
let pairpos = searchpairpos(quotes, '', quotes, 'b')
|
||||
if pairpos[0] != 0
|
||||
return indent(pairpos[0])
|
||||
else
|
||||
" TODO: test to cover this!
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:is_python_string(a:lnum-1)
|
||||
" Previous line is (completely) a string.
|
||||
return indent(a:lnum-1)
|
||||
endif
|
||||
|
||||
if match(prevline, '^\s*\%("""\|''''''\)') != -1
|
||||
" docstring.
|
||||
return indent(a:lnum-1)
|
||||
endif
|
||||
|
||||
let indent_multi = get(b:, 'python_pep8_indent_multiline_string',
|
||||
\ get(g:, 'python_pep8_indent_multiline_string', 0))
|
||||
if match(prevline, '\v%("""|'''''')$') != -1
|
||||
" Opening multiline string, started in previous line.
|
||||
if (&autoindent && indent(a:lnum) == indent(a:lnum-1))
|
||||
\ || match(line, '\v^\s+$') != -1
|
||||
" <CR> with empty line or to split up 'foo("""bar' into
|
||||
" 'foo("""' and 'bar'.
|
||||
if indent_multi == -2
|
||||
return indent(a:lnum-1) + s:sw()
|
||||
endif
|
||||
return indent_multi
|
||||
endif
|
||||
endif
|
||||
|
||||
" Keep existing indent.
|
||||
if match(line, '\v^\s*\S') != -1
|
||||
return -1
|
||||
endif
|
||||
|
||||
if indent_multi != -2
|
||||
return indent_multi
|
||||
endif
|
||||
|
||||
return s:indent_like_opening_paren(a:lnum)
|
||||
endif
|
||||
|
||||
" Parens: If we can find an open parenthesis/bracket/brace, line up with it.
|
||||
let indent = s:indent_like_opening_paren(a:lnum)
|
||||
if indent >= -1
|
||||
return indent
|
||||
endif
|
||||
|
||||
" Blocks: Match indent of first block of this type.
|
||||
let indent = s:indent_like_block(a:lnum)
|
||||
if indent >= -1
|
||||
return indent
|
||||
endif
|
||||
|
||||
return s:indent_like_previous_line(a:lnum)
|
||||
endfunction
|
||||
|
||||
endif
|
||||
@@ -7,42 +7,13 @@ let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=elixir#indent(v:lnum)
|
||||
|
||||
setlocal indentkeys+=0=end,0=catch,0=rescue,0=after,0=else,=->,0},0],0),0=\|>,0=<>
|
||||
setlocal indentkeys+==after,=catch,=do,=else,=end,=rescue,
|
||||
setlocal indentkeys+=*<Return>,=->,=\|>,=<>,0},0],0)
|
||||
|
||||
" TODO: @jbodah 2017-02-27: all operators should cause reindent when typed
|
||||
|
||||
function! elixir#indent(lnum)
|
||||
let lnum = a:lnum
|
||||
let text = getline(lnum)
|
||||
let prev_nb_lnum = prevnonblank(lnum-1)
|
||||
let prev_nb_text = getline(prev_nb_lnum)
|
||||
|
||||
call elixir#indent#debug("==> Indenting line " . lnum)
|
||||
call elixir#indent#debug("text = '" . text . "'")
|
||||
|
||||
let handlers = [
|
||||
\'top_of_file',
|
||||
\'starts_with_end',
|
||||
\'starts_with_mid_or_end_block_keyword',
|
||||
\'following_trailing_do',
|
||||
\'following_trailing_binary_operator',
|
||||
\'starts_with_pipe',
|
||||
\'starts_with_close_bracket',
|
||||
\'starts_with_binary_operator',
|
||||
\'inside_nested_construct',
|
||||
\'starts_with_comment',
|
||||
\'inside_generic_block'
|
||||
\]
|
||||
for handler in handlers
|
||||
call elixir#indent#debug('testing handler elixir#indent#handle_'.handler)
|
||||
let indent = function('elixir#indent#handle_'.handler)(lnum, text, prev_nb_lnum, prev_nb_text)
|
||||
if indent != -1
|
||||
call elixir#indent#debug('line '.lnum.': elixir#indent#handle_'.handler.' returned '.indent)
|
||||
return indent
|
||||
endif
|
||||
endfor
|
||||
|
||||
call elixir#indent#debug("defaulting")
|
||||
return 0
|
||||
return elixir#indent#indent(a:lnum)
|
||||
endfunction
|
||||
|
||||
endif
|
||||
|
||||
212
indent/elm.vim
212
indent/elm.vim
@@ -1,129 +1,115 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: Haskell
|
||||
" Maintainer: lilydjwg <lilydjwg@gmail.com>
|
||||
" Version: 1.0
|
||||
" References: http://en.wikibooks.org/wiki/Haskell/Indentation
|
||||
" http://book.realworldhaskell.org/read/
|
||||
" See Also: The Align plugin http://www.vim.org/scripts/script.php?script_id=294
|
||||
" indentation for Elm (http://elm-lang.org/)
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=HaskellIndent()
|
||||
for i in split('0{,:,0#,e', ',')
|
||||
exec "setlocal indentkeys-=" . i
|
||||
endfor
|
||||
setlocal indentkeys+=0=else,0=in,0=where,0),0<bar>
|
||||
setlocal tabstop=8
|
||||
" Local defaults
|
||||
setlocal expandtab
|
||||
setlocal indentexpr=GetElmIndent()
|
||||
setlocal indentkeys+=0=else,0=if,0=of,0=import,0=then,0=type,0\|,0},0\],0),=-},0=in
|
||||
setlocal nolisp
|
||||
setlocal nosmartindent
|
||||
|
||||
if !exists('g:Haskell_no_mapping')
|
||||
inoremap <silent> <BS> <C-R>=<SID>HaskellDedent(1)<CR>
|
||||
inoremap <silent> <C-D> <C-R>=<SID>HaskellDedent(0)<CR>
|
||||
" Comment formatting
|
||||
setlocal comments=s1fl:{-,mb:\ ,ex:-},:--
|
||||
|
||||
" Only define the function once.
|
||||
if exists('*GetElmIndent')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Only define the functions once.
|
||||
if exists("*HaskellIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:align_map = {
|
||||
\ 'in': '\<let\>',
|
||||
\ '\<else\>': '\<then\>',
|
||||
\ ',': '\v%(\s|\w|^)@<=[[{]%(\s|\w|"|$)@='
|
||||
\ }
|
||||
let s:indent_self = ['=']
|
||||
let s:indent_next = ['let', 'in', 'where', 'do', 'if']
|
||||
let s:indent_if_final = ['=', 'do', '->', 'of', 'where']
|
||||
|
||||
function HaskellIndent()
|
||||
let lnum = v:lnum - 1
|
||||
|
||||
" Hit the start of the file, use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(lnum)
|
||||
let prevline = getline(lnum)
|
||||
let curline = getline(v:lnum)
|
||||
let curwords = split(curline)
|
||||
if len(curwords) > 0
|
||||
if has_key(s:align_map, curwords[0])
|
||||
let word = s:align_map[curwords[0]]
|
||||
let m = -1
|
||||
let line = v:lnum
|
||||
while m == -1
|
||||
let line -= 1
|
||||
if line <= 0
|
||||
return -1
|
||||
endif
|
||||
let m = match(getline(line), word)
|
||||
endwhile
|
||||
return m
|
||||
elseif index(s:indent_self, curwords[0]) != -1
|
||||
return ind + &sw
|
||||
elseif curwords[0] == '|'
|
||||
return match(prevline, '\v%(\s|\w|^)@<=[|=]%(\s|\w)@=')
|
||||
elseif index([')', '}'], curwords[0]) != -1
|
||||
return ind - &sw
|
||||
elseif curwords[0] == 'where'
|
||||
if prevline =~ '\v^\s+\|%(\s|\w)@='
|
||||
return ind - 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let prevwords = split(prevline)
|
||||
if len(prevwords) == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
if prevwords[-1] == 'where' && prevwords[0] == 'module'
|
||||
return 0
|
||||
elseif index(s:indent_if_final, prevwords[-1]) != -1
|
||||
return ind + &sw
|
||||
elseif prevwords[-1] =~ '\v%(\s|\w|^)@<=[[{(]$'
|
||||
return ind + &sw
|
||||
else
|
||||
for word in reverse(prevwords)
|
||||
if index(s:indent_next, word) != -1
|
||||
return match(prevline, '\<'.word.'\>') + len(word) + 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if len(curwords) > 0 && curwords[0] == 'where'
|
||||
return ind + &sw
|
||||
endif
|
||||
|
||||
return ind
|
||||
" Indent pairs
|
||||
function! s:FindPair(pstart, pmid, pend)
|
||||
"call search(a:pend, 'bW')
|
||||
return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
|
||||
endfunction
|
||||
|
||||
function s:HaskellDedent(isbs)
|
||||
if a:isbs && strpart(getline('.'), 0, col('.')-1) !~ '^\s\+$'
|
||||
return "\<BS>"
|
||||
endif
|
||||
function! GetElmIndent()
|
||||
let l:lnum = v:lnum - 1
|
||||
|
||||
let curind = indent('.')
|
||||
let line = line('.') - 1
|
||||
while curind > 0 && line > 0
|
||||
let ind = indent(line)
|
||||
if ind >= curind
|
||||
let line -= 1
|
||||
else
|
||||
echomsg curind ind
|
||||
call setline('.', repeat(' ', ind) .
|
||||
\ substitute(getline('.'), '^\s\+', '', ''))
|
||||
return ''
|
||||
endif
|
||||
endwhile
|
||||
return a:isbs ? "\<BS>" : ''
|
||||
endfunction
|
||||
" Ident 0 if the first line of the file:
|
||||
if l:lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:ind = indent(l:lnum)
|
||||
let l:lline = getline(l:lnum)
|
||||
let l:line = getline(v:lnum)
|
||||
|
||||
" Indent if current line begins with '}':
|
||||
if l:line =~? '^\s*}'
|
||||
return s:FindPair('{', '', '}')
|
||||
|
||||
" Indent if current line begins with 'else':
|
||||
elseif l:line =~# '^\s*else\>'
|
||||
if l:lline !~# '^\s*\(if\|then\)\>'
|
||||
return s:FindPair('\<if\>', '', '\<else\>')
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'then':
|
||||
elseif l:line =~# '^\s*then\>'
|
||||
if l:lline !~# '^\s*\(if\|else\)\>'
|
||||
return s:FindPair('\<if\>', '', '\<then\>')
|
||||
endif
|
||||
|
||||
" HACK: Indent lines in case with nearest case clause:
|
||||
elseif l:line =~# '->' && l:line !~# ':' && l:line !~# '\\'
|
||||
return indent(search('^\s*case', 'bWn')) + &shiftwidth
|
||||
|
||||
" HACK: Don't change the indentation if the last line is a comment.
|
||||
elseif l:lline =~# '^\s*--'
|
||||
return l:ind
|
||||
|
||||
" Align the end of block comments with the start
|
||||
elseif l:line =~# '^\s*-}'
|
||||
return indent(search('{-', 'bWn'))
|
||||
|
||||
" Indent double shift after let with an empty rhs
|
||||
elseif l:lline =~# '\<let\>.*\s=$'
|
||||
return l:ind + 4 + &shiftwidth
|
||||
|
||||
" Align 'in' with the parent let.
|
||||
elseif l:line =~# '^\s*in\>'
|
||||
return indent(search('^\s*let', 'bWn'))
|
||||
|
||||
" Align bindings with the parent let.
|
||||
elseif l:lline =~# '\<let\>'
|
||||
return l:ind + 4
|
||||
|
||||
" Align bindings with the parent in.
|
||||
elseif l:lline =~# '^\s*in\>'
|
||||
return l:ind + 4
|
||||
|
||||
endif
|
||||
|
||||
" Add a 'shiftwidth' after lines ending with:
|
||||
if l:lline =~# '\(|\|=\|->\|<-\|(\|\[\|{\|\<\(of\|else\|if\|then\)\)\s*$'
|
||||
let l:ind = l:ind + &shiftwidth
|
||||
|
||||
" Add a 'shiftwidth' after lines starting with type ending with '=':
|
||||
elseif l:lline =~# '^\s*type' && l:line =~# '^\s*='
|
||||
let l:ind = l:ind + &shiftwidth
|
||||
|
||||
" Back to normal indent after comments:
|
||||
elseif l:lline =~# '-}\s*$'
|
||||
call search('-}', 'bW')
|
||||
let l:ind = indent(searchpair('{-', '', '-}', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
|
||||
|
||||
" Ident some operators if there aren't any starting the last line.
|
||||
elseif l:line =~# '^\s*\(!\|&\|(\|`\|+\||\|{\|[\|,\)=' && l:lline !~# '^\s*\(!\|&\|(\|`\|+\||\|{\|[\|,\)=' && l:lline !~# '^\s*$'
|
||||
let l:ind = l:ind + &shiftwidth
|
||||
|
||||
elseif l:lline ==# '' && getline(l:lnum - 1) !=# ''
|
||||
let l:ind = indent(search('^\s*\S+', 'bWn'))
|
||||
|
||||
endif
|
||||
|
||||
return l:ind
|
||||
endfunc
|
||||
|
||||
endif
|
||||
|
||||
@@ -14,7 +14,7 @@ runtime! indent/ruby.vim
|
||||
unlet! b:did_indent
|
||||
setlocal indentexpr=
|
||||
|
||||
if exists("b:eruby_subtype")
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=# 'eruby'
|
||||
exe "runtime! indent/".b:eruby_subtype.".vim"
|
||||
else
|
||||
runtime! indent/html.vim
|
||||
|
||||
253
indent/fsharp.vim
Normal file
253
indent/fsharp.vim
Normal file
@@ -0,0 +1,253 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fsharp') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: FSharp
|
||||
" Maintainers: Jean-Francois Yuen <jfyuen@happycoders.org>
|
||||
" Mike Leary <leary@nwlink.com>
|
||||
" Markus Mottl <markus.mottl@gmail.com>
|
||||
" Rudi Grinberg <rudi.grinberg@gmail.com>
|
||||
" Gregor Uhlenheuer <kongo2002@gmail.com>
|
||||
" Last Change: 2013 Jun 29
|
||||
" 2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working
|
||||
" 2005 May 09 - Added an option to not indent OCaml-indents specially (MM)
|
||||
" 2013 June - commented textwidth (Marc Weber)
|
||||
" 2014 August - Ported to F#
|
||||
" 2014 August - F# specific cleanup
|
||||
"
|
||||
" Marc Weber's comment: This file may contain a lot of (very custom) stuff
|
||||
" which eventually should be moved somewhere else ..
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetFsharpIndent()
|
||||
setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0;;,0>\],0\|\],0>},0\|,0},0\],0)
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetFsharpIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Skipping pattern, for comments
|
||||
function! s:GetLineWithoutFullComment(lnum)
|
||||
let lnum = prevnonblank(a:lnum - 1)
|
||||
let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '')
|
||||
while lline =~ '^\s*$' && lnum > 0
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '')
|
||||
endwhile
|
||||
return lnum
|
||||
endfunction
|
||||
|
||||
" Indent for ';;' to match multiple 'let'
|
||||
function! s:GetInd(lnum, pat, lim)
|
||||
let llet = search(a:pat, 'bW')
|
||||
let old = indent(a:lnum)
|
||||
while llet > 0
|
||||
let old = indent(llet)
|
||||
let nb = s:GetLineWithoutFullComment(llet)
|
||||
if getline(nb) =~ a:lim
|
||||
return old
|
||||
endif
|
||||
let llet = search(a:pat, 'bW')
|
||||
endwhile
|
||||
return old
|
||||
endfunction
|
||||
|
||||
" Indent pairs
|
||||
function! s:FindPair(pstart, pmid, pend)
|
||||
call search(a:pend, 'bW')
|
||||
return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
|
||||
endfunction
|
||||
|
||||
" Indent 'let'
|
||||
function! s:FindLet(pstart, pmid, pend)
|
||||
call search(a:pend, 'bW')
|
||||
return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ s:beflet'))
|
||||
endfunction
|
||||
|
||||
function! GetFsharpIndent()
|
||||
" Find a non-commented line above the current line.
|
||||
let lnum = s:GetLineWithoutFullComment(v:lnum)
|
||||
|
||||
" At the start of the file use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(lnum)
|
||||
let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '')
|
||||
|
||||
" " Return single 'shiftwidth' after lines matching:
|
||||
" if lline =~ '^\s*|.*->\s*$'
|
||||
" return ind + &sw
|
||||
" endif
|
||||
|
||||
let line = getline(v:lnum)
|
||||
|
||||
" Indent if current line begins with 'end':
|
||||
if line =~ '^\s*end\>'
|
||||
return s:FindPair(s:module, '','\<end\>')
|
||||
|
||||
" Indent if current line begins with 'done' for 'do':
|
||||
elseif line =~ '^\s*done\>'
|
||||
return s:FindPair('\<do\>', '','\<done\>')
|
||||
|
||||
" Indent if current line begins with '}' or '>}':
|
||||
elseif line =~ '^\s*\(\|>\)}'
|
||||
return s:FindPair('{', '','}')
|
||||
|
||||
" Indent if current line begins with ']', '|]' or '>]':
|
||||
elseif line =~ '^\s*\(\||\|>\)\]'
|
||||
return s:FindPair('\[', '','\]')
|
||||
|
||||
" Indent if current line begins with ')':
|
||||
elseif line =~ '^\s*)'
|
||||
return s:FindPair('(', '',')')
|
||||
|
||||
" Indent if current line begins with 'let':
|
||||
elseif line =~ '^\s*let\>'
|
||||
if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet
|
||||
return s:FindLet(s:type, '','\<let\s*$')
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'class' or 'type':
|
||||
elseif line =~ '^\s*\(class\|type\)\>'
|
||||
if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim
|
||||
return s:FindLet(s:type, '','\<\(class\|type\)\s*$')
|
||||
endif
|
||||
|
||||
" Indent for pattern matching:
|
||||
elseif line =~ '^\s*|'
|
||||
if lline !~ '^\s*\(|[^\]]\|\(match\|type\|with\)\>\)\|\<\(function\|private\|with\)\s*$'
|
||||
call search('|', 'bW')
|
||||
return indent(searchpair('^\s*\(match\|type\)\>\|\<\(function\|private\|with\)\s*$', '', '^\s*|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") !~ "^\\s*|.*->"'))
|
||||
endif
|
||||
|
||||
" Indent if current line begins with ';;':
|
||||
elseif line =~ '^\s*;;'
|
||||
if lline !~ ';;\s*$'
|
||||
return s:GetInd(v:lnum, s:letpat, s:letlim)
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'in':
|
||||
elseif line =~ '^\s*in\>'
|
||||
if lline !~ '^\s*\(let\|and\)\>'
|
||||
return s:FindPair('\<let\>', '', '\<in\>')
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'else':
|
||||
elseif line =~ '^\s*else\>'
|
||||
if lline !~ '^\s*\(if\|then\)\>'
|
||||
return s:FindPair('\<if\>', '', '\<else\>')
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'then':
|
||||
elseif line =~ '^\s*then\>'
|
||||
if lline !~ '^\s*\(if\|else\)\>'
|
||||
return s:FindPair('\<if\>', '', '\<then\>')
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'and':
|
||||
elseif line =~ '^\s*and\>'
|
||||
if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$'
|
||||
return ind - &sw
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'with':
|
||||
elseif line =~ '^\s*with\>'
|
||||
if lline !~ '^\s*\(match\|try\)\>'
|
||||
return s:FindPair('\<\%(match\|try\)\>', '','\<with\>')
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'exception', 'external', 'include' or
|
||||
" 'open':
|
||||
elseif line =~ '^\s*\(exception\|external\|include\|open\)\>'
|
||||
if lline !~ s:lim . '\|' . s:letlim
|
||||
call search(line)
|
||||
return indent(search('^\s*\(\(exception\|external\|include\|open\|type\)\>\|val\>.*:\)', 'bW'))
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'val':
|
||||
elseif line =~ '^\s*val\>'
|
||||
if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim
|
||||
return indent(search('^\s*\(\(exception\|include\|initializer\|method\|open\|type\|val\)\>\|external\>.*:\)', 'bW'))
|
||||
endif
|
||||
|
||||
" Indent if current line begins with 'constraint', 'inherit', 'initializer'
|
||||
" or 'method':
|
||||
elseif line =~ '^\s*\(constraint\|inherit\|initializer\|method\)\>'
|
||||
if lline !~ s:obj
|
||||
return indent(search('\<\(object\|object\s*(.*)\)\s*$', 'bW')) + &sw
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
" Add a 'shiftwidth' after lines ending with:
|
||||
if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|else\|fun\|function\|functor\|if\|initializer\|object\|private\|sig\|struct\|then\|try\)\|\<object\s*(.*)\)\s*$'
|
||||
let ind = ind + &sw
|
||||
|
||||
" Back to normal indent after lines ending with ';;':
|
||||
elseif lline =~ ';;\s*$' && lline !~ '^\s*;;'
|
||||
let ind = s:GetInd(v:lnum, s:letpat, s:letlim)
|
||||
|
||||
" Back to normal indent after lines ending with 'end':
|
||||
elseif lline =~ '\<end\s*$'
|
||||
let ind = s:FindPair(s:module, '','\<end\>')
|
||||
|
||||
" Back to normal indent after lines ending with 'in':
|
||||
elseif lline =~ '\<in\s*$' && lline !~ '^\s*in\>'
|
||||
let ind = s:FindPair('\<let\>', '', '\<in\>')
|
||||
|
||||
" Back to normal indent after lines ending with 'done':
|
||||
elseif lline =~ '\<done\s*$'
|
||||
let ind = s:FindPair('\<do\>', '','\<done\>')
|
||||
|
||||
" Back to normal indent after lines ending with '}' or '>}':
|
||||
elseif lline =~ '\(\|>\)}\s*$'
|
||||
let ind = s:FindPair('{', '','}')
|
||||
|
||||
" Back to normal indent after lines ending with ']', '|]' or '>]':
|
||||
elseif lline =~ '\(\||\|>\)\]\s*$'
|
||||
let ind = s:FindPair('\[', '','\]')
|
||||
|
||||
" Back to normal indent after comments:
|
||||
elseif lline =~ '\*)\s*$'
|
||||
call search('\*)', 'bW')
|
||||
let ind = indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
|
||||
|
||||
" Back to normal indent after lines ending with ')':
|
||||
elseif lline =~ ')\s*$'
|
||||
let ind = s:FindPair('(', '',')')
|
||||
|
||||
" If this is a multiline comment then align '*':
|
||||
elseif lline =~ '^\s*(\*' && line =~ '^\s*\*'
|
||||
let ind = ind + 1
|
||||
|
||||
else
|
||||
" Don't change indentation of this line
|
||||
" for new lines (indent==0) use indentation of previous line
|
||||
|
||||
" This is for preventing removing indentation of these args:
|
||||
" let f x =
|
||||
" let y = x + 1 in
|
||||
" Printf.printf
|
||||
" "o" << here
|
||||
" "oeuth" << don't touch indentation
|
||||
|
||||
let i = indent(v:lnum)
|
||||
return i == 0 ? ind : i
|
||||
|
||||
endif
|
||||
|
||||
return ind
|
||||
|
||||
endfunction
|
||||
|
||||
" vim: sw=4 et sts=4
|
||||
|
||||
endif
|
||||
@@ -8,6 +8,7 @@ if exists("b:did_indent")
|
||||
endif
|
||||
|
||||
setlocal autoindent cindent
|
||||
setlocal formatoptions+=roq
|
||||
|
||||
" vim:set sts=2 sw=2 :
|
||||
|
||||
|
||||
@@ -36,9 +36,18 @@ endif
|
||||
if !exists('g:haskell_indent_let')
|
||||
" let x = 0 in
|
||||
" >>>>x
|
||||
"
|
||||
" let x = 0
|
||||
" y = 1
|
||||
let g:haskell_indent_let = 4
|
||||
endif
|
||||
|
||||
if !exists('g:haskell_indent_let_no_in')
|
||||
" let x = 0
|
||||
" x
|
||||
let g:haskell_indent_let_no_in = 4
|
||||
endif
|
||||
|
||||
if !exists('g:haskell_indent_where')
|
||||
" where f :: Int -> Int
|
||||
" >>>>>>f x = x
|
||||
@@ -210,6 +219,9 @@ function! GetHaskellIndent()
|
||||
"
|
||||
" let x = 1
|
||||
" >>>>y = 2
|
||||
"
|
||||
" let x = 1
|
||||
" y 2
|
||||
if l:prevline =~ '\C\<let\>\s\+.\+$'
|
||||
if l:line =~ '\C^\s*\<let\>'
|
||||
let l:s = match(l:prevline, '\C\<let\>')
|
||||
@@ -221,11 +233,16 @@ function! GetHaskellIndent()
|
||||
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
|
||||
return l:s + g:haskell_indent_in
|
||||
endif
|
||||
else
|
||||
elseif l:line =~ '\s=\s'
|
||||
let l:s = match(l:prevline, '\C\<let\>')
|
||||
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
|
||||
return l:s + g:haskell_indent_let
|
||||
endif
|
||||
else
|
||||
let l:s = match(l:prevline, '\C\<let\>')
|
||||
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
|
||||
return l:s + g:haskell_indent_let_no_in
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -260,20 +260,28 @@ let s:html_indent_tags = '[a-z_][a-z0-9_.-]*'
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
|
||||
" [-- count indent-increasing tags of line a:lnum --]
|
||||
fun! <SID>HtmlIndentOpen(lnum, pattern)
|
||||
let s = substitute('x'.getline(a:lnum),
|
||||
\ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
|
||||
func! <SID>HtmlIndentPatternCount(content, pattern)
|
||||
let s = substitute('x'.a:content, a:pattern, "\1", 'g')
|
||||
let s = substitute(s, "[^\1].*$", '', '')
|
||||
return strlen(s)
|
||||
endfun
|
||||
|
||||
" [-- count indent-increasing tags of line a:lnum --]
|
||||
fun! <SID>HtmlIndentOpen(lnum, pattern)
|
||||
return <SID>HtmlIndentPatternCount(getline(a:lnum),
|
||||
\ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)')
|
||||
endfun
|
||||
|
||||
" [-- count indent-decreasing tags of line a:lnum --]
|
||||
fun! <SID>HtmlIndentClose(lnum, pattern)
|
||||
let s = substitute('x'.getline(a:lnum),
|
||||
\ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
|
||||
let s = substitute(s, "[^\1].*$", '', '')
|
||||
return strlen(s)
|
||||
return <SID>HtmlIndentPatternCount(getline(a:lnum),
|
||||
\ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)')
|
||||
endfun
|
||||
|
||||
" [-- count self close tags of line a:lnum --]
|
||||
fun! <SID>HtmlIndentSelfClose(lnum, pattern)
|
||||
return <SID>HtmlIndentPatternCount(getline(a:lnum),
|
||||
\ '.\{-}\(\(<\('.a:pattern.'\).*\)\@<!\/>\)')
|
||||
endfun
|
||||
|
||||
" [-- count indent-increasing '{' of (java|css) line a:lnum --]
|
||||
@@ -292,8 +300,9 @@ fun! <SID>HtmlIndentSum(lnum, style)
|
||||
if a:style == match(getline(a:lnum), '^\s*</\<\('.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) - <SID>HtmlIndentClose(a:lnum, s:html_noindent_tags)
|
||||
if 0 != open || 0 != close
|
||||
return open - close
|
||||
let self_close = <SID>HtmlIndentSelfClose(a:lnum, s:html_noindent_tags)
|
||||
if 0 != open || 0 != close || 0 != self_close
|
||||
return open - close - self_close
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -310,6 +319,13 @@ fun! <SID>HtmlIndentSum(lnum, style)
|
||||
endfun
|
||||
|
||||
fun! HtmlIndentGet(lnum)
|
||||
" Get shiftwidth value.
|
||||
if exists('*shiftwidth')
|
||||
let sw = shiftwidth()
|
||||
else
|
||||
let sw = &sw
|
||||
endif
|
||||
|
||||
" Find a non-empty line above the current line.
|
||||
let lnum = prevnonblank(a:lnum - 1)
|
||||
|
||||
@@ -396,7 +412,7 @@ fun! HtmlIndentGet(lnum)
|
||||
endif
|
||||
|
||||
if 0 == match(getline(a:lnum), '^\s*</')
|
||||
return indent(preline) - (1*&sw)
|
||||
return indent(preline) - (1*sw)
|
||||
else
|
||||
return indent(preline)
|
||||
endif
|
||||
@@ -417,7 +433,7 @@ fun! HtmlIndentGet(lnum)
|
||||
" let tags_exp = '<\(' . join(tags, '\|') . '\)>'
|
||||
" let close_tags_exp = '</\(' . join(tags, '\|') . '\)>'
|
||||
" if getline(a:lnum) =~ tags_exp
|
||||
" let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
|
||||
" let block_start = search('^'.repeat(' ', lind + (sw * ind - 1)).'\S' , 'bnW')
|
||||
" let prev_tag = search(tags_exp, 'bW', block_start)
|
||||
" let prev_closetag = search(close_tags_exp, 'W', a:lnum)
|
||||
" if prev_tag && !prev_closetag
|
||||
@@ -426,7 +442,7 @@ fun! HtmlIndentGet(lnum)
|
||||
" endif
|
||||
|
||||
" if getline(a:lnum) =~ '</\w\+>'
|
||||
" let block_start = search('^'.repeat(' ', lind + (&sw * ind - 1)).'\S' , 'bnW')
|
||||
" let block_start = search('^'.repeat(' ', lind + (sw * ind - 1)).'\S' , 'bnW')
|
||||
" let prev_tag = search(tags_exp, 'bW', block_start)
|
||||
" let prev_closetag = search(close_tags_exp, 'W', a:lnum)
|
||||
" if prev_tag && !prev_closetag
|
||||
@@ -439,7 +455,7 @@ fun! HtmlIndentGet(lnum)
|
||||
setlocal noic
|
||||
endif
|
||||
|
||||
return lind + (&sw * ind)
|
||||
return lind + (sw * ind)
|
||||
endfun
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
|
||||
@@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') ==
|
||||
" Language: Javascript
|
||||
" Maintainer: Chris Paul ( https://github.com/bounceme )
|
||||
" URL: https://github.com/pangloss/vim-javascript
|
||||
" Last Change: May 16, 2017
|
||||
" Last Change: December 4, 2017
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists('b:did_indent')
|
||||
@@ -12,10 +12,6 @@ if exists('b:did_indent')
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
" indent correctly if inside <script>
|
||||
" vim/vim@690afe1 for the switch from cindent
|
||||
let b:html_indent_script1 = 'inc'
|
||||
|
||||
" Now, set up our indentation expression and keys that trigger it.
|
||||
setlocal indentexpr=GetJavascriptIndent()
|
||||
setlocal autoindent nolisp nosmartindent
|
||||
@@ -27,13 +23,6 @@ setlocal indentkeys+=0],0)
|
||||
|
||||
let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<'
|
||||
|
||||
" Regex of syntax group names that are or delimit string or are comments.
|
||||
let b:syng_strcom = get(b:,'syng_strcom','string\|comment\|regex\|special\|doc\|template\%(braces\)\@!')
|
||||
let b:syng_str = get(b:,'syng_str','string\|template\|special')
|
||||
" template strings may want to be excluded when editing graphql:
|
||||
" au! Filetype javascript let b:syng_str = '^\%(.*template\)\@!.*string\|special'
|
||||
" au! Filetype javascript let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'
|
||||
|
||||
" Only define the function once.
|
||||
if exists('*GetJavascriptIndent')
|
||||
finish
|
||||
@@ -42,6 +31,23 @@ endif
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" indent correctly if inside <script>
|
||||
" vim/vim@690afe1 for the switch from cindent
|
||||
" overridden with b:html_indent_script1
|
||||
call extend(g:,{'html_indent_script1': 'inc'},'keep')
|
||||
|
||||
" Regex of syntax group names that are or delimit string or are comments.
|
||||
let s:bvars = {
|
||||
\ 'syng_strcom': 'string\|comment\|regex\|special\|doc\|template\%(braces\)\@!',
|
||||
\ 'syng_str': 'string\|template\|special' }
|
||||
" template strings may want to be excluded when editing graphql:
|
||||
" au! Filetype javascript let b:syng_str = '^\%(.*template\)\@!.*string\|special'
|
||||
" au! Filetype javascript let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'
|
||||
|
||||
function s:GetVars()
|
||||
call extend(b:,extend(s:bvars,{'js_cache': [0,0,0]}),'keep')
|
||||
endfunction
|
||||
|
||||
" Get shiftwidth value
|
||||
if exists('*shiftwidth')
|
||||
function s:sw()
|
||||
@@ -57,343 +63,323 @@ endif
|
||||
" matches before pos.
|
||||
let s:z = has('patch-7.4.984') ? 'z' : ''
|
||||
|
||||
let s:syng_com = 'comment\|doc'
|
||||
" Expression used to check whether we should skip a match with searchpair().
|
||||
let s:skip_expr = "s:syn_at(line('.'),col('.')) =~? b:syng_strcom"
|
||||
let s:skip_expr = "s:SynAt(line('.'),col('.')) =~? b:syng_strcom"
|
||||
let s:in_comm = s:skip_expr[:-14] . "'comment\\|doc'"
|
||||
|
||||
let s:rel = has('reltime')
|
||||
" searchpair() wrapper
|
||||
if has('reltime')
|
||||
function s:GetPair(start,end,flags,skip,time,...)
|
||||
return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time)
|
||||
if s:rel
|
||||
function s:GetPair(start,end,flags,skip)
|
||||
return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,s:l1,a:skip ==# 's:SkipFunc()' ? 2000 : 200)
|
||||
endfunction
|
||||
else
|
||||
function s:GetPair(start,end,flags,skip,...)
|
||||
return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,get(a:000,1)]))
|
||||
function s:GetPair(start,end,flags,skip)
|
||||
return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,s:l1)
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function s:syn_at(l,c)
|
||||
let pos = join([a:l,a:c],',')
|
||||
if has_key(s:synId_cache,pos)
|
||||
return s:synId_cache[pos]
|
||||
function s:SynAt(l,c)
|
||||
let byte = line2byte(a:l) + a:c - 1
|
||||
let pos = index(s:synid_cache[0], byte)
|
||||
if pos == -1
|
||||
let s:synid_cache[:] += [[byte], [synIDattr(synID(a:l, a:c, 0), 'name')]]
|
||||
endif
|
||||
let s:synId_cache[pos] = synIDattr(synID(a:l,a:c,0),'name')
|
||||
return s:synId_cache[pos]
|
||||
return s:synid_cache[1][pos]
|
||||
endfunction
|
||||
|
||||
function s:parse_cino(f)
|
||||
let [cin, divider, n] = [strridx(&cino,a:f), 0, '']
|
||||
if cin == -1
|
||||
return
|
||||
endif
|
||||
let [sign, cstr] = &cino[cin+1] ==# '-' ? [-1, &cino[cin+2:]] : [1, &cino[cin+1:]]
|
||||
function s:ParseCino(f)
|
||||
let [divider, n, cstr] = [0] + matchlist(&cino,
|
||||
\ '\%(.*,\)\=\%(\%d'.char2nr(a:f).'\(-\)\=\([.s0-9]*\)\)\=')[1:2]
|
||||
for c in split(cstr,'\zs')
|
||||
if c ==# '.' && !divider
|
||||
if c == '.' && !divider
|
||||
let divider = 1
|
||||
elseif c ==# 's'
|
||||
if n is ''
|
||||
let n = s:W
|
||||
else
|
||||
let n = str2nr(n) * s:W
|
||||
if n !~ '\d'
|
||||
return n . s:sw() + 0
|
||||
endif
|
||||
let n = str2nr(n) * s:sw()
|
||||
break
|
||||
elseif c =~ '\d'
|
||||
let [n, divider] .= [c, 0]
|
||||
else
|
||||
break
|
||||
let [n, divider] .= [c, 0]
|
||||
endif
|
||||
endfor
|
||||
return sign * str2nr(n) / max([str2nr(divider),1])
|
||||
return str2nr(n) / max([str2nr(divider),1])
|
||||
endfunction
|
||||
|
||||
" Optimized {skip} expr, used only once per GetJavascriptIndent() call
|
||||
function s:skip_func()
|
||||
if s:topCol == 1 || line('.') < s:scriptTag
|
||||
return {} " E728, used as limit condition for loops and searchpair()
|
||||
endif
|
||||
let s:topCol = col('.')
|
||||
if getline('.') =~ '\%<'.s:topCol.'c\/.\{-}\/\|\%>'.s:topCol.'c[''"]\|\\$'
|
||||
" Optimized {skip} expr, only callable from the search loop which
|
||||
" GetJavascriptIndent does to find the containing [[{(] (side-effects)
|
||||
function s:SkipFunc()
|
||||
if s:top_col == 1
|
||||
throw 'out of bounds'
|
||||
elseif s:check_in
|
||||
if eval(s:skip_expr)
|
||||
let s:topCol = 0
|
||||
return 1
|
||||
endif
|
||||
return !s:topCol
|
||||
elseif s:checkIn || search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn)
|
||||
let s:checkIn = eval(s:skip_expr)
|
||||
if s:checkIn
|
||||
let s:topCol = 0
|
||||
let s:check_in = 0
|
||||
elseif getline('.') =~ '\%<'.col('.').'c\/.\{-}\/\|\%>'.col('.').'c[''"]\|\\$'
|
||||
if eval(s:skip_expr)
|
||||
return 1
|
||||
endif
|
||||
elseif search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn)
|
||||
if eval(s:skip_expr)
|
||||
let s:check_in = 1
|
||||
return 1
|
||||
endif
|
||||
else
|
||||
let s:synid_cache[:] += [[line2byte('.') + col('.') - 1], ['']]
|
||||
endif
|
||||
let s:looksyn = line('.')
|
||||
return s:checkIn
|
||||
let [s:looksyn, s:top_col] = getpos('.')[1:2]
|
||||
endfunction
|
||||
|
||||
function s:alternatePair()
|
||||
let [l:pos, pat, l:for] = [getpos('.'), '[][(){};]', 3]
|
||||
while search('\m'.pat,'bW')
|
||||
if s:skip_func() | continue | endif
|
||||
let idx = stridx('])};',s:looking_at())
|
||||
if idx is 3
|
||||
if l:for is 1
|
||||
return s:GetPair('{','}','bW','s:skip_func()',2000) > 0 || setpos('.',l:pos)
|
||||
endif
|
||||
let [pat, l:for] = ['[{}();]', l:for - 1]
|
||||
elseif idx + 1
|
||||
if s:GetPair(['\[','(','{'][idx], '])}'[idx],'bW','s:skip_func()',2000) < 1
|
||||
function s:AlternatePair()
|
||||
let [pat, l:for] = ['[][(){};]', 2]
|
||||
while s:SearchLoop(pat,'bW','s:SkipFunc()')
|
||||
if s:LookingAt() == ';'
|
||||
if !l:for
|
||||
if s:GetPair('{','}','bW','s:SkipFunc()')
|
||||
return
|
||||
endif
|
||||
break
|
||||
else
|
||||
let [pat, l:for] = ['[{}();]', l:for - 1]
|
||||
endif
|
||||
else
|
||||
return
|
||||
let idx = stridx('])}',s:LookingAt())
|
||||
if idx == -1
|
||||
return
|
||||
elseif !s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:SkipFunc()')
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
call setpos('.',l:pos)
|
||||
throw 'out of bounds'
|
||||
endfunction
|
||||
|
||||
function s:looking_at()
|
||||
function s:Nat(int)
|
||||
return a:int * (a:int > 0)
|
||||
endfunction
|
||||
|
||||
function s:LookingAt()
|
||||
return getline('.')[col('.')-1]
|
||||
endfunction
|
||||
|
||||
function s:token()
|
||||
return s:looking_at() =~ '\k' ? expand('<cword>') : s:looking_at()
|
||||
function s:Token()
|
||||
return s:LookingAt() =~ '\k' ? expand('<cword>') : s:LookingAt()
|
||||
endfunction
|
||||
|
||||
function s:previous_token()
|
||||
let l:pos = getpos('.')
|
||||
function s:PreviousToken(...)
|
||||
let [l:pos, tok] = [getpos('.'), '']
|
||||
if search('\m\k\{1,}\|\S','ebW')
|
||||
if (strpart(getline('.'),col('.')-2,2) == '*/' || line('.') != l:pos[1] &&
|
||||
\ getline('.')[:col('.')-1] =~ '\/\/') && s:syn_at(line('.'),col('.')) =~? s:syng_com
|
||||
while search('\m\S\ze\_s*\/[/*]','bW')
|
||||
if s:syn_at(line('.'),col('.')) !~? s:syng_com
|
||||
return s:token()
|
||||
endif
|
||||
endwhile
|
||||
if getline('.')[col('.')-2:col('.')-1] == '*/'
|
||||
if eval(s:in_comm) && !s:SearchLoop('\S\ze\_s*\/[/*]','bW',s:in_comm)
|
||||
call setpos('.',l:pos)
|
||||
else
|
||||
let tok = s:Token()
|
||||
endif
|
||||
else
|
||||
return s:token()
|
||||
let two = a:0 || line('.') != l:pos[1] ? strridx(getline('.')[:col('.')],'//') + 1 : 0
|
||||
if two && eval(s:in_comm)
|
||||
call cursor(0,two)
|
||||
let tok = s:PreviousToken(1)
|
||||
if tok is ''
|
||||
call setpos('.',l:pos)
|
||||
endif
|
||||
else
|
||||
let tok = s:Token()
|
||||
endif
|
||||
endif
|
||||
call setpos('.',l:pos)
|
||||
endif
|
||||
return ''
|
||||
return tok
|
||||
endfunction
|
||||
|
||||
for s:__ in ['__previous_token','__IsBlock']
|
||||
function s:{s:__}(...)
|
||||
let l:pos = getpos('.')
|
||||
try
|
||||
return call('s:'.matchstr(expand('<sfile>'),'.*__\zs\w\+'),a:000)
|
||||
catch
|
||||
finally
|
||||
call setpos('.',l:pos)
|
||||
endtry
|
||||
endfunction
|
||||
endfor
|
||||
function s:Pure(f,...)
|
||||
return eval("[call(a:f,a:000),cursor(a:firstline,".col('.').")][0]")
|
||||
endfunction
|
||||
|
||||
function s:expr_col()
|
||||
function s:SearchLoop(pat,flags,expr)
|
||||
return s:GetPair(a:pat,'\_$.',a:flags,a:expr)
|
||||
endfunction
|
||||
|
||||
function s:ExprCol()
|
||||
if getline('.')[col('.')-2] == ':'
|
||||
return 1
|
||||
endif
|
||||
let [bal, l:pos] = [0, getpos('.')]
|
||||
while bal < 1 && search('\m[{}?:;]','bW',s:scriptTag)
|
||||
if eval(s:skip_expr)
|
||||
continue
|
||||
elseif s:looking_at() == ':'
|
||||
let bal -= strpart(getline('.'),col('.')-2,3) !~ '::'
|
||||
elseif s:looking_at() == '?'
|
||||
let bal = 0
|
||||
while s:SearchLoop('[{}?:]','bW',s:skip_expr)
|
||||
if s:LookingAt() == ':'
|
||||
if getline('.')[col('.')-2] == ':'
|
||||
call cursor(0,col('.')-1)
|
||||
continue
|
||||
endif
|
||||
let bal -= 1
|
||||
elseif s:LookingAt() == '?'
|
||||
if getline('.')[col('.'):col('.')+1] =~ '^\.\d\@!'
|
||||
continue
|
||||
elseif !bal
|
||||
return 1
|
||||
endif
|
||||
let bal += 1
|
||||
elseif s:looking_at() == '{' && getpos('.')[1:2] != b:js_cache[1:] && !s:IsBlock()
|
||||
let bal = 1
|
||||
elseif s:looking_at() != '}' || s:GetPair('{','}','bW',s:skip_expr,200) < 1
|
||||
elseif s:LookingAt() == '{'
|
||||
return !s:IsBlock()
|
||||
elseif !s:GetPair('{','}','bW',s:skip_expr)
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
call setpos('.',l:pos)
|
||||
return max([bal,0])
|
||||
endfunction
|
||||
|
||||
" configurable regexes that define continuation lines, not including (, {, or [.
|
||||
let s:opfirst = '^' . get(g:,'javascript_opfirst',
|
||||
\ '\C\%([<>=,?^%|*/&]\|\([-.:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)')
|
||||
\ '\C\%([<>=,.?^%|/&]\|\([-:+]\)\1\@!\|\*\+\|!=\|in\%(stanceof\)\=\>\)')
|
||||
let s:continuation = get(g:,'javascript_continuation',
|
||||
\ '\C\%([<=,.~!?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<\%(typeof\|new\|delete\|void\|in\|instanceof\|await\)\)') . '$'
|
||||
|
||||
function s:continues(ln,con)
|
||||
let token = matchstr(a:con[-15:],s:continuation)
|
||||
if strlen(token)
|
||||
call cursor(a:ln,strlen(a:con))
|
||||
if token =~ '[/>]'
|
||||
return s:syn_at(a:ln,col('.')) !~? (token == '>' ? 'jsflow\|^html' : 'regex')
|
||||
elseif token =~ '\l'
|
||||
return s:previous_token() != '.'
|
||||
elseif token == ':'
|
||||
return s:expr_col()
|
||||
function s:Continues()
|
||||
let tok = matchstr(strpart(getline('.'),col('.')-15,15),s:continuation)
|
||||
if tok =~ '[a-z:]'
|
||||
return tok == ':' ? s:ExprCol() : s:PreviousToken() != '.'
|
||||
elseif tok !~ '[/>]'
|
||||
return tok isnot ''
|
||||
endif
|
||||
return s:SynAt(line('.'),col('.')) !~? (tok == '>' ? 'jsflow\|^html' : 'regex')
|
||||
endfunction
|
||||
|
||||
" Check if line 'lnum' has a balanced amount of parentheses.
|
||||
function s:Balanced(lnum,line)
|
||||
let l:open = 0
|
||||
let pos = match(a:line, '[][(){}]')
|
||||
while pos != -1
|
||||
if s:SynAt(a:lnum,pos + 1) !~? b:syng_strcom
|
||||
let l:open += match(' ' . a:line[pos],'[[({]')
|
||||
if l:open < 0
|
||||
return
|
||||
endif
|
||||
endif
|
||||
let pos = match(a:line, !l:open ? '[][(){}]' : '()' =~ a:line[pos] ?
|
||||
\ '[()]' : '{}' =~ a:line[pos] ? '[{}]' : '[][]', pos + 1)
|
||||
endwhile
|
||||
return !l:open
|
||||
endfunction
|
||||
|
||||
function s:OneScope()
|
||||
if s:LookingAt() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr)
|
||||
let tok = s:PreviousToken()
|
||||
return (count(split('for if let while with'),tok) ||
|
||||
\ tok =~# '^await$\|^each$' && s:PreviousToken() ==# 'for') &&
|
||||
\ s:Pure('s:PreviousToken') != '.' && !(tok == 'while' && s:DoWhile())
|
||||
elseif s:Token() =~# '^else$\|^do$'
|
||||
return s:Pure('s:PreviousToken') != '.'
|
||||
elseif strpart(getline('.'),col('.')-2,2) == '=>'
|
||||
call cursor(0,col('.')-1)
|
||||
if s:PreviousToken() == ')'
|
||||
return s:GetPair('(', ')', 'bW', s:skip_expr)
|
||||
endif
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function s:Trim(ln)
|
||||
let pline = substitute(getline(a:ln),'\s*$','','')
|
||||
let l:max = max([strridx(pline,'//'), strridx(pline,'/*')])
|
||||
while l:max != -1 && s:syn_at(a:ln, strlen(pline)) =~? s:syng_com
|
||||
let pline = pline[: l:max]
|
||||
let l:max = max([strridx(pline,'//'), strridx(pline,'/*')])
|
||||
let pline = substitute(pline[:-2],'\s*$','','')
|
||||
endwhile
|
||||
return pline
|
||||
endfunction
|
||||
|
||||
" Find line above 'lnum' that isn't empty or in a comment
|
||||
function s:PrevCodeLine(lnum)
|
||||
let l:n = prevnonblank(a:lnum)
|
||||
while l:n
|
||||
if getline(l:n) =~ '^\s*\/[/*]'
|
||||
if (stridx(getline(l:n),'`') > 0 || getline(l:n-1)[-1:] == '\') &&
|
||||
\ s:syn_at(l:n,1) =~? b:syng_str
|
||||
function s:DoWhile()
|
||||
let cpos = searchpos('\m\<','cbW')
|
||||
while s:SearchLoop('\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
|
||||
if s:LookingAt() =~ '\a'
|
||||
if s:Pure('s:IsBlock')
|
||||
if s:LookingAt() ==# 'd'
|
||||
return 1
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let l:n = prevnonblank(l:n-1)
|
||||
elseif stridx(getline(l:n), '*/') + 1 && s:syn_at(l:n,1) =~? s:syng_com
|
||||
let l:pos = getpos('.')
|
||||
call cursor(l:n,1)
|
||||
let l:n = search('\m\S\_s*\/\*','nbW')
|
||||
call setpos('.',l:pos)
|
||||
else
|
||||
elseif s:LookingAt() != '}' || !s:GetPair('{','}','bW',s:skip_expr)
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
return l:n
|
||||
call call('cursor',cpos)
|
||||
endfunction
|
||||
|
||||
" Check if line 'lnum' has a balanced amount of parentheses.
|
||||
function s:Balanced(lnum)
|
||||
let l:open = 0
|
||||
let l:line = getline(a:lnum)
|
||||
let pos = match(l:line, '[][(){}]', 0)
|
||||
while pos != -1
|
||||
if s:syn_at(a:lnum,pos + 1) !~? b:syng_strcom
|
||||
let l:open += match(' ' . l:line[pos],'[[({]')
|
||||
if l:open < 0
|
||||
return
|
||||
endif
|
||||
endif
|
||||
let pos = match(l:line, (l:open ?
|
||||
\ '['.matchstr(['][','()','{}'],l:line[pos]).']' :
|
||||
\ '[][(){}]'), pos + 1)
|
||||
endwhile
|
||||
return !l:open
|
||||
endfunction
|
||||
|
||||
function s:OneScope(lnum)
|
||||
let pline = s:Trim(a:lnum)
|
||||
call cursor(a:lnum,strlen(pline))
|
||||
let kw = 'else do'
|
||||
if pline[-1:] == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
|
||||
if s:previous_token() =~# '^\%(await\|each\)$'
|
||||
call s:previous_token()
|
||||
let kw = 'for'
|
||||
" returns total offset from braceless contexts. 'num' is the lineNr which
|
||||
" encloses the entire context, 'cont' if whether a:firstline is a continued
|
||||
" expression, which could have started in a braceless context
|
||||
function s:IsContOne(cont)
|
||||
let [l:num, b_l] = [b:js_cache[1] + !b:js_cache[1], 0]
|
||||
let pind = b:js_cache[1] ? indent(b:js_cache[1]) + s:sw() : 0
|
||||
let ind = indent('.') + !a:cont
|
||||
while line('.') > l:num && ind > pind || line('.') == l:num
|
||||
if indent('.') < ind && s:OneScope()
|
||||
let b_l += 1
|
||||
elseif !a:cont || b_l || ind < indent(a:firstline)
|
||||
break
|
||||
else
|
||||
let kw = 'for if let while with'
|
||||
call cursor(0,1)
|
||||
endif
|
||||
endif
|
||||
return pline[-2:] == '=>' || index(split(kw),s:token()) + 1 &&
|
||||
\ s:__previous_token() != '.' && !s:doWhile()
|
||||
endfunction
|
||||
|
||||
function s:doWhile()
|
||||
if expand('<cword>') ==# 'while'
|
||||
let [bal, l:pos] = [0, getpos('.')]
|
||||
call search('\m\<','cbW')
|
||||
while bal < 1 && search('\m\C[{}]\|\<\%(do\|while\)\>','bW')
|
||||
if eval(s:skip_expr)
|
||||
continue
|
||||
elseif s:looking_at() ==# 'd'
|
||||
let bal += s:__IsBlock(1)
|
||||
elseif s:looking_at() ==# 'w'
|
||||
let bal -= s:__previous_token() != '.'
|
||||
elseif s:looking_at() != '}' || s:GetPair('{','}','bW',s:skip_expr,200) < 1
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
call setpos('.',l:pos)
|
||||
return max([bal,0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" returns braceless levels started by 'i' and above lines * &sw. 'num' is the
|
||||
" lineNr which encloses the entire context, 'cont' if whether line 'i' + 1 is
|
||||
" a continued expression, which could have started in a braceless context
|
||||
function s:iscontOne(i,num,cont)
|
||||
let [l:i, l:num, bL] = [a:i, a:num + !a:num, 0]
|
||||
let pind = a:num ? indent(l:num) + s:W : 0
|
||||
let ind = indent(l:i) + (a:cont ? 0 : s:W)
|
||||
while l:i >= l:num && (ind > pind || l:i == l:num)
|
||||
if indent(l:i) < ind && s:OneScope(l:i)
|
||||
let bL += s:W
|
||||
let l:i = line('.')
|
||||
elseif !a:cont || bL || ind < indent(a:i)
|
||||
let ind = min([ind, indent('.')])
|
||||
if s:PreviousToken() is ''
|
||||
break
|
||||
endif
|
||||
let ind = min([ind, indent(l:i)])
|
||||
let l:i = s:PrevCodeLine(l:i - 1)
|
||||
endwhile
|
||||
return bL
|
||||
return b_l
|
||||
endfunction
|
||||
|
||||
function s:IsSwitch()
|
||||
call call('cursor',b:js_cache[1:])
|
||||
return search('\m\C\%#.\_s*\%(\%(\/\/.*\_$\|\/\*\_.\{-}\*\/\)\@>\_s*\)*\%(case\|default\)\>','nWc'.s:z)
|
||||
endfunction
|
||||
|
||||
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
|
||||
function s:IsBlock(...)
|
||||
if a:0 || s:looking_at() == '{'
|
||||
let l:n = line('.')
|
||||
let char = s:previous_token()
|
||||
if match(s:stack,'\cxml\|jsx') + 1 && s:syn_at(line('.'),col('.')-1) =~? 'xml\|jsx'
|
||||
return char != '{'
|
||||
elseif char =~ '\k'
|
||||
if char ==# 'type'
|
||||
return s:__previous_token() !~# '^\%(im\|ex\)port$'
|
||||
endif
|
||||
return index(split('return const let import export extends yield default delete var await void typeof throw case new of in instanceof')
|
||||
\ ,char) < (line('.') != l:n) || s:__previous_token() == '.'
|
||||
elseif char == '>'
|
||||
return getline('.')[col('.')-2] == '=' || s:syn_at(line('.'),col('.')) =~? 'jsflow\|^html'
|
||||
elseif char == '*'
|
||||
return s:__previous_token() == ':'
|
||||
elseif char == ':'
|
||||
return !s:expr_col()
|
||||
elseif char == '/'
|
||||
return s:syn_at(line('.'),col('.')) =~? 'regex'
|
||||
function s:IsBlock()
|
||||
let tok = s:PreviousToken()
|
||||
if join(s:stack) =~? 'xml\|jsx' && s:SynAt(line('.'),col('.')-1) =~? 'xml\|jsx'
|
||||
let s:in_jsx = 1
|
||||
return tok != '{'
|
||||
elseif tok =~ '\k'
|
||||
if tok ==# 'type'
|
||||
return s:Pure('eval',"s:PreviousToken() !~# '^\\%(im\\|ex\\)port$' || s:PreviousToken() == '.'")
|
||||
elseif tok ==# 'of'
|
||||
return s:Pure('eval',"!s:GetPair('[[({]','[])}]','bW',s:skip_expr) || s:LookingAt() != '(' ||"
|
||||
\ ."s:{s:PreviousToken() ==# 'await' ? 'Previous' : ''}Token() !=# 'for' || s:PreviousToken() == '.'")
|
||||
endif
|
||||
return char !~ '[=~!<,.?^%|&([]' &&
|
||||
\ (char !~ '[-+]' || l:n != line('.') && getline('.')[col('.')-2] == char)
|
||||
return index(split('return const let import export extends yield default delete var await void typeof throw case new in instanceof')
|
||||
\ ,tok) < (line('.') != a:firstline) || s:Pure('s:PreviousToken') == '.'
|
||||
elseif tok == '>'
|
||||
return getline('.')[col('.')-2] == '=' || s:SynAt(line('.'),col('.')) =~? 'jsflow\|^html'
|
||||
elseif tok == '*'
|
||||
return s:Pure('s:PreviousToken') == ':'
|
||||
elseif tok == ':'
|
||||
return s:Pure('eval',"s:PreviousToken() =~ '^\\K\\k*$' && !s:ExprCol()")
|
||||
elseif tok == '/'
|
||||
return s:SynAt(line('.'),col('.')) =~? 'regex'
|
||||
elseif tok !~ '[=~!<,.?^%|&([]'
|
||||
return tok !~ '[-+]' || line('.') != a:firstline && getline('.')[col('.')-2] == tok
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function GetJavascriptIndent()
|
||||
let b:js_cache = get(b:,'js_cache',[0,0,0])
|
||||
let s:synId_cache = {}
|
||||
" Get the current line.
|
||||
call cursor(v:lnum,1)
|
||||
let l:line = getline('.')
|
||||
call s:GetVars()
|
||||
let s:synid_cache = [[],[]]
|
||||
let l:line = getline(v:lnum)
|
||||
" use synstack as it validates syn state and works in an empty line
|
||||
let s:stack = map(synstack(v:lnum,1),"synIDattr(v:val,'name')")
|
||||
let syns = get(s:stack,-1,'')
|
||||
let s:stack = [''] + map(synstack(v:lnum,1),"synIDattr(v:val,'name')")
|
||||
|
||||
" start with strings,comments,etc.
|
||||
if syns =~? s:syng_com
|
||||
if l:line =~ '^\s*\*'
|
||||
return cindent(v:lnum)
|
||||
elseif l:line !~ '^\s*\/[/*]'
|
||||
return -1
|
||||
if s:stack[-1] =~? 'comment\|doc'
|
||||
if l:line !~ '^\s*\/[/*]'
|
||||
return l:line =~ '^\s*\*' ? cindent(v:lnum) : -1
|
||||
endif
|
||||
elseif syns =~? b:syng_str
|
||||
if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1)
|
||||
elseif s:stack[-1] =~? b:syng_str
|
||||
if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1,getline(v:lnum-1))
|
||||
let b:js_cache[0] = v:lnum
|
||||
endif
|
||||
return -1
|
||||
endif
|
||||
let l:lnum = s:PrevCodeLine(v:lnum - 1)
|
||||
if !l:lnum
|
||||
|
||||
let s:l1 = max([0,prevnonblank(v:lnum) - (s:rel ? 2000 : 1000),
|
||||
\ get(get(b:,'hi_indent',{}),'blocklnr')])
|
||||
call cursor(v:lnum,1)
|
||||
if s:PreviousToken() is ''
|
||||
return
|
||||
endif
|
||||
let [l:lnum, pline] = [line('.'), getline('.')[:col('.')-1]]
|
||||
|
||||
let l:line = substitute(l:line,'^\s*','','')
|
||||
let l:line_raw = l:line
|
||||
if l:line[:1] == '/*'
|
||||
let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','')
|
||||
endif
|
||||
@@ -402,57 +388,92 @@ function GetJavascriptIndent()
|
||||
endif
|
||||
|
||||
" the containing paren, bracket, or curly. Many hacks for performance
|
||||
let [ s:scriptTag, idx ] = [ get(get(b:,'hi_indent',{}),'blocklnr'),
|
||||
\ index([']',')','}'],l:line[0]) ]
|
||||
if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum &&
|
||||
\ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum))
|
||||
call call('cursor',b:js_cache[2] ? b:js_cache[1:] : [0,0])
|
||||
call cursor(v:lnum,1)
|
||||
let idx = index([']',')','}'],l:line[0])
|
||||
if b:js_cache[0] > l:lnum && b:js_cache[0] < v:lnum ||
|
||||
\ b:js_cache[0] == l:lnum && s:Balanced(l:lnum,pline)
|
||||
call call('cursor',b:js_cache[1:])
|
||||
else
|
||||
let [s:looksyn, s:checkIn, s:topCol] = [v:lnum - 1, 0, 0]
|
||||
if idx + 1
|
||||
call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:skip_func()',2000)
|
||||
elseif getline(v:lnum) !~ '^\S' && syns =~? 'block'
|
||||
call s:GetPair('{','}','bW','s:skip_func()',2000)
|
||||
else
|
||||
call s:alternatePair()
|
||||
endif
|
||||
let [s:looksyn, s:top_col, s:check_in, s:l1] = [v:lnum - 1,0,0,
|
||||
\ max([s:l1, &smc ? search('\m^.\{'.&smc.',}','nbW',s:l1 + 1) + 1 : 0])]
|
||||
try
|
||||
if idx != -1
|
||||
call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:SkipFunc()')
|
||||
elseif getline(v:lnum) !~ '^\S' && s:stack[-1] =~? 'block\|^jsobject$'
|
||||
call s:GetPair('{','}','bW','s:SkipFunc()')
|
||||
else
|
||||
call s:AlternatePair()
|
||||
endif
|
||||
catch /^\Cout of bounds$/
|
||||
call cursor(v:lnum,1)
|
||||
endtry
|
||||
let b:js_cache[1:] = line('.') == v:lnum ? [0,0] : getpos('.')[1:2]
|
||||
endif
|
||||
|
||||
let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [s:scriptTag,0] : getpos('.')[1:2])
|
||||
let num = b:js_cache[1]
|
||||
let [b:js_cache[0], num] = [v:lnum, b:js_cache[1]]
|
||||
|
||||
let [s:W, isOp, bL, switch_offset] = [s:sw(),0,0,0]
|
||||
if !b:js_cache[2] || s:IsBlock()
|
||||
let [num_ind, is_op, b_l, l:switch_offset, s:in_jsx] = [s:Nat(indent(num)),0,0,0,0]
|
||||
if !num || s:LookingAt() == '{' && s:IsBlock()
|
||||
let ilnum = line('.')
|
||||
let pline = s:Trim(l:lnum)
|
||||
if b:js_cache[2] && s:looking_at() == ')' && s:GetPair('(',')','bW',s:skip_expr,100) > 0
|
||||
let num = ilnum == num ? line('.') : num
|
||||
if idx < 0 && s:previous_token() ==# 'switch' && s:previous_token() != '.'
|
||||
let switch_offset = &cino !~ ':' ? s:W : max([-indent(num),s:parse_cino(':')])
|
||||
if num && !s:in_jsx && s:LookingAt() == ')' && s:GetPair('(',')','bW',s:skip_expr)
|
||||
if ilnum == num
|
||||
let [num, num_ind] = [line('.'), indent('.')]
|
||||
endif
|
||||
if idx == -1 && s:PreviousToken() ==# 'switch' && s:IsSwitch()
|
||||
let l:switch_offset = &cino !~ ':' ? s:sw() : s:ParseCino(':')
|
||||
if pline[-1:] != '.' && l:line =~# '^\%(default\|case\)\>'
|
||||
return indent(num) + switch_offset
|
||||
return s:Nat(num_ind + l:switch_offset)
|
||||
elseif &cino =~ '='
|
||||
let l:case_offset = s:ParseCino('=')
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if idx < 0 && pline[-1:] !~ '[{;]'
|
||||
let isOp = (l:line =~# s:opfirst || s:continues(l:lnum,pline)) * s:W
|
||||
let bL = s:iscontOne(l:lnum,b:js_cache[1],isOp)
|
||||
let bL -= (bL && l:line[0] == '{') * s:W
|
||||
if idx == -1 && pline[-1:] !~ '[{;]'
|
||||
call cursor(l:lnum, len(pline))
|
||||
let sol = matchstr(l:line,s:opfirst)
|
||||
if sol is '' || sol == '/' && s:SynAt(v:lnum,
|
||||
\ 1 + len(getline(v:lnum)) - len(l:line)) =~? 'regex'
|
||||
if s:Continues()
|
||||
let is_op = s:sw()
|
||||
endif
|
||||
elseif num && sol =~# '^\%(in\%(stanceof\)\=\|\*\)$' &&
|
||||
\ s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr) &&
|
||||
\ s:PreviousToken() == ')' && s:GetPair('(',')','bW',s:skip_expr) &&
|
||||
\ (s:PreviousToken() == ']' || s:LookingAt() =~ '\k' &&
|
||||
\ s:{s:PreviousToken() == '*' ? 'Previous' : ''}Token() !=# 'function')
|
||||
return num_ind + s:sw()
|
||||
else
|
||||
let is_op = s:sw()
|
||||
endif
|
||||
call cursor(l:lnum, len(pline))
|
||||
let b_l = s:Nat(s:IsContOne(is_op) - (!is_op && l:line =~ '^{')) * s:sw()
|
||||
endif
|
||||
elseif idx < 0 && getline(b:js_cache[1])[b:js_cache[2]-1] == '(' && &cino =~ '('
|
||||
let pval = s:parse_cino('(')
|
||||
return !pval || !search('\m\S','nbW',num) && !s:parse_cino('U') ?
|
||||
\ (s:parse_cino('w') ? 0 : -!!search('\m\S','W'.s:z,num)) + virtcol('.') :
|
||||
\ max([indent('.') + pval + s:GetPair('(',')','nbrmW',s:skip_expr,100,num) * s:W,0])
|
||||
elseif idx.s:LookingAt().&cino =~ '^-1(.*(' && (search('\m\S','nbW',num) || s:ParseCino('U'))
|
||||
let pval = s:ParseCino('(')
|
||||
if !pval
|
||||
let [Wval, vcol] = [s:ParseCino('W'), virtcol('.')]
|
||||
if search('\m\S','W',num)
|
||||
return s:ParseCino('w') ? vcol : virtcol('.')-1
|
||||
endif
|
||||
return Wval ? s:Nat(num_ind + Wval) : vcol
|
||||
endif
|
||||
return s:Nat(num_ind + pval + searchpair('\m(','','\m)','nbrmW',s:skip_expr,num) * s:sw())
|
||||
endif
|
||||
|
||||
" main return
|
||||
if l:line =~ '^[])}]\|^|}'
|
||||
return max([indent(num),0])
|
||||
if l:line_raw[0] == ')'
|
||||
if s:ParseCino('M')
|
||||
return indent(l:lnum)
|
||||
elseif num && &cino =~# 'm' && !s:ParseCino('m')
|
||||
return virtcol('.') - 1
|
||||
endif
|
||||
endif
|
||||
return num_ind
|
||||
elseif num
|
||||
return indent(num) + s:W + switch_offset + bL + isOp
|
||||
return s:Nat(num_ind + get(l:,'case_offset',s:sw()) + l:switch_offset + b_l + is_op)
|
||||
endif
|
||||
return bL + isOp
|
||||
return b_l + is_op
|
||||
endfunction
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
|
||||
225
indent/julia.vim
225
indent/julia.vim
@@ -3,13 +3,13 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
||||
" Vim indent file
|
||||
" Language: Julia
|
||||
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
|
||||
" Last Change: 2011 dec 11
|
||||
" Notes: based on Bram Moneaar's indent file for vim
|
||||
" Last Change: 2016 jun 16
|
||||
" Notes: originally based on Bram Molenaar's indent file for vim
|
||||
|
||||
setlocal autoindent
|
||||
|
||||
setlocal indentexpr=GetJuliaIndent()
|
||||
setlocal indentkeys+==end,=else,=catch,=finally
|
||||
setlocal indentkeys+==end,=else,=catch,=finally,),],}
|
||||
setlocal indentkeys-=0#
|
||||
setlocal indentkeys-=:
|
||||
setlocal indentkeys-=0{
|
||||
@@ -21,12 +21,16 @@ if exists("*GetJuliaIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:skipPatterns = '\<julia\%(Comment\)\>'
|
||||
let s:skipPatterns = '\<julia\%(Comprehension\%(For\|If\)\|RangeEnd\|CommentL\|\%([bsv]\|ip\|big\|MIME\|Shell\|Printf\|Doc\)\=String\|RegEx\|SymbolS\?\)\>'
|
||||
|
||||
function JuliaMatch(lnum, str, regex, st)
|
||||
function JuliaMatch(lnum, str, regex, st, ...)
|
||||
let s = a:st
|
||||
let e = a:0 > 0 ? a:1 : -1
|
||||
while 1
|
||||
let f = match(a:str, a:regex, s)
|
||||
if e >= 0 && f >= e
|
||||
return -1
|
||||
endif
|
||||
if f >= 0
|
||||
let attr = synIDattr(synID(a:lnum,f+1,1),"name")
|
||||
if attr =~ s:skipPatterns
|
||||
@@ -39,15 +43,16 @@ function JuliaMatch(lnum, str, regex, st)
|
||||
return f
|
||||
endfunction
|
||||
|
||||
function GetJuliaNestingStruct(lnum)
|
||||
function GetJuliaNestingStruct(lnum, ...)
|
||||
" Auxiliary function to inspect the block structure of a line
|
||||
let line = getline(a:lnum)
|
||||
let s = 0
|
||||
let s = a:0 > 0 ? a:1 : 0
|
||||
let e = a:0 > 1 ? a:2 : -1
|
||||
let blocks_stack = []
|
||||
let num_closed_blocks = 0
|
||||
while 1
|
||||
let fb = JuliaMatch(a:lnum, line, '@\@<!\<\%(if\|else\%(if\)\=\|while\|for\|try\|catch\|finally\|function\|macro\|begin\|type\|immutable\|let\|\%(bare\)\?module\|quote\|do\)\>', s)
|
||||
let fe = JuliaMatch(a:lnum, line, '@\@<!\<end\>', s)
|
||||
let fb = JuliaMatch(a:lnum, line, '@\@<!\<\%(if\|else\%(if\)\=\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|\%(\%(abstract\|primitive\)\s\+\)\@<!type\|immutable\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e)
|
||||
let fe = JuliaMatch(a:lnum, line, '@\@<!\<end\>', s, e)
|
||||
|
||||
if fb < 0 && fe < 0
|
||||
" No blocks found
|
||||
@@ -128,9 +133,13 @@ function GetJuliaNestingStruct(lnum)
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(while\|for\|function\|macro\|begin\|type\|immutable\|let\|quote\|do\)\>', s)
|
||||
let i = JuliaMatch(a:lnum, line, '@\@<!\<\%(while\|for\|\%(staged\)\?function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(\%(abstract\|primitive\)\s\+\)\?type\|immutable\|let\|quote\|do\)\>', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
if match(line, '\<\%(mutable\|abstract\|primitive\)', i) != -1
|
||||
let s = i+11
|
||||
else
|
||||
let s = i+1
|
||||
endif
|
||||
call add(blocks_stack, 'other')
|
||||
continue
|
||||
endif
|
||||
@@ -158,6 +167,128 @@ function GetJuliaNestingStruct(lnum)
|
||||
return [num_open_blocks, num_closed_blocks]
|
||||
endfunction
|
||||
|
||||
function GetJuliaNestingBrackets(lnum, c)
|
||||
" Auxiliary function to inspect the brackets structure of a line
|
||||
let line = getline(a:lnum)[0 : (a:c - 1)]
|
||||
let s = 0
|
||||
let brackets_stack = []
|
||||
let last_closed_bracket = -1
|
||||
while 1
|
||||
let fb = JuliaMatch(a:lnum, line, '[([{]', s)
|
||||
let fe = JuliaMatch(a:lnum, line, '[])}]', s)
|
||||
|
||||
if fb < 0 && fe < 0
|
||||
" No brackets found
|
||||
break
|
||||
end
|
||||
|
||||
if fb >= 0 && (fb < fe || fe < 0)
|
||||
" The first occurrence is an opening bracket
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '(', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
call add(brackets_stack, ['par',i])
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '\[', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
call add(brackets_stack, ['sqbra',i])
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '{', s)
|
||||
if i >= 0 && i == fb
|
||||
let s = i+1
|
||||
call add(brackets_stack, ['curbra',i])
|
||||
continue
|
||||
endif
|
||||
|
||||
" Note: it should be impossible to get here
|
||||
break
|
||||
|
||||
else
|
||||
" The first occurrence is a closing bracket
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, ')', s)
|
||||
if i >= 0 && i == fe
|
||||
let s = i+1
|
||||
if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'par'
|
||||
call remove(brackets_stack, -1)
|
||||
else
|
||||
let last_closed_bracket = i + 1
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, ']', s)
|
||||
if i >= 0 && i == fe
|
||||
let s = i+1
|
||||
if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'sqbra'
|
||||
call remove(brackets_stack, -1)
|
||||
else
|
||||
let last_closed_bracket = i + 1
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
let i = JuliaMatch(a:lnum, line, '}', s)
|
||||
if i >= 0 && i == fe
|
||||
let s = i+1
|
||||
if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'curbra'
|
||||
call remove(brackets_stack, -1)
|
||||
else
|
||||
let last_closed_bracket = i + 1
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
" Note: it should be impossible to get here
|
||||
break
|
||||
|
||||
endif
|
||||
|
||||
" Note: it should be impossible to get here
|
||||
break
|
||||
endwhile
|
||||
let first_open_bracket = -1
|
||||
let last_open_bracket = -1
|
||||
if len(brackets_stack) > 0
|
||||
let first_open_bracket = brackets_stack[0][1]
|
||||
let last_open_bracket = brackets_stack[-1][1]
|
||||
endif
|
||||
return [first_open_bracket, last_open_bracket, last_closed_bracket]
|
||||
endfunction
|
||||
|
||||
let s:bracketBlocks = '\<julia\%(\%(\%(Printf\)\?Par\|SqBra\|CurBra\)Block\|ParBlockInRange\|StringVars\%(Par\|SqBra\|CurBra\)\|Dollar\%(Par\|SqBra\)\|QuotedParBlockS\?\)\>'
|
||||
|
||||
function IsInBrackets(lnum, c)
|
||||
let stack = map(synstack(a:lnum, a:c), 'synIDattr(v:val, "name")')
|
||||
call filter(stack, 'v:val =~# s:bracketBlocks')
|
||||
return len(stack) > 0
|
||||
endfunction
|
||||
|
||||
" Auxiliary function to find a line which does not start in the middle of a
|
||||
" multiline bracketed expression, to be used as reference for block
|
||||
" indentation.
|
||||
function LastBlockIndent(lnum)
|
||||
let lnum = a:lnum
|
||||
let ind = 0
|
||||
while lnum > 0
|
||||
let ind = indent(lnum)
|
||||
if ind == 0
|
||||
return [lnum, 0]
|
||||
endif
|
||||
if !IsInBrackets(lnum, 1)
|
||||
break
|
||||
endif
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
endwhile
|
||||
return [max([lnum,1]), ind]
|
||||
endfunction
|
||||
|
||||
function GetJuliaIndent()
|
||||
let s:save_ignorecase = &ignorecase
|
||||
set noignorecase
|
||||
@@ -172,19 +303,81 @@ function GetJuliaIndent()
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(lnum)
|
||||
let ind = -1
|
||||
let st = -1
|
||||
let lim = -1
|
||||
|
||||
" Analyse previous line
|
||||
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum)
|
||||
" Multiline bracketed expressions take precedence
|
||||
let c = len(getline(lnum)) + 1
|
||||
while IsInBrackets(lnum, c)
|
||||
let [first_open_bracket, last_open_bracket, last_closed_bracket] = GetJuliaNestingBrackets(lnum, c)
|
||||
|
||||
" First scenario: the previous line has a hanging open bracket:
|
||||
" set the indentation to match the opening bracket (plus an extra space)
|
||||
if last_open_bracket != -1
|
||||
let st = last_open_bracket
|
||||
let ind = virtcol([lnum, st + 1])
|
||||
|
||||
" Second scenario: some multiline bracketed expression was closed in the
|
||||
" previous line. But since we know we are still in a bracketed expression,
|
||||
" we need to find the line where the bracket was open
|
||||
elseif last_closed_bracket != -1 " && exists("loaded_matchit")
|
||||
" we use the % command to skip back (this is buggy without matchit, and
|
||||
" is potentially a disaster if % got remapped)
|
||||
call cursor(lnum, last_closed_bracket)
|
||||
normal %
|
||||
if line(".") == lnum
|
||||
" something wrong here, give up
|
||||
let ind = indent(lnum)
|
||||
else
|
||||
let lnum = line(".")
|
||||
let c = col(".") - 1
|
||||
if c == 0
|
||||
" uhm, give up
|
||||
let ind = 0
|
||||
else
|
||||
" we skipped a bracket set, keep searching for an opening bracket
|
||||
let lim = c
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
|
||||
" Third scenario: nothing special, or matchit not available: keep the indentation
|
||||
else
|
||||
let ind = indent(lnum)
|
||||
endif
|
||||
|
||||
" In case the current line starts with a closing bracket, we align it with
|
||||
" the opening one.
|
||||
if JuliaMatch(v:lnum, getline(v:lnum), '[])}]', indent(v:lnum)) == indent(v:lnum) && ind > 0
|
||||
return ind - 1
|
||||
endif
|
||||
|
||||
break
|
||||
endwhile
|
||||
|
||||
if ind == -1
|
||||
" We are not in a multiline bracketed expression. Thus we look for a
|
||||
" previous line to use as a reference
|
||||
let [lnum,ind] = LastBlockIndent(lnum)
|
||||
let c = len(getline(lnum)) + 1
|
||||
if IsInBrackets(lnum, c)
|
||||
let [first_open_bracket, last_open_bracket, last_closed_bracket] = GetJuliaNestingBrackets(lnum, c)
|
||||
let lim = first_open_bracket
|
||||
endif
|
||||
end
|
||||
|
||||
" Analyse the reference line
|
||||
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum, st, lim)
|
||||
|
||||
" Increase indentation for each newly opened block
|
||||
" in the previous line
|
||||
" in the reference line
|
||||
while num_open_blocks > 0
|
||||
let ind += &sw
|
||||
let num_open_blocks -= 1
|
||||
endwhile
|
||||
|
||||
" Analyse current line
|
||||
" Analyse the current line
|
||||
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum)
|
||||
|
||||
" Decrease indentation for each closed block
|
||||
|
||||
@@ -3,13 +3,14 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'kotlin') == -1
|
||||
" Vim indent file
|
||||
" Language: Kotlin
|
||||
" Maintainer: Alexander Udalov
|
||||
" Latest Revision: 27 June 2015
|
||||
" Latest Revision: 15 July 2017
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal cinoptions& cinoptions+=j1,L0
|
||||
setlocal indentexpr=GetKotlinIndent()
|
||||
setlocal indentkeys=0},0),!^F,o,O,e,<CR>
|
||||
setlocal autoindent " TODO ?
|
||||
@@ -25,6 +26,21 @@ function! GetKotlinIndent()
|
||||
let prev_indent = indent(prev_num)
|
||||
let cur = getline(v:lnum)
|
||||
|
||||
if cur =~ '^\s*\*'
|
||||
return cindent(v:lnum)
|
||||
endif
|
||||
|
||||
if prev =~ '^\s*\*/'
|
||||
let st = prev
|
||||
while st > 1
|
||||
if getline(st) =~ '^\s*/\*'
|
||||
break
|
||||
endif
|
||||
let st = st - 1
|
||||
endwhile
|
||||
return indent(st)
|
||||
endif
|
||||
|
||||
let prev_open_paren = prev =~ '^.*(\s*$'
|
||||
let cur_close_paren = cur =~ '^\s*).*$'
|
||||
|
||||
|
||||
@@ -24,21 +24,21 @@ endif
|
||||
|
||||
" Variables -----------------------------------------------{{{1
|
||||
|
||||
let s:open_patt = '\%(\<\%(function\|if\|repeat\|do\)\>\|(\|{\)'
|
||||
let s:middle_patt = '\<\%(else\|elseif\)\>'
|
||||
let s:close_patt = '\%(\<\%(end\|until\)\>\|)\|}\)'
|
||||
let s:open_patt = '\C\%(\<\%(function\|if\|repeat\|do\)\>\|(\|{\)'
|
||||
let s:middle_patt = '\C\<\%(else\|elseif\)\>'
|
||||
let s:close_patt = '\C\%(\<\%(end\|until\)\>\|)\|}\)'
|
||||
|
||||
let s:anon_func_start = '\S\+\s*[({].*\<function\s*(.*)\s*$'
|
||||
let s:anon_func_end = '\<end\%(\s*[)}]\)\+'
|
||||
|
||||
" Expression used to check whether we should skip a match with searchpair().
|
||||
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ 'luaComment\\|luaString'"
|
||||
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~# 'luaComment\\|luaString'"
|
||||
|
||||
" Auxiliary Functions -------------------------------------{{{1
|
||||
|
||||
function s:IsInCommentOrString(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ 'luaCommentLong\|luaStringLong'
|
||||
\ && !(getline(a:lnum) =~ '^\s*\%(--\)\?\[=*\[') " opening tag is not considered 'in'
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~# 'luaCommentLong\|luaStringLong'
|
||||
\ && !(getline(a:lnum) =~# '^\s*\%(--\)\?\[=*\[') " opening tag is not considered 'in'
|
||||
endfunction
|
||||
|
||||
" Find line above 'lnum' that isn't blank, in a comment or string.
|
||||
@@ -74,48 +74,42 @@ function GetLuaIndent()
|
||||
|
||||
let original_cursor_pos = getpos(".")
|
||||
|
||||
let i = 0
|
||||
|
||||
" check if the previous line opens blocks
|
||||
" count how many blocks the previous line opens
|
||||
call cursor(v:lnum, 1)
|
||||
let num_pairs = searchpair(s:open_patt, s:middle_patt, s:close_patt,
|
||||
let num_prev_opens = searchpair(s:open_patt, s:middle_patt, s:close_patt,
|
||||
\ 'mrb', s:skip_expr, prev_line)
|
||||
if num_pairs > 0
|
||||
let i += num_pairs
|
||||
endif
|
||||
|
||||
" special case: call(with, {anon = function() -- should indent only once
|
||||
if num_pairs > 1 && contents_prev =~ s:anon_func_start
|
||||
let i = 1
|
||||
endif
|
||||
|
||||
" check if current line closes blocks
|
||||
" count how many blocks the current line closes
|
||||
call cursor(prev_line, col([prev_line,'$']))
|
||||
let num_pairs = searchpair(s:open_patt, s:middle_patt, s:close_patt,
|
||||
let num_cur_closes = searchpair(s:open_patt, s:middle_patt, s:close_patt,
|
||||
\ 'mr', s:skip_expr, v:lnum)
|
||||
if num_pairs > 0
|
||||
let i -= num_pairs
|
||||
endif
|
||||
|
||||
" special case: end}) -- end of call with anon func should unindent once
|
||||
if num_pairs > 1 && contents_cur =~ s:anon_func_end
|
||||
let i = -1
|
||||
endif
|
||||
let i = num_prev_opens - num_cur_closes
|
||||
|
||||
" if the previous line closed a paren, unindent (except with anon funcs)
|
||||
" if the previous line closed a paren, outdent (except with anon funcs)
|
||||
call cursor(prev_line - 1, col([prev_line - 1, '$']))
|
||||
let num_pairs = searchpair('(', '', ')', 'mr', s:skip_expr, prev_line)
|
||||
if num_pairs > 0 && contents_prev !~ s:anon_func_end
|
||||
let num_prev_closed_parens = searchpair('(', '', ')', 'mr', s:skip_expr, prev_line)
|
||||
if num_prev_closed_parens > 0 && contents_prev !~# s:anon_func_end
|
||||
let i -= 1
|
||||
endif
|
||||
|
||||
" if this line closed a paren, indent (except with anon funcs)
|
||||
call cursor(prev_line, col([prev_line, '$']))
|
||||
let num_pairs = searchpair('(', '', ')', 'mr', s:skip_expr, v:lnum)
|
||||
if num_pairs > 0 && contents_cur !~ s:anon_func_end
|
||||
let num_cur_closed_parens = searchpair('(', '', ')', 'mr', s:skip_expr, v:lnum)
|
||||
if num_cur_closed_parens > 0 && contents_cur !~# s:anon_func_end
|
||||
let i += 1
|
||||
endif
|
||||
|
||||
" special case: call(with, {anon = function() -- should indent only once
|
||||
if i > 1 && contents_prev =~# s:anon_func_start
|
||||
let i = 1
|
||||
endif
|
||||
|
||||
" special case: end}) -- end of call w/ anon func should outdent only once
|
||||
if i < -1 && contents_cur =~# s:anon_func_end
|
||||
let i = -1
|
||||
endif
|
||||
|
||||
" restore cursor
|
||||
call setpos(".", original_cursor_pos)
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'mako') == -1
|
||||
" 0.1 - 06 June 2009
|
||||
" - Initial public release of mako indent file
|
||||
|
||||
let sw=2 " default shiftwidth of 2 spaces
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
@@ -55,6 +53,9 @@ setlocal nosmartindent
|
||||
setlocal noautoindent
|
||||
setlocal nocindent
|
||||
setlocal nolisp
|
||||
setlocal expandtab
|
||||
setlocal softtabstop=2
|
||||
setlocal shiftwidth=2
|
||||
|
||||
setlocal indentexpr=GetMakoIndent()
|
||||
setlocal indentkeys+=*<Return>,<>>,<bs>,end,:
|
||||
|
||||
86
indent/nix.vim
Normal file
86
indent/nix.vim
Normal file
@@ -0,0 +1,86 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: Nix
|
||||
" Maintainer: Daiderd Jordan <daiderd@gmail.com>
|
||||
" URL: https://github.com/LnL7/vim-nix
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetNixIndent()
|
||||
setlocal indentkeys+=0=then,0=else,0=inherit,*<Return>
|
||||
|
||||
if exists("*GetNixIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:skip_syntax = '\%(Comment\|String\)$'
|
||||
let s:block_open = '\%({\|[\)'
|
||||
let s:block_close = '\%(}\|]\)'
|
||||
|
||||
function! GetNixIndent()
|
||||
let lnum = prevnonblank(v:lnum - 1)
|
||||
let ind = indent(lnum)
|
||||
|
||||
" At the start of the file use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax
|
||||
let current_line = getline(v:lnum)
|
||||
let last_line = getline(lnum)
|
||||
|
||||
if last_line =~ s:block_open . '\s*$'
|
||||
let ind += &sw
|
||||
endif
|
||||
|
||||
if current_line =~ '^\s*' . s:block_close
|
||||
let ind -= &sw
|
||||
endif
|
||||
|
||||
if last_line =~ '\<let\s*$'
|
||||
let ind += &sw
|
||||
endif
|
||||
|
||||
if getline(v:lnum - 1) =~ '^\<in\s*$'
|
||||
let ind += &sw
|
||||
endif
|
||||
|
||||
if current_line =~ '^\s*in\>'
|
||||
let ind -= &sw
|
||||
endif
|
||||
endif
|
||||
|
||||
if synIDattr(synID(v:lnum, 1, 1), "name") =~ '^nixString'
|
||||
let current_line = getline(v:lnum)
|
||||
|
||||
let ind = indent(v:lnum)
|
||||
let bslnum = searchpair('''''', '', '''''', 'bnW',
|
||||
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "InterpolationSpecial$"')
|
||||
|
||||
if ind <= indent(bslnum)
|
||||
let ind = indent(bslnum) + &sw
|
||||
endif
|
||||
|
||||
if current_line =~ '^\s*''''[^''\$]'
|
||||
let ind = indent(bslnum)
|
||||
endif
|
||||
if current_line =~ '^\s*''''$'
|
||||
let ind = indent(bslnum)
|
||||
endif
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
endif
|
||||
@@ -136,9 +136,9 @@ function! GetPerlIndent()
|
||||
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
||||
let brace = strpart(line, bracepos, 1)
|
||||
if brace == '(' || brace == '{' || brace == '['
|
||||
let ind = ind + &sw
|
||||
let ind = ind + shiftwidth()
|
||||
else
|
||||
let ind = ind - &sw
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
endif
|
||||
let bracepos = match(line, braceclass, bracepos + 1)
|
||||
@@ -151,25 +151,25 @@ function! GetPerlIndent()
|
||||
\ || synid == "perlBraces"
|
||||
\ || synid == "perlStatementIndirObj"
|
||||
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
||||
let ind = ind - &sw
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if line =~ '[{[(]\s*\(#[^])}]*\)\=$'
|
||||
let ind = ind + &sw
|
||||
let ind = ind + shiftwidth()
|
||||
endif
|
||||
if cline =~ '^\s*[])}]'
|
||||
let ind = ind - &sw
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
endif
|
||||
|
||||
" Indent lines that begin with 'or' or 'and'
|
||||
if cline =~ '^\s*\(or\|and\)\>'
|
||||
if line !~ '^\s*\(or\|and\)\>'
|
||||
let ind = ind + &sw
|
||||
let ind = ind + shiftwidth()
|
||||
endif
|
||||
elseif line =~ '^\s*\(or\|and\)\>'
|
||||
let ind = ind - &sw
|
||||
let ind = ind - shiftwidth()
|
||||
endif
|
||||
|
||||
return ind
|
||||
|
||||
@@ -19,7 +19,7 @@ let s:incIndent =
|
||||
\ '^\s*[hr]\?note\>\%(\%("[^"]*" \<as\>\)\@![^:]\)*$\|' .
|
||||
\ '^\s*title\s*$\|' .
|
||||
\ '^\s*skinparam\>.*{\s*$\|' .
|
||||
\ '^\s*\%(state\|class\|partition\|rectangle\|enum\|interface\|namespace\)\>.*{'
|
||||
\ '^\s*\%(state\|class\|partition\|rectangle\|enum\|interface\|namespace\|object\)\>.*{'
|
||||
|
||||
let s:decIndent = '^\s*\%(end\|else\|}\)'
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ let b:did_indent = 1
|
||||
" smartindent is good enough for powershell
|
||||
setlocal smartindent
|
||||
" disable the indent removal for # marks
|
||||
inoremap # X#
|
||||
inoremap <buffer> # X#
|
||||
|
||||
let b:undo_indent = "setl si<"
|
||||
|
||||
|
||||
@@ -37,9 +37,16 @@ if !exists('g:purescript_indent_let')
|
||||
let g:purescript_indent_let = 4
|
||||
endif
|
||||
|
||||
if !exists('g:purescript_indent_in')
|
||||
" let x = 0
|
||||
" >in
|
||||
let g:purescript_indent_in = 1
|
||||
endif
|
||||
|
||||
if !exists('g:purescript_indent_where')
|
||||
" where f :: Int -> Int
|
||||
" >>>>>>f x = x
|
||||
" where
|
||||
" >>f :: Int -> Int
|
||||
" >>f x = x
|
||||
let g:purescript_indent_where = 6
|
||||
endif
|
||||
|
||||
@@ -49,16 +56,29 @@ if !exists('g:purescript_indent_do')
|
||||
let g:purescript_indent_do = 3
|
||||
endif
|
||||
|
||||
if !exists('g:purescript_indent_dot')
|
||||
" f
|
||||
" :: forall a
|
||||
" >. String
|
||||
" -> String
|
||||
let g:purescript_indent_dot = 1
|
||||
endif
|
||||
|
||||
setlocal indentexpr=GetPurescriptIndent()
|
||||
setlocal indentkeys=!^F,o,O,},=where,=in
|
||||
setlocal indentkeys=!^F,o,O,},=where,=in,=::,=->,=→,==>,=⇒
|
||||
|
||||
function! s:GetSynStack(lnum, col)
|
||||
return map(synstack(a:lnum, a:col), { key, val -> synIDattr(val, "name") })
|
||||
endfunction
|
||||
|
||||
function! GetPurescriptIndent()
|
||||
let ppline = getline(v:lnum - 2)
|
||||
let prevline = getline(v:lnum - 1)
|
||||
let line = getline(v:lnum)
|
||||
|
||||
if line =~ '^\s*\<where\>'
|
||||
let s = match(prevline, '\S')
|
||||
return s + 2
|
||||
let s = indent(v:lnum - 1)
|
||||
return max([s, &l:shiftwidth])
|
||||
endif
|
||||
|
||||
if line =~ '^\s*\<in\>'
|
||||
@@ -67,72 +87,191 @@ function! GetPurescriptIndent()
|
||||
|
||||
while s <= 0 && n > 0
|
||||
let n = n - 1
|
||||
let s = match(getline(n),'\<let\>')
|
||||
let s = match(getline(n), '\<let\>')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') != -1
|
||||
let s = -1
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return s + 1
|
||||
return s + g:purescript_indent_in
|
||||
endif
|
||||
|
||||
if prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
|
||||
let s = match(prevline, '^\s*\zs\(--\|import\)')
|
||||
if s >= 0
|
||||
" comments
|
||||
" imports
|
||||
return s
|
||||
endif
|
||||
|
||||
if prevline =~ '^\S.*::' && line !~ '^\s*\(\.\|->\|→\|=>\|⇒\)' && !~ '^instance'
|
||||
" f :: String
|
||||
" -> String
|
||||
return 0
|
||||
endif
|
||||
|
||||
let s = match(prevline, '[[:alnum:][:blank:]]\@<=|[[:alnum:][:blank:]$]')
|
||||
if s >= 0 && prevline !~ '^class\>' && index(s:GetSynStack(v:lnum - 1, s), "purescriptFunctionDecl") == -1
|
||||
" ident pattern guards but not if we are in a type declaration
|
||||
" what we detect using syntax groups
|
||||
if prevline =~ '|\s*otherwise\>'
|
||||
return indent(search('^\s*\k', 'bnW'))
|
||||
" somehow this pattern does not work :/
|
||||
" return indent(search('^\(\s*|\)\@!', 'bnW'))
|
||||
else
|
||||
return s
|
||||
endif
|
||||
endif
|
||||
|
||||
let s = match(line, '\%(\\.\{-}\)\@<=->')
|
||||
if s >= 0
|
||||
" inline lambda
|
||||
return indent(v:lnum)
|
||||
endif
|
||||
|
||||
" indent rules for -> (lambdas and case expressions)
|
||||
let s = match(line, '->')
|
||||
let p = match(prevline, '\\')
|
||||
" protect that we are not in a type signature
|
||||
" and not in a case expression
|
||||
if s >= 0 && index(s:GetSynStack(s == 0 ? v:lnum - 1 : v:lnum, max([1, s])), "purescriptFunctionDecl") == -1
|
||||
\ && p >= 0 && index(s:GetSynStack(v:lnum - 1, p), "purescriptString") == -1
|
||||
return p
|
||||
endif
|
||||
|
||||
if prevline =~ '^\S'
|
||||
" start typing signature, function body, data & newtype on next line
|
||||
return &l:shiftwidth
|
||||
endif
|
||||
|
||||
if ppline =~ '^\S' && prevline =~ '^\s*$'
|
||||
return 0
|
||||
endif
|
||||
|
||||
if line =~ '^\s*\%(::\|∷\)'
|
||||
return match(prevline, '\S') + &l:shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\(::\|∷\)\s*forall'
|
||||
return match(prevline, '\S') + g:purescript_indent_dot
|
||||
endif
|
||||
|
||||
let s = match(prevline, '^\s*\zs\%(::\|∷\|=>\|⇒\|->\|→\)')
|
||||
let r = match(prevline, '^\s*\zs\.')
|
||||
if s >= 0 || r >= 0
|
||||
if s >= 0
|
||||
if line !~ '^\s*\%(::\|∷\|=>\|⇒\|->\|→\)' && line !~ '^\s*$'
|
||||
return s - 2
|
||||
else
|
||||
return s
|
||||
endif
|
||||
elseif r >= 0
|
||||
if line !~ '^\s\%(::\|∷\|=>\|⇒\|->\|→\)'
|
||||
return r - g:purescript_indent_dot
|
||||
else
|
||||
return r
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if prevline =~ '[!#$%&*+./<>?@\\^~-]\s*$'
|
||||
let s = match(prevline, '=')
|
||||
if s > 0
|
||||
return s + 2
|
||||
return s + &l:shiftwidth
|
||||
endif
|
||||
|
||||
let s = match(prevline, ':')
|
||||
let s = match(prevline, '\<:\>')
|
||||
if s > 0
|
||||
return s + 3
|
||||
return s + &l:shiftwidth
|
||||
else
|
||||
return match(prevline, '\S')
|
||||
return match(prevline, '\S') + &l:shiftwidth
|
||||
endif
|
||||
endif
|
||||
|
||||
if prevline =~ '[{([][^})\]]\+$'
|
||||
echom "return 1"
|
||||
return match(prevline, '[{([]')
|
||||
endif
|
||||
|
||||
if prevline =~ '\<let\>\s\+.\+\(\<in\>\)\?\s*$'
|
||||
let s = match(prevline, '\<let\>\s\+\zs\S')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return s
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<let\>\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return s + g:purescript_indent_let
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<let\>\s\+.\+\(\<in\>\)\?\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
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
|
||||
let s = searchpairpos('\%(--.\{-}\)\@<!\<if\>', '\<then\>', '\<else\>.*\zs$', 'bnrc')[0]
|
||||
if s > 0
|
||||
" this rule ensures that using `=` in visual mode will correctly indent
|
||||
" `if then else`, but it does not handle lines after `then` and `else`
|
||||
if line =~ '\<\%(then\|else\)\>'
|
||||
return match(getline(s), '\<if\>') + &l:shiftwidth
|
||||
endif
|
||||
endif
|
||||
|
||||
if prevline =~ '\(\<where\>\|\<do\>\|=\|[{([]\)\s*$'
|
||||
return match(prevline, '\S') + &shiftwidth
|
||||
let p = match(prevline, '\<if\>\%(.\{-}\<then\>.\{-}\<else\>\)\@!')
|
||||
if p > 0
|
||||
return p + &l:shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '\<where\>\s\+\S\+.*$'
|
||||
return match(prevline, '\<where\>') + g:purescript_indent_where
|
||||
let s = match(prevline, '=\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '\S') + &l:shiftwidth
|
||||
endif
|
||||
|
||||
if prevline =~ '\<do\>\s\+\S\+.*$'
|
||||
return match(prevline, '\<do\>') + g:purescript_indent_do
|
||||
let s = match(prevline, '[{([]\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '\S') + (line !~ '^\s*[})]]' ? 0 : &l:shiftwidth)
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\<data\>\s\+[^=]\+\s\+=\s\+\S\+.*$'
|
||||
if prevline =~ '^class'
|
||||
return &l:shiftwidth
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<where\>\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '\S') + g:purescript_indent_where
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<where\>\s\+\zs\S\+.*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return s
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<do\>\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '\S') + g:purescript_indent_do
|
||||
endif
|
||||
|
||||
let s = match(prevline, '\<do\>\s\+\zs\S\+.*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return s
|
||||
endif
|
||||
|
||||
let s = match(prevline, '^\s*\<data\>\s\+[^=]\+\s\+=\s\+\S\+.*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '=')
|
||||
endif
|
||||
|
||||
if prevline =~ '\<case\>\s\+.\+\<of\>\s*$'
|
||||
let s = match(prevline, '\<case\>\s\+.\+\<of\>\s*$')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '\<case\>') + g:purescript_indent_case
|
||||
endif
|
||||
|
||||
if prevline =~ '^\s*\<\data\>\s\+\S\+\s*$'
|
||||
return match(prevline, '\<data\>') + &shiftwidth
|
||||
return match(prevline, '\<data\>') + &l:shiftwidth
|
||||
endif
|
||||
|
||||
if (line =~ '^\s*}\s*' && prevline !~ '^\s*;')
|
||||
return match(prevline, '\S') - &shiftwidth
|
||||
let s = match(prevline, '^\s*[}\]]')
|
||||
if s >= 0 && index(s:GetSynStack(v:lnum - 1, s), 'purescriptString') == -1
|
||||
return match(prevline, '\S') - &l:shiftwidth
|
||||
endif
|
||||
|
||||
return match(prevline, '\S')
|
||||
|
||||
@@ -1,217 +1,433 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'python') == -1
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'python-ident') == -1
|
||||
|
||||
" PEP8 compatible Python indent file
|
||||
" Language: Python
|
||||
" Maintainer: Daniel Hahler <https://daniel.hahler.de/>
|
||||
" Prev Maintainer: Hynek Schlawack <hs@ox.cx>
|
||||
" Prev Maintainer: Eric Mc Sween <em@tomcom.de> (address invalid)
|
||||
" Original Author: David Bustos <bustos@caltech.edu> (address invalid)
|
||||
" License: CC0
|
||||
"
|
||||
" vim-python-pep8-indent - A nicer Python indentation style for vim.
|
||||
" Written in 2004 by David Bustos <bustos@caltech.edu>
|
||||
" Maintained from 2004-2005 by Eric Mc Sween <em@tomcom.de>
|
||||
" Maintained from 2013 by Hynek Schlawack <hs@ox.cx>
|
||||
" Maintained from 2017 by Daniel Hahler <https://daniel.hahler.de/>
|
||||
"
|
||||
" To the extent possible under law, the author(s) have dedicated all copyright
|
||||
" and related and neighboring rights to this software to the public domain
|
||||
" worldwide. This software is distributed without any warranty.
|
||||
" You should have received a copy of the CC0 Public Domain Dedication along
|
||||
" with this software. If not, see
|
||||
" <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal expandtab
|
||||
setlocal nolisp
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetPythonPEPIndent(v:lnum)
|
||||
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except
|
||||
|
||||
let s:maxoff = 50
|
||||
if !exists('g:python_pep8_indent_multiline_string')
|
||||
let g:python_pep8_indent_multiline_string = 0
|
||||
endif
|
||||
|
||||
let s:block_rules = {
|
||||
\ '^\s*elif\>': ['if', 'elif'],
|
||||
\ '^\s*except\>': ['try', 'except'],
|
||||
\ '^\s*finally\>': ['try', 'except', 'else']
|
||||
\ }
|
||||
let s:block_rules_multiple = {
|
||||
\ '^\s*else\>': ['if', 'elif', 'for', 'try', 'except'],
|
||||
\ }
|
||||
" Pairs to look for when searching for opening parenthesis.
|
||||
" The value is the maximum offset in lines.
|
||||
let s:paren_pairs = {'()': 50, '[]': 100, '{}': 1000}
|
||||
|
||||
if &filetype ==# 'pyrex' || &filetype ==# 'cython'
|
||||
let b:control_statement = '\v^\s*(class|def|if|while|with|for|except|cdef|cpdef)>'
|
||||
else
|
||||
let b:control_statement = '\v^\s*(class|def|if|while|with|for|except)>'
|
||||
endif
|
||||
let s:stop_statement = '^\s*\(break\|continue\|raise\|return\|pass\)\>'
|
||||
|
||||
" Skip strings and comments. Return 1 for chars to skip.
|
||||
" jedi* refers to syntax definitions from jedi-vim for call signatures, which
|
||||
" are inserted temporarily into the buffer.
|
||||
let s:skip_special_chars = 'synIDattr(synID(line("."), col("."), 0), "name") ' .
|
||||
\ '=~? "\\vstring|comment|jedi\\S"'
|
||||
|
||||
let s:skip_after_opening_paren = 'synIDattr(synID(line("."), col("."), 0), "name") ' .
|
||||
\ '=~? "\\vcomment|jedi\\S"'
|
||||
|
||||
" Also ignore anything concealed.
|
||||
" Wrapper around synconcealed for older Vim (7.3.429, used on Travis CI).
|
||||
function! s:is_concealed(line, col)
|
||||
let concealed = synconcealed(a:line, a:col)
|
||||
return len(concealed) && concealed[0]
|
||||
endfunction
|
||||
if has('conceal')
|
||||
let s:skip_special_chars .= '|| s:is_concealed(line("."), col("."))'
|
||||
endif
|
||||
|
||||
|
||||
let s:skip_search = 'synIDattr(synID(line("."), col("."), 0), "name") ' .
|
||||
\ '=~? "comment"'
|
||||
|
||||
" Use 'shiftwidth()' instead of '&sw'.
|
||||
" (Since Vim patch 7.3.629, 'shiftwidth' can be set to 0 to follow 'tabstop').
|
||||
if exists('*shiftwidth')
|
||||
function! s:sw()
|
||||
return shiftwidth()
|
||||
endfunction
|
||||
else
|
||||
function! s:sw()
|
||||
return &shiftwidth
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:pair_sort(x, y)
|
||||
if a:x[0] == a:y[0]
|
||||
return a:x[1] == a:y[1] ? 0 : a:x[1] > a:y[1] ? 1 : -1
|
||||
else
|
||||
return a:x[0] > a:y[0] ? 1 : -1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Find backwards the closest open parenthesis/bracket/brace.
|
||||
function! s:SearchParensPair()
|
||||
let line = line('.')
|
||||
let col = col('.')
|
||||
function! s:find_opening_paren(...)
|
||||
" optional arguments: line and column (defaults to 1) to search around
|
||||
if a:0 > 0
|
||||
let view = winsaveview()
|
||||
call cursor(a:1, a:0 > 1 ? a:2 : 1)
|
||||
let ret = s:find_opening_paren()
|
||||
call winrestview(view)
|
||||
return ret
|
||||
endif
|
||||
|
||||
" Skip strings and comments and don't look too far
|
||||
let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" .
|
||||
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
|
||||
\ '"string\\|comment"'
|
||||
" Return if cursor is in a comment.
|
||||
exe 'if' s:skip_search '| return [0, 0] | endif'
|
||||
|
||||
" Search for parentheses
|
||||
call cursor(line, col)
|
||||
let parlnum = searchpair('(', '', ')', 'bW', skip)
|
||||
let parcol = col('.')
|
||||
|
||||
" Search for brackets
|
||||
call cursor(line, col)
|
||||
let par2lnum = searchpair('\[', '', '\]', 'bW', skip)
|
||||
let par2col = col('.')
|
||||
|
||||
" Search for braces
|
||||
call cursor(line, col)
|
||||
let par3lnum = searchpair('{', '', '}', 'bW', skip)
|
||||
let par3col = col('.')
|
||||
|
||||
" Get the closest match
|
||||
if par2lnum > parlnum || (par2lnum == parlnum && par2col > parcol)
|
||||
let parlnum = par2lnum
|
||||
let parcol = par2col
|
||||
endif
|
||||
if par3lnum > parlnum || (par3lnum == parlnum && par3col > parcol)
|
||||
let parlnum = par3lnum
|
||||
let parcol = par3col
|
||||
endif
|
||||
|
||||
" Put the cursor on the match
|
||||
if parlnum > 0
|
||||
call cursor(parlnum, parcol)
|
||||
endif
|
||||
return parlnum
|
||||
let nearest = [0, 0]
|
||||
for [p, maxoff] in items(s:paren_pairs)
|
||||
let stopline = max([0, line('.') - maxoff, nearest[0]])
|
||||
let next = searchpairpos(
|
||||
\ '\V'.p[0], '', '\V'.p[1], 'bnW', s:skip_special_chars, stopline)
|
||||
if next[0] && (next[0] > nearest[0] || (next[0] == nearest[0] && next[1] > nearest[1]))
|
||||
let nearest = next
|
||||
endif
|
||||
endfor
|
||||
return nearest
|
||||
endfunction
|
||||
|
||||
" Find the start of a multi-line statement
|
||||
function! s:StatementStart(lnum)
|
||||
let lnum = a:lnum
|
||||
while 1
|
||||
if getline(lnum - 1) =~ '\\$'
|
||||
let lnum = lnum - 1
|
||||
else
|
||||
call cursor(lnum, 1)
|
||||
let maybe_lnum = s:SearchParensPair()
|
||||
if maybe_lnum < 1
|
||||
return lnum
|
||||
else
|
||||
let lnum = maybe_lnum
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
function! s:find_start_of_multiline_statement(lnum)
|
||||
let lnum = a:lnum
|
||||
while lnum > 0
|
||||
if getline(lnum - 1) =~# '\\$'
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
else
|
||||
let [paren_lnum, _] = s:find_opening_paren(lnum)
|
||||
if paren_lnum < 1
|
||||
return lnum
|
||||
else
|
||||
let lnum = paren_lnum
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
" Find the block starter that matches the current line
|
||||
function! s:BlockStarter(lnum, block_start_re)
|
||||
let lnum = a:lnum
|
||||
let maxindent = 10000 " whatever
|
||||
while lnum > 1
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
if indent(lnum) < maxindent
|
||||
if getline(lnum) =~ a:block_start_re
|
||||
return lnum
|
||||
else
|
||||
let maxindent = indent(lnum)
|
||||
" It's not worth going further if we reached the top level
|
||||
if maxindent == 0
|
||||
return -1
|
||||
" Find possible indent(s) of the block starter that matches the current line.
|
||||
function! s:find_start_of_block(lnum, types, multiple)
|
||||
let r = []
|
||||
let types = copy(a:types)
|
||||
let re = '\V\^\s\*\('.join(a:types, '\|').'\)\>'
|
||||
let lnum = a:lnum
|
||||
let last_indent = indent(lnum) + 1
|
||||
while lnum > 0 && last_indent > 0
|
||||
let indent = indent(lnum)
|
||||
if indent < last_indent
|
||||
for type in types
|
||||
let re = '\v^\s*'.type.'>'
|
||||
if getline(lnum) =~# re
|
||||
if !a:multiple
|
||||
return [indent]
|
||||
endif
|
||||
if index(r, indent) == -1
|
||||
let r += [indent]
|
||||
endif
|
||||
" Remove any handled type, e.g. 'if'.
|
||||
call remove(types, index(types, type))
|
||||
endif
|
||||
endfor
|
||||
let last_indent = indent(lnum)
|
||||
endif
|
||||
endif
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
endwhile
|
||||
return r
|
||||
endfunction
|
||||
|
||||
" Is "expr" true for every position in "lnum", beginning at "start"?
|
||||
" (optionally up to a:1 / 4th argument)
|
||||
function! s:match_expr_on_line(expr, lnum, start, ...)
|
||||
let text = getline(a:lnum)
|
||||
let end = a:0 ? a:1 : len(text)
|
||||
if a:start > end
|
||||
return 1
|
||||
endif
|
||||
endwhile
|
||||
return -1
|
||||
let save_pos = getpos('.')
|
||||
let r = 1
|
||||
for i in range(a:start, end)
|
||||
call cursor(a:lnum, i)
|
||||
if !(eval(a:expr) || text[i-1] =~# '\s')
|
||||
let r = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
call setpos('.', save_pos)
|
||||
return r
|
||||
endfunction
|
||||
|
||||
" Line up with open parenthesis/bracket/brace.
|
||||
function! s:indent_like_opening_paren(lnum)
|
||||
let [paren_lnum, paren_col] = s:find_opening_paren(a:lnum)
|
||||
if paren_lnum <= 0
|
||||
return -2
|
||||
endif
|
||||
let text = getline(paren_lnum)
|
||||
let base = indent(paren_lnum)
|
||||
|
||||
let nothing_after_opening_paren = s:match_expr_on_line(
|
||||
\ s:skip_after_opening_paren, paren_lnum, paren_col+1)
|
||||
let starts_with_closing_paren = getline(a:lnum) =~# '^\s*[])}]'
|
||||
|
||||
if nothing_after_opening_paren
|
||||
if starts_with_closing_paren
|
||||
let res = base
|
||||
else
|
||||
let res = base + s:sw()
|
||||
endif
|
||||
else
|
||||
" Indent to match position of opening paren.
|
||||
let res = paren_col
|
||||
endif
|
||||
|
||||
" If this line is the continuation of a control statement
|
||||
" indent further to distinguish the continuation line
|
||||
" from the next logical line.
|
||||
if text =~# b:control_statement && res == base + s:sw()
|
||||
return base + s:sw() * 2
|
||||
else
|
||||
return res
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Match indent of first block of this type.
|
||||
function! s:indent_like_block(lnum)
|
||||
let text = getline(a:lnum)
|
||||
for [multiple, block_rules] in [
|
||||
\ [0, s:block_rules],
|
||||
\ [1, s:block_rules_multiple]]
|
||||
for [line_re, blocks] in items(block_rules)
|
||||
if text !~# line_re
|
||||
continue
|
||||
endif
|
||||
|
||||
let indents = s:find_start_of_block(a:lnum - 1, blocks, multiple)
|
||||
if !len(indents)
|
||||
return -1
|
||||
endif
|
||||
if len(indents) == 1
|
||||
return indents[0]
|
||||
endif
|
||||
|
||||
" Multiple valid indents, e.g. for 'else' with both try and if.
|
||||
let indent = indent(a:lnum)
|
||||
if index(indents, indent) != -1
|
||||
" The indent is valid, keep it.
|
||||
return indent
|
||||
endif
|
||||
" Fallback to the first/nearest one.
|
||||
return indents[0]
|
||||
endfor
|
||||
endfor
|
||||
return -2
|
||||
endfunction
|
||||
|
||||
function! s:indent_like_previous_line(lnum)
|
||||
let lnum = prevnonblank(a:lnum - 1)
|
||||
|
||||
" No previous line, keep current indent.
|
||||
if lnum < 1
|
||||
return -1
|
||||
endif
|
||||
|
||||
let text = getline(lnum)
|
||||
let start = s:find_start_of_multiline_statement(lnum)
|
||||
let base = indent(start)
|
||||
let current = indent(a:lnum)
|
||||
|
||||
" Jump to last character in previous line.
|
||||
call cursor(lnum, len(text))
|
||||
let ignore_last_char = eval(s:skip_special_chars)
|
||||
|
||||
" Search for final colon that is not inside something to be ignored.
|
||||
while 1
|
||||
let curpos = getpos('.')[2]
|
||||
if curpos == 1 | break | endif
|
||||
if eval(s:skip_special_chars) || text[curpos-1] =~# '\s'
|
||||
normal! h
|
||||
continue
|
||||
elseif text[curpos-1] ==# ':'
|
||||
return base + s:sw()
|
||||
endif
|
||||
break
|
||||
endwhile
|
||||
|
||||
if text =~# '\\$' && !ignore_last_char
|
||||
" If this line is the continuation of a control statement
|
||||
" indent further to distinguish the continuation line
|
||||
" from the next logical line.
|
||||
if getline(start) =~# b:control_statement
|
||||
return base + s:sw() * 2
|
||||
endif
|
||||
|
||||
" Nest (other) explicit continuations only one level deeper.
|
||||
return base + s:sw()
|
||||
endif
|
||||
|
||||
let empty = getline(a:lnum) =~# '^\s*$'
|
||||
|
||||
" Current and prev line are empty, next is not -> indent like next.
|
||||
if empty && a:lnum > 1 &&
|
||||
\ (getline(a:lnum - 1) =~# '^\s*$') &&
|
||||
\ !(getline(a:lnum + 1) =~# '^\s*$')
|
||||
return indent(a:lnum + 1)
|
||||
endif
|
||||
|
||||
" If the previous statement was a stop-execution statement or a pass
|
||||
if getline(start) =~# s:stop_statement
|
||||
" Remove one level of indentation if the user hasn't already dedented
|
||||
if empty || current > base - s:sw()
|
||||
return base - s:sw()
|
||||
endif
|
||||
" Otherwise, trust the user
|
||||
return -1
|
||||
endif
|
||||
|
||||
if !empty && s:is_dedented_already(current, base)
|
||||
return -1
|
||||
endif
|
||||
|
||||
" In all other cases, line up with the start of the previous statement.
|
||||
return base
|
||||
endfunction
|
||||
|
||||
" If this line is dedented and the number of indent spaces is valid
|
||||
" (multiple of the indentation size), trust the user.
|
||||
function! s:is_dedented_already(current, base)
|
||||
let dedent_size = a:current - a:base
|
||||
return (dedent_size < 0 && a:current % s:sw() == 0) ? 1 : 0
|
||||
endfunction
|
||||
|
||||
" Is the syntax at lnum (and optionally cnum) a python string?
|
||||
function! s:is_python_string(lnum, ...)
|
||||
let line = getline(a:lnum)
|
||||
let linelen = len(line)
|
||||
if linelen < 1
|
||||
let linelen = 1
|
||||
endif
|
||||
let cols = a:0 ? type(a:1) != type([]) ? [a:1] : a:1 : range(1, linelen)
|
||||
for cnum in cols
|
||||
if match(map(synstack(a:lnum, cnum),
|
||||
\ "synIDattr(v:val, 'name')"), 'python\S*String') == -1
|
||||
return 0
|
||||
end
|
||||
endfor
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! GetPythonPEPIndent(lnum)
|
||||
let scol = col('.')
|
||||
|
||||
" First line has indent 0
|
||||
if a:lnum == 1
|
||||
return 0
|
||||
endif
|
||||
|
||||
" If we can find an open parenthesis/bracket/brace, line up with it.
|
||||
call cursor(a:lnum, 1)
|
||||
let parlnum = s:SearchParensPair()
|
||||
if parlnum > 0
|
||||
let parcol = col('.')
|
||||
let matches = matchlist(getline(a:lnum), '^\(\s*\)[])}]')
|
||||
if len(matches) == 0
|
||||
let closing_paren = 0
|
||||
let closing_paren_pos = 0
|
||||
else
|
||||
let closing_paren = 1
|
||||
let closing_paren_pos = len(matches[1])
|
||||
" First line has indent 0
|
||||
if a:lnum == 1
|
||||
return 0
|
||||
endif
|
||||
if match(getline(parlnum), '[([{]\s*$', parcol - 1) != -1
|
||||
if closing_paren
|
||||
return indent(parlnum)
|
||||
else
|
||||
return indent(parlnum) + &shiftwidth
|
||||
endif
|
||||
elseif a:lnum - 1 != parlnum
|
||||
if closing_paren && closing_paren_pos > scol
|
||||
return indent(parlnum)
|
||||
else
|
||||
let lastindent = match(getline(a:lnum - 1), '\S')
|
||||
if lastindent != -1 && lastindent < parcol
|
||||
return lastindent
|
||||
|
||||
let line = getline(a:lnum)
|
||||
let prevline = getline(a:lnum-1)
|
||||
|
||||
" Multilinestrings: continous, docstring or starting.
|
||||
if s:is_python_string(a:lnum-1, len(prevline))
|
||||
\ && (s:is_python_string(a:lnum, 1)
|
||||
\ || match(line, '^\%("""\|''''''\)') != -1)
|
||||
|
||||
" Indent closing quotes as the line with the opening ones.
|
||||
let match_quotes = match(line, '^\s*\zs\%("""\|''''''\)')
|
||||
if match_quotes != -1
|
||||
" closing multiline string
|
||||
let quotes = line[match_quotes:(match_quotes+2)]
|
||||
let pairpos = searchpairpos(quotes, '', quotes, 'b')
|
||||
if pairpos[0] != 0
|
||||
return indent(pairpos[0])
|
||||
else
|
||||
" TODO: test to cover this!
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:is_python_string(a:lnum-1)
|
||||
" Previous line is (completely) a string.
|
||||
return indent(a:lnum-1)
|
||||
endif
|
||||
|
||||
if match(prevline, '^\s*\%("""\|''''''\)') != -1
|
||||
" docstring.
|
||||
return indent(a:lnum-1)
|
||||
endif
|
||||
|
||||
let indent_multi = get(b:, 'python_pep8_indent_multiline_string',
|
||||
\ get(g:, 'python_pep8_indent_multiline_string', 0))
|
||||
if match(prevline, '\v%("""|'''''')$') != -1
|
||||
" Opening multiline string, started in previous line.
|
||||
if (&autoindent && indent(a:lnum) == indent(a:lnum-1))
|
||||
\ || match(line, '\v^\s+$') != -1
|
||||
" <CR> with empty line or to split up 'foo("""bar' into
|
||||
" 'foo("""' and 'bar'.
|
||||
if indent_multi == -2
|
||||
return indent(a:lnum-1) + s:sw()
|
||||
endif
|
||||
return indent_multi
|
||||
endif
|
||||
endif
|
||||
|
||||
" Keep existing indent.
|
||||
if match(line, '\v^\s*\S') != -1
|
||||
return -1
|
||||
endif
|
||||
|
||||
if indent_multi != -2
|
||||
return indent_multi
|
||||
endif
|
||||
|
||||
return s:indent_like_opening_paren(a:lnum)
|
||||
endif
|
||||
|
||||
" If we line up with an opening column there is a special case
|
||||
" we want to handle: a docstring as argument. In that case we
|
||||
" don't want to line up with the paren but with the statement
|
||||
" imagine foo(doc=""" as example
|
||||
echo getline(parlnum)
|
||||
if match(getline(parlnum), '\("""\|' . "'''" . '\)\s*$') != -1
|
||||
return indent(parlnum)
|
||||
" Parens: If we can find an open parenthesis/bracket/brace, line up with it.
|
||||
let indent = s:indent_like_opening_paren(a:lnum)
|
||||
if indent >= -1
|
||||
return indent
|
||||
endif
|
||||
|
||||
return parcol
|
||||
endif
|
||||
|
||||
" Examine this line
|
||||
let thisline = getline(a:lnum)
|
||||
let thisindent = indent(a:lnum)
|
||||
|
||||
" If the line starts with 'elif' or 'else', line up with 'if' or 'elif'
|
||||
if thisline =~ '^\s*\(elif\|else\)\>'
|
||||
let bslnum = s:BlockStarter(a:lnum, '^\s*\(if\|elif\)\>')
|
||||
if bslnum > 0
|
||||
return indent(bslnum)
|
||||
else
|
||||
return -1
|
||||
" Blocks: Match indent of first block of this type.
|
||||
let indent = s:indent_like_block(a:lnum)
|
||||
if indent >= -1
|
||||
return indent
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the line starts with 'except' or 'finally', line up with 'try'
|
||||
" or 'except'
|
||||
if thisline =~ '^\s*\(except\|finally\)\>'
|
||||
let bslnum = s:BlockStarter(a:lnum, '^\s*\(try\|except\)\>')
|
||||
if bslnum > 0
|
||||
return indent(bslnum)
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
|
||||
" Examine previous line
|
||||
let plnum = a:lnum - 1
|
||||
let pline = getline(plnum)
|
||||
let sslnum = s:StatementStart(plnum)
|
||||
|
||||
" If the previous line is blank, keep the same indentation
|
||||
if pline =~ '^\s*$'
|
||||
return -1
|
||||
endif
|
||||
|
||||
" If this line is explicitly joined, try to find an indentation that looks
|
||||
" good.
|
||||
if pline =~ '\\$'
|
||||
let compound_statement = '^\s*\(if\|while\|from\|import\|for\s.*\sin\|except\)\s*'
|
||||
let maybe_indent = matchend(getline(sslnum), compound_statement)
|
||||
if maybe_indent != -1
|
||||
return maybe_indent
|
||||
else
|
||||
return indent(sslnum) + &sw * 2
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the previous line ended with a colon and is not a comment, indent
|
||||
" relative to statement start.
|
||||
if pline =~ '^[^#]*:\s*\(#.*\)\?$'
|
||||
return indent(sslnum) + &sw
|
||||
endif
|
||||
|
||||
" If the previous line was a stop-execution statement or a pass
|
||||
if getline(sslnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>'
|
||||
" See if the user has already dedented
|
||||
if indent(a:lnum) > indent(sslnum) - &sw
|
||||
" If not, recommend one dedent
|
||||
return indent(sslnum) - &sw
|
||||
endif
|
||||
" Otherwise, trust the user
|
||||
return -1
|
||||
endif
|
||||
|
||||
" In all other cases, line up with the start of the previous statement.
|
||||
return indent(sslnum)
|
||||
return s:indent_like_previous_line(a:lnum)
|
||||
endfunction
|
||||
|
||||
endif
|
||||
|
||||
@@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'qml') == -1
|
||||
" Language: QML
|
||||
" Author: Robert Kieffer
|
||||
" URL:
|
||||
" Last Change: 2010-03-27 (Happy Birthday, Dash!)
|
||||
" Last Change: 2017-10-27
|
||||
"
|
||||
" Improved JavaScript indent script.
|
||||
|
||||
@@ -22,10 +22,10 @@ if exists("*GetJsIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Clean up a line of code by removing trailing '//' comments, and trimming
|
||||
" Clean up a line of code by removing trailing '//' and '/* */' comments, and trimming
|
||||
" whitespace
|
||||
function! Trim(line)
|
||||
return substitute(substitute(a:line, '// .*', '', ''), '^\s*\|\s*$', '', 'g')
|
||||
return substitute(substitute(substitute(a:line, '// .*', '', ''), '/\* .* \*/', '', ''), '^\s*\|\s*$', '', 'g')
|
||||
endfunction
|
||||
|
||||
function! GetJsIndent()
|
||||
|
||||
@@ -3,11 +3,12 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'rust') == -1
|
||||
" Vim indent file
|
||||
" Language: Rust
|
||||
" Author: Chris Morgan <me@chrismorgan.info>
|
||||
" Last Change: 2016 Jul 15
|
||||
" Last Change: 2017 Mar 21
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
@@ -15,7 +16,7 @@ setlocal cindent
|
||||
setlocal cinoptions=L0,(0,Ws,J1,j1
|
||||
setlocal cinkeys=0{,0},!^F,o,O,0[,0]
|
||||
" Don't think cinwords will actually do anything at all... never mind
|
||||
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
|
||||
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern,macro
|
||||
|
||||
" Some preliminary settings
|
||||
setlocal nolisp " Make sure lisp indenting doesn't supersede us
|
||||
@@ -27,9 +28,12 @@ setlocal indentexpr=GetRustIndent(v:lnum)
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetRustIndent")
|
||||
finish
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Come here when loading the script the first time.
|
||||
|
||||
function! s:get_line_trimmed(lnum)
|
||||
@@ -207,4 +211,7 @@ function GetRustIndent(lnum)
|
||||
return cindent(a:lnum)
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
endif
|
||||
|
||||
79
indent/slime.vim
Normal file
79
indent/slime.vim
Normal file
@@ -0,0 +1,79 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'slime') == -1
|
||||
|
||||
" Vim indent file
|
||||
" Language: Slime
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
runtime! indent/ruby.vim
|
||||
unlet! b:did_indent
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal autoindent sw=2 et
|
||||
setlocal indentexpr=GetSlimeIndent()
|
||||
setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetSlimeIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)'
|
||||
let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*'
|
||||
|
||||
if !exists('g:haml_self_closing_tags')
|
||||
let g:haml_self_closing_tags = 'meta|link|img|hr|br'
|
||||
endif
|
||||
|
||||
function! GetSlimeIndent()
|
||||
let lnum = prevnonblank(v:lnum-1)
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
let line = substitute(getline(lnum),'\s\+$','','')
|
||||
let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
|
||||
let lastcol = strlen(line)
|
||||
let line = substitute(line,'^\s\+','','')
|
||||
let indent = indent(lnum)
|
||||
let cindent = indent(v:lnum)
|
||||
if cline =~# '\v^-\s*%(elsif|else|when)>'
|
||||
let indent = cindent < indent ? cindent : indent - &sw
|
||||
endif
|
||||
let increase = indent + &sw
|
||||
if indent == indent(lnum)
|
||||
let indent = cindent <= indent ? -1 : increase
|
||||
endif
|
||||
|
||||
let group = synIDattr(synID(lnum,lastcol,1),'name')
|
||||
|
||||
if line =~ '^doctype'
|
||||
return indent
|
||||
elseif line =~ '^/\%(\[[^]]*\]\)\=$'
|
||||
return increase
|
||||
elseif line =~ '^[\.#]'
|
||||
return increase
|
||||
elseif line =~? '^div'
|
||||
return increase
|
||||
elseif group == 'hamlFilter'
|
||||
return increase
|
||||
elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)'
|
||||
return increase
|
||||
elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$'
|
||||
return increase
|
||||
elseif line == '-#'
|
||||
return increase
|
||||
elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^\v('.g:haml_self_closing_tags.')>'
|
||||
return indent
|
||||
elseif group =~? '\v^(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$'
|
||||
return increase
|
||||
elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter'
|
||||
return GetRubyIndent()
|
||||
else
|
||||
return indent
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim:set sw=2:
|
||||
|
||||
endif
|
||||
@@ -51,7 +51,7 @@ endfunction
|
||||
|
||||
function! s:IsCommentLine(lnum)
|
||||
return synIDattr(synID(a:lnum,
|
||||
\ match(getline(a:lnum), "\S") + 1, 0), "name")
|
||||
\ match(getline(a:lnum), "\\S") + 1, 0), "name")
|
||||
\ ==# "swiftComment"
|
||||
endfunction
|
||||
|
||||
@@ -227,8 +227,8 @@ function! SwiftIndent(...)
|
||||
if numOpenParens > 0
|
||||
let savePosition = getcurpos()
|
||||
" 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 cursor(previousNum, [previousNum, col("$")])
|
||||
let previousParen = searchpair("(", "", ")", "cbWn", "s:IsExcludedFromIndent()")
|
||||
call setpos(".", savePosition)
|
||||
return indent(previousParen) + shiftwidth()
|
||||
endif
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1
|
||||
|
||||
" Only load this file if no other indent file was loaded
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal nolisp
|
||||
setlocal autoindent
|
||||
setlocal autoindent sw=2 ts=2
|
||||
setlocal indentexpr=TerraformIndent(v:lnum)
|
||||
setlocal indentkeys+=<:>,0=},0=)
|
||||
|
||||
@@ -16,29 +16,30 @@ if exists("*TerraformIndent")
|
||||
endif
|
||||
|
||||
function! TerraformIndent(lnum)
|
||||
" previous non-blank line
|
||||
let prevlnum = prevnonblank(a:lnum-1)
|
||||
|
||||
" beginning of file?
|
||||
if prevlnum == 0
|
||||
" Beginning of the file should have no indent
|
||||
if a:lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
" previous line without comments
|
||||
" Previous non-blank line should continue the indent level
|
||||
let prevlnum = prevnonblank(a:lnum-1)
|
||||
|
||||
" Previous line without comments should continue the indent level
|
||||
let prevline = substitute(getline(prevlnum), '//.*$', '', '')
|
||||
let previndent = indent(prevlnum)
|
||||
let thisindent = previndent
|
||||
|
||||
" block open?
|
||||
if prevline =~ '[\[{]\s*$'
|
||||
" Config block starting with [ { ( should increase the indent level
|
||||
if prevline =~ '[\[{\(]\s*$'
|
||||
let thisindent += &sw
|
||||
endif
|
||||
|
||||
" current line without comments
|
||||
" Current line without comments should continue the indent level
|
||||
let thisline = substitute(getline(a:lnum), '//.*$', '', '')
|
||||
|
||||
" block close?
|
||||
if thisline =~ '^\s*[\]}]'
|
||||
" Config block ending with ) } ] should get the indentation
|
||||
" level from the initial config block
|
||||
if thisline =~ '^\s*[\)}\]]'
|
||||
let thisindent -= &sw
|
||||
endif
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ let s:languages = [
|
||||
\ { 'name': 'javascript', 'pairs': ['<script', '</script>'] },
|
||||
\ ]
|
||||
|
||||
for language in s:languages
|
||||
for s:language in s:languages
|
||||
" Set 'indentexpr' if the user has an indent file installed for the language
|
||||
if strlen(globpath(&rtp, 'indent/'. language.name .'.vim'))
|
||||
let language.indentexpr = s:get_indentexpr(language.name)
|
||||
if strlen(globpath(&rtp, 'indent/'. s:language.name .'.vim'))
|
||||
let s:language.indentexpr = s:get_indentexpr(s:language.name)
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
||||
27
syntax/Jenkinsfile.vim
Normal file
27
syntax/Jenkinsfile.vim
Normal file
@@ -0,0 +1,27 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jenkins') == -1
|
||||
|
||||
runtime syntax/groovy.vim
|
||||
syn keyword jenkinsfileBuiltInVariable currentBuild
|
||||
|
||||
syn keyword jenkinsfileCoreStep checkout
|
||||
syn keyword jenkinsfileCoreStep node
|
||||
syn keyword jenkinsfileCoreStep scm
|
||||
syn keyword jenkinsfileCoreStep sh
|
||||
syn keyword jenkinsfileCoreStep stage
|
||||
syn keyword jenkinsfileCoreStep step
|
||||
syn keyword jenkinsfileCoreStep tool
|
||||
|
||||
syn keyword jenkinsfilePluginStep docker
|
||||
syn keyword jenkinsfilePluginStep emailext
|
||||
syn keyword jenkinsfilePluginStep exwsAllocate
|
||||
syn keyword jenkinsfilePluginStep exws
|
||||
syn keyword jenkinsfilePluginStep httpRequest
|
||||
syn keyword jenkinsfilePluginStep junit
|
||||
|
||||
hi link jenkinsfileCoreStep Function
|
||||
hi link jenkinsfilePluginStep Include
|
||||
hi link jenkinsfileBuiltInVariable Identifier
|
||||
|
||||
let b:current_syntax = "Jenkinsfile"
|
||||
|
||||
endif
|
||||
@@ -47,6 +47,58 @@ highlight link yamlFlowString NONE
|
||||
" but it does make sense we visualize quotes easily
|
||||
highlight link yamlFlowStringDelimiter Delimiter
|
||||
|
||||
fun! s:normal_keywords_highlight(name)
|
||||
if a:name == 'Comment'
|
||||
highlight link ansible_normal_keywords Comment
|
||||
elseif a:name == 'Constant'
|
||||
highlight link ansible_normal_keywords Constant
|
||||
elseif a:name == 'Identifier'
|
||||
highlight link ansible_normal_keywords Identifier
|
||||
elseif a:name == 'Statement'
|
||||
highlight link ansible_normal_keywords Statement
|
||||
elseif a:name == 'PreProc'
|
||||
highlight link ansible_normal_keywords PreProc
|
||||
elseif a:name == 'Type'
|
||||
highlight link ansible_normal_keywords Type
|
||||
elseif a:name == 'Special'
|
||||
highlight link ansible_normal_keywords Special
|
||||
elseif a:name == 'Underlined'
|
||||
highlight link ansible_normal_keywords Underlined
|
||||
elseif a:name == 'Ignore'
|
||||
highlight link ansible_normal_keywords Ignore
|
||||
elseif a:name == 'Error'
|
||||
highlight link ansible_normal_keywords Error
|
||||
elseif a:name == 'Todo'
|
||||
highlight link ansible_normal_keywords Todo
|
||||
endif
|
||||
endfun
|
||||
|
||||
fun! s:with_keywords_highlight(name)
|
||||
if a:name == 'Comment'
|
||||
highlight link ansible_with_keywords Comment
|
||||
elseif a:name == 'Constant'
|
||||
highlight link ansible_with_keywords Constant
|
||||
elseif a:name == 'Identifier'
|
||||
highlight link ansible_with_keywords Identifier
|
||||
elseif a:name == 'Statement'
|
||||
highlight link ansible_with_keywords Statement
|
||||
elseif a:name == 'PreProc'
|
||||
highlight link ansible_with_keywords PreProc
|
||||
elseif a:name == 'Type'
|
||||
highlight link ansible_with_keywords Type
|
||||
elseif a:name == 'Special'
|
||||
highlight link ansible_with_keywords Special
|
||||
elseif a:name == 'Underlined'
|
||||
highlight link ansible_with_keywords Underlined
|
||||
elseif a:name == 'Ignore'
|
||||
highlight link ansible_with_keywords Ignore
|
||||
elseif a:name == 'Error'
|
||||
highlight link ansible_with_keywords Error
|
||||
elseif a:name == 'Todo'
|
||||
highlight link ansible_with_keywords Todo
|
||||
endif
|
||||
endfun
|
||||
|
||||
fun! s:attribute_highlight(attributes)
|
||||
if a:attributes =~ 'a'
|
||||
syn match ansible_attributes "\v\w+\=" containedin=yamlPlainScalar
|
||||
@@ -85,11 +137,19 @@ if exists("g:ansible_extra_keywords_highlight")
|
||||
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
|
||||
highlight link ansible_special_keywords Statement
|
||||
syn keyword ansible_normal_keywords include include_tasks import_tasks until retries delay when only_if become become_user block rescue always notify containedin=yamlBlockMappingKey contained
|
||||
if exists("g:ansible_normal_keywords_highlight")
|
||||
call s:normal_keywords_highlight(g:ansible_normal_keywords_highlight)
|
||||
else
|
||||
highlight link ansible_normal_keywords Statement
|
||||
endif
|
||||
|
||||
syn match ansible_with_keywords "\vwith_.+" containedin=yamlBlockMappingKey contained
|
||||
highlight link ansible_with_keywords Statement
|
||||
if exists("g:ansible_with_keywords_highlight")
|
||||
call s:with_keywords_highlight(g:ansible_with_keywords_highlight)
|
||||
else
|
||||
highlight link ansible_with_keywords Statement
|
||||
endif
|
||||
|
||||
let b:current_syntax = "ansible"
|
||||
|
||||
|
||||
127
syntax/carp.vim
Normal file
127
syntax/carp.vim
Normal file
@@ -0,0 +1,127 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'carp') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Carp
|
||||
" Maintainer: Veit Heller <veit@veitheller.de>
|
||||
" URL: http://github.com/hellerve/carp-vim.git
|
||||
" Description: Contains all of the keywords in #lang carp
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn match carpError ,[]})],
|
||||
|
||||
if version < 600
|
||||
set iskeyword=33,35-39,42-43,45-58,60-63,65-90,94,95,97-122,124,126,_
|
||||
else
|
||||
setlocal iskeyword=33,35-39,42-43,45-58,60-63,65-90,94,95,97-122,124,126,_
|
||||
endif
|
||||
|
||||
syn keyword carpSyntax def defn let do if while ref address set! the
|
||||
syn keyword carpSyntax defmacro defdynamic quote car cdr cons list array
|
||||
syn keyword carpSyntax expand deftype register system-include register-type
|
||||
syn keyword carpSyntax defmodule copy use module defalias definterface eval
|
||||
syn keyword carpSyntax expand instantiate type info help quit env build run
|
||||
syn keyword carpSyntax cat use project-set! local-include system-include
|
||||
syn keyword carpSyntax add-cflag add-lib project load reload
|
||||
|
||||
syn keyword carpFunc Int Float Double Bool String Char Array Fn Ref Long
|
||||
syn keyword carpFunc not or and + - * / = /= >= <= > < inc dec
|
||||
syn keyword carpFunc println print get-line from-string mod seed random
|
||||
syn keyword carpFunc random-between str mask delete append count duplicate
|
||||
syn keyword carpFunc cstr chars from-chars to-int from-int sin cos sqrt acos
|
||||
syn keyword carpFunc atan2 exit time srand for cond floor abs neg to-float
|
||||
syn keyword carpFunc from-float tan asin atan cosh sinh tanh exp frexp ldexp
|
||||
syn keyword carpFunc log log10 modf pow ceil clamp approx refstr foreach
|
||||
syn keyword carpFunc => ==> repeat nth replicate range raw aset aset! count
|
||||
syn keyword carpFunc push-back pop-back sort index-of element-count
|
||||
|
||||
|
||||
syn match carpSymbol ,\k+, contained
|
||||
syn match carpTodo /\v<(FIXME|NOTE|TODO|OPTIMIZE)/ containedin=carpComment,carpString
|
||||
|
||||
syn cluster carpNormal contains=carpSyntax,carpFunc,carpDelimiter
|
||||
syn cluster carpQuotedStuff contains=carpSymbol
|
||||
syn cluster carpQuotedOrNormal contains=carpDelimiter
|
||||
|
||||
syn region carpQuotedStruc start="@("rs=s+2 end=")"re=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal contained
|
||||
syn region carpQuotedStruc start="&("rs=s+2 end=")"re=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal contained
|
||||
syn region carpQuotedStruc start="("rs=s+1 end=")"re=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal contained
|
||||
syn region carpQuotedStruc start="\["rs=s+1 end="\]"re=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal contained
|
||||
|
||||
syn cluster carpQuotedStuff add=carpQuotedStruc
|
||||
|
||||
syn region carpStruc matchgroup=Delimiter start="@("rs=s+2 matchgroup=Delimiter end=")"re=e-1 contains=@carpNormal
|
||||
syn region carpStruc matchgroup=Delimiter start="&("rs=s+2 matchgroup=Delimiter end=")"re=e-1 contains=@carpNormal
|
||||
syn region carpStruc matchgroup=Delimiter start="&"rs=s+1 end=![ \t()\[\]";]!me=e-1 contains=@carpNormal
|
||||
syn region carpStruc matchgroup=Delimiter start="@"rs=s+1 end=![ \t()\[\]";]!me=e-1 contains=@carpNormal
|
||||
syn region carpStruc matchgroup=Delimiter start="("rs=s+1 matchgroup=Delimiter end=")"re=e-1 contains=@carpNormal
|
||||
syn region carpStruc matchgroup=Delimiter start="\["rs=s+1 matchgroup=Delimiter end="\]"re=e-1 contains=@carpNormal
|
||||
|
||||
syn region carpString start=/\%(\\\)\@<!"/ skip=/\\[\\"]/ end=/"/
|
||||
|
||||
syn cluster carpNormal add=carpError,carpStruc,carpString
|
||||
syn cluster carpQuotedOrNormal add=carpString
|
||||
|
||||
syn match carpNumber "\<[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?[lf]\?\>" contains=carpContainedNumberError
|
||||
syn match carpNumber "\<[-+]\?\d\+/\d\+[lf]\?\>" contains=carpContainedNumberError
|
||||
|
||||
|
||||
syn keyword carpBoolean true false
|
||||
|
||||
syn match carpChar "\<\\.\w\@!"
|
||||
|
||||
syn region carpQuoted matchgroup=Delimiter start="['`]" end=![ \t()\[\]";]!me=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal
|
||||
syn region carpQuoted matchgroup=Delimiter start="['`](" matchgroup=Delimiter end=")" contains=@carpQuotedStuff,@carpQuotedOrNormal
|
||||
|
||||
syn cluster carpNormal add=carpNumber,carpBoolean,carpChar
|
||||
syn cluster carpQuotedOrNormal add=carpNumber,carpBoolean
|
||||
|
||||
syn match carpComment /;.*$/ contains=@Spell
|
||||
|
||||
syn region carpQuoted matchgroup=Delimiter start="#['`]"rs=s+2 end=![ \t()\[\]";]!re=e-1,me=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal
|
||||
syn region carpQuoted matchgroup=Delimiter start="#['`]("rs=s+3 matchgroup=Delimiter end=")"re=e-1 contains=@carpQuotedStuff,@carpQuotedOrNormal
|
||||
|
||||
syn cluster carpNormal add=carpQuoted,carpComment
|
||||
syn cluster carpQuotedOrNormal add=carpComment
|
||||
|
||||
syn sync match matchPlace grouphere NONE "^[^ \t]"
|
||||
|
||||
if version >= 508 || !exists("carp_syntax_init")
|
||||
if version < 508
|
||||
let carp_syntax_init = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink carpSyntax Statement
|
||||
HiLink carpFunc Function
|
||||
HiLink carpCopy Function
|
||||
|
||||
HiLink carpString String
|
||||
HiLink carpChar Character
|
||||
HiLink carpBoolean Boolean
|
||||
|
||||
HiLink carpNumber Number
|
||||
HiLink carpNumberError Error
|
||||
HiLink carpContainedNumberError Error
|
||||
|
||||
HiLink carpQuoted Structure
|
||||
HiLink carpQuotedStruc Structure
|
||||
HiLink carpSymbol Structure
|
||||
HiLink carpAtom Structure
|
||||
|
||||
HiLink carpDelimiter Delimiter
|
||||
HiLink carpConstant Constant
|
||||
|
||||
HiLink carpTodo Todo
|
||||
HiLink carpComment Comment
|
||||
HiLink carpError Error
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "carp"
|
||||
|
||||
endif
|
||||
481
syntax/cmake.vim
Normal file
481
syntax/cmake.vim
Normal file
File diff suppressed because one or more lines are too long
@@ -34,7 +34,7 @@ hi def link coffeeConditional Conditional
|
||||
syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display
|
||||
hi def link coffeeException Exception
|
||||
|
||||
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|await\)\>/
|
||||
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|default\|await\)\>/
|
||||
\ display
|
||||
" The `own` keyword is only a keyword after `for`.
|
||||
syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat
|
||||
@@ -109,7 +109,7 @@ hi def link coffeeFloat Float
|
||||
|
||||
" An error for reserved keywords, taken from the RESERVED array:
|
||||
" http://coffeescript.org/documentation/docs/lexer.html#section-67
|
||||
syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|native\|implements\|interface\|package\|private\|protected\|public\|static\)\>/
|
||||
syn match coffeeReservedError /\<\%(case\|function\|var\|void\|with\|const\|let\|enum\|native\|implements\|interface\|package\|private\|protected\|public\|static\)\>/
|
||||
\ display
|
||||
hi def link coffeeReservedError Error
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'c/c++') == -1
|
||||
" Language: C++
|
||||
" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
|
||||
" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
|
||||
" Last Change: 2016 Oct 28
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
@@ -50,7 +49,7 @@ endif
|
||||
if !exists("cpp_no_cpp14")
|
||||
syn case ignore
|
||||
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
|
||||
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
|
||||
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" contains=cFloat
|
||||
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
|
||||
syn case match
|
||||
endif
|
||||
|
||||
@@ -11,17 +11,17 @@ 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')
|
||||
if exists('g:crystal_space_errors')
|
||||
if !exists('g:crystal_no_trail_space_error')
|
||||
syn match crystalSpaceError display excludenl "\s\+$"
|
||||
endif
|
||||
if !exists('crystal_no_tab_space_error')
|
||||
if !exists('g:crystal_no_tab_space_error')
|
||||
syn match crystalSpaceError display " \+\t"me=e-1
|
||||
endif
|
||||
endif
|
||||
|
||||
" Operators
|
||||
if exists('crystal_operators')
|
||||
if exists('g: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
|
||||
@@ -170,39 +170,39 @@ syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<
|
||||
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'
|
||||
if exists('g: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 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
|
||||
syn match crystalControl "\<\%(break\|in\|next\|rescue\|return\)\>[?!]\@!"
|
||||
syn match crystalOperator "\<defined?" display
|
||||
syn match crystalKeyword "\<\%(super\|previous_def\|yield\|of\|with\|uninitialized\|union\)\>[?!]\@!"
|
||||
syn match crystalBoolean "\<\%(true\|false\)\>[?!]\@!"
|
||||
syn match crystalPseudoVariable "\<\%(nil\|self\|__DIR__\|__FILE__\|__LINE__\|__END_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')
|
||||
if !exists('b:crystal_no_expensive') && !exists('g: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
|
||||
@@ -246,10 +246,10 @@ if !exists('b:crystal_no_expensive') && !exists('crystal_no_expensive')
|
||||
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
|
||||
if !exists('g:crystal_minlines')
|
||||
let g:crystal_minlines = 500
|
||||
endif
|
||||
exec 'syn sync minlines=' . crystal_minlines
|
||||
exec 'syn sync minlines=' . g:crystal_minlines
|
||||
|
||||
else
|
||||
syn match crystalControl "\<def\>[?!]\@!" nextgroup=crystalMethodDeclaration skipwhite skipnl
|
||||
@@ -271,7 +271,7 @@ syn match crystalLinkAttr "@\[" contained containedin=crystalLinkAttrRegion disp
|
||||
syn match crystalLinkAttr "]" contained containedin=crystalLinkAttrRegion display
|
||||
|
||||
" Special Methods
|
||||
if !exists('crystal_no_special_methods')
|
||||
if !exists('g:crystal_no_special_methods')
|
||||
syn keyword crystalAccess protected private
|
||||
" attr is a common variable name
|
||||
syn keyword crystalAttribute getter setter property abstract
|
||||
@@ -293,7 +293,7 @@ syn match crystalMacro "\%({%\|%}\|{{\|}}\)" nextgroup=crystalMacroRegion skipwh
|
||||
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')
|
||||
if !exists('g: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
|
||||
|
||||
@@ -307,7 +307,7 @@ syn match crystalKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)
|
||||
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*\%(extend\|fork\|include\|asm\)\>" 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
|
||||
@@ -335,7 +335,7 @@ 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')
|
||||
if !exists('g:crystal_no_identifiers')
|
||||
hi def link crystalIdentifier Identifier
|
||||
else
|
||||
hi def link crystalIdentifier NONE
|
||||
|
||||
669
syntax/css.vim
669
syntax/css.vim
@@ -1,669 +0,0 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'css') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Cascading Style Sheets
|
||||
" Previous Contributor List:
|
||||
" Claudio Fleiner <claudio@fleiner.com> (Maintainer)
|
||||
" Yeti (Add full CSS2, HTML4 support)
|
||||
" Nikolai Weibull (Add CSS2 support)
|
||||
" Maintainer: Jules Wang <w.jq0722@gmail.com>
|
||||
" URL: https://github.com/JulesWang/css.vim
|
||||
" Last Change: 2015 Aug.25
|
||||
|
||||
" 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 = 'css'
|
||||
elseif exists("b:current_syntax") && b:current_syntax == "css"
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
syn case ignore
|
||||
|
||||
" HTML4 tags
|
||||
syn keyword cssTagName abbr address area a b base
|
||||
syn keyword cssTagName bdo blockquote body br button
|
||||
syn keyword cssTagName caption cite code col colgroup dd del
|
||||
syn keyword cssTagName dfn div dl dt em fieldset form
|
||||
syn keyword cssTagName h1 h2 h3 h4 h5 h6 head hr html img i
|
||||
syn keyword cssTagName iframe input ins isindex kbd label legend li
|
||||
syn keyword cssTagName link map menu meta noscript ol optgroup
|
||||
syn keyword cssTagName option p param pre q s samp script small
|
||||
syn keyword cssTagName span strong sub sup tbody td
|
||||
syn keyword cssTagName textarea tfoot th thead title tr ul u var
|
||||
syn keyword cssTagName object svg
|
||||
syn match cssTagName /\<select\>\|\<style\>\|\<table\>/
|
||||
|
||||
" 34 HTML5 tags
|
||||
syn keyword cssTagName article aside audio bdi canvas command data
|
||||
syn keyword cssTagName datalist details dialog embed figcaption figure footer
|
||||
syn keyword cssTagName header hgroup keygen main mark menuitem meter nav
|
||||
syn keyword cssTagName output progress rt rp ruby section
|
||||
syn keyword cssTagName source summary time track video wbr
|
||||
|
||||
" Tags not supported in HTML5
|
||||
" acronym applet basefont big center dir
|
||||
" font frame frameset noframes strike tt
|
||||
|
||||
syn match cssTagName "\*"
|
||||
|
||||
" selectors
|
||||
syn match cssSelectorOp "[,>+~]"
|
||||
syn match cssSelectorOp2 "[~|^$*]\?=" contained
|
||||
syn region cssAttributeSelector matchgroup=cssSelectorOp start="\[" end="]" contains=cssUnicodeEscape,cssSelectorOp2,cssStringQ,cssStringQQ
|
||||
|
||||
" .class and #id
|
||||
syn match cssClassName "\.[A-Za-z][A-Za-z0-9_-]\+" contains=cssClassNameDot
|
||||
syn match cssClassNameDot contained '\.'
|
||||
|
||||
try
|
||||
syn match cssIdentifier "#[A-Za-z<>-<2D>_@][A-Za-z<>-<2D>0-9_@-]*"
|
||||
catch /^.*/
|
||||
syn match cssIdentifier "#[A-Za-z_@][A-Za-z0-9_@-]*"
|
||||
endtry
|
||||
|
||||
" digits and units
|
||||
syn match cssValueNumber contained "[-+]\=\d\+\(\.\d*\)\=%\=" contains=cssUnitDecorators
|
||||
syn match cssValue contained transparent "[-+]\=\d\+\(\.\d*\)\=\([a-z]\+\)\=\>" contains=cssUnitDecorators,cssValueNumber
|
||||
|
||||
syn match cssIncludeKeyword /@\(-[a-z]\+-\)\=\(media\|keyframes\|import\|charset\|namespace\|page\)/ contained
|
||||
" @media
|
||||
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 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 match cssMediaComma "," skipwhite skipnl contained
|
||||
|
||||
" Reference: http://www.w3.org/TR/css3-mediaqueries/
|
||||
syn keyword cssMediaProp contained width height orientation scan grid
|
||||
syn match cssMediaProp contained /\(\(max\|min\)-\)\=\(\(device\)-\)\=aspect-ratio/
|
||||
syn match cssMediaProp contained /\(\(max\|min\)-\)\=device-pixel-ratio/
|
||||
syn match cssMediaProp contained /\(\(max\|min\)-\)\=device-\(height\|width\)/
|
||||
syn match cssMediaProp contained /\(\(max\|min\)-\)\=\(height\|width\|resolution\|monochrome\|color\(-index\)\=\)/
|
||||
syn keyword cssMediaAttr contained portrait landscape progressive interlace
|
||||
|
||||
" @page
|
||||
" http://www.w3.org/TR/css3-page/
|
||||
syn match cssPage "@page\>[^{]*{\@=" contains=cssPagePseudo,cssIncludeKeyword nextgroup=cssPageWrap transparent 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 match cssPageMargin /@\(\(top\|left\|right\|bottom\)-\(left\|center\|right\|middle\|bottom\)\)\(-corner\)\=/ contained nextgroup=cssDefinition skipwhite skipnl
|
||||
syn keyword cssPageProp contained content size
|
||||
" http://www.w3.org/TR/CSS2/page.html#break-inside
|
||||
syn keyword cssPageProp contained orphans widows
|
||||
|
||||
" @keyframe
|
||||
" http://www.w3.org/TR/css3-animations/#keyframes
|
||||
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 match cssKeyFrameSelector /\([-+]\=\d\+\(\.\d*\)\=%\|from\|to\)\=/ contained skipwhite skipnl nextgroup=cssDefinition
|
||||
|
||||
" @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=/@charset\>/ end=/\ze;/ transparent contains=cssStringQ,cssStringQQ,cssUnicodeEscape,cssComment,cssIncludeKeyword
|
||||
syn region cssInclude start=/@namespace\>/ end=/\ze;/ transparent contains=cssStringQ,cssStringQQ,cssUnicodeEscape,cssComment,cssIncludeKeyword
|
||||
|
||||
" @font-face
|
||||
" http://www.w3.org/TR/css3-fonts/#at-font-face-rule
|
||||
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 match cssFontDescriptorProp contained "\<font-family\>"
|
||||
syn keyword cssFontDescriptorProp contained src
|
||||
syn match cssFontDescriptorProp contained "\<font-\(style\|weight\|stretch\)\>"
|
||||
syn match cssFontDescriptorProp contained "\<unicode-range\>"
|
||||
syn match cssFontDescriptorProp contained "\<font-\(variant\|feature-settings\)\>"
|
||||
|
||||
" src functions
|
||||
syn region cssFontDescriptorFunction contained matchgroup=cssFunctionName start="\<\(uri\|url\|local\|format\)\s*(" end=")" contains=cssStringQ,cssStringQQ oneline keepend
|
||||
" font-sytle and font-weight attributes
|
||||
syn keyword cssFontDescriptorAttr contained normal italic oblique bold
|
||||
" font-stretch attributes
|
||||
syn match cssFontDescriptorAttr contained "\<\(\(ultra\|extra\|semi\)-\)\=\(condensed\|expanded\)\>"
|
||||
" unicode-range attributes
|
||||
syn match cssFontDescriptorAttr contained "U+[0-9A-Fa-f?]\+"
|
||||
syn match cssFontDescriptorAttr contained "U+\x\+-\x\+"
|
||||
" font-feature-settings attributes
|
||||
syn keyword cssFontDescriptorAttr contained on off
|
||||
|
||||
|
||||
|
||||
" The 16 basic color names
|
||||
syn keyword cssColor contained aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal yellow
|
||||
|
||||
" 130 more color names
|
||||
syn keyword cssColor contained aliceblue antiquewhite aquamarine azure
|
||||
syn keyword cssColor contained beige bisque blanchedalmond blueviolet brown burlywood
|
||||
syn keyword cssColor contained cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan
|
||||
syn match cssColor contained /\<dark\(blue\|cyan\|goldenrod\|gray\|green\|grey\|khaki\)\>/
|
||||
syn match cssColor contained /\<dark\(magenta\|olivegreen\|orange\|orchid\|red\|salmon\|seagreen\)\>/
|
||||
syn match cssColor contained /\<darkslate\(blue\|gray\|grey\)\>/
|
||||
syn match cssColor contained /\<dark\(turquoise\|violet\)\>/
|
||||
syn keyword cssColor contained deeppink deepskyblue dimgray dimgrey dodgerblue firebrick
|
||||
syn keyword cssColor contained floralwhite forestgreen gainsboro ghostwhite gold
|
||||
syn keyword cssColor contained goldenrod greenyellow grey honeydew hotpink
|
||||
syn keyword cssColor contained indianred indigo ivory khaki lavender lavenderblush lawngreen
|
||||
syn keyword cssColor contained lemonchiffon limegreen linen magenta
|
||||
syn match cssColor contained /\<light\(blue\|coral\|cyan\|goldenrodyellow\|gray\|green\)\>/
|
||||
syn match cssColor contained /\<light\(grey\|pink\|salmon\|seagreen\|skyblue\|yellow\)\>/
|
||||
syn match cssColor contained /\<light\(slategray\|slategrey\|steelblue\)\>/
|
||||
syn match cssColor contained /\<medium\(aquamarine\|blue\|orchid\|purple\|seagreen\)\>/
|
||||
syn match cssColor contained /\<medium\(slateblue\|springgreen\|turquoise\|violetred\)\>/
|
||||
syn keyword cssColor contained midnightblue mintcream mistyrose moccasin navajowhite
|
||||
syn keyword cssColor contained oldlace olivedrab orange orangered orchid
|
||||
syn match cssColor contained /\<pale\(goldenrod\|green\|turquoise\|violetred\)\>/
|
||||
syn keyword cssColor contained papayawhip peachpuff peru pink plum powderblue
|
||||
syn keyword cssColor contained rosybrown royalblue rebeccapurple saddlebrown salmon
|
||||
syn keyword cssColor contained sandybrown seagreen seashell sienna skyblue slateblue
|
||||
syn keyword cssColor contained slategray slategrey snow springgreen steelblue tan
|
||||
syn keyword cssColor contained thistle tomato turquoise violet wheat
|
||||
syn keyword cssColor contained whitesmoke yellowgreen
|
||||
|
||||
" FIXME: These are actually case-insensitive too, but (a) specs recommend using
|
||||
" mixed-case (b) it's hard to highlight the word `Background' correctly in
|
||||
" all situations
|
||||
syn case match
|
||||
syn keyword cssColor contained ActiveBorder ActiveCaption AppWorkspace ButtonFace ButtonHighlight ButtonShadow ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder InactiveCaption InactiveCaptionText InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow ThreeDFace ThreeDHighlight ThreeDLightShadow ThreeDShadow Window WindowFrame WindowText Background
|
||||
syn case ignore
|
||||
|
||||
syn match cssImportant contained "!\s*important\>"
|
||||
|
||||
syn match cssColor contained "\<transparent\>"
|
||||
syn match cssColor contained "\<currentColor\>"
|
||||
syn match cssColor contained "\<white\>"
|
||||
syn match cssColor contained "#[0-9A-Fa-f]\{3\}\>" 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 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,cssValue,cssFunctionComma,cssFunction
|
||||
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,cssValue,cssFunctionComma
|
||||
syn keyword cssGradientAttr contained top bottom left right cover center middle ellipse at
|
||||
syn match cssFunctionComma contained ","
|
||||
|
||||
" Common Prop and Attr
|
||||
syn keyword cssCommonAttr contained auto none inherit all default normal
|
||||
syn keyword cssCommonAttr contained top bottom center stretch hidden visible
|
||||
"------------------------------------------------
|
||||
" CSS Animations
|
||||
" http://www.w3.org/TR/css3-animations/
|
||||
syn match cssAnimationProp contained "\<animation\(-\(delay\|direction\|duration\|fill-mode\|name\|play-state\|timing-function\|iteration-count\)\)\=\>"
|
||||
|
||||
" animation-direction attributes
|
||||
syn keyword cssAnimationAttr contained alternate reverse
|
||||
syn match cssAnimationAttr contained "\<alternate-reverse\>"
|
||||
|
||||
" animation-fill-mode attributes
|
||||
syn keyword cssAnimationAttr contained forwards backwards both
|
||||
|
||||
" animation-play-state attributes
|
||||
syn keyword cssAnimationAttr contained running paused
|
||||
|
||||
" animation-iteration-count attributes
|
||||
syn keyword cssAnimationAttr contained infinite
|
||||
"------------------------------------------------
|
||||
" CSS Backgrounds and Borders Module Level 3
|
||||
" http://www.w3.org/TR/css3-background/
|
||||
syn match cssBackgroundProp contained "\<background\(-\(attachment\|clip\|color\|image\|origin\|position\|repeat\|size\)\)\=\>"
|
||||
" background-attachment attributes
|
||||
syn keyword cssBackgroundAttr contained scroll fixed local
|
||||
|
||||
" background-position attributes
|
||||
syn keyword cssBackgroundAttr contained left center right top bottom
|
||||
|
||||
" background-repeat attributes
|
||||
syn match cssBackgroundAttr contained "\<no-repeat\>"
|
||||
syn match cssBackgroundAttr contained "\<repeat\(-[xy]\)\=\>"
|
||||
|
||||
" background-size attributes
|
||||
syn keyword cssBackgroundAttr contained cover contain
|
||||
|
||||
syn match cssBorderProp contained "\<border\(-\(top\|right\|bottom\|left\)\)\=\(-\(width\|color\|style\)\)\=\>"
|
||||
syn match cssBorderProp contained "\<border\(-\(top\|bottom\)-\(left\|right\)\)\=-radius\>"
|
||||
syn match cssBorderProp contained "\<border-image\(-\(outset\|repeat\|slice\|source\|width\)\)\=\>"
|
||||
syn match cssBorderProp contained "\<box-decoration-break\>"
|
||||
syn match cssBorderProp contained "\<box-shadow\>"
|
||||
|
||||
" border-image attributes
|
||||
syn keyword cssBorderAttr contained stretch round fill
|
||||
|
||||
" border-style attributes
|
||||
syn keyword cssBorderAttr contained dotted dashed solid double groove ridge inset outset
|
||||
|
||||
" border-width attributes
|
||||
syn keyword cssBorderAttr contained thin thick medium
|
||||
|
||||
" box-decoration-break attributes
|
||||
syn keyword cssBorderAttr contained clone slice
|
||||
"------------------------------------------------
|
||||
|
||||
syn match cssBoxProp contained "\<padding\(-\(top\|right\|bottom\|left\)\)\=\>"
|
||||
syn match cssBoxProp contained "\<margin\(-\(top\|right\|bottom\|left\)\)\=\>"
|
||||
syn match cssBoxProp contained "\<overflow\(-\(x\|y\|style\)\)\=\>"
|
||||
syn match cssBoxProp contained "\<rotation\(-point\)\=\>"
|
||||
syn keyword cssBoxAttr contained visible hidden scroll auto
|
||||
syn match cssBoxAttr contained "\<no-\(display\|content\)\>"
|
||||
|
||||
syn keyword cssColorProp contained opacity
|
||||
syn match cssColorProp contained "\<color-profile\>"
|
||||
syn match cssColorProp contained "\<rendering-intent\>"
|
||||
|
||||
|
||||
syn match cssDimensionProp contained "\<\(min\|max\)-\(width\|height\)\>"
|
||||
syn keyword cssDimensionProp contained height
|
||||
syn keyword cssDimensionProp contained width
|
||||
|
||||
" CSS Flexible Box Layout Module Level 1
|
||||
" http://www.w3.org/TR/css3-flexbox/
|
||||
" CSS Box Alignment Module Level 3
|
||||
" http://www.w3.org/TR/css-align-3/
|
||||
syn match cssFlexibleBoxProp contained "\<flex\(-\(direction\|wrap\|flow\|grow\|shrink\|basis\)\)\=\>"
|
||||
syn match cssFlexibleBoxProp contained "\<\(align\|justify\)\(-\(items\|self\|content\)\)\=\>"
|
||||
syn keyword cssFlexibleBoxProp contained order
|
||||
|
||||
syn match cssFlexibleBoxAttr contained "\<\(row\|column\|wrap\)\(-reverse\)\=\>"
|
||||
syn keyword cssFlexibleBoxAttr contained nowrap stretch baseline center
|
||||
syn match cssFlexibleBoxAttr contained "\<flex\(-\(start\|end\)\)\=\>"
|
||||
syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\)\)\=\>"
|
||||
|
||||
" CSS Fonts Module Level 3
|
||||
" http://www.w3.org/TR/css-fonts-3/
|
||||
syn match cssFontProp contained "\<font\(-\(family\|\|feature-settings\|kerning\|language-override\|size\(-adjust\)\=\|stretch\|style\|synthesis\|variant\(-\(alternates\|caps\|east-asian\|ligatures\|numeric\|position\)\)\=\|weight\)\)\=\>"
|
||||
|
||||
" font attributes
|
||||
syn keyword cssFontAttr contained icon menu caption
|
||||
syn match cssFontAttr contained "\<small-\(caps\|caption\)\>"
|
||||
syn match cssFontAttr contained "\<message-box\>"
|
||||
syn match cssFontAttr contained "\<status-bar\>"
|
||||
syn keyword cssFontAttr contained larger smaller
|
||||
syn match cssFontAttr contained "\<\(x\{1,2\}-\)\=\(large\|small\)\>"
|
||||
" font-family attributes
|
||||
syn match cssFontAttr contained "\<\(sans-\)\=serif\>"
|
||||
syn keyword cssFontAttr contained Antiqua Arial Black Book Charcoal Comic Courier Dingbats Gadget Geneva Georgia Grande Helvetica Impact Linotype Lucida MS Monaco Neue New Palatino Roboto Roman Symbol Tahoma Times Trebuchet Verdana Webdings Wingdings York Zapf
|
||||
syn keyword cssFontAttr contained cursive fantasy monospace
|
||||
" font-feature-settings attributes
|
||||
syn keyword cssFontAttr contained on off
|
||||
" font-stretch attributes
|
||||
syn match cssFontAttr contained "\<\(\(ultra\|extra\|semi\)-\)\=\(condensed\|expanded\)\>"
|
||||
" font-style attributes
|
||||
syn keyword cssFontAttr contained italic oblique
|
||||
" font-synthesis attributes
|
||||
syn keyword cssFontAttr contained weight style
|
||||
" font-weight attributes
|
||||
syn keyword cssFontAttr contained bold bolder lighter
|
||||
" TODO: font-variant-* attributes
|
||||
"------------------------------------------------
|
||||
|
||||
" Webkit specific property/attributes
|
||||
syn match cssFontProp contained "\<font-smooth\>"
|
||||
syn match cssFontAttr contained "\<\(subpixel-\)\=\antialiased\>"
|
||||
|
||||
|
||||
" CSS Multi-column Layout Module
|
||||
" http://www.w3.org/TR/css3-multicol/
|
||||
syn match cssMultiColumnProp contained "\<break-\(after\|before\|inside\)\>"
|
||||
syn match cssMultiColumnProp contained "\<column-\(count\|fill\|gap\|rule\(-\(color\|style\|width\)\)\=\|span\|width\)\>"
|
||||
syn keyword cssMultiColumnProp contained columns
|
||||
syn keyword cssMultiColumnAttr contained balance medium
|
||||
syn keyword cssMultiColumnAttr contained always left right page column
|
||||
syn match cssMultiColumnAttr contained "\<avoid\(-\(page\|column\)\)\=\>"
|
||||
|
||||
" http://www.w3.org/TR/css3-break/#page-break
|
||||
syn match cssMultiColumnProp contained "\<page\(-break-\(before\|after\|inside\)\)\=\>"
|
||||
|
||||
" http://www.w3.org/TR/SVG11/interact.html
|
||||
syn match cssInteractProp contained "\<pointer-events\>"
|
||||
syn match cssInteractAttr contained "\<\(visible\)\=\(Painted\|Fill\|Stroke\)\=\>"
|
||||
|
||||
" TODO find following items in w3c docs.
|
||||
syn keyword cssGeneratedContentProp contained quotes crop
|
||||
syn match cssGeneratedContentProp contained "\<counter-\(reset\|increment\)\>"
|
||||
syn match cssGeneratedContentProp contained "\<move-to\>"
|
||||
syn match cssGeneratedContentProp contained "\<page-policy\>"
|
||||
syn match cssGeneratedContentAttr contained "\<\(no-\)\=\(open\|close\)-quote\>"
|
||||
|
||||
syn match cssGridProp contained "\<grid-\(columns\|rows\)\>"
|
||||
|
||||
syn match cssHyerlinkProp contained "\<target\(-\(name\|new\|position\)\)\=\>"
|
||||
|
||||
syn match cssListProp contained "\<list-style\(-\(type\|position\|image\)\)\=\>"
|
||||
syn match cssListAttr contained "\<\(lower\|upper\)-\(roman\|alpha\|greek\|latin\)\>"
|
||||
syn match cssListAttr contained "\<\(hiragana\|katakana\)\(-iroha\)\=\>"
|
||||
syn match cssListAttr contained "\<\(decimal\(-leading-zero\)\=\|cjk-ideographic\)\>"
|
||||
syn keyword cssListAttr contained disc circle square hebrew armenian georgian
|
||||
syn keyword cssListAttr contained inside outside
|
||||
|
||||
syn keyword cssPositioningProp contained bottom clear clip display float left
|
||||
syn keyword cssPositioningProp contained position right top visibility
|
||||
syn match cssPositioningProp contained "\<z-index\>"
|
||||
syn keyword cssPositioningAttr contained block compact
|
||||
syn match cssPositioningAttr contained "\<table\(-\(row-group\|\(header\|footer\)-group\|row\|column\(-group\)\=\|cell\|caption\)\)\=\>"
|
||||
syn keyword cssPositioningAttr contained left right both
|
||||
syn match cssPositioningAttr contained "\<list-item\>"
|
||||
syn match cssPositioningAttr contained "\<inline\(-\(block\|box\|table\)\)\=\>"
|
||||
syn keyword cssPositioningAttr contained static relative absolute fixed
|
||||
|
||||
syn keyword cssPrintAttr contained landscape portrait crop cross always
|
||||
|
||||
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 cssTextProp contained color direction
|
||||
syn match cssTextProp "\<\(\(word\|letter\)-spacing\|text\(-\(decoration\|transform\|align\|index\|shadow\)\)\=\|vertical-align\|unicode-bidi\|line-height\)\>"
|
||||
syn match cssTextProp contained "\<text-\(justify\|outline\|warp\|align-last\|size-adjust\|rendering\|stroke\|indent\)\>"
|
||||
syn match cssTextProp contained "\<word-\(break\|\wrap\)\>"
|
||||
syn match cssTextProp contained "\<white-space\>"
|
||||
syn match cssTextProp contained "\<hanging-punctuation\>"
|
||||
syn match cssTextProp contained "\<punctuation-trim\>"
|
||||
syn match cssTextAttr contained "\<line-through\>"
|
||||
syn match cssTextAttr contained "\<\(text-\)\=\(top\|bottom\)\>"
|
||||
syn keyword cssTextAttr contained ltr rtl embed nowrap
|
||||
syn keyword cssTextAttr contained underline overline blink sub super middle
|
||||
syn keyword cssTextAttr contained capitalize uppercase lowercase
|
||||
syn keyword cssTextAttr contained justify baseline sub super
|
||||
syn keyword cssTextAttr contained optimizeLegibility optimizeSpeed
|
||||
syn match cssTextAttr contained "\<pre\(-\(line\|wrap\)\)\=\>"
|
||||
syn match cssTextAttr contained "\<\(allow\|force\)-end\>"
|
||||
syn keyword cssTextAttr contained start end adjacent
|
||||
syn match cssTextAttr contained "\<inter-\(word\|ideographic\|cluster\)\>"
|
||||
syn keyword cssTextAttr contained distribute kashida first last
|
||||
syn keyword cssTextAttr contained clip ellipsis unrestricted suppress
|
||||
syn match cssTextAttr contained "\<break-all\>"
|
||||
syn match cssTextAttr contained "\<break-word\>"
|
||||
syn keyword cssTextAttr contained hyphenate
|
||||
syn match cssTextAttr contained "\<bidi-override\>"
|
||||
|
||||
syn match cssTransformProp contained "\<transform\(-\(origin\|style\)\)\=\>"
|
||||
syn match cssTransformProp contained "\<perspective\(-origin\)\=\>"
|
||||
syn match cssTransformProp contained "\<backface-visibility\>"
|
||||
|
||||
" CSS Transitions
|
||||
" http://www.w3.org/TR/css3-transitions/
|
||||
syn match cssTransitionProp contained "\<transition\(-\(delay\|duration\|property\|timing-function\)\)\=\>"
|
||||
|
||||
" transition-time-function attributes
|
||||
syn match cssTransitionAttr contained "\<linear\(-gradient\)\@!\>"
|
||||
syn match cssTransitionAttr contained "\<ease\(-\(in-out\|out\|in\)\)\=\>"
|
||||
syn match cssTransitionAttr contained "\<step\(-start\|-end\)\=\>"
|
||||
"------------------------------------------------
|
||||
" CSS Basic User Interface Module Level 3 (CSS3 UI)
|
||||
" http://www.w3.org/TR/css3-ui/
|
||||
syn match cssUIProp contained "\<box-sizing\>"
|
||||
syn match cssUIAttr contained "\<\(content\|padding\|border\)\(-box\)\=\>"
|
||||
|
||||
syn keyword cssUIProp contained cursor
|
||||
syn match cssUIAttr contained "\<\(\([ns]\=[ew]\=\)\|col\|row\|nesw\|nwse\)-resize\>"
|
||||
syn keyword cssUIAttr contained crosshair help move pointer alias copy
|
||||
syn keyword cssUIAttr contained progress wait text cell move
|
||||
syn match cssUIAttr contained "\<context-menu\>"
|
||||
syn match cssUIAttr contained "\<no-drop\>"
|
||||
syn match cssUIAttr contained "\<not-allowed\>"
|
||||
syn match cssUIAttr contained "\<all-scroll\>"
|
||||
syn match cssUIAttr contained "\<\(vertical-\)\=text\>"
|
||||
syn match cssUIAttr contained "\<zoom\(-in\|-out\)\=\>"
|
||||
|
||||
syn match cssUIProp contained "\<ime-mode\>"
|
||||
syn keyword cssUIAttr contained active inactive disabled
|
||||
|
||||
syn match cssUIProp contained "\<nav-\(down\|index\|left\|right\|up\)\=\>"
|
||||
syn match cssUIProp contained "\<outline\(-\(width\|style\|color\|offset\)\)\=\>"
|
||||
syn keyword cssUIAttr contained invert
|
||||
|
||||
syn keyword cssUIProp contained icon resize
|
||||
syn keyword cssUIAttr contained both horizontal vertical
|
||||
|
||||
syn match cssUIProp contained "\<text-overflow\>"
|
||||
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
|
||||
"------------------------------------------------
|
||||
" Webkit/iOS specific attributes
|
||||
syn match cssUIAttr contained '\(preserve-3d\)'
|
||||
" IE specific attributes
|
||||
syn match cssIEUIAttr contained '\(bicubic\)'
|
||||
|
||||
" Webkit/iOS specific properties
|
||||
syn match cssUIProp contained '\(tap-highlight-color\|user-select\|touch-callout\)'
|
||||
" IE specific properties
|
||||
syn match cssIEUIProp contained '\(interpolation-mode\|zoom\|filter\)'
|
||||
|
||||
" Webkit/Firebox specific properties/attributes
|
||||
syn keyword cssUIProp contained appearance
|
||||
syn keyword cssUIAttr contained window button field icon document menu
|
||||
|
||||
|
||||
syn match cssAuralProp contained "\<\(pause\|cue\)\(-\(before\|after\)\)\=\>"
|
||||
syn match cssAuralProp contained "\<\(play-during\|speech-rate\|voice-family\|pitch\(-range\)\=\|speak\(-\(punctuation\|numeral\|header\)\)\=\)\>"
|
||||
syn keyword cssAuralProp contained volume during azimuth elevation stress richness
|
||||
syn match cssAuralAttr contained "\<\(x-\)\=\(soft\|loud\)\>"
|
||||
syn keyword cssAuralAttr contained silent
|
||||
syn match cssAuralAttr contained "\<spell-out\>"
|
||||
syn keyword cssAuralAttr contained non mix
|
||||
syn match cssAuralAttr contained "\<\(left\|right\)-side\>"
|
||||
syn match cssAuralAttr contained "\<\(far\|center\)-\(left\|center\|right\)\>"
|
||||
syn keyword cssAuralAttr contained leftwards rightwards behind
|
||||
syn keyword cssAuralAttr contained below level above lower higher
|
||||
syn match cssAuralAttr contained "\<\(x-\)\=\(slow\|fast\|low\|high\)\>"
|
||||
syn keyword cssAuralAttr contained faster slower
|
||||
syn keyword cssAuralAttr contained male female child code digits continuous
|
||||
|
||||
" mobile text
|
||||
syn match cssMobileTextProp contained "\<text-size-adjust\>"
|
||||
|
||||
|
||||
|
||||
syn match cssBraces 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 match cssBraceError "}"
|
||||
syn match cssAttrComma ","
|
||||
|
||||
" Pseudo class
|
||||
" http://www.w3.org/TR/css3-selectors/
|
||||
syn match cssPseudoClass ":[A-Za-z0-9_-]*" contains=cssNoise,cssPseudoClassId,cssUnicodeEscape,cssVendor,cssPseudoClassFn
|
||||
syn keyword cssPseudoClassId contained link visited active hover before after left right
|
||||
syn keyword cssPseudoClassId contained root empty target enable disabled checked invalid
|
||||
syn match cssPseudoClassId contained "\<first-\(line\|letter\)\>"
|
||||
syn match cssPseudoClassId contained "\<\(first\|last\|only\)-\(of-type\|child\)\>"
|
||||
syn region cssPseudoClassFn contained matchgroup=cssFunctionName start="\<\(not\|lang\|\(nth\|nth-last\)-\(of-type\|child\)\)(" end=")"
|
||||
" ------------------------------------
|
||||
" Vendor specific properties
|
||||
syn match cssPseudoClassId contained "\<selection\>"
|
||||
syn match cssPseudoClassId contained "\<focus\(-inner\)\=\>"
|
||||
syn match cssPseudoClassId contained "\<\(input-\)\=placeholder\>"
|
||||
|
||||
" 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 cssNoise contained /\(:\|;\|\/\)/
|
||||
|
||||
" Comment
|
||||
syn region cssComment start="/\*" end="\*/" contains=@Spell fold
|
||||
|
||||
syn match cssUnicodeEscape "\\\x\{1,6}\s\?"
|
||||
syn match cssSpecialCharQQ +\\\\\|\\"+ contained
|
||||
syn match cssSpecialCharQ +\\\\\|\\'+ contained
|
||||
syn region cssStringQQ start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=cssUnicodeEscape,cssSpecialCharQQ
|
||||
syn region cssStringQ start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=cssUnicodeEscape,cssSpecialCharQ
|
||||
|
||||
" Vendor Prefix
|
||||
syn match cssVendor contained "\(-\(webkit\|moz\|o\|ms\)-\)"
|
||||
|
||||
" Various CSS Hack characters
|
||||
" In earlier versions of IE (6 and 7), one can prefix property names
|
||||
" with a _ or * to isolate those definitions to particular versions of IE
|
||||
" This is purely decorative and therefore we assign to the same highlight
|
||||
" group to cssVendor, for more information:
|
||||
" http://www.paulirish.com/2009/browser-specific-css-hacks/
|
||||
syn match cssHacks contained /\(_\|*\)/
|
||||
|
||||
" Attr Enhance
|
||||
" 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
|
||||
|
||||
" Hack for transition
|
||||
" '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
|
||||
|
||||
|
||||
if main_syntax == "css"
|
||||
syn sync minlines=10
|
||||
endif
|
||||
|
||||
" 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_css_syn_inits")
|
||||
if version < 508
|
||||
let did_css_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink cssComment Comment
|
||||
HiLink cssVendor Comment
|
||||
HiLink cssHacks Comment
|
||||
HiLink cssTagName Statement
|
||||
HiLink cssDeprecated Error
|
||||
HiLink cssSelectorOp Special
|
||||
HiLink cssSelectorOp2 Special
|
||||
HiLink cssAttrComma Special
|
||||
|
||||
HiLink cssAnimationProp cssProp
|
||||
HiLink cssAuralProp cssProp
|
||||
HiLink cssBackgroundProp cssProp
|
||||
HiLink cssBorderProp cssProp
|
||||
HiLink cssBoxProp cssProp
|
||||
HiLink cssColorProp cssProp
|
||||
HiLink cssContentForPagedMediaProp cssProp
|
||||
HiLink cssDimensionProp cssProp
|
||||
HiLink cssFlexibleBoxProp cssProp
|
||||
HiLink cssFontProp cssProp
|
||||
HiLink cssGeneratedContentProp cssProp
|
||||
HiLink cssGridProp cssProp
|
||||
HiLink cssHyerlinkProp cssProp
|
||||
HiLink cssIEUIProp cssProp
|
||||
HiLink cssInteractProp cssProp
|
||||
HiLink cssLineboxProp cssProp
|
||||
HiLink cssListProp cssProp
|
||||
HiLink cssMarqueeProp cssProp
|
||||
HiLink cssMobileTextProp cssProp
|
||||
HiLink cssMultiColumnProp cssProp
|
||||
HiLink cssPagedMediaProp cssProp
|
||||
HiLink cssPositioningProp cssProp
|
||||
HiLink cssPrintProp cssProp
|
||||
HiLink cssRenderProp cssProp
|
||||
HiLink cssRubyProp cssProp
|
||||
HiLink cssSpeechProp cssProp
|
||||
HiLink cssTableProp cssProp
|
||||
HiLink cssTextProp cssProp
|
||||
HiLink cssTransformProp cssProp
|
||||
HiLink cssTransitionProp cssProp
|
||||
HiLink cssUIProp cssProp
|
||||
|
||||
HiLink cssAnimationAttr cssAttr
|
||||
HiLink cssAuralAttr cssAttr
|
||||
HiLink cssBackgroundAttr cssAttr
|
||||
HiLink cssBorderAttr cssAttr
|
||||
HiLink cssBoxAttr cssAttr
|
||||
HiLink cssContentForPagedMediaAttr cssAttr
|
||||
HiLink cssCommonAttr cssAttr
|
||||
HiLink cssDimensionAttr cssAttr
|
||||
HiLink cssFlexibleBoxAttr cssAttr
|
||||
HiLink cssFontAttr cssAttr
|
||||
HiLink cssGeneratedContentAttr cssAttr
|
||||
HiLink cssGridAttr cssAttr
|
||||
HiLink cssHyerlinkAttr cssAttr
|
||||
HiLink cssIEUIAttr cssAttr
|
||||
HiLink cssInteractAttr cssAttr
|
||||
HiLink cssLineboxAttr cssAttr
|
||||
HiLink cssListAttr cssAttr
|
||||
HiLink cssMarginAttr cssAttr
|
||||
HiLink cssMarqueeAttr cssAttr
|
||||
HiLink cssMultiColumnAttr cssAttr
|
||||
HiLink cssPaddingAttr cssAttr
|
||||
HiLink cssPagedMediaAttr cssAttr
|
||||
HiLink cssPositioningAttr cssAttr
|
||||
HiLink cssGradientAttr cssAttr
|
||||
HiLink cssPrintAttr cssAttr
|
||||
HiLink cssRenderAttr cssAttr
|
||||
HiLink cssRubyAttr cssAttr
|
||||
HiLink cssSpeechAttr cssAttr
|
||||
HiLink cssTableAttr cssAttr
|
||||
HiLink cssTextAttr cssAttr
|
||||
HiLink cssTransformAttr cssAttr
|
||||
HiLink cssTransitionAttr cssAttr
|
||||
HiLink cssUIAttr cssAttr
|
||||
|
||||
HiLink cssPseudoClassId PreProc
|
||||
HiLink cssPseudoClassLang Constant
|
||||
HiLink cssValueNumber Number
|
||||
HiLink cssFunction Constant
|
||||
HiLink cssURL String
|
||||
HiLink cssFunctionName Function
|
||||
HiLink cssFunctionComma Function
|
||||
HiLink cssColor Constant
|
||||
HiLink cssIdentifier Function
|
||||
HiLink cssInclude Include
|
||||
HiLink cssIncludeKeyword atKeyword
|
||||
HiLink cssImportant Special
|
||||
HiLink cssBraces Function
|
||||
HiLink cssBraceError Error
|
||||
HiLink cssError Error
|
||||
HiLink cssUnicodeEscape Special
|
||||
HiLink cssStringQQ String
|
||||
HiLink cssStringQ String
|
||||
HiLink cssAttributeSelector String
|
||||
HiLink cssMedia atKeyword
|
||||
HiLink cssMediaType Special
|
||||
HiLink cssMediaComma Normal
|
||||
HiLink cssMediaKeyword Statement
|
||||
HiLink cssMediaProp cssProp
|
||||
HiLink cssMediaAttr cssAttr
|
||||
HiLink cssPage atKeyword
|
||||
HiLink cssPagePseudo PreProc
|
||||
HiLink cssPageMargin atKeyword
|
||||
HiLink cssPageProp cssProp
|
||||
HiLink cssKeyFrame atKeyword
|
||||
HiLink cssKeyFrameSelector Constant
|
||||
HiLink cssFontDescriptor Special
|
||||
HiLink cssFontDescriptorFunction Constant
|
||||
HiLink cssFontDescriptorProp cssProp
|
||||
HiLink cssFontDescriptorAttr cssAttr
|
||||
HiLink cssUnicodeRange Constant
|
||||
HiLink cssClassName Function
|
||||
HiLink cssClassNameDot Function
|
||||
HiLink cssProp StorageClass
|
||||
HiLink cssAttr Constant
|
||||
HiLink cssUnitDecorators Number
|
||||
HiLink cssNoise Noise
|
||||
HiLink atKeyword PreProc
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "css"
|
||||
|
||||
if main_syntax == 'css'
|
||||
unlet main_syntax
|
||||
endif
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
" vim: ts=8
|
||||
|
||||
|
||||
endif
|
||||
@@ -18,6 +18,8 @@ endif
|
||||
" Ensure long multiline strings are highlighted.
|
||||
syntax sync fromstart
|
||||
|
||||
syntax case match
|
||||
|
||||
" keyword definitions
|
||||
syntax keyword dartConditional if else switch
|
||||
syntax keyword dartRepeat do while for
|
||||
@@ -26,14 +28,14 @@ syntax keyword dartConstant null
|
||||
syntax keyword dartTypedef this super class typedef enum
|
||||
syntax keyword dartOperator new is as in
|
||||
syntax match dartOperator "+=\=\|-=\=\|*=\=\|/=\=\|%=\=\|\~/=\=\|<<=\=\|>>=\=\|[<>]=\=\|===\=\|\!==\=\|&=\=\|\^=\=\||=\=\|||\|&&\|\[\]=\=\|=>\|!\|\~\|?\|:"
|
||||
syntax keyword dartType void var bool int double num dynamic
|
||||
syntax keyword dartType void var bool int double num dynamic covariant
|
||||
syntax keyword dartStatement return
|
||||
syntax keyword dartStorageClass static abstract final const factory
|
||||
syntax keyword dartExceptions throw rethrow try on catch finally
|
||||
syntax keyword dartAssert assert
|
||||
syntax keyword dartClassDecl extends with implements
|
||||
syntax keyword dartBranch break continue nextgroup=dartUserLabelRef skipwhite
|
||||
syntax keyword dartKeyword get set operator call external async await yield sync
|
||||
syntax keyword dartKeyword get set operator call external async await yield sync native
|
||||
syntax match dartUserLabelRef "\k\+" contained
|
||||
|
||||
syntax region dartLabelRegion transparent matchgroup=dartLabel start="\<case\>" matchgroup=NONE end=":"
|
||||
@@ -47,29 +49,45 @@ syntax match dartLibrary "^\(library\|part of\|part\)\>"
|
||||
|
||||
syntax match dartMetadata "@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>"
|
||||
|
||||
" Numbers
|
||||
syntax match dartNumber "\<\d\+\(\.\d\+\)\=\>"
|
||||
|
||||
" Core libraries
|
||||
if !exists('dart_corelib_highlight') || dart_corelib_highlight
|
||||
syntax keyword dartCoreClasses BidirectionalIterator Comparable DateTime
|
||||
\ Duration Expando Function Invocation Iterable Iterator List Map Match
|
||||
\ Object Pattern RegExp RuneIterator Runes Set StackTrace Stopwatch String
|
||||
\ StringBuffer StringSink Symbol Type
|
||||
syntax keyword dartCoreTypedefs Comparator
|
||||
syntax keyword dartCoreExceptions AbstractClassInstantiationError
|
||||
\ ArgumentError AssertionError CastError ConcurrentModificationError
|
||||
\ Error Exception FallThroughError FormatException
|
||||
\ IntegerDivisionByZeroException NoSuchMethodError NullThrownError
|
||||
\ OutOfMemoryError RangeError RuntimeError StackOverflowError StateError
|
||||
\ TypeError UnimplementedError UnsupportedError
|
||||
endif
|
||||
|
||||
" Comments
|
||||
syntax keyword dartTodo contained TODO FIXME XXX
|
||||
syntax region dartComment start="/\*" end="\*/" contains=dartComment,dartTodo,dartDocLink,@Spell
|
||||
syntax match dartLineComment "//.*" contains=dartTodo,@Spell
|
||||
syntax match dartLineDocComment "///.*" contains=dartTodo,dartDocLink,@Spell
|
||||
syntax match dartShebangLine /^\%1l#!.*/
|
||||
syntax region dartDocLink oneline contained start=+\[+ end=+\]+
|
||||
|
||||
" Strings
|
||||
syntax region dartString start=+\z(["']\)+ end=+\z1+ contains=@Spell,dartInterpolation,dartSpecialChar
|
||||
syntax region dartRawString start=+r\z(["']\)+ end=+\z1+ contains=@Spell
|
||||
syntax region dartMultilineString start=+\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@Spell,dartInterpolation,dartSpecialChar
|
||||
syntax region dartRawMultilineString start=+r\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@Spell
|
||||
syntax match dartInterpolation contained "\$\(\w\+\|{[^}]\+}\)"
|
||||
syntax match dartSpecialChar contained "\\\(u\x\{4\}\|u{\x\+}\|x\x\x\|x{\x\+}\|.\)"
|
||||
|
||||
" Numbers
|
||||
syntax match dartNumber "\<\d\+\(\.\d\+\)\=\>"
|
||||
|
||||
" TODO(antonm): consider conditional highlighting of corelib classes.
|
||||
syntax keyword dartCoreClasses BidirectionalIterator Comparable DateTime Duration Expando Function Invocation Iterable Iterator List Map Match Object Pattern RegExp RuneIterator Runes Set StackTrace Stopwatch String StringBuffer StringSink Symbol Type
|
||||
syntax keyword dartCoreTypedefs Comparator
|
||||
syntax keyword dartCoreExceptions AbstractClassInstantiationError ArgumentError AssertionError CastError ConcurrentModificationError Error Exception FallThroughError FormatException IntegerDivisionByZeroException NoSuchMethodError NullThrownError OutOfMemoryError RangeError RuntimeError StackOverflowError StateError TypeError UnimplementedError UnsupportedError
|
||||
|
||||
syntax cluster dartRawStringContains contains=@Spell
|
||||
if exists('dart_html_in_strings') && dart_html_in_strings
|
||||
syntax include @HTML syntax/html.vim
|
||||
syntax cluster dartRawStringContains add=@HTML
|
||||
endif
|
||||
syntax cluster dartStringContains contains=@dartRawStringContains,dartInterpolation,dartSpecialChar
|
||||
syntax region dartString oneline start=+\z(["']\)+ end=+\z1+ contains=@dartStringContains keepend
|
||||
syntax region dartRawString oneline start=+r\z(["']\)+ end=+\z1+ contains=@dartRawStringContains keepend
|
||||
syntax region dartMultilineString start=+\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@dartStringContains keepend
|
||||
syntax region dartRawMultilineString start=+r\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@dartSRawtringContains keepend
|
||||
syntax match dartInterpolation contained "\$\(\w\+\|{[^}]\+}\)" extend
|
||||
syntax match dartSpecialChar contained "\\\(u\x\{4\}\|u{\x\+}\|x\x\x\|x{\x\+}\|.\)" extend
|
||||
|
||||
" The default highlighting.
|
||||
highlight default link dartBranch Conditional
|
||||
@@ -93,6 +111,7 @@ highlight default link dartOperator Operator
|
||||
highlight default link dartComment Comment
|
||||
highlight default link dartLineComment Comment
|
||||
highlight default link dartLineDocComment Comment
|
||||
highlight default link dartShebangLine Comment
|
||||
highlight default link dartConstant Constant
|
||||
highlight default link dartTypedef Typedef
|
||||
highlight default link dartTodo Todo
|
||||
|
||||
@@ -18,26 +18,27 @@ syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirModuleDec
|
||||
syn match elixirComment '#.*' contains=elixirTodo,@Spell
|
||||
syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained
|
||||
|
||||
syn match elixirId '\<[_a-zA-Z]\w*[!?]\?\>'
|
||||
syn match elixirId '\<[_a-zA-Z]\w*[!?]\?\>' contains=elixirUnusedVariable,elixirKernelFunction
|
||||
|
||||
syn match elixirKeyword '\(\.\)\@<!\<\(for\|case\|when\|with\|cond\|if\|unless\|try\|receive\|send\)\>'
|
||||
syn match elixirKeyword '\(\.\)\@<!\<\(exit\|raise\|throw\|after\|rescue\|catch\|else\)\>'
|
||||
syn match elixirKeyword '\(\.\)\@<!\<\(quote\|unquote\|super\|spawn\|spawn_link\|spawn_monitor\)\>'
|
||||
|
||||
" Kernel functions
|
||||
syn match elixirKernelFunction contained containedin=elixirGuard '\<\(is_atom\|is_binary\|is_bitstring\|is_boolean\|is_float\|is_function\|is_integer\|is_list\|is_map\|is_nil\|is_number\|is_pid\|is_port\)\>\([ (]\)\@='
|
||||
syn match elixirKernelFunction contained containedin=elixirGuard '\<\(is_record\|is_reference\|is_tuple\|is_exception\|abs\|bit_size\|byte_size\|div\|elem\|hd\|length\|map_size\|node\|rem\|round\|tl\|trunc\|tuple_size\)\>\([ (]\)\@='
|
||||
|
||||
syn match elixirGuard '.*when.*' contains=ALLBUT,@elixirNotTop
|
||||
syn keyword elixirKernelFunction contained is_atom is_binary is_bitstring is_boolean is_float
|
||||
syn keyword elixirKernelFunction contained is_function is_integer is_list is_map is_nil
|
||||
syn keyword elixirKernelFunction contained is_number is_pid is_port is_reference is_tuple
|
||||
syn keyword elixirKernelFunction contained abs binary_part bit_size byte_size div elem hd length
|
||||
syn keyword elixirKernelFunction contained map_size node rem round tl trunc tuple_size
|
||||
|
||||
syn keyword elixirInclude import require alias use
|
||||
|
||||
syn keyword elixirSelf self
|
||||
|
||||
" This unfortunately also matches function names in function calls
|
||||
syn match elixirUnusedVariable contained '\<_\w*\>'
|
||||
syn match elixirUnusedVariable contained '\v%(^|[^.])@<=<_\w*>'
|
||||
|
||||
syn keyword elixirOperator and not or in
|
||||
syn match elixirOperator '\v\.@<!<%(and|or|in|not)>'
|
||||
syn match elixirOperator '!==\|!=\|!'
|
||||
syn match elixirOperator '=\~\|===\|==\|='
|
||||
syn match elixirOperator '<<<\|<<\|<=\|<-\|<'
|
||||
@@ -54,8 +55,6 @@ syn match elixirAtom '\(:\)\@<!:\%([a-zA-Z_]\w*\%([?!]\|=[>=]\@!\)\?\|<>\|===\
|
||||
syn match elixirAtom '\(:\)\@<!:\%(<=>\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)'
|
||||
syn match elixirAtom "\%([a-zA-Z_]\w*[?!]\?\):\(:\)\@!"
|
||||
|
||||
syn match elixirBlockInline "\<\(do\|else\)\>:\@="
|
||||
|
||||
syn match elixirAlias '\([a-z]\)\@<![A-Z]\w*'
|
||||
|
||||
syn keyword elixirBoolean true false nil
|
||||
@@ -65,9 +64,10 @@ syn match elixirVariable '&\d\+'
|
||||
|
||||
syn keyword elixirPseudoVariable __FILE__ __DIR__ __MODULE__ __ENV__ __CALLER__
|
||||
|
||||
syn match elixirNumber '\<\d\(_\?\d\)*\(\.[^[:space:][:digit:]]\@!\(_\?\d\)*\)\?\([eE][-+]\?\d\(_\?\d\)*\)\?\>'
|
||||
syn match elixirNumber '\<0[xX][0-9A-Fa-f]\+\>'
|
||||
syn match elixirNumber '\<0[bB][01]\+\>'
|
||||
syn match elixirNumber '\<-\?\d\(_\?\d\)*\(\.[^[:space:][:digit:]]\@!\(_\?\d\)*\)\?\([eE][-+]\?\d\(_\?\d\)*\)\?\>'
|
||||
syn match elixirNumber '\<-\?0[xX][0-9A-Fa-f]\+\>'
|
||||
syn match elixirNumber '\<-\?0[oO][0-7]\+\>'
|
||||
syn match elixirNumber '\<-\?0[bB][01]\+\>'
|
||||
|
||||
syn match elixirRegexEscape "\\\\\|\\[aAbBcdDefGhHnrsStvVwW]\|\\\d\{3}\|\\x[0-9a-fA-F]\{2}" contained
|
||||
syn match elixirRegexEscapePunctuation "?\|\\.\|*\|\\\[\|\\\]\|+\|\\^\|\\\$\|\\|\|\\(\|\\)\|\\{\|\\}" contained
|
||||
@@ -84,10 +84,10 @@ syn region elixirStruct matchgroup=elixirStructDelimiter start="%\(\w\+{\)\@=" e
|
||||
|
||||
syn region elixirMap matchgroup=elixirMapDelimiter start="%{" end="}" contains=ALLBUT,@elixirNotTop
|
||||
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z('\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z('''\)+ end=+^\s*\z1+ contains=@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z("""\)+ end=+^\s*\z1+ contains=@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z('\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@Spell,@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z("\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=@Spell,@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z('''\)+ end=+^\s*\z1+ contains=@Spell,@elixirStringContained
|
||||
syn region elixirString matchgroup=elixirStringDelimiter start=+\z("""\)+ end=+^\s*\z1+ contains=@Spell,@elixirStringContained
|
||||
syn region elixirInterpolation matchgroup=elixirInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,elixirKernelFunction,elixirComment,@elixirNotTop
|
||||
|
||||
syn match elixirAtomInterpolated ':\("\)\@=' contains=elixirString
|
||||
@@ -97,7 +97,7 @@ syn region elixirBlock matchgroup=elixirBlockDefinition start="\<do
|
||||
syn region elixirElseBlock matchgroup=elixirBlockDefinition start="\<else\>:\@!" end="\<end\>" contains=ALLBUT,elixirKernelFunction,@elixirNotTop fold
|
||||
syn region elixirAnonymousFunction matchgroup=elixirBlockDefinition start="\<fn\>" end="\<end\>" contains=ALLBUT,elixirKernelFunction,@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,elixirAnonymousFunction
|
||||
syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirAtom,elixirPseudoVariable,elixirAlias,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirAtomInterpolated,elixirRegex,elixirString,elixirStringDelimiter,elixirRegexDelimiter,elixirInterpolationDelimiter,elixirSigil,elixirAnonymousFunction
|
||||
|
||||
syn match elixirDelimEscape "\\[(<{\[)>}\]/\"'|]" transparent display contained contains=NONE
|
||||
|
||||
@@ -121,10 +121,10 @@ syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z('''\)+ end=
|
||||
" Documentation
|
||||
if exists('g:elixir_use_markdown_for_docs') && g:elixir_use_markdown_for_docs
|
||||
syn include @markdown syntax/markdown.vim
|
||||
syn cluster elixirDocStringContained contains=@markdown,@Spell
|
||||
syn cluster elixirDocStringContained contains=@markdown,@Spell,elixirInterpolation
|
||||
else
|
||||
let g:elixir_use_markdown_for_docs = 0
|
||||
syn cluster elixirDocStringContained contains=elixirDocTest,elixirTodo,@Spell
|
||||
syn cluster elixirDocStringContained contains=elixirDocTest,elixirTodo,@Spell,elixirInterpolation
|
||||
|
||||
" doctests
|
||||
syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained
|
||||
@@ -174,7 +174,6 @@ syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|
|
||||
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(assert\|assert_in_delta\|assert_raise\|assert_receive\|assert_received\|catch_error\)\>"
|
||||
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(catch_exit\|catch_throw\|flunk\|refute\|refute_in_delta\|refute_receive\|refute_received\)\>"
|
||||
|
||||
hi def link elixirBlockInline Keyword
|
||||
hi def link elixirBlockDefinition Keyword
|
||||
hi def link elixirDefine Define
|
||||
hi def link elixirPrivateDefine Define
|
||||
|
||||
124
syntax/elm.vim
124
syntax/elm.vim
@@ -1,81 +1,73 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elm') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: Elm (http://elm-lang.org/)
|
||||
" Maintainer: Alexander Noriega
|
||||
" Latest Revision: 19 April 2015
|
||||
" syntax highlighting for Elm (http://elm-lang.org/)
|
||||
|
||||
if exists("b:current_syntax")
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
" Keywords
|
||||
syn keyword elmKeyword alias as case else exposing if import in let module of port then type where
|
||||
syn keyword elmConditional case else if of then
|
||||
syn keyword elmAlias alias
|
||||
syn keyword elmTypedef type port let in
|
||||
syn keyword elmImport exposing as import module where
|
||||
|
||||
" Builtin operators
|
||||
syn match elmBuiltinOp "\~"
|
||||
syn match elmBuiltinOp "||"
|
||||
syn match elmBuiltinOp "|>"
|
||||
syn match elmBuiltinOp "|"
|
||||
syn match elmBuiltinOp "`"
|
||||
syn match elmBuiltinOp "\^"
|
||||
syn match elmBuiltinOp "\\"
|
||||
syn match elmBuiltinOp ">>"
|
||||
syn match elmBuiltinOp ">="
|
||||
syn match elmBuiltinOp ">"
|
||||
syn match elmBuiltinOp "=="
|
||||
syn match elmBuiltinOp "="
|
||||
syn match elmBuiltinOp "<\~"
|
||||
syn match elmBuiltinOp "<|"
|
||||
syn match elmBuiltinOp "<="
|
||||
syn match elmBuiltinOp "<<"
|
||||
syn match elmBuiltinOp "<-"
|
||||
syn match elmBuiltinOp "<"
|
||||
syn match elmBuiltinOp "::"
|
||||
syn match elmBuiltinOp ":"
|
||||
syn match elmBuiltinOp "/="
|
||||
syn match elmBuiltinOp "//"
|
||||
syn match elmBuiltinOp "/"
|
||||
syn match elmBuiltinOp "\.\."
|
||||
syn match elmBuiltinOp "\."
|
||||
syn match elmBuiltinOp "->"
|
||||
syn match elmBuiltinOp "-"
|
||||
syn match elmBuiltinOp "++"
|
||||
syn match elmBuiltinOp "+"
|
||||
syn match elmBuiltinOp "*"
|
||||
syn match elmBuiltinOp "&&"
|
||||
syn match elmBuiltinOp "%"
|
||||
|
||||
" Special names
|
||||
syntax match specialName "^main "
|
||||
|
||||
" Comments
|
||||
syn match elmTodo "[tT][oO][dD][oO]\|FIXME\|XXX" contained
|
||||
syn match elmLineComment "--.*" contains=elmTodo,@spell
|
||||
syn region elmComment matchgroup=elmComment start="{-|\=" end="-}" contains=elmTodo,elmComment,@spell
|
||||
|
||||
" String literals
|
||||
syn region elmString start="\"" skip="\\\"" end="\"" contains=elmStringEscape
|
||||
syn match elmStringEscape "\\u[0-9a-fA-F]\{4}" contained
|
||||
syn match elmStringEscape "\\[nrfvbt\\\"]" contained
|
||||
|
||||
" Number literals
|
||||
syn match elmNumber "\(\<\d\+\>\)"
|
||||
syn match elmNumber "\(\<\d\+\.\d\+\>\)"
|
||||
" Operators
|
||||
syn match elmOperator "\([-!#$%`&\*\+./<=>\?@\\^|~:]\|\<_\>\)"
|
||||
|
||||
" Types
|
||||
syn match elmType "\<[A-Z][0-9A-Za-z_'-]*"
|
||||
syn keyword elmNumberType number
|
||||
|
||||
let b:current_syntax = "elm"
|
||||
" Delimiters
|
||||
syn match elmDelimiter "[,;]"
|
||||
syn match elmBraces "[()[\]{}]"
|
||||
|
||||
hi def link elmKeyword Keyword
|
||||
hi def link elmBuiltinOp Special
|
||||
hi def link elmType Type
|
||||
hi def link elmTodo Todo
|
||||
hi def link elmLineComment Comment
|
||||
hi def link elmComment Comment
|
||||
hi def link elmString String
|
||||
hi def link elmNumber Number
|
||||
hi def link specialName Special
|
||||
" Functions
|
||||
syn match elmTupleFunction "\((,\+)\)"
|
||||
|
||||
" Comments
|
||||
syn keyword elmTodo TODO FIXME XXX contained
|
||||
syn match elmLineComment "--.*" contains=elmTodo,@spell
|
||||
syn region elmComment matchgroup=elmComment start="{-|\=" end="-}" contains=elmTodo,elmComment,@spell
|
||||
|
||||
" Strings
|
||||
syn match elmStringEscape "\\u[0-9a-fA-F]\{4}" contained
|
||||
syn match elmStringEscape "\\[nrfvbt\\\"]" contained
|
||||
syn region elmString start="\"" skip="\\\"" end="\"" contains=elmStringEscape,@spell
|
||||
syn region elmTripleString start="\"\"\"" skip="\\\"" end="\"\"\"" contains=elmStringEscape,@spell
|
||||
syn match elmChar "'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'"
|
||||
|
||||
" Numbers
|
||||
syn match elmInt "-\?\<\d\+\>\|0[xX][0-9a-fA-F]\+\>"
|
||||
syn match elmFloat "\(\<\d\+\.\d\+\>\)"
|
||||
|
||||
" Identifiers
|
||||
syn match elmTopLevelDecl "^\s*[a-zA-Z][a-zA-z0-9_]*\('\)*\s\+:\s\+" contains=elmOperator
|
||||
|
||||
hi def link elmTopLevelDecl Function
|
||||
hi def link elmTupleFunction Normal
|
||||
hi def link elmTodo Todo
|
||||
hi def link elmComment Comment
|
||||
hi def link elmLineComment Comment
|
||||
hi def link elmString String
|
||||
hi def link elmTripleString String
|
||||
hi def link elmChar String
|
||||
hi def link elmStringEscape Special
|
||||
hi def link elmInt Number
|
||||
hi def link elmFloat Float
|
||||
hi def link elmDelimiter Delimiter
|
||||
hi def link elmBraces Delimiter
|
||||
hi def link elmTypedef TypeDef
|
||||
hi def link elmImport Include
|
||||
hi def link elmConditional Conditional
|
||||
hi def link elmAlias Delimiter
|
||||
hi def link elmOperator Operator
|
||||
hi def link elmType Identifier
|
||||
hi def link elmNumberType Identifier
|
||||
|
||||
syn sync minlines=500
|
||||
|
||||
let b:current_syntax = 'elm'
|
||||
|
||||
endif
|
||||
|
||||
@@ -118,14 +118,14 @@ syn keyword erlangBIF garbage_collect get get_keys group_leader contained
|
||||
syn keyword erlangBIF halt hd integer_to_binary integer_to_list contained
|
||||
syn keyword erlangBIF iolist_to_binary iolist_size is_alive contained
|
||||
syn keyword erlangBIF is_atom is_binary is_bitstring is_boolean contained
|
||||
syn keyword erlangBIF is_float is_function is_integer is_list contained
|
||||
syn keyword erlangBIF is_float is_function is_integer is_list is_map contained
|
||||
syn keyword erlangBIF is_number is_pid is_port is_process_alive contained
|
||||
syn keyword erlangBIF is_record is_reference is_tuple length link contained
|
||||
syn keyword erlangBIF list_to_atom list_to_binary contained
|
||||
syn keyword erlangBIF list_to_bitstring list_to_existing_atom contained
|
||||
syn keyword erlangBIF list_to_float list_to_integer list_to_pid contained
|
||||
syn keyword erlangBIF list_to_tuple load_module make_ref max min contained
|
||||
syn keyword erlangBIF module_loaded monitor monitor_node node contained
|
||||
syn keyword erlangBIF list_to_tuple load_module make_ref map_size max contained
|
||||
syn keyword erlangBIF min module_loaded monitor monitor_node node contained
|
||||
syn keyword erlangBIF nodes now open_port pid_to_list port_close contained
|
||||
syn keyword erlangBIF port_command port_connect pre_loaded contained
|
||||
syn keyword erlangBIF process_flag process_flag process_info contained
|
||||
|
||||
@@ -24,7 +24,7 @@ elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
||||
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
||||
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
||||
if b:eruby_subtype == ''
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
endif
|
||||
if b:eruby_subtype == 'rhtml'
|
||||
let b:eruby_subtype = 'html'
|
||||
@@ -49,7 +49,7 @@ if !b:eruby_nest_level
|
||||
let b:eruby_nest_level = 1
|
||||
endif
|
||||
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby'
|
||||
exe "runtime! syntax/".b:eruby_subtype.".vim"
|
||||
unlet! b:current_syntax
|
||||
endif
|
||||
|
||||
@@ -22,7 +22,7 @@ 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
|
||||
\ contains=fishSpecial,fishIdentifier,fishString,fishCharacter,fishStatement,fishCommandSub,fishComment
|
||||
|
||||
highlight default link fishKeyword Keyword
|
||||
highlight default link fishConditional Conditional
|
||||
|
||||
269
syntax/fsharp.vim
Normal file
269
syntax/fsharp.vim
Normal file
@@ -0,0 +1,269 @@
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fsharp') == -1
|
||||
|
||||
" Vim syntax file
|
||||
" Language: F#
|
||||
" Last Change: Sun 19 Oct 2014 11:11:44 PM CEST
|
||||
" Maintainer: Gregor Uhlenheuer <kongo2002@googlemail.com>
|
||||
"
|
||||
" Note: This syntax file is a complete rewrite of the original version
|
||||
" of fs.vim from Choy Rim <choy.rim@gmail.com> and a slight
|
||||
" modified version from Thomas Schank <ThomasSchank@gmail.com>
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
" F# is case sensitive.
|
||||
syn case match
|
||||
|
||||
" reset 'iskeyword' setting
|
||||
setl isk&vim
|
||||
|
||||
" Scripting/preprocessor directives
|
||||
syn match fsharpSScript "^\s*#\S\+" transparent contains=fsharpScript,fsharpRegion,fsharpPreCondit
|
||||
|
||||
syn match fsharpScript contained "#"
|
||||
syn keyword fsharpScript contained quitlabels warnings directory cd load use
|
||||
syn keyword fsharpScript contained install_printer remove_printer requirethread
|
||||
syn keyword fsharpScript contained trace untrace untrace_all print_depth
|
||||
syn keyword fsharpScript contained print_length define undef if elif else endif
|
||||
syn keyword fsharpScript contained line error warning light nowarn
|
||||
|
||||
|
||||
" comments
|
||||
syn match fsharpSingleLineComment "//.*$" contains=fsharpTodo,@Spell
|
||||
syn region fsharpDocComment start="///" end="$" contains=fsharpTodo,fsharpXml,@Spell keepend oneline
|
||||
syn region fsharpXml matchgroup=fsharpXmlDoc start="<[^>]\+>" end="</[^>]\+>" contained contains=fsharpXml
|
||||
|
||||
" Double-backtick identifiers
|
||||
syn region fsharpDoubleBacktick start="``" end="``" keepend oneline
|
||||
|
||||
|
||||
" symbol names
|
||||
syn match fsharpSymbol "\%(let\|use\|mutable\|rec\|and\|private\)\@<=!\=\s\+\zs\w\+\ze\s*[^=:]*[=:]"
|
||||
syn match fsharpSymbol "\%(member\)\@<=\s\+\w\+\.\zs\w\+"
|
||||
|
||||
|
||||
" types
|
||||
syn match fsharpTypeName "\%(\<type\s\+\)\@<=\w\+"
|
||||
|
||||
|
||||
" errors
|
||||
syn match fsharpBraceErr "}"
|
||||
syn match fsharpBrackErr "\]"
|
||||
syn match fsharpParenErr ")"
|
||||
syn match fsharpArrErr "|]"
|
||||
syn match fsharpCommentErr "\*)"
|
||||
|
||||
|
||||
" enclosing delimiters
|
||||
syn region fsharpEncl transparent matchgroup=fsharpKeyword start="(" matchgroup=fsharpKeyword end=")" contains=ALLBUT,fsharpParenErr,fsharpScript
|
||||
syn region fsharpEncl transparent matchgroup=fsharpKeyword start="{" matchgroup=fsharpKeyword end="}" contains=ALLBUT,fsharpBraceErr,fsharpScript
|
||||
syn region fsharpEncl transparent matchgroup=fsharpKeyword start="\[" matchgroup=fsharpKeyword end="\]" contains=ALLBUT,fsharpBrackErr,fsharpScript
|
||||
syn region fsharpEncl transparent matchgroup=fsharpKeyword start="\[|" matchgroup=fsharpKeyword end="|\]" contains=ALLBUT,fsharpArrErr,fsharpScript
|
||||
|
||||
|
||||
" comments
|
||||
syn region fsharpMultiLineComment start="(\*" end="\*)" contains=fsharpTodo
|
||||
syn keyword fsharpTodo contained TODO FIXME XXX NOTE
|
||||
|
||||
" keywords
|
||||
syn keyword fsharpKeyword abstract as assert base begin class default delegate
|
||||
syn keyword fsharpKeyword do done downcast downto elif else end exception
|
||||
syn keyword fsharpKeyword extern for fun function global if in inherit inline
|
||||
syn keyword fsharpKeyword interface lazy let match member module mutable
|
||||
syn keyword fsharpKeyword namespace new of override rec static struct then
|
||||
syn keyword fsharpKeyword to type upcast use val void when while with
|
||||
|
||||
syn keyword fsharpKeyword async atomic break checked component const constraint
|
||||
syn keyword fsharpKeyword constructor continue decimal eager event external
|
||||
syn keyword fsharpKeyword fixed functor include method mixin object parallel
|
||||
syn keyword fsharpKeyword process pure return seq tailcall trait
|
||||
|
||||
" additional operator keywords (Microsoft.FSharp.Core.Operators)
|
||||
syn keyword fsharpKeyword box hash sizeof typeof typedefof unbox ref fst snd
|
||||
syn keyword fsharpKeyword stdin stdout stderr
|
||||
|
||||
" math operators (Microsoft.FSharp.Core.Operators)
|
||||
syn keyword fsharpKeyword abs acos asin atan atan2 ceil cos cosh exp floor log
|
||||
syn keyword fsharpKeyword log10 pown round sign sin sinh sqrt tan tanh
|
||||
|
||||
syn keyword fsharpOCaml asr land lor lsl lsr lxor mod sig
|
||||
|
||||
if !exists('g:fsharp_no_linq') || g:fsharp_no_linq == 0
|
||||
syn keyword fsharpLinq orderBy select where yield
|
||||
endif
|
||||
|
||||
" open
|
||||
syn keyword fsharpOpen open
|
||||
|
||||
" exceptions
|
||||
syn keyword fsharpException try failwith failwithf finally invalid_arg raise
|
||||
syn keyword fsharpException rethrow
|
||||
|
||||
" modifiers
|
||||
syn keyword fsharpModifier abstract const extern internal override private
|
||||
syn keyword fsharpModifier protected public readonly sealed static virtual
|
||||
syn keyword fsharpModifier volatile
|
||||
|
||||
" constants
|
||||
syn keyword fsharpConstant null
|
||||
syn keyword fsharpBoolean false true
|
||||
|
||||
" types
|
||||
syn keyword fsharpType array bool byte char decimal double enum exn float
|
||||
syn keyword fsharpType float32 int int16 int32 int64 lazy_t list nativeint
|
||||
syn keyword fsharpType obj option sbyte single string uint uint32 uint64
|
||||
syn keyword fsharpType uint16 unativeint unit
|
||||
|
||||
" core classes
|
||||
syn match fsharpCore "\u\a*\." transparent contains=fsharpCoreClass
|
||||
|
||||
syn keyword fsharpCoreClass Array Async Directory File List Option Path Map Set contained
|
||||
syn keyword fsharpCoreClass String Seq Tuple contained
|
||||
|
||||
syn keyword fsharpCoreMethod printf printfn sprintf eprintf eprintfn fprintf
|
||||
syn keyword fsharpCoreMethod fprintfn
|
||||
|
||||
" options
|
||||
syn keyword fsharpOption Some None
|
||||
|
||||
" operators
|
||||
syn keyword fsharpOperator not and or
|
||||
|
||||
syn match fsharpFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bscdiuxXoEefFgGMOAat]\|\[\^\=.[^]]*\]\)" contained
|
||||
|
||||
syn match fsharpCharacter "'\\\d\d\d'\|'\\[\'ntbr]'\|'.'"
|
||||
syn match fsharpCharErr "'\\\d\d'\|'\\\d'"
|
||||
syn match fsharpCharErr "'\\[^\'ntbr]'"
|
||||
syn region fsharpString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=fsharpFormat
|
||||
syn region fsharpString start=+"""+ skip=+\\\\\|\\"+ end=+"""+ contains=fsharpFormat
|
||||
syn region fsharpString start=+@"+ skip=+""+ end=+"+ contains=fsharpFormat
|
||||
|
||||
syn match fsharpFunDef "->"
|
||||
syn match fsharpRefAssign ":="
|
||||
syn match fsharpTopStop ";;"
|
||||
syn match fsharpOperator "\^"
|
||||
syn match fsharpOperator "::"
|
||||
|
||||
syn match fsharpLabel "\<_\>"
|
||||
|
||||
syn match fsharpOperator "&&"
|
||||
syn match fsharpOperator "<"
|
||||
syn match fsharpOperator ">"
|
||||
syn match fsharpOperator "|>"
|
||||
syn match fsharpOperator ":>"
|
||||
syn match fsharpOperator ":?>"
|
||||
syn match fsharpOperator "&&&"
|
||||
syn match fsharpOperator "|||"
|
||||
syn match fsharpOperator "\.\."
|
||||
|
||||
syn match fsharpKeyChar "|[^\]]"me=e-1
|
||||
syn match fsharpKeyChar ";"
|
||||
syn match fsharpKeyChar "\~"
|
||||
syn match fsharpKeyChar "?"
|
||||
syn match fsharpKeyChar "\*"
|
||||
syn match fsharpKeyChar "+"
|
||||
syn match fsharpKeyChar "="
|
||||
syn match fsharpKeyChar "|"
|
||||
syn match fsharpKeyChar "(\*)"
|
||||
|
||||
syn match fsharpOperator "<-"
|
||||
|
||||
syn match fsharpNumber "\<\d\+"
|
||||
syn match fsharpNumber "\<-\=\d\(_\|\d\)*\(u\|u\?[yslLn]\|UL\)\?\>"
|
||||
syn match fsharpNumber "\<-\=0[x|X]\(\x\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>"
|
||||
syn match fsharpNumber "\<-\=0[o|O]\(\o\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>"
|
||||
syn match fsharpNumber "\<-\=0[b|B]\([01]\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>"
|
||||
syn match fsharpFloat "\<-\=\d\(_\|\d\)*\.\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>"
|
||||
syn match fsharpFloat "\<-\=\d\(_\|\d\)*\.\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>"
|
||||
syn match fsharpFloat "\<\d\+\.\d*"
|
||||
|
||||
" modules
|
||||
syn match fsharpModule "\%(\<open\s\+\)\@<=[a-zA-Z.]\+"
|
||||
|
||||
" attributes
|
||||
syn region fsharpAttrib matchgroup=fsharpAttribute start="\[<" end=">]"
|
||||
|
||||
" regions
|
||||
syn region fsharpRegion matchgroup=fsharpPreCondit start="\%(end\)\@<!region.*$"
|
||||
\ end="endregion" fold contains=ALL contained
|
||||
|
||||
if version >= 508 || !exists("did_fs_syntax_inits")
|
||||
if version < 508
|
||||
let did_fs_syntax_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink fsharpBraceErr Error
|
||||
HiLink fsharpBrackErr Error
|
||||
HiLink fsharpParenErr Error
|
||||
HiLink fsharpArrErr Error
|
||||
HiLink fsharpCommentErr Error
|
||||
|
||||
HiLink fsharpSingleLineComment Comment
|
||||
HiLink fsharpMultiLineComment Comment
|
||||
HiLink fsharpDocComment Comment
|
||||
HiLink fsharpXml Comment
|
||||
HiLink fsharpDoubleBacktick String
|
||||
|
||||
HiLink fsharpOpen Include
|
||||
HiLink fsharpModPath Include
|
||||
HiLink fsharpScript Include
|
||||
HiLink fsharpPreCondit Include
|
||||
|
||||
HiLink fsharpKeyword Keyword
|
||||
HiLink fsharpCoreMethod Keyword
|
||||
|
||||
HiLink fsharpOCaml Statement
|
||||
HiLink fsharpLinq Statement
|
||||
|
||||
HiLink fsharpSymbol Function
|
||||
|
||||
HiLink fsharpFunDef Operator
|
||||
HiLink fsharpRefAssign Operator
|
||||
HiLink fsharpTopStop Operator
|
||||
HiLink fsharpKeyChar Operator
|
||||
HiLink fsharpOperator Operator
|
||||
|
||||
HiLink fsharpBoolean Boolean
|
||||
HiLink fsharpConstant Constant
|
||||
HiLink fsharpCharacter Character
|
||||
HiLink fsharpNumber Number
|
||||
HiLink fsharpFloat Float
|
||||
|
||||
HiLink fsharpString String
|
||||
HiLink fsharpFormat Special
|
||||
|
||||
HiLink fsharpModifier StorageClass
|
||||
|
||||
HiLink fsharpException Exception
|
||||
|
||||
HiLink fsharpLabel Identifier
|
||||
HiLink fsharpOption Identifier
|
||||
HiLink fsharpTypeName Identifier
|
||||
HiLink fsharpModule Identifier
|
||||
|
||||
HiLink fsharpType Type
|
||||
|
||||
HiLink fsharpCoreClass Typedef
|
||||
HiLink fsharpAttrib Typedef
|
||||
HiLink fsharpXmlDoc Typedef
|
||||
|
||||
HiLink fsharpTodo Todo
|
||||
|
||||
HiLink fsharpEncl Delimiter
|
||||
HiLink fsharpAttribute Delimiter
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = 'fsharp'
|
||||
|
||||
" vim: sw=4 et sts=4
|
||||
|
||||
endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user