mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 19:43:52 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11f53253ad | ||
|
|
9fe009095a | ||
|
|
dce9e8dec5 | ||
|
|
30c87b73de | ||
|
|
1713d35f06 | ||
|
|
5ddfa1ac28 | ||
|
|
dbe9bc927f | ||
|
|
d219055bc8 | ||
|
|
0e9041f29a | ||
|
|
a0b8a6e77f | ||
|
|
a61ab44810 | ||
|
|
dd4b5cbdd6 |
15
README.md
15
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.
|
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||||
|
|
||||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||||
- It **installs and updates 100+ times faster** than 100+ packages it consist of.
|
- It **installs and updates 100+ times faster** than 100+ packages it consists of.
|
||||||
- Solid syntax and indentation support. Only the best language packs.
|
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||||
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
||||||
- Each build is tested by automated vimrunner script on CI. See `spec` directory.
|
- 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
|
## Installation
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
|||||||
- [caddyfile](https://github.com/isobit/vim-caddyfile) (syntax, indent, ftplugin)
|
- [caddyfile](https://github.com/isobit/vim-caddyfile) (syntax, indent, ftplugin)
|
||||||
- [cjsx](https://github.com/mtscout6/vim-cjsx) (syntax, ftplugin)
|
- [cjsx](https://github.com/mtscout6/vim-cjsx) (syntax, ftplugin)
|
||||||
- [clojure](https://github.com/guns/vim-clojure-static) (syntax, indent, autoload, 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)
|
- [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin)
|
||||||
- [cql](https://github.com/elubow/cql-vim) (syntax)
|
- [cql](https://github.com/elubow/cql-vim) (syntax)
|
||||||
- [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim) (syntax, compiler, ftplugin)
|
- [cryptol](https://github.com/victoredwardocallaghan/cryptol.vim) (syntax, compiler, ftplugin)
|
||||||
@@ -80,9 +81,9 @@ If you need full functionality of any plugin, please use it directly with your p
|
|||||||
- [json](https://github.com/elzr/vim-json) (syntax, indent, ftplugin)
|
- [json](https://github.com/elzr/vim-json) (syntax, indent, ftplugin)
|
||||||
- [jst](https://github.com/briancollins/vim-jst) (syntax, indent)
|
- [jst](https://github.com/briancollins/vim-jst) (syntax, indent)
|
||||||
- [jsx](https://github.com/mxw/vim-jsx) (after)
|
- [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)
|
- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent)
|
||||||
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin)
|
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) ()
|
||||||
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
|
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
|
||||||
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin)
|
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin)
|
||||||
- [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin)
|
- [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin)
|
||||||
@@ -92,12 +93,11 @@ If you need full functionality of any plugin, please use it directly with your p
|
|||||||
- [mathematica](https://github.com/rsmenon/vim-mathematica) (syntax, ftplugin)
|
- [mathematica](https://github.com/rsmenon/vim-mathematica) (syntax, ftplugin)
|
||||||
- [nginx](https://github.com/chr4/nginx.vim) (syntax, indent, ftplugin)
|
- [nginx](https://github.com/chr4/nginx.vim) (syntax, indent, ftplugin)
|
||||||
- [nim](https://github.com/zah/nim.vim) (syntax, compiler, indent)
|
- [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)
|
- [objc](https://github.com/b4winckler/vim-objc) (ftplugin, syntax, indent)
|
||||||
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
|
- [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin)
|
||||||
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
|
- [octave](https://github.com/vim-scripts/octave.vim--) (syntax)
|
||||||
- [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin)
|
- [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin)
|
||||||
- [openscad](https://github.com/sirtaj/vim-openscad) (syntax, ftplugin)
|
|
||||||
- [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin)
|
- [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin)
|
||||||
- [pgsql](https://github.com/exu/pgsql.vim) (syntax)
|
- [pgsql](https://github.com/exu/pgsql.vim) (syntax)
|
||||||
- [php](https://github.com/StanAngeloff/php.vim) (syntax)
|
- [php](https://github.com/StanAngeloff/php.vim) (syntax)
|
||||||
@@ -121,6 +121,7 @@ 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)
|
- [scala](https://github.com/derekwyatt/vim-scala) (syntax, indent, compiler, ftplugin)
|
||||||
- [scss](https://github.com/cakebaker/scss-syntax.vim) (syntax, autoload, ftplugin)
|
- [scss](https://github.com/cakebaker/scss-syntax.vim) (syntax, autoload, ftplugin)
|
||||||
- [slim](https://github.com/slim-template/vim-slim) (syntax, indent, ftplugin)
|
- [slim](https://github.com/slim-template/vim-slim) (syntax, indent, ftplugin)
|
||||||
|
- [slime](https://github.com/slime-lang/vim-slime-syntax) (syntax, indent)
|
||||||
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
|
||||||
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
|
||||||
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ if !exists('g:terraform_remap_spacebar')
|
|||||||
let g:terraform_remap_spacebar = 0
|
let g:terraform_remap_spacebar = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists('g:terraform_fold_sections')
|
||||||
|
let g:terraform_fold_sections = 0
|
||||||
|
endif
|
||||||
|
|
||||||
if g:terraform_align && exists(':Tabularize')
|
if g:terraform_align && exists(':Tabularize')
|
||||||
inoremap <buffer> <silent> = =<Esc>:call <SID>terraformalign()<CR>a
|
inoremap <buffer> <silent> = =<Esc>:call <SID>terraformalign()<CR>a
|
||||||
function! s:terraformalign()
|
function! s:terraformalign()
|
||||||
@@ -22,36 +26,39 @@ if g:terraform_align && exists(':Tabularize')
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
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()
|
function! TerraformFoldText()
|
||||||
let thisline = getline(v:lnum)
|
let foldsize = (v:foldend-v:foldstart)
|
||||||
if match(thisline, '^resource') >= 0
|
return getline(v:foldstart).' ('.foldsize.' lines)'
|
||||||
return ">1"
|
endfunction
|
||||||
elseif match(thisline, '^provider') >= 0
|
setlocal foldtext=TerraformFoldText()
|
||||||
return ">1"
|
endif
|
||||||
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"
|
|
||||||
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()
|
|
||||||
|
|
||||||
" Re-map the space bar to fold and unfold
|
" Re-map the space bar to fold and unfold
|
||||||
if get(g:, "terraform_remap_spacebar", 1)
|
if get(g:, "terraform_remap_spacebar", 1)
|
||||||
@@ -68,5 +75,4 @@ if get(g:, "terraform_align", 1)
|
|||||||
setlocal shiftwidth=2
|
setlocal shiftwidth=2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ syn region jsxChild contained start=+{+ end=++ contains=jsBlock,javascriptBlock
|
|||||||
" and generic Flow type annotations (http://flowtype.org/).
|
" and generic Flow type annotations (http://flowtype.org/).
|
||||||
syn region jsxRegion
|
syn region jsxRegion
|
||||||
\ contains=@Spell,@XMLSyntax,jsxRegion,jsxChild,jsBlock,javascriptBlock
|
\ 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=+<!--\_.\{-}-->+
|
\ skip=+<!--\_.\{-}-->+
|
||||||
\ end=+</\z1\_\s\{-}>+
|
\ end=+</\z1\_\s\{-}>+
|
||||||
\ end=+/>+
|
\ end=+/>+
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" adds support for cleverref package
|
|
||||||
" \Cref, \cref, \cpageref, \labelcref, \labelcpageref
|
|
||||||
syn region texRefZone matchgroup=texStatement start="\\Cref{" end="}\|%stopzone\>" contains=@texRefGroup
|
|
||||||
syn region texRefZone matchgroup=texStatement start="\\\(label\|\)c\(page\|\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
|
|
||||||
|
|
||||||
" adds support for listings package
|
|
||||||
syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>"
|
|
||||||
syn match texInputFile "\\lstinputlisting\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
|
|
||||||
syn match texZone "\\lstinline\s*\(\[.*\]\)\={.\{-}}"
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -26,7 +26,7 @@ syn match yamlBlock "[\[\]\{\}\|\>]"
|
|||||||
syn region yamlComment start="\#" end="$"
|
syn region yamlComment start="\#" end="$"
|
||||||
syn match yamlIndicator "#YAML:\S\+"
|
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 region yamlString start='"' end='"' skip='\\"' contains=yamlEscape
|
||||||
syn match yamlEscape +\\[abfnrtv'"\\]+ contained
|
syn match yamlEscape +\\[abfnrtv'"\\]+ contained
|
||||||
syn match yamlEscape "\\\o\o\=\o\=" contained
|
syn match yamlEscape "\\\o\o\=\o\=" contained
|
||||||
|
|||||||
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
|
||||||
@@ -152,4 +152,13 @@ function! s:DotPackagesFile() abort
|
|||||||
return [v:false, '']
|
return [v:false, '']
|
||||||
endfunction
|
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
|
endif
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1
|
||||||
|
|
||||||
function! fish#Indent()
|
function! fish#Indent()
|
||||||
|
let l:shiftwidth = shiftwidth()
|
||||||
let l:prevlnum = prevnonblank(v:lnum - 1)
|
let l:prevlnum = prevnonblank(v:lnum - 1)
|
||||||
if l:prevlnum ==# 0
|
if l:prevlnum ==# 0
|
||||||
return 0
|
return 0
|
||||||
@@ -8,15 +9,15 @@ function! fish#Indent()
|
|||||||
let l:indent = 0
|
let l:indent = 0
|
||||||
let l:prevline = getline(l:prevlnum)
|
let l:prevline = getline(l:prevlnum)
|
||||||
if l:prevline =~# '\v^\s*switch>'
|
if l:prevline =~# '\v^\s*switch>'
|
||||||
let l:indent = &shiftwidth * 2
|
let l:indent = l:shiftwidth * 2
|
||||||
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
|
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
|
||||||
let l:indent = &shiftwidth
|
let l:indent = l:shiftwidth
|
||||||
endif
|
endif
|
||||||
let l:line = getline(v:lnum)
|
let l:line = getline(v:lnum)
|
||||||
if l:line =~# '\v^\s*end>'
|
if l:line =~# '\v^\s*end>'
|
||||||
return indent(v:lnum) - (l:indent ==# 0 ? &shiftwidth : l:indent)
|
return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent)
|
||||||
elseif l:line =~# '\v^\s*%(case|else)>'
|
elseif l:line =~# '\v^\s*%(case|else)>'
|
||||||
return indent(v:lnum) - &shiftwidth
|
return indent(v:lnum) - l:shiftwidth
|
||||||
endif
|
endif
|
||||||
return indent(l:prevlnum) + l:indent
|
return indent(l:prevlnum) + l:indent
|
||||||
endfunction
|
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
@@ -583,7 +583,7 @@ let g:xmldata_html5 = {
|
|||||||
\ ],
|
\ ],
|
||||||
\ 'img': [
|
\ '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': [
|
\ 'input': [
|
||||||
\ [],
|
\ [],
|
||||||
|
|||||||
7
build
7
build
@@ -120,6 +120,7 @@ PACKS="
|
|||||||
caddyfile:isobit/vim-caddyfile
|
caddyfile:isobit/vim-caddyfile
|
||||||
cjsx:mtscout6/vim-cjsx
|
cjsx:mtscout6/vim-cjsx
|
||||||
clojure:guns/vim-clojure-static
|
clojure:guns/vim-clojure-static
|
||||||
|
cmake:pboettch/vim-cmake-syntax
|
||||||
coffee-script:kchmck/vim-coffee-script
|
coffee-script:kchmck/vim-coffee-script
|
||||||
cryptol:victoredwardocallaghan/cryptol.vim
|
cryptol:victoredwardocallaghan/cryptol.vim
|
||||||
crystal:rhysd/vim-crystal
|
crystal:rhysd/vim-crystal
|
||||||
@@ -136,7 +137,6 @@ PACKS="
|
|||||||
fsharp:fsharp/vim-fsharp:_BASIC
|
fsharp:fsharp/vim-fsharp:_BASIC
|
||||||
git:tpope/vim-git
|
git:tpope/vim-git
|
||||||
gmpl:maelvalais/gmpl.vim
|
gmpl:maelvalais/gmpl.vim
|
||||||
openscad:sirtaj/vim-openscad
|
|
||||||
glsl:tikhomirov/vim-glsl
|
glsl:tikhomirov/vim-glsl
|
||||||
gnuplot:vim-scripts/gnuplot-syntax-highlighting
|
gnuplot:vim-scripts/gnuplot-syntax-highlighting
|
||||||
go:fatih/vim-go:_BASIC
|
go:fatih/vim-go:_BASIC
|
||||||
@@ -153,7 +153,7 @@ PACKS="
|
|||||||
json:elzr/vim-json
|
json:elzr/vim-json
|
||||||
jst:briancollins/vim-jst
|
jst:briancollins/vim-jst
|
||||||
jsx:mxw/vim-jsx:_ALL
|
jsx:mxw/vim-jsx:_ALL
|
||||||
julia:dcjones/julia-minimalist-vim
|
julia:JuliaEditorSupport/julia-vim
|
||||||
kotlin:udalov/kotlin-vim
|
kotlin:udalov/kotlin-vim
|
||||||
latex:LaTeX-Box-Team/LaTeX-Box
|
latex:LaTeX-Box-Team/LaTeX-Box
|
||||||
less:groenewege/vim-less
|
less:groenewege/vim-less
|
||||||
@@ -165,7 +165,7 @@ PACKS="
|
|||||||
mathematica:rsmenon/vim-mathematica
|
mathematica:rsmenon/vim-mathematica
|
||||||
nginx:chr4/nginx.vim
|
nginx:chr4/nginx.vim
|
||||||
nim:zah/nim.vim:_BASIC
|
nim:zah/nim.vim:_BASIC
|
||||||
nix:spwhitt/vim-nix
|
nix:LnL7/vim-nix
|
||||||
objc:b4winckler/vim-objc
|
objc:b4winckler/vim-objc
|
||||||
ocaml:jrk/vim-ocaml
|
ocaml:jrk/vim-ocaml
|
||||||
octave:vim-scripts/octave.vim--
|
octave:vim-scripts/octave.vim--
|
||||||
@@ -193,6 +193,7 @@ PACKS="
|
|||||||
scala:derekwyatt/vim-scala
|
scala:derekwyatt/vim-scala
|
||||||
scss:cakebaker/scss-syntax.vim
|
scss:cakebaker/scss-syntax.vim
|
||||||
slim:slim-template/vim-slim
|
slim:slim-template/vim-slim
|
||||||
|
slime:slime-lang/vim-slime-syntax
|
||||||
solidity:tomlion/vim-solidity
|
solidity:tomlion/vim-solidity
|
||||||
stylus:wavded/vim-stylus
|
stylus:wavded/vim-stylus
|
||||||
swift:keith/swift.vim
|
swift:keith/swift.vim
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
|
|||||||
"
|
"
|
||||||
" compiler/go.vim: Vim compiler file for Go.
|
" compiler/go.vim: Vim compiler file for Go.
|
||||||
|
|
||||||
if exists("current_compiler")
|
if exists("g:current_compiler")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let current_compiler = "go"
|
let g:current_compiler = "go"
|
||||||
|
|
||||||
if exists(":CompilerSet") != 2
|
if exists(":CompilerSet") != 2
|
||||||
command -nargs=* CompilerSet setlocal <args>
|
command -nargs=* CompilerSet setlocal <args>
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ if !exists('g:vim_json_syntax_conceal')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let g:filetype_euphoria = 'elixir'
|
let g:filetype_euphoria = 'elixir'
|
||||||
|
|
||||||
|
augroup filetypedetect
|
||||||
|
autocmd BufNewFile,BufReadPost *.vb setlocal filetype=vbnet
|
||||||
|
augroup END
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ if !exists('g:vim_json_syntax_conceal')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let g:filetype_euphoria = 'elixir'
|
let g:filetype_euphoria = 'elixir'
|
||||||
|
|
||||||
|
augroup filetypedetect
|
||||||
|
autocmd BufNewFile,BufReadPost *.vb setlocal filetype=vbnet
|
||||||
|
augroup END
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" apiblueprint:sheerun/apiblueprint.vim
|
" apiblueprint:sheerun/apiblueprint.vim
|
||||||
autocmd BufReadPost,BufNewFile *.apib set filetype=apiblueprint
|
autocmd BufReadPost,BufNewFile *.apib set filetype=apiblueprint
|
||||||
@@ -91,6 +95,10 @@ augroup filetypedetect
|
|||||||
autocmd BufNewFile,BufRead *.clj,*.cljs,*.edn,*.cljx,*.cljc,{build,profile}.boot setlocal filetype=clojure
|
autocmd BufNewFile,BufRead *.clj,*.cljs,*.edn,*.cljx,*.cljc,{build,profile}.boot setlocal filetype=clojure
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
augroup filetypedetect
|
||||||
|
" cmake:pboettch/vim-cmake-syntax
|
||||||
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" coffee-script:kchmck/vim-coffee-script
|
" coffee-script:kchmck/vim-coffee-script
|
||||||
" Language: CoffeeScript
|
" Language: CoffeeScript
|
||||||
@@ -295,12 +303,6 @@ augroup filetypedetect
|
|||||||
au BufRead,BufNewFile *.mod set filetype=gmpl
|
au BufRead,BufNewFile *.mod set filetype=gmpl
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
|
||||||
" openscad:sirtaj/vim-openscad
|
|
||||||
au BufRead,BufNewFile *.scad setfiletype openscad
|
|
||||||
an 50.80.265 &Syntax.NO.OpenSCAD :cal SetSyn("openscad")<CR>
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" glsl:tikhomirov/vim-glsl
|
" glsl:tikhomirov/vim-glsl
|
||||||
" Language: OpenGL Shading Language
|
" Language: OpenGL Shading Language
|
||||||
@@ -339,15 +341,18 @@ function! s:gofiletype_post()
|
|||||||
let &g:fileencodings = s:current_fileencodings
|
let &g:fileencodings = s:current_fileencodings
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix
|
augroup vim-go-filetype
|
||||||
au BufRead *.go call s:gofiletype_pre("go")
|
autocmd!
|
||||||
au BufReadPost *.go call s:gofiletype_post()
|
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 BufNewFile *.s setfiletype asm | setlocal fileencoding=utf-8 fileformat=unix
|
||||||
au BufRead *.s call s:gofiletype_pre("asm")
|
au BufRead *.s call s:gofiletype_pre("asm")
|
||||||
au BufReadPost *.s call s:gofiletype_post()
|
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
|
" vim: sw=2 ts=2 et
|
||||||
augroup END
|
augroup END
|
||||||
@@ -390,7 +395,7 @@ augroup filetypedetect
|
|||||||
" i3:PotatoesMaster/i3-vim-syntax
|
" i3:PotatoesMaster/i3-vim-syntax
|
||||||
augroup i3_ftdetect
|
augroup i3_ftdetect
|
||||||
au!
|
au!
|
||||||
au BufRead,BufNewFile *i3/config set ft=i3
|
au BufRead,BufNewFile *i3/config,*sway/config set ft=i3
|
||||||
augroup END
|
augroup END
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
@@ -434,6 +439,7 @@ augroup filetypedetect
|
|||||||
autocmd BufNewFile,BufRead *.json setlocal filetype=json
|
autocmd BufNewFile,BufRead *.json setlocal filetype=json
|
||||||
autocmd BufNewFile,BufRead *.jsonp setlocal filetype=json
|
autocmd BufNewFile,BufRead *.jsonp setlocal filetype=json
|
||||||
autocmd BufNewFile,BufRead *.geojson setlocal filetype=json
|
autocmd BufNewFile,BufRead *.geojson setlocal filetype=json
|
||||||
|
autocmd BufNewFile,BufRead *.template setlocal filetype=json
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
@@ -487,13 +493,28 @@ autocmd BufNewFile,BufRead *.js
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" julia:dcjones/julia-minimalist-vim
|
" julia:JuliaEditorSupport/julia-vim
|
||||||
" NOTE: this line fixes an issue with the default system-wide lisp ftplugin
|
if v:version < 704
|
||||||
" which doesn't define b:undo_ftplugin
|
" NOTE: this line fixes an issue with the default system-wide lisp ftplugin
|
||||||
" (*.jt files are recognized as lisp)
|
" which didn't define b:undo_ftplugin on older Vim versions
|
||||||
au BufRead,BufNewFile *.jl let b:undo_ftplugin = "setlocal comments< define< formatoptions< iskeyword< lisp<"
|
" (*.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 END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
@@ -588,8 +609,14 @@ au BufNewFile,BufRead *.nim,*.nims set filetype=nim
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" nix:spwhitt/vim-nix
|
" nix:LnL7/vim-nix
|
||||||
autocmd BufNewFile,BufRead *.nix setfiletype 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 END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
@@ -919,7 +946,7 @@ fun! s:DetectScala()
|
|||||||
endif
|
endif
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
au BufRead,BufNewFile *.scala set filetype=scala
|
au BufRead,BufNewFile *.scala,*.sc set filetype=scala
|
||||||
au BufRead,BufNewFile * call s:DetectScala()
|
au BufRead,BufNewFile * call s:DetectScala()
|
||||||
|
|
||||||
" Install vim-sbt for additional syntax highlighting.
|
" Install vim-sbt for additional syntax highlighting.
|
||||||
@@ -937,6 +964,11 @@ augroup filetypedetect
|
|||||||
autocmd BufNewFile,BufRead *.slim setfiletype slim
|
autocmd BufNewFile,BufRead *.slim setfiletype slim
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
augroup filetypedetect
|
||||||
|
" slime:slime-lang/vim-slime-syntax
|
||||||
|
autocmd BufNewFile,BufRead *.slime set filetype=slime
|
||||||
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" solidity:tomlion/vim-solidity
|
" solidity:tomlion/vim-solidity
|
||||||
au BufNewFile,BufRead *.sol setf solidity
|
au BufNewFile,BufRead *.sol setf solidity
|
||||||
@@ -1021,8 +1053,8 @@ augroup END
|
|||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
" toml:cespare/vim-toml
|
" toml:cespare/vim-toml
|
||||||
" Rust uses several TOML config files that are not named with .toml.
|
" Go dep and Rust use several TOML config files that are not named with .toml.
|
||||||
autocmd BufNewFile,BufRead *.toml,Cargo.lock,*/.cargo/config set filetype=toml
|
autocmd BufNewFile,BufRead *.toml,Gopkg.lock,Cargo.lock,*/.cargo/config set filetype=toml
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ endif
|
|||||||
" Use the 'man' wrapper function in fish to include fish's man pages.
|
" 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
|
" Have to use a script for this; 'fish -c man' would make the the man page an
|
||||||
" argument to fish instead of man.
|
" 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 =
|
let b:match_words =
|
||||||
\ escape('<%(begin|function|if|switch|while|for)>:<end>', '<>%|)')
|
\ escape('<%(begin|function|if|switch|while|for)>:<end>', '<>%|)')
|
||||||
|
|||||||
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
|
||||||
@@ -1,417 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX Box common functions
|
|
||||||
|
|
||||||
" Error Format {{{
|
|
||||||
" Note: The error formats assume we're using the -file-line-error with
|
|
||||||
" [pdf]latex.
|
|
||||||
" Note: See |errorformat-LaTeX| for more info.
|
|
||||||
|
|
||||||
" Check for options
|
|
||||||
if !exists("g:LatexBox_show_warnings")
|
|
||||||
let g:LatexBox_show_warnings=1
|
|
||||||
endif
|
|
||||||
if !exists("g:LatexBox_ignore_warnings")
|
|
||||||
let g:LatexBox_ignore_warnings =
|
|
||||||
\['Underfull',
|
|
||||||
\ 'Overfull',
|
|
||||||
\ 'specifier changed to']
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Standard error message formats
|
|
||||||
" Note: We consider statements that starts with "!" as errors
|
|
||||||
setlocal efm=%E!\ LaTeX\ %trror:\ %m
|
|
||||||
setlocal efm+=%E%f:%l:\ %m
|
|
||||||
setlocal efm+=%E!\ %m
|
|
||||||
|
|
||||||
" More info for undefined control sequences
|
|
||||||
setlocal efm+=%Z<argument>\ %m
|
|
||||||
|
|
||||||
" More info for some errors
|
|
||||||
setlocal efm+=%Cl.%l\ %m
|
|
||||||
|
|
||||||
" Show or ignore warnings
|
|
||||||
if g:LatexBox_show_warnings
|
|
||||||
" Parse biblatex warnings
|
|
||||||
setlocal efm+=%-C(biblatex)%.%#in\ t%.%#
|
|
||||||
setlocal efm+=%-C(biblatex)%.%#Please\ v%.%#
|
|
||||||
setlocal efm+=%-C(biblatex)%.%#LaTeX\ a%.%#
|
|
||||||
setlocal efm+=%-Z(biblatex)%m
|
|
||||||
|
|
||||||
" Parse hyperref warnings
|
|
||||||
setlocal efm+=%-C(hyperref)%.%#on\ input\ line\ %l.
|
|
||||||
|
|
||||||
for w in g:LatexBox_ignore_warnings
|
|
||||||
let warning = escape(substitute(w, '[\,]', '%\\\\&', 'g'), ' ')
|
|
||||||
exe 'setlocal efm+=%-G%.%#'. warning .'%.%#'
|
|
||||||
endfor
|
|
||||||
setlocal efm+=%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#
|
|
||||||
setlocal efm+=%+W%.%#\ at\ lines\ %l--%*\\d
|
|
||||||
setlocal efm+=%+WLaTeX\ %.%#Warning:\ %m
|
|
||||||
setlocal efm+=%+W%.%#Warning:\ %m
|
|
||||||
else
|
|
||||||
setlocal efm+=%-WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#
|
|
||||||
setlocal efm+=%-W%.%#\ at\ lines\ %l--%*\\d
|
|
||||||
setlocal efm+=%-WLaTeX\ %.%#Warning:\ %m
|
|
||||||
setlocal efm+=%-W%.%#Warning:\ %m
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Push file to file stack
|
|
||||||
setlocal efm+=%+P**%f
|
|
||||||
setlocal efm+=%+P**\"%f\"
|
|
||||||
|
|
||||||
" Ignore unmatched lines
|
|
||||||
setlocal efm+=%-G%.%#
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Vim Windows {{{
|
|
||||||
|
|
||||||
" Type of split, "new" for horiz. "vnew" for vert.
|
|
||||||
if !exists('g:LatexBox_split_type')
|
|
||||||
let g:LatexBox_split_type = "vnew"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Length of vertical splits
|
|
||||||
if !exists('g:LatexBox_split_length')
|
|
||||||
let g:LatexBox_split_length = 15
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Width of horizontal splits
|
|
||||||
if !exists('g:LatexBox_split_width')
|
|
||||||
let g:LatexBox_split_width = 30
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Where splits appear
|
|
||||||
if !exists('g:LatexBox_split_side')
|
|
||||||
let g:LatexBox_split_side = "aboveleft"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Resize when split?
|
|
||||||
if !exists('g:LatexBox_split_resize')
|
|
||||||
let g:LatexBox_split_resize = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Toggle help info
|
|
||||||
if !exists('g:LatexBox_toc_hidehelp')
|
|
||||||
let g:LatexBox_toc_hidehelp = 0
|
|
||||||
endif
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Filename utilities {{{
|
|
||||||
function! LatexBox_GetMainTexFile()
|
|
||||||
|
|
||||||
" 1. check for the b:main_tex_file variable
|
|
||||||
if exists('b:main_tex_file') && filereadable(b:main_tex_file)
|
|
||||||
return b:main_tex_file
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
" 2. scan the first few lines of the file for root = filename
|
|
||||||
for linenum in range(1,5)
|
|
||||||
let linecontents = getline(linenum)
|
|
||||||
if linecontents =~ 'root\s*='
|
|
||||||
" Remove everything but the filename
|
|
||||||
let b:main_tex_file = substitute(linecontents,
|
|
||||||
\ '.*root\s*=\s*', "", "")
|
|
||||||
let b:main_tex_file = substitute(b:main_tex_file, '\s*$', "", "")
|
|
||||||
" Prepend current directory if this isn't an absolute path
|
|
||||||
if b:main_tex_file !~ '^/'
|
|
||||||
let b:main_tex_file = expand('%:p:h') . '/' . b:main_tex_file
|
|
||||||
endif
|
|
||||||
let b:main_tex_file = fnamemodify(b:main_tex_file, ":p")
|
|
||||||
if b:main_tex_file !~ '\.tex$'
|
|
||||||
let b:main_tex_file .= '.tex'
|
|
||||||
endif
|
|
||||||
return b:main_tex_file
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" 3. scan current file for "\begin{document}"
|
|
||||||
if &filetype == 'tex' && search('\m\C\\begin\_\s*{document}', 'nw') != 0
|
|
||||||
return expand('%:p')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 4. use 'main.tex' if it exists in the same directory (and is readable)
|
|
||||||
let s:main_dot_tex_file=expand('%:p:h') . '/main.tex'
|
|
||||||
if filereadable(s:main_dot_tex_file)
|
|
||||||
let b:main_tex_file=s:main_dot_tex_file
|
|
||||||
return b:main_tex_file
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 5. borrow the Vim-Latex-Suite method of finding it
|
|
||||||
if LatexBox_GetMainFileName() != expand('%:p')
|
|
||||||
let b:main_tex_file = LatexBox_GetMainFileName()
|
|
||||||
return b:main_tex_file
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 6. prompt for file with completion
|
|
||||||
let b:main_tex_file = s:PromptForMainFile()
|
|
||||||
return b:main_tex_file
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:PromptForMainFile()
|
|
||||||
let saved_dir = getcwd()
|
|
||||||
execute 'cd ' . fnameescape(expand('%:p:h'))
|
|
||||||
|
|
||||||
" Prompt for file
|
|
||||||
let l:file = ''
|
|
||||||
while !filereadable(l:file)
|
|
||||||
let l:file = input('main LaTeX file: ', '', 'file')
|
|
||||||
if l:file !~ '\.tex$'
|
|
||||||
let l:file .= '.tex'
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
let l:file = fnamemodify(l:file, ':p')
|
|
||||||
|
|
||||||
" Make persistent
|
|
||||||
let l:persistent = ''
|
|
||||||
while l:persistent !~ '\v^(y|n)'
|
|
||||||
let l:persistent = input('make choice persistent? (y, n) ')
|
|
||||||
if l:persistent == 'y'
|
|
||||||
call writefile([], l:file . '.latexmain')
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
execute 'cd ' . fnameescape(saved_dir)
|
|
||||||
return l:file
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Return the directory of the main tex file
|
|
||||||
function! LatexBox_GetTexRoot()
|
|
||||||
return fnamemodify(LatexBox_GetMainTexFile(), ':h')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LatexBox_GetBuildBasename(with_dir)
|
|
||||||
" 1. Check for g:LatexBox_jobname
|
|
||||||
if exists('g:LatexBox_jobname')
|
|
||||||
return g:LatexBox_jobname
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 2. Get the basename from the main tex file
|
|
||||||
if a:with_dir
|
|
||||||
return fnamemodify(LatexBox_GetMainTexFile(), ':r')
|
|
||||||
else
|
|
||||||
return fnamemodify(LatexBox_GetMainTexFile(), ':t:r')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LatexBox_GetAuxFile()
|
|
||||||
" 1. check for b:build_dir variable
|
|
||||||
if exists('b:build_dir') && isdirectory(b:build_dir)
|
|
||||||
return b:build_dir . '/' . LatexBox_GetBuildBasename(0) . '.aux'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 2. check for g:LatexBox_build_dir variable
|
|
||||||
if exists('g:LatexBox_build_dir') && isdirectory(g:LatexBox_build_dir)
|
|
||||||
return g:LatexBox_build_dir . '/' . LatexBox_GetBuildBasename(0) . '.aux'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 3. use the base name of main tex file
|
|
||||||
return LatexBox_GetBuildBasename(1) . '.aux'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LatexBox_GetLogFile()
|
|
||||||
" 1. check for b:build_dir variable
|
|
||||||
if exists('b:build_dir') && isdirectory(b:build_dir)
|
|
||||||
return b:build_dir . '/' . LatexBox_GetBuildBasename(0) . '.log'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 2. check for g:LatexBox_build_dir variable
|
|
||||||
if exists('g:LatexBox_build_dir') && isdirectory(g:LatexBox_build_dir)
|
|
||||||
return g:LatexBox_build_dir . '/' . LatexBox_GetBuildBasename(0) . '.log'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 3. use the base name of main tex file
|
|
||||||
return LatexBox_GetBuildBasename(1) . '.log'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LatexBox_GetOutputFile()
|
|
||||||
" 1. check for b:build_dir variable
|
|
||||||
if exists('b:build_dir') && isdirectory(b:build_dir)
|
|
||||||
return b:build_dir . '/' . LatexBox_GetBuildBasename(0)
|
|
||||||
\ . '.' . g:LatexBox_output_type
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 2. check for g:LatexBox_build_dir variable
|
|
||||||
if exists('g:LatexBox_build_dir') && isdirectory(g:LatexBox_build_dir)
|
|
||||||
return g:LatexBox_build_dir . '/' . LatexBox_GetBuildBasename(0)
|
|
||||||
\ . '.' . g:LatexBox_output_type
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 3. use the base name of main tex file
|
|
||||||
return LatexBox_GetBuildBasename(1) . '.' . g:LatexBox_output_type
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" View Output {{{
|
|
||||||
|
|
||||||
" Default pdf viewer
|
|
||||||
if !exists('g:LatexBox_viewer')
|
|
||||||
" On windows, 'running' a file will open it with the default program
|
|
||||||
let s:viewer = ''
|
|
||||||
if has('unix')
|
|
||||||
" echo -n necessary as uname -s will append \n otherwise
|
|
||||||
let s:uname = system('echo -n $(uname -s)')
|
|
||||||
if s:uname == "Darwin"
|
|
||||||
let s:viewer = 'open'
|
|
||||||
else
|
|
||||||
let s:viewer = 'xdg-open'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let g:LatexBox_viewer = s:viewer
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! LatexBox_View(...)
|
|
||||||
let lvargs = join(a:000, ' ')
|
|
||||||
let outfile = LatexBox_GetOutputFile()
|
|
||||||
if !filereadable(outfile)
|
|
||||||
echomsg fnamemodify(outfile, ':.') . ' is not readable'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let cmd = g:LatexBox_viewer . ' ' . lvargs . ' ' . shellescape(outfile)
|
|
||||||
if has('win32')
|
|
||||||
let cmd = '!start /b ' . cmd . ' >nul'
|
|
||||||
else
|
|
||||||
let cmd = '!' . cmd . ' '
|
|
||||||
if fnamemodify(&shell, ':t') ==# 'fish'
|
|
||||||
let cmd .= ' >/dev/null ^/dev/null &'
|
|
||||||
else
|
|
||||||
let cmd .= ' &>/dev/null &'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
silent execute cmd
|
|
||||||
if !has("gui_running")
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=* LatexView call LatexBox_View('<args>')
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" In Comment {{{
|
|
||||||
|
|
||||||
" LatexBox_InComment([line], [col])
|
|
||||||
" return true if inside comment
|
|
||||||
function! LatexBox_InComment(...)
|
|
||||||
let line = a:0 >= 1 ? a:1 : line('.')
|
|
||||||
let col = a:0 >= 2 ? a:2 : col('.')
|
|
||||||
return synIDattr(synID(line, col, 0), "name") =~# '^texComment'
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Get Current Environment {{{
|
|
||||||
|
|
||||||
" LatexBox_GetCurrentEnvironment([with_pos])
|
|
||||||
" Returns:
|
|
||||||
" - environment
|
|
||||||
" if with_pos is not given
|
|
||||||
" - [envirnoment, lnum_begin, cnum_begin, lnum_end, cnum_end]
|
|
||||||
" if with_pos is nonzero
|
|
||||||
function! LatexBox_GetCurrentEnvironment(...)
|
|
||||||
if a:0 > 0
|
|
||||||
let with_pos = a:1
|
|
||||||
else
|
|
||||||
let with_pos = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
let begin_pat = '\C\\begin\_\s*{[^}]*}\|\\\@<!\\\[\|\\\@<!\\('
|
|
||||||
let end_pat = '\C\\end\_\s*{[^}]*}\|\\\@<!\\\]\|\\\@<!\\)'
|
|
||||||
let saved_pos = getpos('.')
|
|
||||||
|
|
||||||
" move to the left until on a backslash
|
|
||||||
let [bufnum, lnum, cnum, off] = getpos('.')
|
|
||||||
let line = getline(lnum)
|
|
||||||
while cnum > 1 && line[cnum - 1] != '\'
|
|
||||||
let cnum -= 1
|
|
||||||
endwhile
|
|
||||||
call cursor(lnum, cnum)
|
|
||||||
|
|
||||||
" match begin/end pairs but skip comments
|
|
||||||
let flags = 'bnW'
|
|
||||||
if strpart(getline('.'), col('.') - 1) =~ '^\%(' . begin_pat . '\)'
|
|
||||||
let flags .= 'c'
|
|
||||||
endif
|
|
||||||
let [lnum1, cnum1] = searchpairpos(begin_pat, '', end_pat, flags,
|
|
||||||
\ 'LatexBox_InComment()')
|
|
||||||
|
|
||||||
let env = ''
|
|
||||||
|
|
||||||
if lnum1
|
|
||||||
let line = strpart(getline(lnum1), cnum1 - 1)
|
|
||||||
|
|
||||||
if empty(env)
|
|
||||||
let env = matchstr(line, '^\C\\begin\_\s*{\zs[^}]*\ze}')
|
|
||||||
endif
|
|
||||||
if empty(env)
|
|
||||||
let env = matchstr(line, '^\\\[')
|
|
||||||
endif
|
|
||||||
if empty(env)
|
|
||||||
let env = matchstr(line, '^\\(')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if with_pos == 1
|
|
||||||
let flags = 'nW'
|
|
||||||
if !(lnum1 == lnum && cnum1 == cnum)
|
|
||||||
let flags .= 'c'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [lnum2, cnum2] = searchpairpos(begin_pat, '', end_pat, flags,
|
|
||||||
\ 'LatexBox_InComment()')
|
|
||||||
|
|
||||||
call setpos('.', saved_pos)
|
|
||||||
return [env, lnum1, cnum1, lnum2, cnum2]
|
|
||||||
else
|
|
||||||
call setpos('.', saved_pos)
|
|
||||||
return env
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Tex To Tree {{{
|
|
||||||
" stores nested braces in a tree structure
|
|
||||||
function! LatexBox_TexToTree(str)
|
|
||||||
let tree = []
|
|
||||||
let i1 = 0
|
|
||||||
let i2 = -1
|
|
||||||
let depth = 0
|
|
||||||
while i2 < len(a:str)
|
|
||||||
let i2 = match(a:str, '[{}]', i2 + 1)
|
|
||||||
if i2 < 0
|
|
||||||
let i2 = len(a:str)
|
|
||||||
endif
|
|
||||||
if i2 >= len(a:str) || a:str[i2] == '{'
|
|
||||||
if depth == 0
|
|
||||||
let item = substitute(strpart(a:str, i1, i2 - i1),
|
|
||||||
\ '^\s*\|\s*$', '', 'g')
|
|
||||||
if !empty(item)
|
|
||||||
call add(tree, item)
|
|
||||||
endif
|
|
||||||
let i1 = i2 + 1
|
|
||||||
endif
|
|
||||||
let depth += 1
|
|
||||||
else
|
|
||||||
let depth -= 1
|
|
||||||
if depth == 0
|
|
||||||
call add(tree, LatexBox_TexToTree(strpart(a:str, i1, i2 - i1)))
|
|
||||||
let i1 = i2 + 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
return tree
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Tree To Tex {{{
|
|
||||||
function! LatexBox_TreeToTex(tree)
|
|
||||||
if type(a:tree) == type('')
|
|
||||||
return a:tree
|
|
||||||
else
|
|
||||||
return '{' . join(map(a:tree, 'LatexBox_TreeToTex(v:val)'), '') . '}'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,936 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX Box completion
|
|
||||||
|
|
||||||
setlocal omnifunc=LatexBox_Complete
|
|
||||||
|
|
||||||
" <SID> Wrap {{{
|
|
||||||
function! s:GetSID()
|
|
||||||
return matchstr(expand('<sfile>'), '\zs<SNR>\d\+_\ze.*$')
|
|
||||||
endfunction
|
|
||||||
let s:SID = s:GetSID()
|
|
||||||
function! s:SIDWrap(func)
|
|
||||||
return s:SID . a:func
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Completion {{{
|
|
||||||
if !exists('g:LatexBox_completion_close_braces')
|
|
||||||
let g:LatexBox_completion_close_braces = 1
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_bibtex_wild_spaces')
|
|
||||||
let g:LatexBox_bibtex_wild_spaces = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:LatexBox_cite_pattern')
|
|
||||||
let g:LatexBox_cite_pattern = '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{'
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_ref_pattern')
|
|
||||||
let g:LatexBox_ref_pattern = '\C\\v\?\(eq\|page\|[cC]\|labelc\|name\|auto\)\?ref\*\?\_\s*{'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:LatexBox_completion_environments')
|
|
||||||
let g:LatexBox_completion_environments = [
|
|
||||||
\ {'word': 'itemize', 'menu': 'bullet list' },
|
|
||||||
\ {'word': 'enumerate', 'menu': 'numbered list' },
|
|
||||||
\ {'word': 'description', 'menu': 'description' },
|
|
||||||
\ {'word': 'center', 'menu': 'centered text' },
|
|
||||||
\ {'word': 'figure', 'menu': 'floating figure' },
|
|
||||||
\ {'word': 'table', 'menu': 'floating table' },
|
|
||||||
\ {'word': 'equation', 'menu': 'equation (numbered)' },
|
|
||||||
\ {'word': 'align', 'menu': 'aligned equations (numbered)' },
|
|
||||||
\ {'word': 'align*', 'menu': 'aligned equations' },
|
|
||||||
\ {'word': 'document' },
|
|
||||||
\ {'word': 'abstract' },
|
|
||||||
\ ]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:LatexBox_completion_commands')
|
|
||||||
let g:LatexBox_completion_commands = [
|
|
||||||
\ {'word': '\begin{' },
|
|
||||||
\ {'word': '\end{' },
|
|
||||||
\ {'word': '\item' },
|
|
||||||
\ {'word': '\label{' },
|
|
||||||
\ {'word': '\ref{' },
|
|
||||||
\ {'word': '\eqref{eq:' },
|
|
||||||
\ {'word': '\cite{' },
|
|
||||||
\ {'word': '\chapter{' },
|
|
||||||
\ {'word': '\section{' },
|
|
||||||
\ {'word': '\subsection{' },
|
|
||||||
\ {'word': '\subsubsection{' },
|
|
||||||
\ {'word': '\paragraph{' },
|
|
||||||
\ {'word': '\nonumber' },
|
|
||||||
\ {'word': '\bibliography' },
|
|
||||||
\ {'word': '\bibliographystyle' },
|
|
||||||
\ ]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:LatexBox_complete_inlineMath')
|
|
||||||
let g:LatexBox_complete_inlineMath = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:LatexBox_eq_env_patterns')
|
|
||||||
let g:LatexBox_eq_env_patterns = 'equation\|gather\|multiline\|align\|flalign\|alignat\|eqnarray'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
"LatexBox_kpsewhich {{{
|
|
||||||
function! LatexBox_kpsewhich(file)
|
|
||||||
let old_dir = getcwd()
|
|
||||||
execute 'lcd ' . fnameescape(LatexBox_GetTexRoot())
|
|
||||||
let out = system('kpsewhich "' . a:file . '"')
|
|
||||||
|
|
||||||
" If kpsewhich has found something, it returns a non-empty string with a
|
|
||||||
" newline at the end; otherwise the string is empty
|
|
||||||
if len(out)
|
|
||||||
" Remove the trailing newline
|
|
||||||
let out = fnamemodify(out[:-2], ':p')
|
|
||||||
endif
|
|
||||||
|
|
||||||
execute 'lcd ' . fnameescape(old_dir)
|
|
||||||
|
|
||||||
return out
|
|
||||||
endfunction
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Omni Completion {{{
|
|
||||||
|
|
||||||
let s:completion_type = ''
|
|
||||||
|
|
||||||
function! LatexBox_Complete(findstart, base)
|
|
||||||
if a:findstart
|
|
||||||
" return the starting position of the word
|
|
||||||
let line = getline('.')
|
|
||||||
let pos = col('.') - 1
|
|
||||||
while pos > 0 && line[pos - 1] !~ '\\\|{'
|
|
||||||
let pos -= 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let line_start = line[:pos-1]
|
|
||||||
if line_start =~ '\m\C\\begin\_\s*{$'
|
|
||||||
let s:completion_type = 'begin'
|
|
||||||
elseif line_start =~ '\m\C\\end\_\s*{$'
|
|
||||||
let s:completion_type = 'end'
|
|
||||||
elseif line_start =~ '\m' . g:LatexBox_ref_pattern . '$'
|
|
||||||
let s:completion_type = 'ref'
|
|
||||||
elseif line_start =~ '\m' . g:LatexBox_cite_pattern . '$'
|
|
||||||
let s:completion_type = 'bib'
|
|
||||||
" check for multiple citations
|
|
||||||
let pos = col('.') - 1
|
|
||||||
while pos > 0 && line[pos - 1] !~ '{\|,'
|
|
||||||
let pos -= 1
|
|
||||||
endwhile
|
|
||||||
elseif s:LatexBox_complete_inlineMath_or_not()
|
|
||||||
let s:completion_type = 'inlineMath'
|
|
||||||
let pos = s:eq_pos
|
|
||||||
else
|
|
||||||
let s:completion_type = 'command'
|
|
||||||
if line[pos - 1] == '\'
|
|
||||||
let pos -= 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return pos
|
|
||||||
else
|
|
||||||
" return suggestions in an array
|
|
||||||
let suggestions = []
|
|
||||||
|
|
||||||
if s:completion_type == 'begin'
|
|
||||||
" suggest known environments
|
|
||||||
for entry in g:LatexBox_completion_environments
|
|
||||||
if entry.word =~ '^' . escape(a:base, '\')
|
|
||||||
if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^}')
|
|
||||||
" add trailing '}'
|
|
||||||
let entry = copy(entry)
|
|
||||||
let entry.abbr = entry.word
|
|
||||||
let entry.word = entry.word . '}'
|
|
||||||
endif
|
|
||||||
call add(suggestions, entry)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
elseif s:completion_type == 'end'
|
|
||||||
" suggest known environments
|
|
||||||
let env = LatexBox_GetCurrentEnvironment()
|
|
||||||
if env != ''
|
|
||||||
if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^\s*[,}]')
|
|
||||||
call add(suggestions, {'word': env . '}', 'abbr': env})
|
|
||||||
else
|
|
||||||
call add(suggestions, env)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
elseif s:completion_type == 'command'
|
|
||||||
" suggest known commands
|
|
||||||
for entry in g:LatexBox_completion_commands
|
|
||||||
if entry.word =~ '^' . escape(a:base, '\')
|
|
||||||
" do not display trailing '{'
|
|
||||||
if entry.word =~ '{'
|
|
||||||
let entry.abbr = entry.word[0:-2]
|
|
||||||
endif
|
|
||||||
call add(suggestions, entry)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
elseif s:completion_type == 'ref'
|
|
||||||
let suggestions = s:CompleteLabels(a:base)
|
|
||||||
elseif s:completion_type == 'bib'
|
|
||||||
" suggest BibTeX entries
|
|
||||||
let suggestions = LatexBox_BibComplete(a:base)
|
|
||||||
elseif s:completion_type == 'inlineMath'
|
|
||||||
let suggestions = s:LatexBox_inlineMath_completion(a:base)
|
|
||||||
endif
|
|
||||||
if !has('gui_running')
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
return suggestions
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" BibTeX search {{{
|
|
||||||
|
|
||||||
" find the \bibliography{...} commands
|
|
||||||
" the optional argument is the file name to be searched
|
|
||||||
|
|
||||||
function! s:FindBibData(...)
|
|
||||||
if a:0 == 0
|
|
||||||
let file = LatexBox_GetMainTexFile()
|
|
||||||
else
|
|
||||||
let file = a:1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !filereadable(file)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
let lines = readfile(file)
|
|
||||||
let bibdata_list = []
|
|
||||||
|
|
||||||
"
|
|
||||||
" Search for added bibliographies
|
|
||||||
"
|
|
||||||
let bibliography_cmds = [
|
|
||||||
\ '\\bibliography',
|
|
||||||
\ '\\addbibresource',
|
|
||||||
\ '\\addglobalbib',
|
|
||||||
\ '\\addsectionbib',
|
|
||||||
\ ]
|
|
||||||
for cmd in bibliography_cmds
|
|
||||||
let filtered = filter(copy(lines),
|
|
||||||
\ 'v:val =~ ''\C' . cmd . '\s*{[^}]\+}''')
|
|
||||||
let files = map(filtered,
|
|
||||||
\ 'matchstr(v:val, ''\C' . cmd . '\s*{\zs[^}]\+\ze}'')')
|
|
||||||
for file in files
|
|
||||||
let bibdata_list += map(split(file, ','),
|
|
||||||
\ 'fnamemodify(v:val, '':r'')')
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
|
|
||||||
"
|
|
||||||
" Also search included files
|
|
||||||
"
|
|
||||||
for input in filter(lines,
|
|
||||||
\ 'v:val =~ ''\C\\\%(input\|include\)\s*{[^}]\+}''')
|
|
||||||
let bibdata_list += s:FindBibData(LatexBox_kpsewhich(
|
|
||||||
\ matchstr(input,
|
|
||||||
\ '\C\\\%(input\|include\)\s*{\zs[^}]\+\ze}')))
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return bibdata_list
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:bstfile = expand('<sfile>:p:h') . '/vimcomplete'
|
|
||||||
|
|
||||||
function! LatexBox_BibSearch(regexp)
|
|
||||||
let res = []
|
|
||||||
|
|
||||||
" Find data from bib files
|
|
||||||
let bibdata = join(s:FindBibData(), ',')
|
|
||||||
if bibdata != ''
|
|
||||||
|
|
||||||
" write temporary aux file
|
|
||||||
let tmpbase = LatexBox_GetTexRoot() . '/_LatexBox_BibComplete'
|
|
||||||
let auxfile = tmpbase . '.aux'
|
|
||||||
let bblfile = tmpbase . '.bbl'
|
|
||||||
let blgfile = tmpbase . '.blg'
|
|
||||||
|
|
||||||
call writefile(['\citation{*}', '\bibstyle{' . s:bstfile . '}',
|
|
||||||
\ '\bibdata{' . bibdata . '}'], auxfile)
|
|
||||||
|
|
||||||
if has('win32')
|
|
||||||
let l:old_shellslash = &l:shellslash
|
|
||||||
setlocal noshellslash
|
|
||||||
call system('cd ' . shellescape(LatexBox_GetTexRoot()) .
|
|
||||||
\ ' & bibtex -terse '
|
|
||||||
\ . fnamemodify(auxfile, ':t') . ' >nul')
|
|
||||||
let &l:shellslash = l:old_shellslash
|
|
||||||
else
|
|
||||||
call system('cd ' . shellescape(LatexBox_GetTexRoot()) .
|
|
||||||
\ ' ; bibtex -terse '
|
|
||||||
\ . fnamemodify(auxfile, ':t') . ' >/dev/null')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let lines = split(substitute(join(readfile(bblfile), "\n"),
|
|
||||||
\ '\n\n\@!\(\s\=\)\s*\|{\|}', '\1', 'g'), "\n")
|
|
||||||
|
|
||||||
for line in filter(lines, 'v:val =~ a:regexp')
|
|
||||||
let matches = matchlist(line,
|
|
||||||
\ '^\(.*\)||\(.*\)||\(.*\)||\(.*\)||\(.*\)')
|
|
||||||
if !empty(matches) && !empty(matches[1])
|
|
||||||
let s:type_length = max([s:type_length,
|
|
||||||
\ len(matches[2]) + 3])
|
|
||||||
call add(res, {
|
|
||||||
\ 'key': matches[1],
|
|
||||||
\ 'type': matches[2],
|
|
||||||
\ 'author': matches[3],
|
|
||||||
\ 'year': matches[4],
|
|
||||||
\ 'title': matches[5],
|
|
||||||
\ })
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
call delete(auxfile)
|
|
||||||
call delete(bblfile)
|
|
||||||
call delete(blgfile)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Find data from 'thebibliography' environments
|
|
||||||
let lines = readfile(LatexBox_GetMainTexFile())
|
|
||||||
if match(lines, '\C\\begin{thebibliography}') >= 0
|
|
||||||
for line in filter(filter(lines, 'v:val =~ ''\C\\bibitem'''),
|
|
||||||
\ 'v:val =~ a:regexp')
|
|
||||||
let match = matchlist(line, '\\bibitem{\([^}]*\)')[1]
|
|
||||||
call add(res, {
|
|
||||||
\ 'key': match,
|
|
||||||
\ 'type': '',
|
|
||||||
\ 'author': '',
|
|
||||||
\ 'year': '',
|
|
||||||
\ 'title': match,
|
|
||||||
\ })
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
return res
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" BibTeX completion {{{
|
|
||||||
let s:type_length=0
|
|
||||||
function! LatexBox_BibComplete(regexp)
|
|
||||||
|
|
||||||
" treat spaces as '.*' if needed
|
|
||||||
if g:LatexBox_bibtex_wild_spaces
|
|
||||||
"let regexp = substitute(a:regexp, '\s\+', '.*', 'g')
|
|
||||||
let regexp = '.*' . substitute(a:regexp, '\s\+', '\\\&.*', 'g')
|
|
||||||
else
|
|
||||||
let regexp = a:regexp
|
|
||||||
endif
|
|
||||||
|
|
||||||
let res = []
|
|
||||||
let s:type_length = 4
|
|
||||||
for m in LatexBox_BibSearch(regexp)
|
|
||||||
let type = m['type'] == '' ? '[-]' : '[' . m['type'] . '] '
|
|
||||||
let type = printf('%-' . s:type_length . 's', type)
|
|
||||||
let auth = m['author'] == '' ? '' : m['author'][:20] . ' '
|
|
||||||
let auth = substitute(auth, '\~', ' ', 'g')
|
|
||||||
let auth = substitute(auth, ',.*\ze', ' et al. ', '')
|
|
||||||
let year = m['year'] == '' ? '' : '(' . m['year'] . ')'
|
|
||||||
let w = { 'word': m['key'],
|
|
||||||
\ 'abbr': type . auth . year,
|
|
||||||
\ 'menu': m['title'] }
|
|
||||||
|
|
||||||
" close braces if needed
|
|
||||||
if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^\s*[,}]')
|
|
||||||
let w.word = w.word . '}'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(res, w)
|
|
||||||
endfor
|
|
||||||
return res
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" ExtractLabels {{{
|
|
||||||
" Generate list of \newlabel commands in current buffer.
|
|
||||||
"
|
|
||||||
" Searches the current buffer for commands of the form
|
|
||||||
" \newlabel{name}{{number}{page}.*
|
|
||||||
" and returns list of [ name, number, page ] tuples.
|
|
||||||
function! s:ExtractLabels()
|
|
||||||
call cursor(1,1)
|
|
||||||
|
|
||||||
let matches = []
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
|
|
||||||
while [lblline, lblbegin] != [0,0]
|
|
||||||
let [nln, nameend] = searchpairpos( '{', '', '}', 'W' )
|
|
||||||
if nln != lblline
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let curname = strpart( getline( lblline ), lblbegin, nameend - lblbegin - 1 )
|
|
||||||
|
|
||||||
" Ignore cref entries (because they are duplicates)
|
|
||||||
if curname =~# "@cref$"
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
if 0 == search( '\m{\w*{', 'ce', lblline )
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let numberbegin = getpos('.')[2]
|
|
||||||
let [nln, numberend] = searchpairpos( '{', '', '}', 'W' )
|
|
||||||
if nln != lblline
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let curnumber = strpart( getline( lblline ), numberbegin, numberend - numberbegin - 1 )
|
|
||||||
|
|
||||||
if 0 == search( '\m\w*{', 'ce', lblline )
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let pagebegin = getpos('.')[2]
|
|
||||||
let [nln, pageend] = searchpairpos( '{', '', '}', 'W' )
|
|
||||||
if nln != lblline
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let curpage = strpart( getline( lblline ), pagebegin, pageend - pagebegin - 1 )
|
|
||||||
|
|
||||||
let matches += [ [ curname, curnumber, curpage ] ]
|
|
||||||
|
|
||||||
let [lblline, lblbegin] = searchpos( '\\newlabel{', 'ecW' )
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return matches
|
|
||||||
endfunction
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" ExtractInputs {{{
|
|
||||||
" Generate list of \@input commands in current buffer.
|
|
||||||
"
|
|
||||||
" Searches the current buffer for \@input{file} entries and
|
|
||||||
" returns list of all files.
|
|
||||||
function! s:ExtractInputs()
|
|
||||||
call cursor(1,1)
|
|
||||||
|
|
||||||
let matches = []
|
|
||||||
let [inline, inbegin] = searchpos( '\\@input{', 'ecW' )
|
|
||||||
|
|
||||||
while [inline, inbegin] != [0,0]
|
|
||||||
let [nln, inend] = searchpairpos( '{', '', '}', 'W' )
|
|
||||||
if nln != inline
|
|
||||||
let [inline, inbegin] = searchpos( '\\@input{', 'ecW' )
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let matches += [ LatexBox_kpsewhich(strpart( getline( inline ), inbegin, inend - inbegin - 1 )) ]
|
|
||||||
|
|
||||||
let [inline, inbegin] = searchpos( '\\@input{', 'ecW' )
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
" Remove empty strings for nonexistant .aux files
|
|
||||||
return filter(matches, 'v:val != ""')
|
|
||||||
endfunction
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" LabelCache {{{
|
|
||||||
" Cache of all labels.
|
|
||||||
"
|
|
||||||
" LabelCache is a dictionary mapping filenames to tuples
|
|
||||||
" [ time, labels, inputs ]
|
|
||||||
" where
|
|
||||||
" * time is modification time of the cache entry
|
|
||||||
" * labels is a list like returned by ExtractLabels
|
|
||||||
" * inputs is a list like returned by ExtractInputs
|
|
||||||
let s:LabelCache = {}
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" GetLabelCache {{{
|
|
||||||
" Extract labels from LabelCache and update it.
|
|
||||||
"
|
|
||||||
" Compares modification time of each entry in the label
|
|
||||||
" cache and updates it, if necessary. During traversal of
|
|
||||||
" the LabelCache, all current labels are collected and
|
|
||||||
" returned.
|
|
||||||
function! s:GetLabelCache(file)
|
|
||||||
if !filereadable(a:file)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !has_key(s:LabelCache , a:file) || s:LabelCache[a:file][0] != getftime(a:file)
|
|
||||||
" Open file in temporary split window for label extraction.
|
|
||||||
let main_tex_file = LatexBox_GetMainTexFile()
|
|
||||||
silent execute '1sp +let\ b:main_tex_file=main_tex_file|let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . fnameescape(a:file)
|
|
||||||
let s:LabelCache[a:file] = [ getftime(a:file), labels, inputs ]
|
|
||||||
endif
|
|
||||||
|
|
||||||
" We need to create a copy of s:LabelCache[fid][1], otherwise all inputs'
|
|
||||||
" labels would be added to the current file's label cache upon each
|
|
||||||
" completion call, leading to duplicates/triplicates/etc. and decreased
|
|
||||||
" performance.
|
|
||||||
" Also, because we don't anything with the list besides matching copies,
|
|
||||||
" we can get away with a shallow copy for now.
|
|
||||||
let labels = copy(s:LabelCache[a:file][1])
|
|
||||||
|
|
||||||
for input in s:LabelCache[a:file][2]
|
|
||||||
let labels += s:GetLabelCache(input)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return labels
|
|
||||||
endfunction
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Complete Labels {{{
|
|
||||||
function! s:CompleteLabels(regex)
|
|
||||||
let labels = s:GetLabelCache(LatexBox_GetAuxFile())
|
|
||||||
|
|
||||||
let matches = filter( copy(labels), 'match(v:val[0], "' . a:regex . '") != -1' )
|
|
||||||
if empty(matches)
|
|
||||||
" also try to match label and number
|
|
||||||
let regex_split = split(a:regex)
|
|
||||||
if len(regex_split) > 1
|
|
||||||
let base = regex_split[0]
|
|
||||||
let number = escape(join(regex_split[1:], ' '), '.')
|
|
||||||
let matches = filter( copy(labels), 'match(v:val[0], "' . base . '") != -1 && match(v:val[1], "' . number . '") != -1' )
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if empty(matches)
|
|
||||||
" also try to match number
|
|
||||||
let matches = filter( copy(labels), 'match(v:val[1], "' . a:regex . '") != -1' )
|
|
||||||
endif
|
|
||||||
|
|
||||||
let suggestions = []
|
|
||||||
for m in matches
|
|
||||||
let entry = {'word': m[0], 'menu': printf("%7s [p. %s]", '('.m[1].')', m[2])}
|
|
||||||
if g:LatexBox_completion_close_braces && !s:NextCharsMatch('^\s*[,}]')
|
|
||||||
" add trailing '}'
|
|
||||||
let entry = copy(entry)
|
|
||||||
let entry.abbr = entry.word
|
|
||||||
let entry.word = entry.word . '}'
|
|
||||||
endif
|
|
||||||
call add(suggestions, entry)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return suggestions
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Complete Inline Math Or Not {{{
|
|
||||||
" Return 1, when cursor is in a math env:
|
|
||||||
" 1, there is a single $ in the current line on the left of cursor
|
|
||||||
" 2, there is an open-eq-env on/above the current line
|
|
||||||
" (open-eq-env : \(, \[, and \begin{eq-env} )
|
|
||||||
" Return 0, when cursor is not in a math env
|
|
||||||
function! s:LatexBox_complete_inlineMath_or_not()
|
|
||||||
|
|
||||||
" switch of inline math completion feature
|
|
||||||
if g:LatexBox_complete_inlineMath == 0
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" env names that can't appear in an eq env
|
|
||||||
if !exists('s:LatexBox_doc_structure_patterns')
|
|
||||||
let s:LatexBox_doc_structure_patterns = '\%(' . '\\begin\s*{document}\|' .
|
|
||||||
\ '\\\%(chapter\|section\|subsection\|subsubsection\)\*\?\s*{' . '\)'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('s:LatexBox_eq_env_open_patterns')
|
|
||||||
let s:LatexBox_eq_env_open_patterns = ['\\(','\\\[']
|
|
||||||
endif
|
|
||||||
if !exists('s:LatexBox_eq_env_close_patterns')
|
|
||||||
let s:LatexBox_eq_env_close_patterns = ['\\)','\\\]']
|
|
||||||
endif
|
|
||||||
|
|
||||||
let notcomment = '\%(\%(\\\@<!\%(\\\\\)*\)\@<=%.*\)\@<!'
|
|
||||||
|
|
||||||
let lnum_saved = line('.')
|
|
||||||
let cnum_saved = col('.') -1
|
|
||||||
|
|
||||||
let line = getline('.')
|
|
||||||
let line_start_2_cnum_saved = line[:cnum_saved]
|
|
||||||
|
|
||||||
" determine whether there is a single $ before cursor
|
|
||||||
let cursor_dollar_pair = 0
|
|
||||||
while matchend(line_start_2_cnum_saved, '\$[^$]\+\$', cursor_dollar_pair) >= 0
|
|
||||||
" find the end of dollar pair
|
|
||||||
let cursor_dollar_pair = matchend(line_start_2_cnum_saved, '\$[^$]\+\$', cursor_dollar_pair)
|
|
||||||
endwhile
|
|
||||||
" find single $ after cursor_dollar_pair
|
|
||||||
let cursor_single_dollar = matchend(line_start_2_cnum_saved, '\$', cursor_dollar_pair)
|
|
||||||
|
|
||||||
" if single $ is found
|
|
||||||
if cursor_single_dollar >= 0
|
|
||||||
" check whether $ is in \(...\), \[...\], or \begin{eq}...\end{eq}
|
|
||||||
|
|
||||||
" check current line,
|
|
||||||
" search for LatexBox_eq_env_close_patterns: \[ and \(
|
|
||||||
let lnum = line('.')
|
|
||||||
for i in range(0, (len(s:LatexBox_eq_env_open_patterns)-1))
|
|
||||||
call cursor(lnum_saved, cnum_saved)
|
|
||||||
let cnum_close = searchpos(''. s:LatexBox_eq_env_close_patterns[i].'', 'cbW', lnum_saved)[1]
|
|
||||||
let cnum_open = matchend(line_start_2_cnum_saved, s:LatexBox_eq_env_open_patterns[i], cnum_close)
|
|
||||||
if cnum_open >= 0
|
|
||||||
let s:eq_dollar_parenthesis_bracket_empty = ''
|
|
||||||
let s:eq_pos = cursor_single_dollar - 1
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" check the lines above
|
|
||||||
" search for s:LatexBox_doc_structure_patterns, and end-of-math-env
|
|
||||||
let lnum -= 1
|
|
||||||
while lnum > 0
|
|
||||||
let line = getline(lnum)
|
|
||||||
if line =~ notcomment . '\(' . s:LatexBox_doc_structure_patterns .
|
|
||||||
\ '\|' . '\\end\s*{\(' . g:LatexBox_eq_env_patterns . '\)\*\?}\)'
|
|
||||||
" when s:LatexBox_doc_structure_patterns or g:LatexBox_eq_env_patterns
|
|
||||||
" are found first, complete math, leave with $ at both sides
|
|
||||||
let s:eq_dollar_parenthesis_bracket_empty = '$'
|
|
||||||
let s:eq_pos = cursor_single_dollar
|
|
||||||
break
|
|
||||||
elseif line =~ notcomment . '\\begin\s*{\(' . g:LatexBox_eq_env_patterns . '\)\*\?}'
|
|
||||||
" g:LatexBox_eq_env_patterns is found, complete math, remove $
|
|
||||||
let s:eq_dollar_parenthesis_bracket_empty = ''
|
|
||||||
let s:eq_pos = cursor_single_dollar - 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let lnum -= 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
" no $ is found, then search for \( or \[ in current line
|
|
||||||
" 1, whether there is \(
|
|
||||||
call cursor(lnum_saved, cnum_saved)
|
|
||||||
let cnum_parenthesis_close = searchpos('\\)', 'cbW', lnum_saved)[1]
|
|
||||||
let cnum_parenthesis_open = matchend(line_start_2_cnum_saved, '\\(', cnum_parenthesis_close)
|
|
||||||
if cnum_parenthesis_open >= 0
|
|
||||||
let s:eq_dollar_parenthesis_bracket_empty = '\)'
|
|
||||||
let s:eq_pos = cnum_parenthesis_open
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
" 2, whether there is \[
|
|
||||||
call cursor(lnum_saved, cnum_saved)
|
|
||||||
let cnum_bracket_close = searchpos('\\\]', 'cbW', lnum_saved)[1]
|
|
||||||
let cnum_bracket_open = matchend(line_start_2_cnum_saved, '\\\[', cnum_bracket_close)
|
|
||||||
if cnum_bracket_open >= 0
|
|
||||||
let s:eq_dollar_parenthesis_bracket_empty = '\]'
|
|
||||||
let s:eq_pos = cnum_bracket_open
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
" not inline math completion
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Complete inline euqation{{{
|
|
||||||
function! s:LatexBox_inlineMath_completion(regex, ...)
|
|
||||||
|
|
||||||
if a:0 == 0
|
|
||||||
let file = LatexBox_GetMainTexFile()
|
|
||||||
else
|
|
||||||
let file = a:1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if empty(glob(file, 1))
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
if empty(s:eq_dollar_parenthesis_bracket_empty)
|
|
||||||
let inline_pattern1 = '\$\s*\(' . escape(substitute(a:regex[1:], '^\s\+', '', ""), '\.*^') . '[^$]*\)\s*\$'
|
|
||||||
let inline_pattern2 = '\\(\s*\(' . escape(substitute(a:regex[1:], '^\s\+', '', ""), '\.*^') . '.*\)\s*\\)'
|
|
||||||
else
|
|
||||||
let inline_pattern1 = '\$\s*\(' . escape(substitute(a:regex, '^\s\+', '', ""), '\.*^') . '[^$]*\)\s*\$'
|
|
||||||
let inline_pattern2 = '\\(\s*\(' . escape(substitute(a:regex, '^\s\+', '', ""), '\.*^') . '.*\)\s*\\)'
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
let suggestions = []
|
|
||||||
let line_num = 0
|
|
||||||
for line in readfile(file)
|
|
||||||
let line_num = line_num + 1
|
|
||||||
|
|
||||||
let suggestions += s:LatexBox_inlineMath_mathlist(line,inline_pattern1 , line_num) + s:LatexBox_inlineMath_mathlist( line,inline_pattern2, line_num)
|
|
||||||
|
|
||||||
" search for included files
|
|
||||||
let included_file = matchstr(line, '^\\@input{\zs[^}]*\ze}')
|
|
||||||
if included_file != ''
|
|
||||||
let included_file = LatexBox_kpsewhich(included_file)
|
|
||||||
call extend(suggestions, s:LatexBox_inlineMath_completion(a:regex, included_file))
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return suggestions
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Search for inline maths {{{
|
|
||||||
" search for $ ... $ and \( ... \) in each line
|
|
||||||
function! s:LatexBox_inlineMath_mathlist(line,inline_pattern, line_num)
|
|
||||||
let col_start = 0
|
|
||||||
let suggestions = []
|
|
||||||
while 1
|
|
||||||
let matches = matchlist(a:line, a:inline_pattern, col_start)
|
|
||||||
if !empty(matches)
|
|
||||||
|
|
||||||
" show line number of inline math
|
|
||||||
let entry = {'word': matches[1], 'menu': '[' . a:line_num . ']'}
|
|
||||||
|
|
||||||
if s:eq_dollar_parenthesis_bracket_empty != ''
|
|
||||||
let entry = copy(entry)
|
|
||||||
let entry.abbr = entry.word
|
|
||||||
let entry.word = entry.word . s:eq_dollar_parenthesis_bracket_empty
|
|
||||||
endif
|
|
||||||
call add(suggestions, entry)
|
|
||||||
|
|
||||||
" update col_start
|
|
||||||
let col_start = matchend(a:line, a:inline_pattern, col_start)
|
|
||||||
else
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return suggestions
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Close Current Environment {{{
|
|
||||||
function! s:CloseCurEnv()
|
|
||||||
" first, try with \left/\right pairs
|
|
||||||
let [lnum, cnum] = searchpairpos('\C\\left\>', '', '\C\\right\>', 'bnW', 'LatexBox_InComment()')
|
|
||||||
if lnum
|
|
||||||
let line = strpart(getline(lnum), cnum - 1)
|
|
||||||
let bracket = matchstr(line, '^\\left\zs\((\|\[\|\\{\||\|\.\)\ze')
|
|
||||||
for [open, close] in [['(', ')'], ['\[', '\]'], ['\\{', '\\}'], ['|', '|'], ['\.', '|']]
|
|
||||||
let bracket = substitute(bracket, open, close, 'g')
|
|
||||||
endfor
|
|
||||||
return '\right' . bracket
|
|
||||||
endif
|
|
||||||
|
|
||||||
" second, try with environments
|
|
||||||
let env = LatexBox_GetCurrentEnvironment()
|
|
||||||
if env == '\['
|
|
||||||
return '\]'
|
|
||||||
elseif env == '\('
|
|
||||||
return '\)'
|
|
||||||
elseif env != ''
|
|
||||||
return '\end{' . env . '}'
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Wrap Selection {{{
|
|
||||||
function! s:WrapSelection(wrapper)
|
|
||||||
keepjumps normal! `>a}
|
|
||||||
execute 'keepjumps normal! `<i\' . a:wrapper . '{'
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Wrap Selection in Environment with Prompt {{{
|
|
||||||
function! s:PromptEnvWrapSelection(...)
|
|
||||||
let env = input('environment: ', '', 'customlist,' . s:SIDWrap('GetEnvironmentList'))
|
|
||||||
if empty(env)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" LaTeXBox's custom indentation can interfere with environment
|
|
||||||
" insertion when environments are indented (common for nested
|
|
||||||
" environments). Temporarily disable it for this operation:
|
|
||||||
let ieOld = &indentexpr
|
|
||||||
setlocal indentexpr=""
|
|
||||||
if visualmode() ==# 'V'
|
|
||||||
execute 'keepjumps normal! `>o\end{' . env . '}'
|
|
||||||
execute 'keepjumps normal! `<O\begin{' . env . '}'
|
|
||||||
" indent and format, if requested.
|
|
||||||
if a:0 && a:1
|
|
||||||
normal! gv>
|
|
||||||
normal! gvgq
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
execute 'keepjumps normal! `>a\end{' . env . '}'
|
|
||||||
execute 'keepjumps normal! `<i\begin{' . env . '}'
|
|
||||||
endif
|
|
||||||
exe "setlocal indentexpr=" . ieOld
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" List Labels with Prompt {{{
|
|
||||||
function! s:PromptLabelList(...)
|
|
||||||
" Check if window already exists
|
|
||||||
let winnr = bufwinnr(bufnr('LaTeX Labels'))
|
|
||||||
if winnr >= 0
|
|
||||||
if a:0 == 0
|
|
||||||
silent execute winnr . 'wincmd w'
|
|
||||||
else
|
|
||||||
" Supplying an argument to this function causes toggling instead
|
|
||||||
" of jumping to the labels window
|
|
||||||
if g:LatexBox_split_resize
|
|
||||||
silent exe "set columns-=" . g:LatexBox_split_width
|
|
||||||
endif
|
|
||||||
silent execute 'bwipeout' . bufnr('LaTeX Labels')
|
|
||||||
endif
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Get label suggestions
|
|
||||||
let regexp = input('filter labels with regexp: ', '')
|
|
||||||
let labels = s:CompleteLabels(regexp)
|
|
||||||
|
|
||||||
let calling_buf = bufnr('%')
|
|
||||||
|
|
||||||
" Create labels window and set local settings
|
|
||||||
if g:LatexBox_split_resize
|
|
||||||
silent exe "set columns+=" . g:LatexBox_split_width
|
|
||||||
endif
|
|
||||||
silent exe g:LatexBox_split_side g:LatexBox_split_width . 'vnew LaTeX\ Labels'
|
|
||||||
let b:toc = []
|
|
||||||
let b:toc_numbers = 1
|
|
||||||
let b:calling_win = bufwinnr(calling_buf)
|
|
||||||
setlocal filetype=latextoc
|
|
||||||
|
|
||||||
" Add label entries and jump to the closest section
|
|
||||||
for entry in labels
|
|
||||||
let number = matchstr(entry['menu'], '^\s*(\zs[^)]\+\ze)')
|
|
||||||
let page = matchstr(entry['menu'], '^[^)]*)\s*\[\zs[^]]\+\ze\]')
|
|
||||||
let e = {'file': bufname(calling_buf),
|
|
||||||
\ 'level': 'label',
|
|
||||||
\ 'number': number,
|
|
||||||
\ 'text': entry['abbr'],
|
|
||||||
\ 'page': page}
|
|
||||||
call add(b:toc, e)
|
|
||||||
if b:toc_numbers
|
|
||||||
call append('$', e['number'] . "\t" . e['text'])
|
|
||||||
else
|
|
||||||
call append('$', e['text'])
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
if !g:LatexBox_toc_hidehelp
|
|
||||||
call append('$', "")
|
|
||||||
call append('$', "<Esc>/q: close")
|
|
||||||
call append('$', "<Space>: jump")
|
|
||||||
call append('$', "<Enter>: jump and close")
|
|
||||||
call append('$', "s: hide numbering")
|
|
||||||
endif
|
|
||||||
0delete _
|
|
||||||
|
|
||||||
" Lock buffer
|
|
||||||
setlocal nomodifiable
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Change Environment {{{
|
|
||||||
function! s:ChangeEnvPrompt()
|
|
||||||
|
|
||||||
let [env, lnum, cnum, lnum2, cnum2] = LatexBox_GetCurrentEnvironment(1)
|
|
||||||
|
|
||||||
let new_env = input('change ' . env . ' for: ', '', 'customlist,' . s:SIDWrap('GetEnvironmentList'))
|
|
||||||
if empty(new_env)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if new_env == '\[' || new_env == '['
|
|
||||||
let begin = '\['
|
|
||||||
let end = '\]'
|
|
||||||
elseif new_env == '\(' || new_env == '('
|
|
||||||
let begin = '\('
|
|
||||||
let end = '\)'
|
|
||||||
else
|
|
||||||
let l:begin = '\begin{' . new_env . '}'
|
|
||||||
let l:end = '\end{' . new_env . '}'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if env == '\[' || env == '\('
|
|
||||||
let line = getline(lnum2)
|
|
||||||
let line = strpart(line, 0, cnum2 - 1) . l:end . strpart(line, cnum2 + 1)
|
|
||||||
call setline(lnum2, line)
|
|
||||||
|
|
||||||
let line = getline(lnum)
|
|
||||||
let line = strpart(line, 0, cnum - 1) . l:begin . strpart(line, cnum + 1)
|
|
||||||
call setline(lnum, line)
|
|
||||||
else
|
|
||||||
let line = getline(lnum2)
|
|
||||||
let line = strpart(line, 0, cnum2 - 1) . l:end . strpart(line, cnum2 + len(env) + 5)
|
|
||||||
call setline(lnum2, line)
|
|
||||||
|
|
||||||
let line = getline(lnum)
|
|
||||||
let line = strpart(line, 0, cnum - 1) . l:begin . strpart(line, cnum + len(env) + 7)
|
|
||||||
call setline(lnum, line)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:GetEnvironmentList(lead, cmdline, pos)
|
|
||||||
let suggestions = []
|
|
||||||
for entry in g:LatexBox_completion_environments
|
|
||||||
let env = entry.word
|
|
||||||
if env =~ '^' . a:lead
|
|
||||||
call add(suggestions, env)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return suggestions
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:LatexToggleStarEnv()
|
|
||||||
let [env, lnum, cnum, lnum2, cnum2] = LatexBox_GetCurrentEnvironment(1)
|
|
||||||
|
|
||||||
if env == '\('
|
|
||||||
return
|
|
||||||
elseif env == '\['
|
|
||||||
let begin = '\begin{equation}'
|
|
||||||
let end = '\end{equation}'
|
|
||||||
elseif env[-1:] == '*'
|
|
||||||
let begin = '\begin{' . env[:-2] . '}'
|
|
||||||
let end = '\end{' . env[:-2] . '}'
|
|
||||||
else
|
|
||||||
let begin = '\begin{' . env . '*}'
|
|
||||||
let end = '\end{' . env . '*}'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if env == '\['
|
|
||||||
let line = getline(lnum2)
|
|
||||||
let line = strpart(line, 0, cnum2 - 1) . l:end . strpart(line, cnum2 + 1)
|
|
||||||
call setline(lnum2, line)
|
|
||||||
|
|
||||||
let line = getline(lnum)
|
|
||||||
let line = strpart(line, 0, cnum - 1) . l:begin . strpart(line, cnum + 1)
|
|
||||||
call setline(lnum, line)
|
|
||||||
else
|
|
||||||
let line = getline(lnum2)
|
|
||||||
let line = strpart(line, 0, cnum2 - 1) . l:end . strpart(line, cnum2 + len(env) + 5)
|
|
||||||
call setline(lnum2, line)
|
|
||||||
|
|
||||||
let line = getline(lnum)
|
|
||||||
let line = strpart(line, 0, cnum - 1) . l:begin . strpart(line, cnum + len(env) + 7)
|
|
||||||
call setline(lnum, line)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Next Charaters Match {{{
|
|
||||||
function! s:NextCharsMatch(regex)
|
|
||||||
let rest_of_line = strpart(getline('.'), col('.') - 1)
|
|
||||||
return rest_of_line =~ a:regex
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Mappings {{{
|
|
||||||
inoremap <silent> <Plug>LatexCloseCurEnv <C-R>=<SID>CloseCurEnv()<CR>
|
|
||||||
vnoremap <silent> <Plug>LatexWrapSelection :<c-u>call <SID>WrapSelection('')<CR>i
|
|
||||||
vnoremap <silent> <Plug>LatexEnvWrapSelection :<c-u>call <SID>PromptEnvWrapSelection()<CR>
|
|
||||||
vnoremap <silent> <Plug>LatexEnvWrapFmtSelection :<c-u>call <SID>PromptEnvWrapSelection(1)<CR>
|
|
||||||
nnoremap <silent> <Plug>LatexChangeEnv :call <SID>ChangeEnvPrompt()<CR>
|
|
||||||
nnoremap <silent> <Plug>LatexToggleStarEnv :call <SID>LatexToggleStarEnv()<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Commands {{{
|
|
||||||
command! LatexLabels call <SID>PromptLabelList()
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LatexBox_GetMainFileName: gets the name of the main file being compiled. {{{
|
|
||||||
" Description: returns the full path name of the main file.
|
|
||||||
" This function checks for the existence of a .latexmain file
|
|
||||||
" which might point to the location of a "main" latex file.
|
|
||||||
" If .latexmain exists, then return the full path name of the
|
|
||||||
" file being pointed to by it.
|
|
||||||
"
|
|
||||||
" Otherwise, return the full path name of the current buffer.
|
|
||||||
"
|
|
||||||
" You can supply an optional "modifier" argument to the
|
|
||||||
" function, which will optionally modify the file name before
|
|
||||||
" returning.
|
|
||||||
" NOTE: From version 1.6 onwards, this function always trims
|
|
||||||
" away the .latexmain part of the file name before applying the
|
|
||||||
" modifier argument.
|
|
||||||
" NOTE: This function is copied from the Latex-Suite project!
|
|
||||||
function! LatexBox_GetMainFileName(...)
|
|
||||||
if a:0 > 0
|
|
||||||
let modifier = a:1
|
|
||||||
else
|
|
||||||
let modifier = ':p'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:origdir = fnameescape(getcwd())
|
|
||||||
|
|
||||||
let dirmodifier = '%:p:h'
|
|
||||||
let dirLast = fnameescape(expand(dirmodifier))
|
|
||||||
exe 'cd '.dirLast
|
|
||||||
|
|
||||||
" move up the directory tree until we find a .latexmain file.
|
|
||||||
" TODO: Should we be doing this recursion by default, or should there be a
|
|
||||||
" setting?
|
|
||||||
while glob('*.latexmain',1) == ''
|
|
||||||
let dirmodifier = dirmodifier.':h'
|
|
||||||
let dirNew = fnameescape(expand(dirmodifier))
|
|
||||||
" break from the loop if we cannot go up any further.
|
|
||||||
if dirNew == dirLast
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let dirLast = dirNew
|
|
||||||
exe 'cd '.dirLast
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let lheadfile = glob('*.latexmain',1)
|
|
||||||
if lheadfile != ''
|
|
||||||
" Remove the trailing .latexmain part of the filename... We never want
|
|
||||||
" that.
|
|
||||||
let lheadfile = fnamemodify(substitute(lheadfile, '\.latexmain$', '', ''), modifier)
|
|
||||||
else
|
|
||||||
" If we cannot find any main file, just modify the filename of the
|
|
||||||
" current buffer.
|
|
||||||
let lheadfile = expand('%'.modifier)
|
|
||||||
endif
|
|
||||||
|
|
||||||
exe 'cd '.s:origdir
|
|
||||||
|
|
||||||
" NOTE: The caller of this function needs to escape the file name with
|
|
||||||
" fnameescape() . The reason its not done here is that escaping is not
|
|
||||||
" safe if this file is to be used as part of an external command on
|
|
||||||
" certain platforms.
|
|
||||||
return lheadfile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,382 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" Folding support for LaTeX
|
|
||||||
|
|
||||||
"
|
|
||||||
" Options
|
|
||||||
" g:LatexBox_Folding - Turn on/off folding
|
|
||||||
" g:LatexBox_fold_text - Turn on/off LatexBox fold text function
|
|
||||||
" g:LatexBox_fold_preamble - Turn on/off folding of preamble
|
|
||||||
" g:LatexBox_fold_parts - Define parts (eq. appendix, frontmatter) to fold
|
|
||||||
" g:LatexBox_fold_sections - Define section levels to fold
|
|
||||||
" g:LatexBox_fold_envs - Turn on/off folding of environments
|
|
||||||
" g:LatexBox_fold_toc - Turn on/off folding of TOC
|
|
||||||
" g:LatexBox_fold_toc_levels - Set max TOC fold level
|
|
||||||
"
|
|
||||||
" {{{1 Initialize options to default values.
|
|
||||||
if !exists('g:LatexBox_Folding')
|
|
||||||
let g:LatexBox_Folding=0
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_text')
|
|
||||||
let g:LatexBox_fold_text=1
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_preamble')
|
|
||||||
let g:LatexBox_fold_preamble=1
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_envs')
|
|
||||||
let g:LatexBox_fold_envs=1
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_envs_force')
|
|
||||||
let g:LatexBox_fold_envs_force = []
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_parts')
|
|
||||||
let g:LatexBox_fold_parts=[
|
|
||||||
\ "appendix",
|
|
||||||
\ "frontmatter",
|
|
||||||
\ "mainmatter",
|
|
||||||
\ "backmatter"
|
|
||||||
\ ]
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_sections')
|
|
||||||
let g:LatexBox_fold_sections=[
|
|
||||||
\ "part",
|
|
||||||
\ "chapter",
|
|
||||||
\ "section",
|
|
||||||
\ "subsection",
|
|
||||||
\ "subsubsection"
|
|
||||||
\ ]
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_toc')
|
|
||||||
let g:LatexBox_fold_toc=0
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_toc_levels')
|
|
||||||
let g:LatexBox_fold_toc_levels=1
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_fold_automatic')
|
|
||||||
let g:LatexBox_fold_automatic=1
|
|
||||||
endif
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
if g:LatexBox_Folding == 0
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" {{{1 Set folding options for vim
|
|
||||||
setl foldexpr=LatexBox_FoldLevel(v:lnum)
|
|
||||||
if g:LatexBox_fold_text == 1
|
|
||||||
setl foldtext=LatexBox_FoldText()
|
|
||||||
endif
|
|
||||||
if g:LatexBox_fold_automatic == 1
|
|
||||||
setl foldmethod=expr
|
|
||||||
|
|
||||||
"
|
|
||||||
" The foldexpr function returns "=" for most lines, which means it can become
|
|
||||||
" slow for large files. The following is a hack that is based on this reply to
|
|
||||||
" a discussion on the Vim Developer list:
|
|
||||||
" http://permalink.gmane.org/gmane.editors.vim.devel/14100
|
|
||||||
"
|
|
||||||
augroup FastFold
|
|
||||||
autocmd!
|
|
||||||
autocmd InsertEnter *.tex if !&diff | setlocal foldmethod=manual | endif
|
|
||||||
autocmd InsertLeave *.tex if !&diff | setlocal foldmethod=expr | endif
|
|
||||||
augroup end
|
|
||||||
else
|
|
||||||
setl foldmethod=manual
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! LatexBox_FoldOnDemand()
|
|
||||||
setl foldmethod=expr
|
|
||||||
normal! zx
|
|
||||||
setl foldmethod=manual
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! LatexFold call LatexBox_FoldOnDemand()
|
|
||||||
|
|
||||||
" {{{1 LatexBox_FoldLevel help functions
|
|
||||||
|
|
||||||
" This function parses the tex file to find the sections that are to be folded
|
|
||||||
" and their levels, and then predefines the patterns for optimized folding.
|
|
||||||
function! s:FoldSectionLevels()
|
|
||||||
" Initialize
|
|
||||||
let level = 1
|
|
||||||
let foldsections = []
|
|
||||||
|
|
||||||
" If we use two or more of the *matter commands, we need one more foldlevel
|
|
||||||
let nparts = 0
|
|
||||||
for part in g:LatexBox_fold_parts
|
|
||||||
let i = 1
|
|
||||||
while i < line("$")
|
|
||||||
if getline(i) =~ '^\s*\\' . part . '\>'
|
|
||||||
let nparts += 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
if nparts > 1
|
|
||||||
let level = 2
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Combine sections and levels, but ignore unused section commands: If we
|
|
||||||
" don't use the part command, then chapter should have the highest
|
|
||||||
" level. If we don't use the chapter command, then section should be the
|
|
||||||
" highest level. And so on.
|
|
||||||
let ignore = 1
|
|
||||||
for part in g:LatexBox_fold_sections
|
|
||||||
" For each part, check if it is used in the file. We start adding the
|
|
||||||
" part patterns to the fold sections array whenever we find one.
|
|
||||||
let partpattern = '^\s*\(\\\|% Fake\)' . part . '\>'
|
|
||||||
if ignore
|
|
||||||
let i = 1
|
|
||||||
while i < line("$")
|
|
||||||
if getline(i) =~# partpattern
|
|
||||||
call insert(foldsections, [partpattern, level])
|
|
||||||
let level += 1
|
|
||||||
let ignore = 0
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
else
|
|
||||||
call insert(foldsections, [partpattern, level])
|
|
||||||
let level += 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return foldsections
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{1 LatexBox_FoldLevel
|
|
||||||
|
|
||||||
" Parse file to dynamically set the sectioning fold levels
|
|
||||||
let b:LatexBox_FoldSections = s:FoldSectionLevels()
|
|
||||||
|
|
||||||
" Optimize by predefine common patterns
|
|
||||||
let s:notbslash = '\%(\\\@<!\%(\\\\\)*\)\@<='
|
|
||||||
let s:notcomment = '\%(\%(\\\@<!\%(\\\\\)*\)\@<=%.*\)\@<!'
|
|
||||||
let s:envbeginpattern = s:notcomment . s:notbslash . '\\begin\s*{.\{-}}'
|
|
||||||
let s:envendpattern = s:notcomment . s:notbslash . '\\end\s*{.\{-}}'
|
|
||||||
let s:foldparts = '^\s*\\\%(' . join(g:LatexBox_fold_parts, '\|') . '\)'
|
|
||||||
let s:folded = '\(% Fake\|\\\(document\|begin\|end\|paragraph\|'
|
|
||||||
\ . 'front\|main\|back\|app\|sub\|section\|chapter\|part\)\)'
|
|
||||||
|
|
||||||
function! LatexBox_FoldLevel(lnum)
|
|
||||||
" Check for normal lines first (optimization)
|
|
||||||
let line = getline(a:lnum)
|
|
||||||
if line !~ s:folded
|
|
||||||
return "="
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fold preamble
|
|
||||||
if g:LatexBox_fold_preamble == 1
|
|
||||||
if line =~# s:notcomment . s:notbslash . '\s*\\documentclass'
|
|
||||||
return ">1"
|
|
||||||
elseif line =~# s:notcomment . s:notbslash . '\s*\\begin\s*{\s*document\s*}'
|
|
||||||
return "0"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fold parts (\frontmatter, \mainmatter, \backmatter, and \appendix)
|
|
||||||
if line =~# s:foldparts
|
|
||||||
return ">1"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fold chapters and sections
|
|
||||||
for [part, level] in b:LatexBox_FoldSections
|
|
||||||
if line =~# part
|
|
||||||
return ">" . level
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Never fold \end{document}
|
|
||||||
if line =~# '^\s*\\end{document}'
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fold environments
|
|
||||||
if line =~# s:envbeginpattern && line =~# s:envendpattern
|
|
||||||
" If the begin and end pattern are on the same line , do not fold
|
|
||||||
return "="
|
|
||||||
else
|
|
||||||
if line =~# s:envbeginpattern
|
|
||||||
if g:LatexBox_fold_envs == 1
|
|
||||||
return "a1"
|
|
||||||
else
|
|
||||||
let env = matchstr(line,'\\begin\*\?{\zs\w*\*\?\ze}')
|
|
||||||
if index(g:LatexBox_fold_envs_force, env) >= 0
|
|
||||||
return "a1"
|
|
||||||
else
|
|
||||||
return "="
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
elseif line =~# s:envendpattern
|
|
||||||
if g:LatexBox_fold_envs == 1
|
|
||||||
return "s1"
|
|
||||||
else
|
|
||||||
let env = matchstr(line,'\\end\*\?{\zs\w*\*\?\ze}')
|
|
||||||
if index(g:LatexBox_fold_envs_force, env) >= 0
|
|
||||||
return "s1"
|
|
||||||
else
|
|
||||||
return "="
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Return foldlevel of previous line
|
|
||||||
return "="
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{1 LatexBox_FoldText help functions
|
|
||||||
function! s:LabelEnv()
|
|
||||||
let i = v:foldend
|
|
||||||
while i >= v:foldstart
|
|
||||||
if getline(i) =~ '^\s*\\label'
|
|
||||||
return matchstr(getline(i), '^\s*\\label{\zs.*\ze}')
|
|
||||||
end
|
|
||||||
let i -= 1
|
|
||||||
endwhile
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:CaptionEnv()
|
|
||||||
let i = v:foldend
|
|
||||||
while i >= v:foldstart
|
|
||||||
if getline(i) =~ '^\s*\\caption'
|
|
||||||
return matchstr(getline(i), '^\s*\\caption\(\[.*\]\)\?{\zs.\+')
|
|
||||||
end
|
|
||||||
let i -= 1
|
|
||||||
endwhile
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:CaptionTable()
|
|
||||||
let i = v:foldstart
|
|
||||||
while i <= v:foldend
|
|
||||||
if getline(i) =~ '^\s*\\caption'
|
|
||||||
return matchstr(getline(i), '^\s*\\caption\(\[.*\]\)\?{\zs.\+')
|
|
||||||
end
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
return ""
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:CaptionFrame(line)
|
|
||||||
" Test simple variants first
|
|
||||||
let caption1 = matchstr(a:line,'\\begin\*\?{.*}{\zs.\+\ze}')
|
|
||||||
let caption2 = matchstr(a:line,'\\begin\*\?{.*}{\zs.\+')
|
|
||||||
|
|
||||||
if len(caption1) > 0
|
|
||||||
return caption1
|
|
||||||
elseif len(caption2) > 0
|
|
||||||
return caption2
|
|
||||||
else
|
|
||||||
let i = v:foldstart
|
|
||||||
while i <= v:foldend
|
|
||||||
if getline(i) =~ '^\s*\\frametitle'
|
|
||||||
return matchstr(getline(i),
|
|
||||||
\ '^\s*\\frametitle\(\[.*\]\)\?{\zs.\+')
|
|
||||||
end
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LatexBox_FoldText_title()
|
|
||||||
let line = getline(v:foldstart)
|
|
||||||
let title = 'Not defined'
|
|
||||||
|
|
||||||
" Preamble
|
|
||||||
if line =~ '\s*\\documentclass'
|
|
||||||
return "Preamble"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Parts, sections and fakesections
|
|
||||||
let sections = '\(\(sub\)*\(section\|paragraph\)\|part\|chapter\)'
|
|
||||||
let secpat1 = '^\s*\\' . sections . '\*\?\s*{'
|
|
||||||
let secpat2 = '^\s*\\' . sections . '\*\?\s*\['
|
|
||||||
if line =~ '\\frontmatter'
|
|
||||||
let title = "Frontmatter"
|
|
||||||
elseif line =~ '\\mainmatter'
|
|
||||||
let title = "Mainmatter"
|
|
||||||
elseif line =~ '\\backmatter'
|
|
||||||
let title = "Backmatter"
|
|
||||||
elseif line =~ '\\appendix'
|
|
||||||
let title = "Appendix"
|
|
||||||
elseif line =~ secpat1 . '.*}'
|
|
||||||
let title = matchstr(line, secpat1 . '\zs.\{-}\ze}')
|
|
||||||
elseif line =~ secpat1
|
|
||||||
let title = matchstr(line, secpat1 . '\zs.*')
|
|
||||||
elseif line =~ secpat2 . '.*\]'
|
|
||||||
let title = matchstr(line, secpat2 . '\zs.\{-}\ze\]')
|
|
||||||
elseif line =~ secpat2
|
|
||||||
let title = matchstr(line, secpat2 . '\zs.*')
|
|
||||||
elseif line =~ 'Fake' . sections . ':'
|
|
||||||
let title = matchstr(line,'Fake' . sections . ':\s*\zs.*')
|
|
||||||
elseif line =~ 'Fake' . sections
|
|
||||||
let title = matchstr(line, 'Fake' . sections)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Environments
|
|
||||||
if line =~ '\\begin'
|
|
||||||
" Capture environment name
|
|
||||||
let env = matchstr(line,'\\begin\*\?{\zs\w*\*\?\ze}')
|
|
||||||
|
|
||||||
" Set caption based on type of environment
|
|
||||||
if env == 'frame'
|
|
||||||
let label = ''
|
|
||||||
let caption = s:CaptionFrame(line)
|
|
||||||
elseif env == 'table'
|
|
||||||
let label = s:LabelEnv()
|
|
||||||
let caption = s:CaptionTable()
|
|
||||||
else
|
|
||||||
let label = s:LabelEnv()
|
|
||||||
let caption = s:CaptionEnv()
|
|
||||||
endif
|
|
||||||
|
|
||||||
" If no caption found, check for a caption comment
|
|
||||||
if caption == ''
|
|
||||||
let caption = matchstr(line,'\\begin\*\?{.*}\s*%\s*\zs.*')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Create title based on caption and label
|
|
||||||
if caption . label == ''
|
|
||||||
let title = env
|
|
||||||
elseif label == ''
|
|
||||||
let title = printf('%-12s%s', env . ':',
|
|
||||||
\ substitute(caption, '}\s*$', '',''))
|
|
||||||
elseif caption == ''
|
|
||||||
let title = printf('%-12s%56s', env, '(' . label . ')')
|
|
||||||
else
|
|
||||||
let title = printf('%-12s%-30s %21s', env . ':',
|
|
||||||
\ strpart(substitute(caption, '}\s*$', '',''),0,34),
|
|
||||||
\ '(' . label . ')')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
return title
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{1 LatexBox_FoldText
|
|
||||||
function! LatexBox_FoldText()
|
|
||||||
let nlines = v:foldend - v:foldstart + 1
|
|
||||||
let title = strpart(LatexBox_FoldText_title(), 0, 68)
|
|
||||||
let level = ''
|
|
||||||
|
|
||||||
" Fold level
|
|
||||||
let level = strpart(repeat('-', v:foldlevel-1) . '*',0,3)
|
|
||||||
if v:foldlevel > 3
|
|
||||||
let level = strpart(level, 1) . v:foldlevel
|
|
||||||
endif
|
|
||||||
let level = printf('%-3s', level)
|
|
||||||
|
|
||||||
return printf('%-3s %-68s #%5d', level, title, nlines)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{1 Footer
|
|
||||||
" vim:fdm=marker:ff=unix:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,558 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX Box latexmk functions
|
|
||||||
|
|
||||||
" Options and variables {{{
|
|
||||||
|
|
||||||
if !exists('g:LatexBox_latexmk_options')
|
|
||||||
let g:LatexBox_latexmk_options = ''
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_latexmk_env')
|
|
||||||
let g:LatexBox_latexmk_env = ''
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_latexmk_async')
|
|
||||||
let g:LatexBox_latexmk_async = 0
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_latexmk_preview_continuously')
|
|
||||||
let g:LatexBox_latexmk_preview_continuously = 0
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_output_type')
|
|
||||||
let g:LatexBox_output_type = 'pdf'
|
|
||||||
endif
|
|
||||||
if !exists('g:LatexBox_autojump')
|
|
||||||
let g:LatexBox_autojump = 0
|
|
||||||
endif
|
|
||||||
if ! exists('g:LatexBox_quickfix')
|
|
||||||
let g:LatexBox_quickfix = 1
|
|
||||||
endif
|
|
||||||
if ! exists('g:LatexBox_personal_latexmkrc')
|
|
||||||
let g:LatexBox_personal_latexmkrc = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Process ID management (used for asynchronous and continuous mode) {{{
|
|
||||||
|
|
||||||
" A dictionary of latexmk PID's (basename: pid)
|
|
||||||
if !exists('g:latexmk_running_pids')
|
|
||||||
let g:latexmk_running_pids = {}
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Set PID {{{
|
|
||||||
function! s:LatexmkSetPID(basename, pid)
|
|
||||||
let g:latexmk_running_pids[a:basename] = a:pid
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" kill_latexmk_process {{{
|
|
||||||
function! s:kill_latexmk_process(pid)
|
|
||||||
if has('win32')
|
|
||||||
silent execute '!taskkill /PID ' . a:pid . ' /T /F'
|
|
||||||
else
|
|
||||||
if g:LatexBox_latexmk_async
|
|
||||||
" vim-server mode
|
|
||||||
let pids = []
|
|
||||||
let tmpfile = tempname()
|
|
||||||
silent execute '!ps x -o pgid,pid > ' . tmpfile
|
|
||||||
for line in readfile(tmpfile)
|
|
||||||
let new_pid = matchstr(line, '^\s*' . a:pid . '\s\+\zs\d\+\ze')
|
|
||||||
if !empty(new_pid)
|
|
||||||
call add(pids, new_pid)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
call delete(tmpfile)
|
|
||||||
if !empty(pids)
|
|
||||||
silent execute '!kill ' . join(pids)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
" single background process
|
|
||||||
silent execute '!kill ' . a:pid
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if !has('gui_running')
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" kill_all_latexmk_processes {{{
|
|
||||||
function! s:kill_all_latexmk_processes()
|
|
||||||
for pid in values(g:latexmk_running_pids)
|
|
||||||
call s:kill_latexmk_process(pid)
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Setup for vim-server {{{
|
|
||||||
function! s:SIDWrap(func)
|
|
||||||
if !exists('s:SID')
|
|
||||||
let s:SID = matchstr(expand('<sfile>'), '\zs<SNR>\d\+_\ze.*$')
|
|
||||||
endif
|
|
||||||
return s:SID . a:func
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:LatexmkCallback(basename, status)
|
|
||||||
" Only remove the pid if not in continuous mode
|
|
||||||
if !g:LatexBox_latexmk_preview_continuously
|
|
||||||
call remove(g:latexmk_running_pids, a:basename)
|
|
||||||
endif
|
|
||||||
call LatexBox_LatexErrors(a:status, a:basename)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:setup_vim_server()
|
|
||||||
if !exists('g:vim_program')
|
|
||||||
|
|
||||||
" attempt autodetection of vim executable
|
|
||||||
let g:vim_program = ''
|
|
||||||
if has('win32')
|
|
||||||
" Just drop through to the default for windows
|
|
||||||
else
|
|
||||||
if match(&shell, '\(bash\|zsh\)$') >= 0
|
|
||||||
let ppid = '$PPID'
|
|
||||||
else
|
|
||||||
let ppid = '$$'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let tmpfile = tempname()
|
|
||||||
silent execute '!ps -o command= -p ' . ppid . ' > ' . tmpfile
|
|
||||||
for line in readfile(tmpfile)
|
|
||||||
let line = matchstr(line, '^\S\+\>')
|
|
||||||
if !empty(line) && executable(line)
|
|
||||||
let g:vim_program = line . ' -g'
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
call delete(tmpfile)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if empty(g:vim_program)
|
|
||||||
if has('gui_macvim')
|
|
||||||
let g:vim_program
|
|
||||||
\ = '/Applications/MacVim.app/Contents/MacOS/Vim -g'
|
|
||||||
else
|
|
||||||
let g:vim_program = v:progname
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Latexmk {{{
|
|
||||||
|
|
||||||
function! LatexBox_Latexmk(force)
|
|
||||||
" Define often used names
|
|
||||||
let basepath = LatexBox_GetBuildBasename(1)
|
|
||||||
let basename = fnamemodify(basepath, ':t')
|
|
||||||
let texroot = shellescape(LatexBox_GetTexRoot())
|
|
||||||
let mainfile = fnameescape(fnamemodify(LatexBox_GetMainTexFile(), ':t'))
|
|
||||||
|
|
||||||
" Check if latexmk is installed
|
|
||||||
if !executable('latexmk')
|
|
||||||
echomsg "Error: LaTeX-Box relies on latexmk for compilation, but it" .
|
|
||||||
\ " is not installed!"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Check if already running
|
|
||||||
if has_key(g:latexmk_running_pids, basepath)
|
|
||||||
echomsg "latexmk is already running for `" . basename . "'"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Set wrap width in log file
|
|
||||||
let max_print_line = 2000
|
|
||||||
if has('win32')
|
|
||||||
let env = 'set max_print_line=' . max_print_line . ' & '
|
|
||||||
elseif match(&shell, '/tcsh$') >= 0
|
|
||||||
let env = 'setenv max_print_line ' . max_print_line . '; '
|
|
||||||
else
|
|
||||||
if fnamemodify(&shell, ':t') ==# 'fish'
|
|
||||||
let env = 'set max_print_line ' . max_print_line . '; and '
|
|
||||||
else
|
|
||||||
let env = 'max_print_line=' . max_print_line
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Set environment options
|
|
||||||
let env .= ' ' . g:LatexBox_latexmk_env . ' '
|
|
||||||
|
|
||||||
" Set latexmk command with options
|
|
||||||
if has('win32')
|
|
||||||
" Make sure to switch drive as well as directory
|
|
||||||
let cmd = 'cd /D ' . texroot . ' && '
|
|
||||||
else
|
|
||||||
if fnamemodify(&shell, ':t') ==# 'fish'
|
|
||||||
let cmd = 'cd ' . texroot . '; and '
|
|
||||||
else
|
|
||||||
let cmd = 'cd ' . texroot . ' && '
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let cmd .= env . ' latexmk'
|
|
||||||
if ! g:LatexBox_personal_latexmkrc
|
|
||||||
let cmd .= ' -' . g:LatexBox_output_type
|
|
||||||
endif
|
|
||||||
let cmd .= ' -quiet '
|
|
||||||
let cmd .= g:LatexBox_latexmk_options
|
|
||||||
if a:force
|
|
||||||
let cmd .= ' -g'
|
|
||||||
endif
|
|
||||||
if g:LatexBox_latexmk_preview_continuously
|
|
||||||
let cmd .= ' -pvc'
|
|
||||||
endif
|
|
||||||
let cmd .= ' -e ' . shellescape('$pdflatex =~ s/ / -file-line-error /')
|
|
||||||
let cmd .= ' -e ' . shellescape('$latex =~ s/ / -file-line-error /')
|
|
||||||
if g:LatexBox_latexmk_preview_continuously
|
|
||||||
let cmd .= ' -e ' . shellescape('$success_cmd = $ENV{SUCCESSCMD}')
|
|
||||||
let cmd .= ' -e ' . shellescape('$failure_cmd = $ENV{FAILURECMD}')
|
|
||||||
endif
|
|
||||||
let cmd .= ' ' . mainfile
|
|
||||||
|
|
||||||
" Redirect output to null
|
|
||||||
if has('win32')
|
|
||||||
let cmd .= ' >nul'
|
|
||||||
else
|
|
||||||
if fnamemodify(&shell, ':t') ==# 'fish'
|
|
||||||
let cmd .= ' >/dev/null ^/dev/null'
|
|
||||||
else
|
|
||||||
let cmd .= ' &>/dev/null'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:LatexBox_latexmk_async
|
|
||||||
" Check if VIM server exists
|
|
||||||
if empty(v:servername)
|
|
||||||
echoerr "cannot run latexmk in background without a VIM server"
|
|
||||||
echoerr "set g:LatexBox_latexmk_async to 0 to change compiling mode"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Start vim server if necessary
|
|
||||||
call s:setup_vim_server()
|
|
||||||
|
|
||||||
let setpidfunc = s:SIDWrap('LatexmkSetPID')
|
|
||||||
let callbackfunc = s:SIDWrap('LatexmkCallback')
|
|
||||||
if has('win32')
|
|
||||||
let vim_program = substitute(g:vim_program,
|
|
||||||
\ 'gvim\.exe$', 'vim.exe', '')
|
|
||||||
|
|
||||||
" Define callback to set the pid
|
|
||||||
let callsetpid = setpidfunc . '(''' . basepath . ''', %CMDPID%)'
|
|
||||||
let vimsetpid = vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . shellescape(callsetpid)
|
|
||||||
|
|
||||||
" Define callback after latexmk is finished
|
|
||||||
let callback = callbackfunc . '(''' . basepath . ''', %LATEXERR%)'
|
|
||||||
let vimcmd = vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . shellescape(callback)
|
|
||||||
let scallback = callbackfunc . '(''' . basepath . ''', 0)'
|
|
||||||
let svimcmd = vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . shellescape(scallback)
|
|
||||||
let fcallback = callbackfunc . '(''' . basepath . ''', 1)'
|
|
||||||
let fvimcmd = vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . shellescape(fcallback)
|
|
||||||
|
|
||||||
let asyncbat = tempname() . '.bat'
|
|
||||||
if g:LatexBox_latexmk_preview_continuously
|
|
||||||
call writefile(['setlocal',
|
|
||||||
\ 'set T=%TEMP%\sthUnique.tmp',
|
|
||||||
\ 'wmic process where (Name="WMIC.exe" AND CommandLine LIKE "%%%TIME%%%") '
|
|
||||||
\ . 'get ParentProcessId /value | find "ParentProcessId" >%T%',
|
|
||||||
\ 'set /P A=<%T%',
|
|
||||||
\ 'set CMDPID=%A:~16% & del %T%',
|
|
||||||
\ vimsetpid,
|
|
||||||
\ 'set SUCCESSCMD='.svimcmd,
|
|
||||||
\ 'set FAILURECMD='.fvimcmd,
|
|
||||||
\ cmd,
|
|
||||||
\ 'endlocal'], asyncbat)
|
|
||||||
else
|
|
||||||
call writefile(['setlocal',
|
|
||||||
\ 'set T=%TEMP%\sthUnique.tmp',
|
|
||||||
\ 'wmic process where (Name="WMIC.exe" AND CommandLine LIKE "%%%TIME%%%") '
|
|
||||||
\ . 'get ParentProcessId /value | find "ParentProcessId" >%T%',
|
|
||||||
\ 'set /P A=<%T%',
|
|
||||||
\ 'set CMDPID=%A:~16% & del %T%',
|
|
||||||
\ vimsetpid,
|
|
||||||
\ cmd,
|
|
||||||
\ 'set LATEXERR=%ERRORLEVEL%',
|
|
||||||
\ vimcmd,
|
|
||||||
\ 'endlocal'], asyncbat)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Define command
|
|
||||||
let cmd = '!start /b ' . asyncbat . ' & del ' . asyncbat
|
|
||||||
else
|
|
||||||
" Define callback to set the pid
|
|
||||||
let callsetpid = shellescape(setpidfunc).'"(\"'.basepath.'\",$$)"'
|
|
||||||
let vimsetpid = g:vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . callsetpid
|
|
||||||
|
|
||||||
" Define callback after latexmk is finished
|
|
||||||
let callback = shellescape(callbackfunc).'"(\"'.basepath.'\",$?)"'
|
|
||||||
let vimcmd = g:vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . callback
|
|
||||||
let scallback = shellescape(callbackfunc).'"(\"'.basepath.'\",0)"'
|
|
||||||
let svimcmd = g:vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . scallback
|
|
||||||
let fcallback = shellescape(callbackfunc).'"(\"'.basepath.'\",1)"'
|
|
||||||
let fvimcmd = g:vim_program . ' --servername ' . v:servername
|
|
||||||
\ . ' --remote-expr ' . fcallback
|
|
||||||
|
|
||||||
" Define command
|
|
||||||
" Note: Here we escape '%' because it may be given as a user option
|
|
||||||
" through g:LatexBox_latexmk_options, for instance with
|
|
||||||
" g:Latex..._options = "-pdflatex='pdflatex -synctex=1 \%O \%S'"
|
|
||||||
if g:LatexBox_latexmk_preview_continuously
|
|
||||||
let cmd = vimsetpid . ' ; '
|
|
||||||
\ . 'export SUCCESSCMD=' . shellescape(svimcmd) . ' '
|
|
||||||
\ . ' FAILURECMD=' . shellescape(fvimcmd) . ' ; '
|
|
||||||
\ . escape(cmd, '%')
|
|
||||||
else
|
|
||||||
let cmd = vimsetpid . ' ; ' . escape(cmd, '%') . ' ; ' . vimcmd
|
|
||||||
endif
|
|
||||||
let cmd = '! (' . cmd . ') >/dev/null &'
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:LatexBox_latexmk_preview_continuously
|
|
||||||
echo 'Compiling to ' . g:LatexBox_output_type
|
|
||||||
\ . ' with continuous preview.'
|
|
||||||
else
|
|
||||||
echo 'Compiling to ' . g:LatexBox_output_type . ' ...'
|
|
||||||
endif
|
|
||||||
silent execute cmd
|
|
||||||
else
|
|
||||||
if g:LatexBox_latexmk_preview_continuously
|
|
||||||
if has('win32')
|
|
||||||
let cmd = '!start /b cmd /s /c "' . cmd . '"'
|
|
||||||
else
|
|
||||||
let cmd = '!' . cmd . ' &'
|
|
||||||
endif
|
|
||||||
echo 'Compiling to ' . g:LatexBox_output_type . ' ...'
|
|
||||||
silent execute cmd
|
|
||||||
|
|
||||||
" Save PID in order to be able to kill the process when wanted.
|
|
||||||
if has('win32')
|
|
||||||
let tmpfile = tempname()
|
|
||||||
let pidcmd = 'cmd /c "wmic process where '
|
|
||||||
\ . '(CommandLine LIKE "latexmk\%'.mainfile.'\%") '
|
|
||||||
\ . 'get ProcessId /value | find "ProcessId" '
|
|
||||||
\ . '>'.tmpfile.' "'
|
|
||||||
silent execute '! ' . pidcmd
|
|
||||||
let pids = readfile(tmpfile)
|
|
||||||
let pid = strpart(pids[0], 10)
|
|
||||||
let g:latexmk_running_pids[basepath] = pid
|
|
||||||
else
|
|
||||||
let pid = substitute(system('pgrep -f "perl.*'
|
|
||||||
\ . mainfile . '" | head -n 1'),'\D','','')
|
|
||||||
let g:latexmk_running_pids[basepath] = pid
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
" Execute command and check for errors
|
|
||||||
echo 'Compiling to ' . g:LatexBox_output_type . ' ... (async off!)'
|
|
||||||
call system(cmd)
|
|
||||||
call LatexBox_LatexErrors(v:shell_error)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Redraw screen if necessary
|
|
||||||
if !has("gui_running")
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" LatexmkClean {{{
|
|
||||||
function! LatexBox_LatexmkClean(cleanall)
|
|
||||||
" Check if latexmk is installed
|
|
||||||
if !executable('latexmk')
|
|
||||||
echomsg "Error: LaTeX-Box relies on latexmk for compilation, but it" .
|
|
||||||
\ " is not installed!"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let basename = LatexBox_GetBuildBasename(1)
|
|
||||||
|
|
||||||
if has_key(g:latexmk_running_pids, basename)
|
|
||||||
echomsg "don't clean when latexmk is running"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if has('win32')
|
|
||||||
let cmd = 'cd /D ' . shellescape(LatexBox_GetTexRoot()) . ' & '
|
|
||||||
else
|
|
||||||
let cmd = 'cd ' . shellescape(LatexBox_GetTexRoot()) . ';'
|
|
||||||
endif
|
|
||||||
if a:cleanall
|
|
||||||
let cmd .= 'latexmk -C '
|
|
||||||
else
|
|
||||||
let cmd .= 'latexmk -c '
|
|
||||||
endif
|
|
||||||
let cmd .= shellescape(LatexBox_GetMainTexFile())
|
|
||||||
if has('win32')
|
|
||||||
let cmd .= ' >nul'
|
|
||||||
else
|
|
||||||
let cmd .= ' >&/dev/null'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call system(cmd)
|
|
||||||
if !has('gui_running')
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
|
|
||||||
echomsg "latexmk clean finished"
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" LatexErrors {{{
|
|
||||||
function! LatexBox_LatexErrors(status, ...)
|
|
||||||
if a:0 >= 1
|
|
||||||
let log = a:1 . '.log'
|
|
||||||
else
|
|
||||||
let log = LatexBox_GetLogFile()
|
|
||||||
endif
|
|
||||||
|
|
||||||
cclose
|
|
||||||
|
|
||||||
" set cwd to expand error file correctly
|
|
||||||
let l:cwd = fnamemodify(getcwd(), ':p')
|
|
||||||
execute 'lcd ' . fnameescape(LatexBox_GetTexRoot())
|
|
||||||
try
|
|
||||||
if g:LatexBox_autojump
|
|
||||||
execute 'cfile ' . fnameescape(log)
|
|
||||||
else
|
|
||||||
execute 'cgetfile ' . fnameescape(log)
|
|
||||||
endif
|
|
||||||
finally
|
|
||||||
" restore cwd
|
|
||||||
execute 'lcd ' . fnameescape(l:cwd)
|
|
||||||
endtry
|
|
||||||
|
|
||||||
" Always open window if started by LatexErrors command
|
|
||||||
if a:status < 0
|
|
||||||
botright copen
|
|
||||||
else
|
|
||||||
" Only open window when an error/warning is detected
|
|
||||||
if g:LatexBox_quickfix >= 3
|
|
||||||
\ ? s:log_contains_error(log)
|
|
||||||
\ : g:LatexBox_quickfix > 0
|
|
||||||
belowright cw
|
|
||||||
if g:LatexBox_quickfix == 2 || g:LatexBox_quickfix == 4
|
|
||||||
wincmd p
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
redraw
|
|
||||||
|
|
||||||
" Write status message to screen
|
|
||||||
if a:status > 0 || len(getqflist())>1
|
|
||||||
if s:log_contains_error(log)
|
|
||||||
let l:status_msg = ' ... failed!'
|
|
||||||
else
|
|
||||||
let l:status_msg = ' ... there were warnings!'
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let l:status_msg = ' ... success!'
|
|
||||||
endif
|
|
||||||
echomsg 'Compiling to ' . g:LatexBox_output_type . l:status_msg
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Redefine uniq() for compatibility with older Vim versions (< 7.4.218)
|
|
||||||
function! s:uniq(list)
|
|
||||||
if exists('*uniq')
|
|
||||||
return uniq(a:list)
|
|
||||||
elseif len(a:list) <= 1
|
|
||||||
return a:list
|
|
||||||
endif
|
|
||||||
|
|
||||||
let last_element = get(a:list,0)
|
|
||||||
let uniq_list = [last_element]
|
|
||||||
|
|
||||||
for i in range(1, len(a:list)-1)
|
|
||||||
let next_element = get(a:list, i)
|
|
||||||
if last_element == next_element
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let last_element = next_element
|
|
||||||
call add(uniq_list, next_element)
|
|
||||||
endfor
|
|
||||||
return uniq_list
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:log_contains_error(file)
|
|
||||||
let lines = readfile(a:file)
|
|
||||||
let lines = filter(lines, 'v:val =~ ''^.*:\d\+: ''')
|
|
||||||
let lines = s:uniq(map(lines, 'matchstr(v:val, ''^.*\ze:\d\+:'')'))
|
|
||||||
let lines = filter(lines, 'filereadable(fnameescape(v:val))')
|
|
||||||
return len(lines) > 0
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" LatexmkStatus {{{
|
|
||||||
function! LatexBox_LatexmkStatus(detailed)
|
|
||||||
if a:detailed
|
|
||||||
if empty(g:latexmk_running_pids)
|
|
||||||
echo "latexmk is not running"
|
|
||||||
else
|
|
||||||
let plist = ""
|
|
||||||
for [basename, pid] in items(g:latexmk_running_pids)
|
|
||||||
if !empty(plist)
|
|
||||||
let plist .= '; '
|
|
||||||
endif
|
|
||||||
let plist .= fnamemodify(basename, ':t') . ':' . pid
|
|
||||||
endfor
|
|
||||||
echo "latexmk is running (" . plist . ")"
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let basename = LatexBox_GetBuildBasename(1)
|
|
||||||
if has_key(g:latexmk_running_pids, basename)
|
|
||||||
echo "latexmk is running"
|
|
||||||
else
|
|
||||||
echo "latexmk is not running"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" LatexmkStop {{{
|
|
||||||
function! LatexBox_LatexmkStop(silent)
|
|
||||||
if empty(g:latexmk_running_pids)
|
|
||||||
if !a:silent
|
|
||||||
let basepath = LatexBox_GetBuildBasename(1)
|
|
||||||
let basename = fnamemodify(basepath, ':t')
|
|
||||||
echoerr "latexmk is not running for `" . basename . "'"
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let basepath = LatexBox_GetBuildBasename(1)
|
|
||||||
let basename = fnamemodify(basepath, ':t')
|
|
||||||
if has_key(g:latexmk_running_pids, basepath)
|
|
||||||
call s:kill_latexmk_process(g:latexmk_running_pids[basepath])
|
|
||||||
call remove(g:latexmk_running_pids, basepath)
|
|
||||||
if !a:silent
|
|
||||||
echomsg "latexmk stopped for `" . basename . "'"
|
|
||||||
endif
|
|
||||||
elseif !a:silent
|
|
||||||
echoerr "latexmk is not running for `" . basename . "'"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Commands {{{
|
|
||||||
|
|
||||||
command! -bang Latexmk call LatexBox_Latexmk(<q-bang> == "!")
|
|
||||||
command! -bang LatexmkClean call LatexBox_LatexmkClean(<q-bang> == "!")
|
|
||||||
command! -bang LatexmkStatus call LatexBox_LatexmkStatus(<q-bang> == "!")
|
|
||||||
command! LatexmkStop call LatexBox_LatexmkStop(0)
|
|
||||||
command! LatexErrors call LatexBox_LatexErrors(-1)
|
|
||||||
|
|
||||||
if g:LatexBox_latexmk_async || g:LatexBox_latexmk_preview_continuously
|
|
||||||
autocmd BufUnload <buffer> call LatexBox_LatexmkStop(1)
|
|
||||||
autocmd VimLeave * call <SID>kill_all_latexmk_processes()
|
|
||||||
endif
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX Box mappings
|
|
||||||
|
|
||||||
if exists("g:LatexBox_no_mappings")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" latexmk {{{
|
|
||||||
noremap <buffer> <LocalLeader>ll :Latexmk<CR>
|
|
||||||
noremap <buffer> <LocalLeader>lL :Latexmk!<CR>
|
|
||||||
noremap <buffer> <LocalLeader>lc :LatexmkClean<CR>
|
|
||||||
noremap <buffer> <LocalLeader>lC :LatexmkClean!<CR>
|
|
||||||
noremap <buffer> <LocalLeader>lg :LatexmkStatus<CR>
|
|
||||||
noremap <buffer> <LocalLeader>lG :LatexmkStatus!<CR>
|
|
||||||
noremap <buffer> <LocalLeader>lk :LatexmkStop<CR>
|
|
||||||
noremap <buffer> <LocalLeader>le :LatexErrors<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" View {{{
|
|
||||||
noremap <buffer> <LocalLeader>lv :LatexView<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" TOC {{{
|
|
||||||
noremap <silent> <buffer> <LocalLeader>lt :LatexTOC<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" List of labels {{{
|
|
||||||
noremap <silent> <buffer> <LocalLeader>lj :LatexLabels<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Folding {{{
|
|
||||||
if g:LatexBox_Folding == 1
|
|
||||||
noremap <buffer> <LocalLeader>lf :LatexFold<CR>
|
|
||||||
endif
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Jump to match {{{
|
|
||||||
if !exists('g:LatexBox_loaded_matchparen')
|
|
||||||
nmap <buffer> % <Plug>LatexBox_JumpToMatch
|
|
||||||
vmap <buffer> % <Plug>LatexBox_JumpToMatch
|
|
||||||
omap <buffer> % <Plug>LatexBox_JumpToMatch
|
|
||||||
endif
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Define text objects {{{
|
|
||||||
vmap <buffer> ie <Plug>LatexBox_SelectCurrentEnvInner
|
|
||||||
vmap <buffer> ae <Plug>LatexBox_SelectCurrentEnvOuter
|
|
||||||
onoremap <buffer> ie :normal vie<CR>
|
|
||||||
onoremap <buffer> ae :normal vae<CR>
|
|
||||||
vmap <buffer> i$ <Plug>LatexBox_SelectInlineMathInner
|
|
||||||
vmap <buffer> a$ <Plug>LatexBox_SelectInlineMathOuter
|
|
||||||
onoremap <buffer> i$ :normal vi$<CR>
|
|
||||||
onoremap <buffer> a$ :normal va$<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Jump between sections {{{
|
|
||||||
function! s:LatexBoxNextSection(type, backwards, visual)
|
|
||||||
" Restore visual mode if desired
|
|
||||||
if a:visual
|
|
||||||
normal! gv
|
|
||||||
endif
|
|
||||||
|
|
||||||
" For the [] and ][ commands we move up or down before the search
|
|
||||||
if a:type == 1
|
|
||||||
if a:backwards
|
|
||||||
normal! k
|
|
||||||
else
|
|
||||||
normal! j
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Define search pattern and do the search while preserving "/
|
|
||||||
let save_search = @/
|
|
||||||
let flags = 'W'
|
|
||||||
if a:backwards
|
|
||||||
let flags = 'b' . flags
|
|
||||||
endif
|
|
||||||
let notcomment = '\%(\%(\\\@<!\%(\\\\\)*\)\@<=%.*\)\@<!'
|
|
||||||
let pattern = notcomment . '\v\s*\\(' . join([
|
|
||||||
\ '(sub)*section',
|
|
||||||
\ 'chapter',
|
|
||||||
\ 'part',
|
|
||||||
\ 'appendix',
|
|
||||||
\ '(front|back|main)matter'], '|') . ')>'
|
|
||||||
call search(pattern, flags)
|
|
||||||
let @/ = save_search
|
|
||||||
|
|
||||||
" For the [] and ][ commands we move down or up after the search
|
|
||||||
if a:type == 1
|
|
||||||
if a:backwards
|
|
||||||
normal! j
|
|
||||||
else
|
|
||||||
normal! k
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
noremap <buffer> <silent> ]] :call <SID>LatexBoxNextSection(0,0,0)<CR>
|
|
||||||
noremap <buffer> <silent> ][ :call <SID>LatexBoxNextSection(1,0,0)<CR>
|
|
||||||
noremap <buffer> <silent> [] :call <SID>LatexBoxNextSection(1,1,0)<CR>
|
|
||||||
noremap <buffer> <silent> [[ :call <SID>LatexBoxNextSection(0,1,0)<CR>
|
|
||||||
vnoremap <buffer> <silent> ]] :<c-u>call <SID>LatexBoxNextSection(0,0,1)<CR>
|
|
||||||
vnoremap <buffer> <silent> ][ :<c-u>call <SID>LatexBoxNextSection(1,0,1)<CR>
|
|
||||||
vnoremap <buffer> <silent> [] :<c-u>call <SID>LatexBoxNextSection(1,1,1)<CR>
|
|
||||||
vnoremap <buffer> <silent> [[ :<c-u>call <SID>LatexBoxNextSection(0,1,1)<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,548 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX Box motion functions
|
|
||||||
|
|
||||||
" Motion options {{{
|
|
||||||
" Opening and closing patterns
|
|
||||||
if !exists('g:LatexBox_open_pats')
|
|
||||||
let g:LatexBox_open_pats = [ '\\{','{','\\(','(','\\\[','\[',
|
|
||||||
\ '\\begin\s*{.\{-}}', '\\left\s*\%([^\\]\|\\.\|\\\a*\)']
|
|
||||||
let g:LatexBox_close_pats = [ '\\}','}','\\)',')','\\\]','\]',
|
|
||||||
\ '\\end\s*{.\{-}}', '\\right\s*\%([^\\]\|\\.\|\\\a*\)']
|
|
||||||
endif
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" HasSyntax {{{
|
|
||||||
" s:HasSyntax(syntaxName, [line], [col])
|
|
||||||
function! s:HasSyntax(syntaxName, ...)
|
|
||||||
let line = a:0 >= 1 ? a:1 : line('.')
|
|
||||||
let col = a:0 >= 2 ? a:2 : col('.')
|
|
||||||
return index(map(synstack(line, col),
|
|
||||||
\ 'synIDattr(v:val, "name") == "' . a:syntaxName . '"'),
|
|
||||||
\ 1) >= 0
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Search and Skip Comments {{{
|
|
||||||
" s:SearchAndSkipComments(pattern, [flags], [stopline])
|
|
||||||
function! s:SearchAndSkipComments(pat, ...)
|
|
||||||
let flags = a:0 >= 1 ? a:1 : ''
|
|
||||||
let stopline = a:0 >= 2 ? a:2 : 0
|
|
||||||
let saved_pos = getpos('.')
|
|
||||||
|
|
||||||
" search once
|
|
||||||
let ret = search(a:pat, flags, stopline)
|
|
||||||
|
|
||||||
if ret
|
|
||||||
" do not match at current position if inside comment
|
|
||||||
let flags = substitute(flags, 'c', '', 'g')
|
|
||||||
|
|
||||||
" keep searching while in comment
|
|
||||||
while LatexBox_InComment()
|
|
||||||
let ret = search(a:pat, flags, stopline)
|
|
||||||
if !ret
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !ret
|
|
||||||
" if no match found, restore position
|
|
||||||
call setpos('.', saved_pos)
|
|
||||||
endif
|
|
||||||
|
|
||||||
return ret
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Finding Matching Pair {{{
|
|
||||||
function! s:FindMatchingPair(mode)
|
|
||||||
|
|
||||||
if a:mode =~ 'h\|i'
|
|
||||||
2match none
|
|
||||||
elseif a:mode == 'v'
|
|
||||||
normal! gv
|
|
||||||
endif
|
|
||||||
|
|
||||||
if LatexBox_InComment() | return | endif
|
|
||||||
|
|
||||||
" open/close pairs (dollars signs are treated apart)
|
|
||||||
let dollar_pat = '\$'
|
|
||||||
let notbslash = '\%(\\\@<!\%(\\\\\)*\)\@<='
|
|
||||||
let notcomment = '\%(\%(\\\@<!\%(\\\\\)*\)\@<=%.*\)\@<!'
|
|
||||||
let anymatch = '\('
|
|
||||||
\ . join(g:LatexBox_open_pats + g:LatexBox_close_pats, '\|')
|
|
||||||
\ . '\|' . dollar_pat . '\)'
|
|
||||||
|
|
||||||
let lnum = line('.')
|
|
||||||
let cnum = searchpos('\A', 'cbnW', lnum)[1]
|
|
||||||
" if the previous char is a backslash
|
|
||||||
if strpart(getline(lnum), cnum-2, 1) == '\'
|
|
||||||
let cnum = cnum-1
|
|
||||||
endif
|
|
||||||
let delim = matchstr(getline(lnum), '\C^'. anymatch , cnum - 1)
|
|
||||||
|
|
||||||
if empty(delim) || strlen(delim)+cnum-1< col('.')
|
|
||||||
if a:mode =~ 'n\|v\|o'
|
|
||||||
" if not found, search forward
|
|
||||||
let cnum = match(getline(lnum), '\C'. anymatch , col('.') - 1) + 1
|
|
||||||
if cnum == 0 | return | endif
|
|
||||||
call cursor(lnum, cnum)
|
|
||||||
let delim = matchstr(getline(lnum), '\C^'. anymatch , cnum - 1)
|
|
||||||
elseif a:mode =~ 'i'
|
|
||||||
" if not found, move one char bacward and search
|
|
||||||
let cnum = searchpos('\A', 'bnW', lnum)[1]
|
|
||||||
" if the previous char is a backslash
|
|
||||||
if strpart(getline(lnum), cnum-2, 1) == '\'
|
|
||||||
let cnum = cnum-1
|
|
||||||
endif
|
|
||||||
let delim = matchstr(getline(lnum), '\C^'. anymatch , cnum - 1)
|
|
||||||
if empty(delim) || strlen(delim)+cnum< col('.') | return | endif
|
|
||||||
elseif a:mode =~ 'h'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if delim =~ '^\$'
|
|
||||||
|
|
||||||
" match $-pairs
|
|
||||||
" check if next character is in inline math
|
|
||||||
let [lnum0, cnum0] = searchpos('.', 'nW')
|
|
||||||
if lnum0 && s:HasSyntax('texMathZoneX', lnum0, cnum0)
|
|
||||||
let [lnum2, cnum2] = searchpos(notcomment . notbslash. dollar_pat, 'nW', line('w$')*(a:mode =~ 'h\|i') , 200)
|
|
||||||
else
|
|
||||||
let [lnum2, cnum2] = searchpos('\%(\%'. lnum . 'l\%' . cnum . 'c\)\@!'. notcomment . notbslash . dollar_pat, 'bnW', line('w0')*(a:mode =~ 'h\|i') , 200)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:mode =~ 'h\|i'
|
|
||||||
execute '2match MatchParen /\%(\%' . lnum . 'l\%' . cnum . 'c\$' . '\|\%' . lnum2 . 'l\%' . cnum2 . 'c\$\)/'
|
|
||||||
elseif a:mode =~ 'n\|v\|o'
|
|
||||||
call cursor(lnum2,cnum2)
|
|
||||||
endif
|
|
||||||
|
|
||||||
else
|
|
||||||
" match other pairs
|
|
||||||
for i in range(len(g:LatexBox_open_pats))
|
|
||||||
let open_pat = notbslash . g:LatexBox_open_pats[i]
|
|
||||||
let close_pat = notbslash . g:LatexBox_close_pats[i]
|
|
||||||
|
|
||||||
if delim =~# '^' . open_pat
|
|
||||||
" if on opening pattern, search for closing pattern
|
|
||||||
let [lnum2, cnum2] = searchpairpos('\C' . open_pat, '', '\C'
|
|
||||||
\ . close_pat, 'nW', 'LatexBox_InComment()',
|
|
||||||
\ line('w$')*(a:mode =~ 'h\|i') , 200)
|
|
||||||
if a:mode =~ 'h\|i'
|
|
||||||
execute '2match MatchParen /\%(\%' . lnum . 'l\%' . cnum
|
|
||||||
\ . 'c' . g:LatexBox_open_pats[i] . '\|\%'
|
|
||||||
\ . lnum2 . 'l\%' . cnum2 . 'c'
|
|
||||||
\ . g:LatexBox_close_pats[i] . '\)/'
|
|
||||||
elseif a:mode =~ 'n\|v\|o'
|
|
||||||
call cursor(lnum2,cnum2)
|
|
||||||
if strlen(close_pat)>1 && a:mode =~ 'o'
|
|
||||||
call cursor(lnum2, matchend(getline('.'), '\C'
|
|
||||||
\ . close_pat, col('.')-1))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
elseif delim =~# '^' . close_pat
|
|
||||||
" if on closing pattern, search for opening pattern
|
|
||||||
let [lnum2, cnum2] = searchpairpos('\C' . open_pat, '',
|
|
||||||
\ '\C\%(\%'. lnum . 'l\%' . cnum . 'c\)\@!'
|
|
||||||
\ . close_pat, 'bnW', 'LatexBox_InComment()',
|
|
||||||
\ line('w0')*(a:mode =~ 'h\|i') , 200)
|
|
||||||
if a:mode =~ 'h\|i'
|
|
||||||
execute '2match MatchParen /\%(\%' . lnum2 . 'l\%' . cnum2
|
|
||||||
\ . 'c' . g:LatexBox_open_pats[i] . '\|\%'
|
|
||||||
\ . lnum . 'l\%' . cnum . 'c'
|
|
||||||
\ . g:LatexBox_close_pats[i] . '\)/'
|
|
||||||
elseif a:mode =~ 'n\|v\|o'
|
|
||||||
call cursor(lnum2,cnum2)
|
|
||||||
endif
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Allow to disable functionality if desired
|
|
||||||
if !exists('g:LatexBox_loaded_matchparen')
|
|
||||||
" Disable matchparen autocommands
|
|
||||||
augroup LatexBox_HighlightPairs
|
|
||||||
autocmd BufEnter * if !exists("g:loaded_matchparen") || !g:loaded_matchparen | runtime plugin/matchparen.vim | endif
|
|
||||||
autocmd BufEnter *.tex 3match none | unlet! g:loaded_matchparen | au! matchparen
|
|
||||||
autocmd! CursorMoved *.tex call s:FindMatchingPair('h')
|
|
||||||
autocmd! CursorMovedI *.tex call s:FindMatchingPair('i')
|
|
||||||
augroup END
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Use LatexBox'es FindMatchingPair as '%' (enable jump between e.g. $'s)
|
|
||||||
nnoremap <silent> <Plug>LatexBox_JumpToMatch :call <SID>FindMatchingPair('n')<CR>
|
|
||||||
vnoremap <silent> <Plug>LatexBox_JumpToMatch :call <SID>FindMatchingPair('v')<CR>
|
|
||||||
onoremap <silent> <Plug>LatexBox_JumpToMatch v:call <SID>FindMatchingPair('o')<CR>
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" select inline math {{{
|
|
||||||
" s:SelectInlineMath(seltype)
|
|
||||||
" where seltype is either 'inner' or 'outer'
|
|
||||||
function! s:SelectInlineMath(seltype)
|
|
||||||
|
|
||||||
let dollar_pat = '\\\@<!\$'
|
|
||||||
|
|
||||||
if s:HasSyntax('texMathZoneX')
|
|
||||||
call s:SearchAndSkipComments(dollar_pat, 'cbW')
|
|
||||||
elseif getline('.')[col('.') - 1] == '$'
|
|
||||||
call s:SearchAndSkipComments(dollar_pat, 'bW')
|
|
||||||
else
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:seltype == 'inner'
|
|
||||||
normal! l
|
|
||||||
endif
|
|
||||||
|
|
||||||
if visualmode() ==# 'V'
|
|
||||||
normal! V
|
|
||||||
else
|
|
||||||
normal! v
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:SearchAndSkipComments(dollar_pat, 'W')
|
|
||||||
|
|
||||||
if a:seltype == 'inner'
|
|
||||||
normal! h
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
vnoremap <silent> <Plug>LatexBox_SelectInlineMathInner
|
|
||||||
\ :<C-U>call <SID>SelectInlineMath('inner')<CR>
|
|
||||||
vnoremap <silent> <Plug>LatexBox_SelectInlineMathOuter
|
|
||||||
\ :<C-U>call <SID>SelectInlineMath('outer')<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" select current environment {{{
|
|
||||||
function! s:SelectCurrentEnv(seltype)
|
|
||||||
let [env, lnum, cnum, lnum2, cnum2] = LatexBox_GetCurrentEnvironment(1)
|
|
||||||
call cursor(lnum, cnum)
|
|
||||||
if a:seltype == 'inner'
|
|
||||||
if env =~ '^\'
|
|
||||||
call search('\\.\_\s*\S', 'eW')
|
|
||||||
else
|
|
||||||
call search('}\(\_\s*\[\_[^]]*\]\)\?\_\s*\S', 'eW')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if visualmode() ==# 'V'
|
|
||||||
normal! V
|
|
||||||
else
|
|
||||||
normal! v
|
|
||||||
endif
|
|
||||||
call cursor(lnum2, cnum2)
|
|
||||||
if a:seltype == 'inner'
|
|
||||||
call search('\S\_\s*', 'bW')
|
|
||||||
else
|
|
||||||
if env =~ '^\'
|
|
||||||
normal! l
|
|
||||||
else
|
|
||||||
call search('}', 'eW')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
vnoremap <silent> <Plug>LatexBox_SelectCurrentEnvInner :<C-U>call <SID>SelectCurrentEnv('inner')<CR>
|
|
||||||
vnoremap <silent> <Plug>LatexBox_SelectCurrentEnvOuter :<C-U>call <SID>SelectCurrentEnv('outer')<CR>
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Jump to the next braces {{{
|
|
||||||
"
|
|
||||||
function! LatexBox_JumpToNextBraces(backward)
|
|
||||||
let flags = ''
|
|
||||||
if a:backward
|
|
||||||
normal h
|
|
||||||
let flags .= 'b'
|
|
||||||
else
|
|
||||||
let flags .= 'c'
|
|
||||||
endif
|
|
||||||
if search('[][}{]', flags) > 0
|
|
||||||
normal l
|
|
||||||
endif
|
|
||||||
let prev = strpart(getline('.'), col('.') - 2, 1)
|
|
||||||
let next = strpart(getline('.'), col('.') - 1, 1)
|
|
||||||
if next =~ '[]}]' && prev !~ '[][{}]'
|
|
||||||
return "\<Right>"
|
|
||||||
else
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Table of Contents {{{
|
|
||||||
|
|
||||||
" Special UTF-8 conversion
|
|
||||||
function! s:ConvertBack(line)
|
|
||||||
let line = a:line
|
|
||||||
if exists('g:LatexBox_plaintext_toc')
|
|
||||||
"
|
|
||||||
" Substitute stuff like '\IeC{\"u}' to plain 'u'
|
|
||||||
"
|
|
||||||
let line = substitute(line, '\\IeC\s*{\\.\(.\)}', '\1', 'g')
|
|
||||||
else
|
|
||||||
"
|
|
||||||
" Substitute stuff like '\IeC{\"u}' to corresponding unicode symbols
|
|
||||||
"
|
|
||||||
for [pat, symbol] in s:ConvBackPats
|
|
||||||
let line = substitute(line, pat, symbol, 'g')
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
return line
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:ReadTOC(auxfile, texfile, ...)
|
|
||||||
let texfile = a:texfile
|
|
||||||
let prefix = fnamemodify(a:auxfile, ':p:h')
|
|
||||||
|
|
||||||
if a:0 != 2
|
|
||||||
let toc = []
|
|
||||||
let fileindices = { texfile : [] }
|
|
||||||
else
|
|
||||||
let toc = a:1
|
|
||||||
let fileindices = a:2
|
|
||||||
let fileindices[ texfile ] = []
|
|
||||||
endif
|
|
||||||
|
|
||||||
for line in readfile(a:auxfile)
|
|
||||||
let included = matchstr(line, '^\\@input{\zs[^}]*\ze}')
|
|
||||||
if included != ''
|
|
||||||
" append the input TOX to `toc` and `fileindices`
|
|
||||||
let newaux = prefix . '/' . included
|
|
||||||
let newtex = fnamemodify(newaux, ':r') . '.tex'
|
|
||||||
call s:ReadTOC(newaux, newtex, toc, fileindices)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Parse statements like:
|
|
||||||
" \@writefile{toc}{\contentsline {section}{\numberline {secnum}Section Title}{pagenumber}}
|
|
||||||
" \@writefile{toc}{\contentsline {section}{\tocsection {}{1}{Section Title}}{pagenumber}}
|
|
||||||
" \@writefile{toc}{\contentsline {section}{\numberline {secnum}Section Title}{pagenumber}{otherstuff}}
|
|
||||||
|
|
||||||
let line = matchstr(line,
|
|
||||||
\ '\\@writefile{toc}{\\contentsline\s*\zs.*\ze}\s*$')
|
|
||||||
if empty(line)
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let tree = LatexBox_TexToTree(s:ConvertBack(line))
|
|
||||||
|
|
||||||
if len(tree) < 3
|
|
||||||
" unknown entry type: just skip it
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
" parse level
|
|
||||||
let level = tree[0][0]
|
|
||||||
" parse page
|
|
||||||
if !empty(tree[2])
|
|
||||||
let page = tree[2][0]
|
|
||||||
else
|
|
||||||
let page = ''
|
|
||||||
endif
|
|
||||||
" parse section number
|
|
||||||
let secnum = ''
|
|
||||||
let tree = tree[1]
|
|
||||||
if len(tree) > 3 && empty(tree[1])
|
|
||||||
call remove(tree, 1)
|
|
||||||
endif
|
|
||||||
if len(tree) > 1 && type(tree[0]) == type("") && tree[0] =~ '^\\\(\(chapter\)\?numberline\|tocsection\)'
|
|
||||||
let secnum = LatexBox_TreeToTex(tree[1])
|
|
||||||
let secnum = substitute(secnum, '\\\S\+\s', '', 'g')
|
|
||||||
let secnum = substitute(secnum, '\\\S\+{\(.\{-}\)}', '\1', 'g')
|
|
||||||
let secnum = substitute(secnum, '^{\+\|}\+$', '', 'g')
|
|
||||||
call remove(tree, 1)
|
|
||||||
endif
|
|
||||||
" parse section title
|
|
||||||
let text = LatexBox_TreeToTex(tree)
|
|
||||||
let text = substitute(text, '^{\+\|}\+$', '', 'g')
|
|
||||||
let text = substitute(text, '\m^\\\(no\)\?\(chapter\)\?numberline\s*', '', '')
|
|
||||||
let text = substitute(text, '\*', '', 'g')
|
|
||||||
|
|
||||||
" add TOC entry
|
|
||||||
call add(fileindices[texfile], len(toc))
|
|
||||||
call add(toc, {'file': texfile,
|
|
||||||
\ 'level': level,
|
|
||||||
\ 'number': secnum,
|
|
||||||
\ 'text': text,
|
|
||||||
\ 'page': page})
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return [toc, fileindices]
|
|
||||||
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LatexBox_TOC(...)
|
|
||||||
|
|
||||||
" Check if window already exists
|
|
||||||
let winnr = bufwinnr(bufnr('LaTeX TOC'))
|
|
||||||
" Two types of splits, horizontal and vertical
|
|
||||||
let l:hori = "new"
|
|
||||||
let l:vert = "vnew"
|
|
||||||
|
|
||||||
" Set General Vars and initialize size
|
|
||||||
let l:type = g:LatexBox_split_type
|
|
||||||
let l:size = 10
|
|
||||||
|
|
||||||
" Size detection
|
|
||||||
if l:type == l:hori
|
|
||||||
let l:size = g:LatexBox_split_length
|
|
||||||
elseif l:type == l:vert
|
|
||||||
let l:size = g:LatexBox_split_width
|
|
||||||
endif
|
|
||||||
|
|
||||||
if winnr >= 0
|
|
||||||
if a:0 == 0
|
|
||||||
silent execute winnr . 'wincmd w'
|
|
||||||
else
|
|
||||||
" Supplying an argument to this function causes toggling instead
|
|
||||||
" of jumping to the TOC window
|
|
||||||
if g:LatexBox_split_resize
|
|
||||||
silent exe "set columns-=" . l:size
|
|
||||||
endif
|
|
||||||
silent execute 'bwipeout' . bufnr('LaTeX TOC')
|
|
||||||
endif
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" Read TOC
|
|
||||||
let [toc, fileindices] = s:ReadTOC(LatexBox_GetAuxFile(),
|
|
||||||
\ LatexBox_GetMainTexFile())
|
|
||||||
let calling_buf = bufnr('%')
|
|
||||||
|
|
||||||
" Find closest section in current buffer
|
|
||||||
let closest_index = s:FindClosestSection(toc,fileindices)
|
|
||||||
|
|
||||||
" Create TOC window and set local settings
|
|
||||||
if g:LatexBox_split_resize
|
|
||||||
silent exe "set columns+=" . l:size
|
|
||||||
endif
|
|
||||||
silent exe g:LatexBox_split_side l:size . l:type . ' LaTeX\ TOC'
|
|
||||||
|
|
||||||
let b:toc = toc
|
|
||||||
let b:toc_numbers = 1
|
|
||||||
let b:calling_win = bufwinnr(calling_buf)
|
|
||||||
setlocal filetype=latextoc
|
|
||||||
|
|
||||||
" Add TOC entries and jump to the closest section
|
|
||||||
for entry in toc
|
|
||||||
call append('$', entry['number'] . "\t" . entry['text'])
|
|
||||||
endfor
|
|
||||||
if !g:LatexBox_toc_hidehelp
|
|
||||||
call append('$', "")
|
|
||||||
call append('$', "<Esc>/q: close")
|
|
||||||
call append('$', "<Space>: jump")
|
|
||||||
call append('$', "<Enter>: jump and close")
|
|
||||||
call append('$', "s: hide numbering")
|
|
||||||
endif
|
|
||||||
0delete _
|
|
||||||
|
|
||||||
execute 'normal! ' . (closest_index + 1) . 'G'
|
|
||||||
|
|
||||||
" Lock buffer
|
|
||||||
setlocal nomodifiable
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Binary search for the closest section
|
|
||||||
" return the index of the TOC entry
|
|
||||||
function! s:FindClosestSection(toc, fileindices)
|
|
||||||
let file = expand('%:p')
|
|
||||||
if !has_key(a:fileindices, file)
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
let imax = len(a:fileindices[file])
|
|
||||||
if imax > 0
|
|
||||||
let imin = 0
|
|
||||||
while imin < imax - 1
|
|
||||||
let i = (imax + imin) / 2
|
|
||||||
let tocindex = a:fileindices[file][i]
|
|
||||||
let entry = a:toc[tocindex]
|
|
||||||
let titlestr = entry['text']
|
|
||||||
let titlestr = escape(titlestr, '\')
|
|
||||||
let titlestr = substitute(titlestr, ' ', '\\_\\s\\+', 'g')
|
|
||||||
let [lnum, cnum] = searchpos('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'nW')
|
|
||||||
if lnum
|
|
||||||
let imax = i
|
|
||||||
else
|
|
||||||
let imin = i
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
return a:fileindices[file][imin]
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:ConvBackPats = map([
|
|
||||||
\ ['\\''A}' , 'Á'],
|
|
||||||
\ ['\\`A}' , 'À'],
|
|
||||||
\ ['\\^A}' , 'À'],
|
|
||||||
\ ['\\¨A}' , 'Ä'],
|
|
||||||
\ ['\\"A}' , 'Ä'],
|
|
||||||
\ ['\\''a}' , 'á'],
|
|
||||||
\ ['\\`a}' , 'à'],
|
|
||||||
\ ['\\^a}' , 'à'],
|
|
||||||
\ ['\\¨a}' , 'ä'],
|
|
||||||
\ ['\\"a}' , 'ä'],
|
|
||||||
\ ['\\''E}' , 'É'],
|
|
||||||
\ ['\\`E}' , 'È'],
|
|
||||||
\ ['\\^E}' , 'Ê'],
|
|
||||||
\ ['\\¨E}' , 'Ë'],
|
|
||||||
\ ['\\"E}' , 'Ë'],
|
|
||||||
\ ['\\''e}' , 'é'],
|
|
||||||
\ ['\\`e}' , 'è'],
|
|
||||||
\ ['\\^e}' , 'ê'],
|
|
||||||
\ ['\\¨e}' , 'ë'],
|
|
||||||
\ ['\\"e}' , 'ë'],
|
|
||||||
\ ['\\''I}' , 'Í'],
|
|
||||||
\ ['\\`I}' , 'Î'],
|
|
||||||
\ ['\\^I}' , 'Ì'],
|
|
||||||
\ ['\\¨I}' , 'Ï'],
|
|
||||||
\ ['\\"I}' , 'Ï'],
|
|
||||||
\ ['\\''i}' , 'í'],
|
|
||||||
\ ['\\`i}' , 'î'],
|
|
||||||
\ ['\\^i}' , 'ì'],
|
|
||||||
\ ['\\¨i}' , 'ï'],
|
|
||||||
\ ['\\"i}' , 'ï'],
|
|
||||||
\ ['\\''{\?\\i }' , 'í'],
|
|
||||||
\ ['\\''O}' , 'Ó'],
|
|
||||||
\ ['\\`O}' , 'Ò'],
|
|
||||||
\ ['\\^O}' , 'Ô'],
|
|
||||||
\ ['\\¨O}' , 'Ö'],
|
|
||||||
\ ['\\"O}' , 'Ö'],
|
|
||||||
\ ['\\''o}' , 'ó'],
|
|
||||||
\ ['\\`o}' , 'ò'],
|
|
||||||
\ ['\\^o}' , 'ô'],
|
|
||||||
\ ['\\¨o}' , 'ö'],
|
|
||||||
\ ['\\"o}' , 'ö'],
|
|
||||||
\ ['\\''U}' , 'Ú'],
|
|
||||||
\ ['\\`U}' , 'Ù'],
|
|
||||||
\ ['\\^U}' , 'Û'],
|
|
||||||
\ ['\\¨U}' , 'Ü'],
|
|
||||||
\ ['\\"U}' , 'Ü'],
|
|
||||||
\ ['\\''u}' , 'ú'],
|
|
||||||
\ ['\\`u}' , 'ù'],
|
|
||||||
\ ['\\^u}' , 'û'],
|
|
||||||
\ ['\\¨u}' , 'ü'],
|
|
||||||
\ ['\\"u}' , 'ü'],
|
|
||||||
\ ['\\`N}' , 'Ǹ'],
|
|
||||||
\ ['\\\~N}' , 'Ñ'],
|
|
||||||
\ ['\\''n}' , 'ń'],
|
|
||||||
\ ['\\`n}' , 'ǹ'],
|
|
||||||
\ ['\\\~n}' , 'ñ'],
|
|
||||||
\], '[''\C\(\\IeC\s*{\)\?'' . v:val[0], v:val[1]]')
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" TOC Command {{{
|
|
||||||
command! LatexTOC call LatexBox_TOC()
|
|
||||||
command! LatexTOCToggle call LatexBox_TOC(1)
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,206 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" {{{1 Settings
|
|
||||||
setlocal buftype=nofile
|
|
||||||
setlocal bufhidden=wipe
|
|
||||||
setlocal nobuflisted
|
|
||||||
setlocal noswapfile
|
|
||||||
setlocal nowrap
|
|
||||||
setlocal nospell
|
|
||||||
setlocal cursorline
|
|
||||||
setlocal nonumber
|
|
||||||
setlocal nolist
|
|
||||||
setlocal tabstop=8
|
|
||||||
setlocal cole=0
|
|
||||||
setlocal cocu=nvic
|
|
||||||
if g:LatexBox_fold_toc
|
|
||||||
setlocal foldmethod=expr
|
|
||||||
setlocal foldexpr=TOCFoldLevel(v:lnum)
|
|
||||||
setlocal foldtext=TOCFoldText()
|
|
||||||
endif
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" {{{1 Functions
|
|
||||||
" {{{2 TOCClose
|
|
||||||
function! s:TOCClose()
|
|
||||||
if g:LatexBox_split_resize
|
|
||||||
silent exe "set columns-=" . g:LatexBox_split_width
|
|
||||||
endif
|
|
||||||
bwipeout
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 TOCToggleNumbers
|
|
||||||
function! s:TOCToggleNumbers()
|
|
||||||
if b:toc_numbers
|
|
||||||
setlocal conceallevel=3
|
|
||||||
let b:toc_numbers = 0
|
|
||||||
else
|
|
||||||
setlocal conceallevel=0
|
|
||||||
let b:toc_numbers = 1
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 EscapeTitle
|
|
||||||
function! s:EscapeTitle(titlestr)
|
|
||||||
let titlestr = substitute(a:titlestr, '\\[a-zA-Z@]*\>\s*{\?', '.*', 'g')
|
|
||||||
let titlestr = substitute(titlestr, '}', '', 'g')
|
|
||||||
let titlestr = substitute(titlestr, '\%(\.\*\s*\)\{2,}', '.*', 'g')
|
|
||||||
return titlestr
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 TOCActivate
|
|
||||||
function! s:TOCActivate(close)
|
|
||||||
let n = getpos('.')[1] - 1
|
|
||||||
|
|
||||||
if n >= len(b:toc)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let entry = b:toc[n]
|
|
||||||
|
|
||||||
let titlestr = s:EscapeTitle(entry['text'])
|
|
||||||
|
|
||||||
" Search for duplicates
|
|
||||||
"
|
|
||||||
let i=0
|
|
||||||
let entry_hash = entry['level'].titlestr
|
|
||||||
let duplicates = 0
|
|
||||||
while i<n
|
|
||||||
let i_entry = b:toc[n]
|
|
||||||
let i_hash = b:toc[i]['level'].s:EscapeTitle(b:toc[i]['text'])
|
|
||||||
if i_hash == entry_hash
|
|
||||||
let duplicates += 1
|
|
||||||
endif
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
let toc_bnr = bufnr('%')
|
|
||||||
let toc_wnr = winnr()
|
|
||||||
|
|
||||||
execute b:calling_win . 'wincmd w'
|
|
||||||
|
|
||||||
let root = fnamemodify(entry['file'], ':h') . '/'
|
|
||||||
let files = [entry['file']]
|
|
||||||
for line in filter(readfile(entry['file']), 'v:val =~ ''\\input{''')
|
|
||||||
let file = matchstr(line, '{\zs.\{-}\ze\(\.tex\)\?}') . '.tex'
|
|
||||||
if file[0] != '/'
|
|
||||||
let file = root . file
|
|
||||||
endif
|
|
||||||
call add(files, file)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Find section in buffer (or inputted files)
|
|
||||||
if entry['level'] == 'label'
|
|
||||||
let re = '\(\\label\_\s*{\|label\s*=\s*\)' . titlestr . '\>'
|
|
||||||
else
|
|
||||||
let re = '\\' . entry['level'] . '\_\s*{' . titlestr . '}'
|
|
||||||
endif
|
|
||||||
call s:TOCFindMatch(re, duplicates, files)
|
|
||||||
|
|
||||||
if a:close
|
|
||||||
if g:LatexBox_split_resize
|
|
||||||
silent exe "set columns-=" . g:LatexBox_split_width
|
|
||||||
endif
|
|
||||||
execute 'bwipeout ' . toc_bnr
|
|
||||||
else
|
|
||||||
execute toc_wnr . 'wincmd w'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 TOCFindMatch
|
|
||||||
function! s:TOCFindMatch(strsearch,duplicates,files)
|
|
||||||
if len(a:files) == 0
|
|
||||||
echoerr "Could not find: " . a:strsearch
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:TOCOpenBuf(a:files[0])
|
|
||||||
let dups = a:duplicates
|
|
||||||
|
|
||||||
" Skip duplicates
|
|
||||||
while dups > 0
|
|
||||||
if search(a:strsearch, 'w')
|
|
||||||
let dups -= 1
|
|
||||||
else
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
if search(a:strsearch, 'w')
|
|
||||||
normal! zv
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:TOCFindMatch(a:strsearch,dups,a:files[1:])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 TOCFoldLevel
|
|
||||||
function! TOCFoldLevel(lnum)
|
|
||||||
let line = getline(a:lnum)
|
|
||||||
let match_s1 = line =~# '^\w\+\s'
|
|
||||||
let match_s2 = line =~# '^\w\+\.\w\+\s'
|
|
||||||
let match_s3 = line =~# '^\w\+\.\w\+\.\w\+\s'
|
|
||||||
|
|
||||||
if g:LatexBox_fold_toc_levels >= 3
|
|
||||||
if match_s3
|
|
||||||
return ">3"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:LatexBox_fold_toc_levels >= 2
|
|
||||||
if match_s2
|
|
||||||
return ">2"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if match_s1
|
|
||||||
return ">1"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Don't fold options
|
|
||||||
if line =~# '^\s*$'
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Return previous fold level
|
|
||||||
return "="
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 TOCFoldText
|
|
||||||
function! TOCFoldText()
|
|
||||||
let parts = matchlist(getline(v:foldstart), '^\(.*\)\t\(.*\)$')
|
|
||||||
return printf('%-8s%-72s', parts[1], parts[2])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{2 TOCOpenBuf
|
|
||||||
function! s:TOCOpenBuf(file)
|
|
||||||
|
|
||||||
let bnr = bufnr(a:file)
|
|
||||||
if bnr == -1
|
|
||||||
execute 'badd ' . a:file
|
|
||||||
let bnr = bufnr(a:file)
|
|
||||||
endif
|
|
||||||
execute 'buffer! ' . bnr
|
|
||||||
normal! gg
|
|
||||||
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" {{{1 Mappings
|
|
||||||
nnoremap <buffer> <silent> s :call <SID>TOCToggleNumbers()<CR>
|
|
||||||
nnoremap <buffer> <silent> q :call <SID>TOCClose()<CR>
|
|
||||||
nnoremap <buffer> <silent> <Esc> :call <SID>TOCClose()<CR>
|
|
||||||
nnoremap <buffer> <silent> <Space> :call <SID>TOCActivate(0)<CR>
|
|
||||||
nnoremap <buffer> <silent> <CR> :call <SID>TOCActivate(1)<CR>
|
|
||||||
nnoremap <buffer> <silent> <leftrelease> :call <SID>TOCActivate(0)<cr>
|
|
||||||
nnoremap <buffer> <silent> <2-leftmouse> :call <SID>TOCActivate(1)<cr>
|
|
||||||
nnoremap <buffer> <silent> G G4k
|
|
||||||
nnoremap <buffer> <silent> <Esc>OA k
|
|
||||||
nnoremap <buffer> <silent> <Esc>OB j
|
|
||||||
nnoremap <buffer> <silent> <Esc>OC l
|
|
||||||
nnoremap <buffer> <silent> <Esc>OD h
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:et:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
" Vim filetype plugin
|
||||||
finish
|
" Language: Nix
|
||||||
endif
|
" Maintainer: Daiderd Jordan <daiderd@gmail.com>
|
||||||
let b:did_ftplugin=1
|
" 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
|
setlocal commentstring=#\ %s
|
||||||
|
|
||||||
" Nixpkgs indent settings
|
|
||||||
setlocal tabstop=2
|
|
||||||
setlocal softtabstop=2
|
|
||||||
setlocal shiftwidth=2
|
|
||||||
setlocal expandtab
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'openscad') == -1
|
|
||||||
|
|
||||||
" Blatantly stolen from vim74\ftplugin\c.vim
|
|
||||||
|
|
||||||
" Set 'formatoptions' to break comment lines but not other lines,
|
|
||||||
" and insert the comment leader when hitting <CR> or using "o".
|
|
||||||
setlocal fo-=t fo+=croql
|
|
||||||
|
|
||||||
" Set 'comments' to format dashed lists in comments.
|
|
||||||
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
|
|
||||||
|
|
||||||
" Win32 can filter files in the browse dialog
|
|
||||||
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
|
|
||||||
let b:browsefilter = "OpenSCAD Source Files (*.scad)\t*.scad\n" .
|
|
||||||
\ "All Files (*.*)\t*.*\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX Box plugin for Vim
|
|
||||||
" Maintainer: David Munger
|
|
||||||
" Email: mungerd@gmail.com
|
|
||||||
" Version: 0.9.6
|
|
||||||
|
|
||||||
if exists('*fnameescape')
|
|
||||||
function! s:FNameEscape(s)
|
|
||||||
return fnameescape(a:s)
|
|
||||||
endfunction
|
|
||||||
else
|
|
||||||
function! s:FNameEscape(s)
|
|
||||||
return a:s
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('b:LatexBox_loaded')
|
|
||||||
|
|
||||||
let prefix = expand('<sfile>:p:h') . '/latex-box/'
|
|
||||||
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'common.vim')
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'complete.vim')
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'motion.vim')
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'latexmk.vim')
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'folding.vim')
|
|
||||||
" added by AH to add main.tex file finder
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'findmain.vim')
|
|
||||||
execute 'source ' . s:FNameEscape(prefix . 'mappings.vim')
|
|
||||||
|
|
||||||
let b:LatexBox_loaded = 1
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -15,7 +15,7 @@ setlocal commentstring=//\ %s
|
|||||||
" " and insert the comment leader when hitting <CR> or using "o".
|
" " and insert the comment leader when hitting <CR> or using "o".
|
||||||
setlocal formatoptions-=t formatoptions+=croql
|
setlocal formatoptions-=t formatoptions+=croql
|
||||||
|
|
||||||
setlocal suffixesadd+=.ts
|
setlocal suffixesadd+=.ts,.tsx
|
||||||
|
|
||||||
let b:undo_ftplugin = "setl fo< ofu< com< cms<"
|
let b:undo_ftplugin = "setl fo< ofu< com< cms<"
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ let b:did_indent = 1
|
|||||||
|
|
||||||
" Doesn't include 'foreach' and 'forelse' because these already get matched by 'for'.
|
" 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\|' .
|
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'
|
let s:directives_end = 'else\|end\|empty\|show\|stop\|append\|overwrite'
|
||||||
|
|
||||||
if exists('g:blade_custom_directives_pairs')
|
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 #?
|
" Check if form is a reader conditional, that is, it is prefixed by #?
|
||||||
" or @#?
|
" or @#?
|
||||||
function! s:is_reader_conditional_special_case(position)
|
function! s:is_reader_conditional_special_case(position)
|
||||||
if getline(a:position[0])[a:position[1] - 3 : a:position[1] - 2] == "#?"
|
return getline(a:position[0])[a:position[1] - 3 : a:position[1] - 2] == "#?"
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
return 0
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Returns 1 for opening brackets, -1 for _anything else_.
|
" Returns 1 for opening brackets, -1 for _anything else_.
|
||||||
@@ -294,6 +290,19 @@ if exists("*searchpairpos")
|
|||||||
return paren
|
return paren
|
||||||
endif
|
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
|
" Test words without namespace qualifiers and leading reader macro
|
||||||
" metacharacters.
|
" 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
|
||||||
@@ -8,6 +8,7 @@ if exists("b:did_indent")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
setlocal autoindent cindent
|
setlocal autoindent cindent
|
||||||
|
setlocal formatoptions+=roq
|
||||||
|
|
||||||
" vim:set sts=2 sw=2 :
|
" vim:set sts=2 sw=2 :
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') ==
|
|||||||
" Language: Javascript
|
" Language: Javascript
|
||||||
" Maintainer: Chris Paul ( https://github.com/bounceme )
|
" Maintainer: Chris Paul ( https://github.com/bounceme )
|
||||||
" URL: https://github.com/pangloss/vim-javascript
|
" URL: https://github.com/pangloss/vim-javascript
|
||||||
" Last Change: September 18, 2017
|
" Last Change: December 4, 2017
|
||||||
|
|
||||||
" Only load this indent file when no other was loaded.
|
" Only load this indent file when no other was loaded.
|
||||||
if exists('b:did_indent')
|
if exists('b:did_indent')
|
||||||
@@ -12,10 +12,6 @@ if exists('b:did_indent')
|
|||||||
endif
|
endif
|
||||||
let b:did_indent = 1
|
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.
|
" Now, set up our indentation expression and keys that trigger it.
|
||||||
setlocal indentexpr=GetJavascriptIndent()
|
setlocal indentexpr=GetJavascriptIndent()
|
||||||
setlocal autoindent nolisp nosmartindent
|
setlocal autoindent nolisp nosmartindent
|
||||||
@@ -27,13 +23,6 @@ setlocal indentkeys+=0],0)
|
|||||||
|
|
||||||
let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<'
|
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.
|
" Only define the function once.
|
||||||
if exists('*GetJavascriptIndent')
|
if exists('*GetJavascriptIndent')
|
||||||
finish
|
finish
|
||||||
@@ -42,6 +31,23 @@ endif
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
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
|
" Get shiftwidth value
|
||||||
if exists('*shiftwidth')
|
if exists('*shiftwidth')
|
||||||
function s:sw()
|
function s:sw()
|
||||||
@@ -106,9 +112,7 @@ endfunction
|
|||||||
function s:SkipFunc()
|
function s:SkipFunc()
|
||||||
if s:top_col == 1
|
if s:top_col == 1
|
||||||
throw 'out of bounds'
|
throw 'out of bounds'
|
||||||
endif
|
elseif s:check_in
|
||||||
let s:top_col = 0
|
|
||||||
if s:check_in
|
|
||||||
if eval(s:skip_expr)
|
if eval(s:skip_expr)
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
@@ -117,11 +121,14 @@ function s:SkipFunc()
|
|||||||
if eval(s:skip_expr)
|
if eval(s:skip_expr)
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
elseif search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn) && eval(s:skip_expr)
|
elseif search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn)
|
||||||
let s:check_in = 1
|
if eval(s:skip_expr)
|
||||||
return 1
|
let s:check_in = 1
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let s:synid_cache[:] += [[line2byte('.') + col('.') - 1], ['']]
|
||||||
endif
|
endif
|
||||||
let s:synid_cache[:] += [[line2byte('.') + col('.') - 1], ['']]
|
|
||||||
let [s:looksyn, s:top_col] = getpos('.')[1:2]
|
let [s:looksyn, s:top_col] = getpos('.')[1:2]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -161,19 +168,29 @@ function s:Token()
|
|||||||
return s:LookingAt() =~ '\k' ? expand('<cword>') : s:LookingAt()
|
return s:LookingAt() =~ '\k' ? expand('<cword>') : s:LookingAt()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function s:PreviousToken()
|
function s:PreviousToken(...)
|
||||||
let l:col = col('.')
|
let [l:pos, tok] = [getpos('.'), '']
|
||||||
if search('\m\k\{1,}\|\S','ebW')
|
if search('\m\k\{1,}\|\S','ebW')
|
||||||
if search('\m\*\%#\/\|\/\/\%<'.a:firstline.'l','nbW',line('.')) && eval(s:in_comm)
|
if getline('.')[col('.')-2:col('.')-1] == '*/'
|
||||||
if s:SearchLoop('\S\ze\_s*\/[/*]','bW',s:in_comm)
|
if eval(s:in_comm) && !s:SearchLoop('\S\ze\_s*\/[/*]','bW',s:in_comm)
|
||||||
return s:Token()
|
call setpos('.',l:pos)
|
||||||
|
else
|
||||||
|
let tok = s:Token()
|
||||||
endif
|
endif
|
||||||
call cursor(a:firstline, l:col)
|
|
||||||
else
|
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
|
endif
|
||||||
endif
|
endif
|
||||||
return ''
|
return tok
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function s:Pure(f,...)
|
function s:Pure(f,...)
|
||||||
@@ -217,30 +234,29 @@ let s:opfirst = '^' . get(g:,'javascript_opfirst',
|
|||||||
let s:continuation = get(g:,'javascript_continuation',
|
let s:continuation = get(g:,'javascript_continuation',
|
||||||
\ '\C\%([<=,.~!?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<\%(typeof\|new\|delete\|void\|in\|instanceof\|await\)\)') . '$'
|
\ '\C\%([<=,.~!?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<\%(typeof\|new\|delete\|void\|in\|instanceof\|await\)\)') . '$'
|
||||||
|
|
||||||
function s:Continues(ln,con)
|
function s:Continues()
|
||||||
let tok = matchstr(a:con[-15:],s:continuation)
|
let tok = matchstr(strpart(getline('.'),col('.')-15,15),s:continuation)
|
||||||
if tok =~ '[a-z:]'
|
if tok =~ '[a-z:]'
|
||||||
call cursor(a:ln, len(a:con))
|
|
||||||
return tok == ':' ? s:ExprCol() : s:PreviousToken() != '.'
|
return tok == ':' ? s:ExprCol() : s:PreviousToken() != '.'
|
||||||
elseif tok !~ '[/>]'
|
elseif tok !~ '[/>]'
|
||||||
return tok isnot ''
|
return tok isnot ''
|
||||||
endif
|
endif
|
||||||
return s:SynAt(a:ln, len(a:con)) !~? (tok == '>' ? 'jsflow\|^html' : 'regex')
|
return s:SynAt(line('.'),col('.')) !~? (tok == '>' ? 'jsflow\|^html' : 'regex')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Check if line 'lnum' has a balanced amount of parentheses.
|
" Check if line 'lnum' has a balanced amount of parentheses.
|
||||||
function s:Balanced(lnum)
|
function s:Balanced(lnum,line)
|
||||||
let [l:open, l:line] = [0, getline(a:lnum)]
|
let l:open = 0
|
||||||
let pos = match(l:line, '[][(){}]')
|
let pos = match(a:line, '[][(){}]')
|
||||||
while pos != -1
|
while pos != -1
|
||||||
if s:SynAt(a:lnum,pos + 1) !~? b:syng_strcom
|
if s:SynAt(a:lnum,pos + 1) !~? b:syng_strcom
|
||||||
let l:open += match(' ' . l:line[pos],'[[({]')
|
let l:open += match(' ' . a:line[pos],'[[({]')
|
||||||
if l:open < 0
|
if l:open < 0
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let pos = match(l:line, !l:open ? '[][(){}]' : '()' =~ l:line[pos] ?
|
let pos = match(a:line, !l:open ? '[][(){}]' : '()' =~ a:line[pos] ?
|
||||||
\ '[()]' : '{}' =~ l:line[pos] ? '[{}]' : '[][]', pos + 1)
|
\ '[()]' : '{}' =~ a:line[pos] ? '[{}]' : '[][]', pos + 1)
|
||||||
endwhile
|
endwhile
|
||||||
return !l:open
|
return !l:open
|
||||||
endfunction
|
endfunction
|
||||||
@@ -253,27 +269,38 @@ function s:OneScope()
|
|||||||
\ s:Pure('s:PreviousToken') != '.' && !(tok == 'while' && s:DoWhile())
|
\ s:Pure('s:PreviousToken') != '.' && !(tok == 'while' && s:DoWhile())
|
||||||
elseif s:Token() =~# '^else$\|^do$'
|
elseif s:Token() =~# '^else$\|^do$'
|
||||||
return s:Pure('s:PreviousToken') != '.'
|
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
|
endif
|
||||||
return strpart(getline('.'),col('.')-2,2) == '=>'
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function s:DoWhile()
|
function s:DoWhile()
|
||||||
let cpos = searchpos('\m\<','cbW')
|
let cpos = searchpos('\m\<','cbW')
|
||||||
if s:SearchLoop('\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
|
while s:SearchLoop('\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
|
||||||
if s:{s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr) ?
|
if s:LookingAt() =~ '\a'
|
||||||
\ 'Previous' : ''}Token() ==# 'do' && s:IsBlock()
|
if s:Pure('s:IsBlock')
|
||||||
return 1
|
if s:LookingAt() ==# 'd'
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
elseif s:LookingAt() != '}' || !s:GetPair('{','}','bW',s:skip_expr)
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
call call('cursor',cpos)
|
endwhile
|
||||||
endif
|
call call('cursor',cpos)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" returns total offset from braceless contexts. 'num' is the lineNr which
|
" returns total offset from braceless contexts. 'num' is the lineNr which
|
||||||
" encloses the entire context, 'cont' if whether a:firstline is a continued
|
" encloses the entire context, 'cont' if whether a:firstline is a continued
|
||||||
" expression, which could have started in a braceless context
|
" expression, which could have started in a braceless context
|
||||||
function s:IsContOne(num,cont)
|
function s:IsContOne(cont)
|
||||||
let [l:num, b_l] = [a:num + !a:num, 0]
|
let [l:num, b_l] = [b:js_cache[1] + !b:js_cache[1], 0]
|
||||||
let pind = a:num ? indent(a:num) + s:sw() : 0
|
let pind = b:js_cache[1] ? indent(b:js_cache[1]) + s:sw() : 0
|
||||||
let ind = indent('.') + !a:cont
|
let ind = indent('.') + !a:cont
|
||||||
while line('.') > l:num && ind > pind || line('.') == l:num
|
while line('.') > l:num && ind > pind || line('.') == l:num
|
||||||
if indent('.') < ind && s:OneScope()
|
if indent('.') < ind && s:OneScope()
|
||||||
@@ -300,6 +327,7 @@ endfunction
|
|||||||
function s:IsBlock()
|
function s:IsBlock()
|
||||||
let tok = s:PreviousToken()
|
let tok = s:PreviousToken()
|
||||||
if join(s:stack) =~? 'xml\|jsx' && s:SynAt(line('.'),col('.')-1) =~? 'xml\|jsx'
|
if join(s:stack) =~? 'xml\|jsx' && s:SynAt(line('.'),col('.')-1) =~? 'xml\|jsx'
|
||||||
|
let s:in_jsx = 1
|
||||||
return tok != '{'
|
return tok != '{'
|
||||||
elseif tok =~ '\k'
|
elseif tok =~ '\k'
|
||||||
if tok ==# 'type'
|
if tok ==# 'type'
|
||||||
@@ -324,7 +352,7 @@ function s:IsBlock()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function GetJavascriptIndent()
|
function GetJavascriptIndent()
|
||||||
let b:js_cache = get(b:,'js_cache',[0,0,0])
|
call s:GetVars()
|
||||||
let s:synid_cache = [[],[]]
|
let s:synid_cache = [[],[]]
|
||||||
let l:line = getline(v:lnum)
|
let l:line = getline(v:lnum)
|
||||||
" use synstack as it validates syn state and works in an empty line
|
" use synstack as it validates syn state and works in an empty line
|
||||||
@@ -338,7 +366,7 @@ function GetJavascriptIndent()
|
|||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
elseif s:stack[-1] =~? b:syng_str
|
elseif s:stack[-1] =~? b:syng_str
|
||||||
if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1)
|
if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1,getline(v:lnum-1))
|
||||||
let b:js_cache[0] = v:lnum
|
let b:js_cache[0] = v:lnum
|
||||||
endif
|
endif
|
||||||
return -1
|
return -1
|
||||||
@@ -365,7 +393,7 @@ function GetJavascriptIndent()
|
|||||||
call cursor(v:lnum,1)
|
call cursor(v:lnum,1)
|
||||||
let idx = index([']',')','}'],l:line[0])
|
let idx = index([']',')','}'],l:line[0])
|
||||||
if b:js_cache[0] > l:lnum && b:js_cache[0] < v:lnum ||
|
if b:js_cache[0] > l:lnum && b:js_cache[0] < v:lnum ||
|
||||||
\ b:js_cache[0] == l:lnum && s:Balanced(l:lnum)
|
\ b:js_cache[0] == l:lnum && s:Balanced(l:lnum,pline)
|
||||||
call call('cursor',b:js_cache[1:])
|
call call('cursor',b:js_cache[1:])
|
||||||
else
|
else
|
||||||
let [s:looksyn, s:top_col, s:check_in, s:l1] = [v:lnum - 1,0,0,
|
let [s:looksyn, s:top_col, s:check_in, s:l1] = [v:lnum - 1,0,0,
|
||||||
@@ -386,10 +414,10 @@ function GetJavascriptIndent()
|
|||||||
|
|
||||||
let [b:js_cache[0], num] = [v:lnum, b:js_cache[1]]
|
let [b:js_cache[0], num] = [v:lnum, b:js_cache[1]]
|
||||||
|
|
||||||
let [num_ind, is_op, b_l, l:switch_offset] = [s:Nat(indent(num)),0,0,0]
|
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()
|
if !num || s:LookingAt() == '{' && s:IsBlock()
|
||||||
let ilnum = line('.')
|
let ilnum = line('.')
|
||||||
if num && s:LookingAt() == ')' && s:GetPair('(',')','bW',s:skip_expr)
|
if num && !s:in_jsx && s:LookingAt() == ')' && s:GetPair('(',')','bW',s:skip_expr)
|
||||||
if ilnum == num
|
if ilnum == num
|
||||||
let [num, num_ind] = [line('.'), indent('.')]
|
let [num, num_ind] = [line('.'), indent('.')]
|
||||||
endif
|
endif
|
||||||
@@ -403,26 +431,24 @@ function GetJavascriptIndent()
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if idx == -1 && pline[-1:] !~ '[{;]'
|
if idx == -1 && pline[-1:] !~ '[{;]'
|
||||||
|
call cursor(l:lnum, len(pline))
|
||||||
let sol = matchstr(l:line,s:opfirst)
|
let sol = matchstr(l:line,s:opfirst)
|
||||||
if sol is '' || sol == '/' && s:SynAt(v:lnum,
|
if sol is '' || sol == '/' && s:SynAt(v:lnum,
|
||||||
\ 1 + len(getline(v:lnum)) - len(l:line)) =~? 'regex'
|
\ 1 + len(getline(v:lnum)) - len(l:line)) =~? 'regex'
|
||||||
if s:Continues(l:lnum,pline)
|
if s:Continues()
|
||||||
let is_op = s:sw()
|
let is_op = s:sw()
|
||||||
endif
|
endif
|
||||||
elseif num && sol =~# '^\%(in\%(stanceof\)\=\|\*\)$'
|
elseif num && sol =~# '^\%(in\%(stanceof\)\=\|\*\)$' &&
|
||||||
call cursor(l:lnum, len(pline))
|
\ s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr) &&
|
||||||
if s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr) &&
|
\ s:PreviousToken() == ')' && s:GetPair('(',')','bW',s:skip_expr) &&
|
||||||
\ s:PreviousToken() == ')' && s:GetPair('(',')','bW',s:skip_expr) &&
|
\ (s:PreviousToken() == ']' || s:LookingAt() =~ '\k' &&
|
||||||
\ (s:PreviousToken() == ']' || s:Token() =~ '\k' &&
|
\ s:{s:PreviousToken() == '*' ? 'Previous' : ''}Token() !=# 'function')
|
||||||
\ s:{s:PreviousToken() == '*' ? 'Previous' : ''}Token() !=# 'function')
|
return num_ind + s:sw()
|
||||||
return num_ind + s:sw()
|
|
||||||
endif
|
|
||||||
let is_op = s:sw()
|
|
||||||
else
|
else
|
||||||
let is_op = s:sw()
|
let is_op = s:sw()
|
||||||
endif
|
endif
|
||||||
call cursor(l:lnum, len(pline))
|
call cursor(l:lnum, len(pline))
|
||||||
let b_l = s:Nat(s:IsContOne(b:js_cache[1],is_op) - (!is_op && l:line =~ '^{')) * s:sw()
|
let b_l = s:Nat(s:IsContOne(is_op) - (!is_op && l:line =~ '^{')) * s:sw()
|
||||||
endif
|
endif
|
||||||
elseif idx.s:LookingAt().&cino =~ '^-1(.*(' && (search('\m\S','nbW',num) || s:ParseCino('U'))
|
elseif idx.s:LookingAt().&cino =~ '^-1(.*(' && (search('\m\S','nbW',num) || s:ParseCino('U'))
|
||||||
let pval = s:ParseCino('(')
|
let pval = s:ParseCino('(')
|
||||||
@@ -438,10 +464,10 @@ function GetJavascriptIndent()
|
|||||||
|
|
||||||
" main return
|
" main return
|
||||||
if l:line =~ '^[])}]\|^|}'
|
if l:line =~ '^[])}]\|^|}'
|
||||||
if l:line_raw[0] == ')' && getline(num)[b:js_cache[2]-1] == '('
|
if l:line_raw[0] == ')'
|
||||||
if s:ParseCino('M')
|
if s:ParseCino('M')
|
||||||
return indent(l:lnum)
|
return indent(l:lnum)
|
||||||
elseif &cino =~# 'm' && !s:ParseCino('m')
|
elseif num && &cino =~# 'm' && !s:ParseCino('m')
|
||||||
return virtcol('.') - 1
|
return virtcol('.') - 1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
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
|
" Vim indent file
|
||||||
" Language: Julia
|
" Language: Julia
|
||||||
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
|
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
|
||||||
" Last Change: 2011 dec 11
|
" Last Change: 2016 jun 16
|
||||||
" Notes: based on Bram Moneaar's indent file for vim
|
" Notes: originally based on Bram Molenaar's indent file for vim
|
||||||
|
|
||||||
setlocal autoindent
|
setlocal autoindent
|
||||||
|
|
||||||
setlocal indentexpr=GetJuliaIndent()
|
setlocal indentexpr=GetJuliaIndent()
|
||||||
setlocal indentkeys+==end,=else,=catch,=finally
|
setlocal indentkeys+==end,=else,=catch,=finally,),],}
|
||||||
setlocal indentkeys-=0#
|
setlocal indentkeys-=0#
|
||||||
setlocal indentkeys-=:
|
setlocal indentkeys-=:
|
||||||
setlocal indentkeys-=0{
|
setlocal indentkeys-=0{
|
||||||
@@ -21,12 +21,16 @@ if exists("*GetJuliaIndent")
|
|||||||
finish
|
finish
|
||||||
endif
|
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 s = a:st
|
||||||
|
let e = a:0 > 0 ? a:1 : -1
|
||||||
while 1
|
while 1
|
||||||
let f = match(a:str, a:regex, s)
|
let f = match(a:str, a:regex, s)
|
||||||
|
if e >= 0 && f >= e
|
||||||
|
return -1
|
||||||
|
endif
|
||||||
if f >= 0
|
if f >= 0
|
||||||
let attr = synIDattr(synID(a:lnum,f+1,1),"name")
|
let attr = synIDattr(synID(a:lnum,f+1,1),"name")
|
||||||
if attr =~ s:skipPatterns
|
if attr =~ s:skipPatterns
|
||||||
@@ -39,15 +43,16 @@ function JuliaMatch(lnum, str, regex, st)
|
|||||||
return f
|
return f
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function GetJuliaNestingStruct(lnum)
|
function GetJuliaNestingStruct(lnum, ...)
|
||||||
" Auxiliary function to inspect the block structure of a line
|
" Auxiliary function to inspect the block structure of a line
|
||||||
let line = getline(a:lnum)
|
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 blocks_stack = []
|
||||||
let num_closed_blocks = 0
|
let num_closed_blocks = 0
|
||||||
while 1
|
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 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)
|
let fe = JuliaMatch(a:lnum, line, '@\@<!\<end\>', s, e)
|
||||||
|
|
||||||
if fb < 0 && fe < 0
|
if fb < 0 && fe < 0
|
||||||
" No blocks found
|
" No blocks found
|
||||||
@@ -128,9 +133,13 @@ function GetJuliaNestingStruct(lnum)
|
|||||||
continue
|
continue
|
||||||
endif
|
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
|
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')
|
call add(blocks_stack, 'other')
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
@@ -158,6 +167,128 @@ function GetJuliaNestingStruct(lnum)
|
|||||||
return [num_open_blocks, num_closed_blocks]
|
return [num_open_blocks, num_closed_blocks]
|
||||||
endfunction
|
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()
|
function GetJuliaIndent()
|
||||||
let s:save_ignorecase = &ignorecase
|
let s:save_ignorecase = &ignorecase
|
||||||
set noignorecase
|
set noignorecase
|
||||||
@@ -172,19 +303,81 @@ function GetJuliaIndent()
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let ind = indent(lnum)
|
let ind = -1
|
||||||
|
let st = -1
|
||||||
|
let lim = -1
|
||||||
|
|
||||||
" Analyse previous line
|
" Multiline bracketed expressions take precedence
|
||||||
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum)
|
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
|
" Increase indentation for each newly opened block
|
||||||
" in the previous line
|
" in the reference line
|
||||||
while num_open_blocks > 0
|
while num_open_blocks > 0
|
||||||
let ind += &sw
|
let ind += &sw
|
||||||
let num_open_blocks -= 1
|
let num_open_blocks -= 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Analyse current line
|
" Analyse the current line
|
||||||
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum)
|
let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum)
|
||||||
|
|
||||||
" Decrease indentation for each closed block
|
" Decrease indentation for each closed block
|
||||||
|
|||||||
@@ -74,48 +74,42 @@ function GetLuaIndent()
|
|||||||
|
|
||||||
let original_cursor_pos = getpos(".")
|
let original_cursor_pos = getpos(".")
|
||||||
|
|
||||||
let i = 0
|
" count how many blocks the previous line opens
|
||||||
|
|
||||||
" check if the previous line opens blocks
|
|
||||||
call cursor(v:lnum, 1)
|
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)
|
\ '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
|
" count how many blocks the current line closes
|
||||||
if num_pairs > 1 && contents_prev =~# s:anon_func_start
|
|
||||||
let i = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" check if current line closes blocks
|
|
||||||
call cursor(prev_line, col([prev_line,'$']))
|
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)
|
\ '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
|
let i = num_prev_opens - num_cur_closes
|
||||||
if num_pairs > 1 && contents_cur =~# s:anon_func_end
|
|
||||||
let i = -1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" 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, '$']))
|
call cursor(prev_line - 1, col([prev_line - 1, '$']))
|
||||||
let num_pairs = searchpair('(', '', ')', 'mr', s:skip_expr, prev_line)
|
let num_prev_closed_parens = searchpair('(', '', ')', 'mr', s:skip_expr, prev_line)
|
||||||
if num_pairs > 0 && contents_prev !~ s:anon_func_end
|
if num_prev_closed_parens > 0 && contents_prev !~# s:anon_func_end
|
||||||
let i -= 1
|
let i -= 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" if this line closed a paren, indent (except with anon funcs)
|
" if this line closed a paren, indent (except with anon funcs)
|
||||||
call cursor(prev_line, col([prev_line, '$']))
|
call cursor(prev_line, col([prev_line, '$']))
|
||||||
let num_pairs = searchpair('(', '', ')', 'mr', s:skip_expr, v:lnum)
|
let num_cur_closed_parens = searchpair('(', '', ')', 'mr', s:skip_expr, v:lnum)
|
||||||
if num_pairs > 0 && contents_cur !~ s:anon_func_end
|
if num_cur_closed_parens > 0 && contents_cur !~# s:anon_func_end
|
||||||
let i += 1
|
let i += 1
|
||||||
endif
|
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
|
" restore cursor
|
||||||
call setpos(".", original_cursor_pos)
|
call setpos(".", original_cursor_pos)
|
||||||
|
|
||||||
|
|||||||
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'
|
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
||||||
let brace = strpart(line, bracepos, 1)
|
let brace = strpart(line, bracepos, 1)
|
||||||
if brace == '(' || brace == '{' || brace == '['
|
if brace == '(' || brace == '{' || brace == '['
|
||||||
let ind = ind + &sw
|
let ind = ind + shiftwidth()
|
||||||
else
|
else
|
||||||
let ind = ind - &sw
|
let ind = ind - shiftwidth()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let bracepos = match(line, braceclass, bracepos + 1)
|
let bracepos = match(line, braceclass, bracepos + 1)
|
||||||
@@ -151,25 +151,25 @@ function! GetPerlIndent()
|
|||||||
\ || synid == "perlBraces"
|
\ || synid == "perlBraces"
|
||||||
\ || synid == "perlStatementIndirObj"
|
\ || synid == "perlStatementIndirObj"
|
||||||
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
\ || synid =~ '^perl\(Sub\|Block\|Package\)Fold'
|
||||||
let ind = ind - &sw
|
let ind = ind - shiftwidth()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if line =~ '[{[(]\s*\(#[^])}]*\)\=$'
|
if line =~ '[{[(]\s*\(#[^])}]*\)\=$'
|
||||||
let ind = ind + &sw
|
let ind = ind + shiftwidth()
|
||||||
endif
|
endif
|
||||||
if cline =~ '^\s*[])}]'
|
if cline =~ '^\s*[])}]'
|
||||||
let ind = ind - &sw
|
let ind = ind - shiftwidth()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Indent lines that begin with 'or' or 'and'
|
" Indent lines that begin with 'or' or 'and'
|
||||||
if cline =~ '^\s*\(or\|and\)\>'
|
if cline =~ '^\s*\(or\|and\)\>'
|
||||||
if line !~ '^\s*\(or\|and\)\>'
|
if line !~ '^\s*\(or\|and\)\>'
|
||||||
let ind = ind + &sw
|
let ind = ind + shiftwidth()
|
||||||
endif
|
endif
|
||||||
elseif line =~ '^\s*\(or\|and\)\>'
|
elseif line =~ '^\s*\(or\|and\)\>'
|
||||||
let ind = ind - &sw
|
let ind = ind - shiftwidth()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return ind
|
return ind
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ let b:did_indent = 1
|
|||||||
" smartindent is good enough for powershell
|
" smartindent is good enough for powershell
|
||||||
setlocal smartindent
|
setlocal smartindent
|
||||||
" disable the indent removal for # marks
|
" disable the indent removal for # marks
|
||||||
inoremap # X#
|
inoremap <buffer> # X#
|
||||||
|
|
||||||
let b:undo_indent = "setl si<"
|
let b:undo_indent = "setl si<"
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'qml') == -1
|
|||||||
" Language: QML
|
" Language: QML
|
||||||
" Author: Robert Kieffer
|
" Author: Robert Kieffer
|
||||||
" URL:
|
" URL:
|
||||||
" Last Change: 2010-03-27 (Happy Birthday, Dash!)
|
" Last Change: 2017-10-27
|
||||||
"
|
"
|
||||||
" Improved JavaScript indent script.
|
" Improved JavaScript indent script.
|
||||||
|
|
||||||
@@ -22,10 +22,10 @@ if exists("*GetJsIndent")
|
|||||||
finish
|
finish
|
||||||
endif
|
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
|
" whitespace
|
||||||
function! Trim(line)
|
function! Trim(line)
|
||||||
return substitute(substitute(a:line, '// .*', '', ''), '^\s*\|\s*$', '', 'g')
|
return substitute(substitute(substitute(a:line, '// .*', '', ''), '/\* .* \*/', '', ''), '^\s*\|\s*$', '', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! GetJsIndent()
|
function! GetJsIndent()
|
||||||
|
|||||||
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
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'terraform') == -1
|
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")
|
if exists("b:did_indent")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let b:did_indent = 1
|
let b:did_indent = 1
|
||||||
|
|
||||||
setlocal nolisp
|
setlocal nolisp
|
||||||
setlocal autoindent
|
setlocal autoindent sw=2 ts=2
|
||||||
setlocal indentexpr=TerraformIndent(v:lnum)
|
setlocal indentexpr=TerraformIndent(v:lnum)
|
||||||
setlocal indentkeys+=<:>,0=},0=)
|
setlocal indentkeys+=<:>,0=},0=)
|
||||||
|
|
||||||
@@ -16,29 +16,30 @@ if exists("*TerraformIndent")
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! TerraformIndent(lnum)
|
function! TerraformIndent(lnum)
|
||||||
" previous non-blank line
|
" Beginning of the file should have no indent
|
||||||
let prevlnum = prevnonblank(a:lnum-1)
|
if a:lnum == 0
|
||||||
|
|
||||||
" beginning of file?
|
|
||||||
if prevlnum == 0
|
|
||||||
return 0
|
return 0
|
||||||
endif
|
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 prevline = substitute(getline(prevlnum), '//.*$', '', '')
|
||||||
let previndent = indent(prevlnum)
|
let previndent = indent(prevlnum)
|
||||||
let thisindent = previndent
|
let thisindent = previndent
|
||||||
|
|
||||||
" block open?
|
" Config block starting with [ { ( should increase the indent level
|
||||||
if prevline =~ '[\[{\(]\s*$'
|
if prevline =~ '[\[{\(]\s*$'
|
||||||
let thisindent += &sw
|
let thisindent += &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" current line without comments
|
" Current line without comments should continue the indent level
|
||||||
let thisline = substitute(getline(a:lnum), '//.*$', '', '')
|
let thisline = substitute(getline(a:lnum), '//.*$', '', '')
|
||||||
|
|
||||||
" block close?
|
" Config block ending with ) } ] should get the indentation
|
||||||
if thisline =~ '^\s*[\)\]}]'
|
" level from the initial config block
|
||||||
|
if thisline =~ '^\s*[\)}\]]'
|
||||||
let thisindent -= &sw
|
let thisindent -= &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
140
indent/tex.vim
140
indent/tex.vim
@@ -1,140 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
" LaTeX indent file (part of LaTeX Box)
|
|
||||||
" Maintainer: David Munger (mungerd@gmail.com)
|
|
||||||
|
|
||||||
if exists("g:LatexBox_custom_indent") && ! g:LatexBox_custom_indent
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
if exists("b:did_indent")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:did_indent = 1
|
|
||||||
|
|
||||||
setlocal indentexpr=LatexBox_TexIndent()
|
|
||||||
setlocal indentkeys=0=\\end,0=\\end{enumerate},0=\\end{itemize},0=\\end{description},0=\\right,0=\\item,0=\\),0=\\],0},o,O,0\\
|
|
||||||
|
|
||||||
let s:list_envs = ['itemize', 'enumerate', 'description']
|
|
||||||
" indent on \left( and on \(, but not on (
|
|
||||||
" indent on \left[ and on \[, but not on [
|
|
||||||
" indent on \left\{ and on {, but not on \{
|
|
||||||
let s:open_pat = '\\\@<!\%(\\begin\|\\left\a\@!\|\\(\|\\\[\|{\)'
|
|
||||||
let s:close_pat = '\\\@<!\%(\\end\|\\right\a\@!\|\\)\|\\\]\|}\)'
|
|
||||||
let s:list_open_pat = '\\\@<!\\begin{\%(' . join(s:list_envs, '\|') . '\)}'
|
|
||||||
let s:list_close_pat = '\\\@<!\\end{\%(' . join(s:list_envs, '\|') . '\)}'
|
|
||||||
|
|
||||||
function! s:CountMatches(str, pat)
|
|
||||||
return len(substitute(substitute(a:str, a:pat, "\n", 'g'), "[^\n]", '', 'g'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
" TexIndent {{{
|
|
||||||
function! LatexBox_TexIndent()
|
|
||||||
|
|
||||||
let lnum_curr = v:lnum
|
|
||||||
let lnum_prev = prevnonblank(lnum_curr - 1)
|
|
||||||
|
|
||||||
if lnum_prev == 0
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
let line_curr = getline(lnum_curr)
|
|
||||||
let line_prev = getline(lnum_prev)
|
|
||||||
|
|
||||||
" remove \\
|
|
||||||
let line_curr = substitute(line_curr, '\\\\', '', 'g')
|
|
||||||
let line_prev = substitute(line_prev, '\\\\', '', 'g')
|
|
||||||
|
|
||||||
" strip comments
|
|
||||||
let line_curr = substitute(line_curr, '\\\@<!%.*$', '', 'g')
|
|
||||||
let line_prev = substitute(line_prev, '\\\@<!%.*$', '', 'g')
|
|
||||||
|
|
||||||
" find unmatched opening patterns on previous line
|
|
||||||
let n = s:CountMatches(line_prev, s:open_pat)-s:CountMatches(line_prev, s:close_pat)
|
|
||||||
let n += s:CountMatches(line_prev, s:list_open_pat)-s:CountMatches(line_prev, s:list_close_pat)
|
|
||||||
|
|
||||||
" reduce indentation if current line starts with a closing pattern
|
|
||||||
if line_curr =~ '^\s*\%(' . s:close_pat . '\)'
|
|
||||||
let n -= 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" compensate indentation if previous line starts with a closing pattern
|
|
||||||
if line_prev =~ '^\s*\%(' . s:close_pat . '\)'
|
|
||||||
let n += 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" reduce indentation if current line starts with a closing list
|
|
||||||
if line_curr =~ '^\s*\%(' . s:list_close_pat . '\)'
|
|
||||||
let n -= 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" compensate indentation if previous line starts with a closing list
|
|
||||||
if line_prev =~ '^\s*\%(' . s:list_close_pat . '\)'
|
|
||||||
let n += 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" reduce indentation if previous line is \begin{document}
|
|
||||||
if line_prev =~ '\\begin\s*{document}'
|
|
||||||
let n -= 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" less shift for lines starting with \item
|
|
||||||
let item_here = line_curr =~ '^\s*\\item'
|
|
||||||
let item_above = line_prev =~ '^\s*\\item'
|
|
||||||
if !item_here && item_above
|
|
||||||
let n += 1
|
|
||||||
elseif item_here && !item_above
|
|
||||||
let n -= 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
return indent(lnum_prev) + n * &sw
|
|
||||||
endfunction
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" Restore cursor position, window position, and last search after running a
|
|
||||||
" command.
|
|
||||||
function! Latexbox_CallIndent()
|
|
||||||
" Save the current cursor position.
|
|
||||||
let cursor = getpos('.')
|
|
||||||
|
|
||||||
" Save the current window position.
|
|
||||||
normal! H
|
|
||||||
let window = getpos('.')
|
|
||||||
call setpos('.', cursor)
|
|
||||||
|
|
||||||
" Get first non-whitespace character of current line.
|
|
||||||
let line_start_char = matchstr(getline('.'), '\S')
|
|
||||||
|
|
||||||
" Get initial tab position.
|
|
||||||
let initial_tab = stridx(getline('.'), line_start_char)
|
|
||||||
|
|
||||||
" Execute the command.
|
|
||||||
execute 'normal! =='
|
|
||||||
|
|
||||||
" Get tab position difference.
|
|
||||||
let difference = stridx(getline('.'), line_start_char) - initial_tab
|
|
||||||
|
|
||||||
" Set new cursor Y position based on calculated difference.
|
|
||||||
let cursor[2] = cursor[2] + difference
|
|
||||||
|
|
||||||
" Restore the previous window position.
|
|
||||||
call setpos('.', window)
|
|
||||||
normal! zt
|
|
||||||
|
|
||||||
" Restore the previous cursor position.
|
|
||||||
call setpos('.', cursor)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" autocmd to call indent after completion
|
|
||||||
" 7.3.598
|
|
||||||
if v:version > 703 || (v:version == 703 && has('patch598'))
|
|
||||||
augroup LatexBox_Completion
|
|
||||||
autocmd!
|
|
||||||
autocmd CompleteDone <buffer> call Latexbox_CallIndent()
|
|
||||||
augroup END
|
|
||||||
endif
|
|
||||||
|
|
||||||
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
|
|
||||||
|
|
||||||
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
|
syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display
|
||||||
hi def link coffeeException Exception
|
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
|
\ display
|
||||||
" The `own` keyword is only a keyword after `for`.
|
" The `own` keyword is only a keyword after `for`.
|
||||||
syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat
|
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:
|
" An error for reserved keywords, taken from the RESERVED array:
|
||||||
" http://coffeescript.org/documentation/docs/lexer.html#section-67
|
" 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
|
\ display
|
||||||
hi def link coffeeReservedError Error
|
hi def link coffeeReservedError Error
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ endif
|
|||||||
|
|
||||||
syn cluster crystalNotTop contains=@crystalExtendedStringSpecial,@crystalRegexpSpecial,@crystalDeclaration,crystalConditional,crystalExceptional,crystalMethodExceptional,crystalTodo,crystalLinkAttr
|
syn cluster crystalNotTop contains=@crystalExtendedStringSpecial,@crystalRegexpSpecial,@crystalDeclaration,crystalConditional,crystalExceptional,crystalMethodExceptional,crystalTodo,crystalLinkAttr
|
||||||
|
|
||||||
if exists('crystal_space_errors')
|
if exists('g:crystal_space_errors')
|
||||||
if !exists('crystal_no_trail_space_error')
|
if !exists('g:crystal_no_trail_space_error')
|
||||||
syn match crystalSpaceError display excludenl "\s\+$"
|
syn match crystalSpaceError display excludenl "\s\+$"
|
||||||
endif
|
endif
|
||||||
if !exists('crystal_no_tab_space_error')
|
if !exists('g:crystal_no_tab_space_error')
|
||||||
syn match crystalSpaceError display " \+\t"me=e-1
|
syn match crystalSpaceError display " \+\t"me=e-1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Operators
|
" Operators
|
||||||
if exists('crystal_operators')
|
if exists('g:crystal_operators')
|
||||||
syn match crystalOperator "[~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::"
|
syn match crystalOperator "[~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::"
|
||||||
syn match crystalOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!="
|
syn match crystalOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!="
|
||||||
syn region crystalBracketOperator matchgroup=crystalOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@crystalNotTop
|
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 fold keepend
|
||||||
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=crystalStringDelimiter end=+^\s*\zs\z1$+ contains=crystalHeredocStart,@crystalStringSpecial fold keepend
|
syn region crystalString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3 matchgroup=crystalStringDelimiter end=+^\s*\zs\z1$+ contains=crystalHeredocStart,@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
|
let b:crystal_no_expensive = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
syn match crystalAliasDeclaration "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable nextgroup=crystalAliasDeclaration2 skipwhite
|
syn match crystalAliasDeclaration "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable nextgroup=crystalAliasDeclaration2 skipwhite
|
||||||
syn match crystalAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable
|
syn match crystalAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=crystalSymbol,crystalGlobalVariable,crystalPredefinedVariable
|
||||||
syn match crystalMethodDeclaration "[^[:space:];#(]\+" contained contains=crystalConstant,crystalBoolean,crystalPseudoVariable,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable
|
syn match crystalMethodDeclaration "[^[:space:];#(]\+" contained contains=crystalConstant,crystalBoolean,crystalPseudoVariable,crystalInstanceVariable,crystalClassVariable,crystalGlobalVariable
|
||||||
syn match crystalFunctionDeclaration "[^[:space:];#(=]\+" contained contains=crystalConstant
|
syn match crystalFunctionDeclaration "[^[:space:];#(=]\+" contained contains=crystalConstant
|
||||||
syn match crystalTypeDeclaration "[^[:space:];#=]\+" contained contains=crystalConstant
|
syn match crystalTypeDeclaration "[^[:space:];#=]\+" contained contains=crystalConstant
|
||||||
syn match crystalClassDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
syn match crystalClassDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
||||||
syn match crystalModuleDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
syn match crystalModuleDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
||||||
syn match crystalStructDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
syn match crystalStructDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
||||||
syn match crystalLibDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
syn match crystalLibDeclaration "[^[:space:];#<]\+" contained contains=crystalConstant,crystalOperator
|
||||||
syn match crystalMacroDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant,crystalOperator
|
syn match crystalMacroDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant,crystalOperator
|
||||||
syn match crystalEnumDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant
|
syn match crystalEnumDeclaration "[^[:space:];#<\"]\+" contained contains=crystalConstant
|
||||||
syn match crystalFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=crystalMethodDeclaration,crystalFunctionDeclaration
|
syn match crystalFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=crystalMethodDeclaration,crystalFunctionDeclaration
|
||||||
syn match crystalFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2
|
syn match crystalFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2
|
||||||
syn match crystalFunction "\%([[:space:].]\|^\)\@<=\%(\[\][=?]\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration
|
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
|
syn cluster crystalDeclaration contains=crystalAliasDeclaration,crystalAliasDeclaration2,crystalMethodDeclaration,crystalFunctionDeclaration,crystalModuleDeclaration,crystalClassDeclaration,crystalStructDeclaration,crystalLibDeclaration,crystalMacroDeclaration,crystalFunction,crystalBlockParameter,crystalTypeDeclaration,crystalEnumDeclaration
|
||||||
|
|
||||||
" Keywords
|
" Keywords
|
||||||
" Note: the following keywords have already been defined:
|
" Note: the following keywords have already been defined:
|
||||||
" begin case class def do end for if module unless until while
|
" begin case class def do end for if module unless until while
|
||||||
syn match crystalControl "\<\%(break\|in\|next\|rescue\|return\)\>[?!]\@!"
|
syn match crystalControl "\<\%(break\|in\|next\|rescue\|return\)\>[?!]\@!"
|
||||||
syn match crystalOperator "\<defined?" display
|
syn match crystalOperator "\<defined?" display
|
||||||
syn match crystalKeyword "\<\%(super\|previous_def\|yield\|as\|of\|with\)\>[?!]\@!"
|
syn match crystalKeyword "\<\%(super\|previous_def\|yield\|of\|with\|uninitialized\|union\)\>[?!]\@!"
|
||||||
syn match crystalBoolean "\<\%(true\|false\)\>[?!]\@!"
|
syn match crystalBoolean "\<\%(true\|false\)\>[?!]\@!"
|
||||||
syn match crystalPseudoVariable "\<\%(nil\|self\|__DIR__\|__FILE__\|__LINE__\)\>[?!]\@!" " TODO: reorganise
|
syn match crystalPseudoVariable "\<\%(nil\|self\|__DIR__\|__FILE__\|__LINE__\|__END_LINE__\)\>[?!]\@!" " TODO: reorganise
|
||||||
|
|
||||||
" Expensive Mode - match 'end' with the appropriate opening keyword for syntax
|
" Expensive Mode - match 'end' with the appropriate opening keyword for syntax
|
||||||
" based folding and special highlighting of module/class/method definitions
|
" 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 "\<alias\>" nextgroup=crystalAliasDeclaration skipwhite skipnl
|
||||||
syn match crystalDefine "\<def\>" nextgroup=crystalMethodDeclaration skipwhite skipnl
|
syn match crystalDefine "\<def\>" nextgroup=crystalMethodDeclaration skipwhite skipnl
|
||||||
syn match crystalDefine "\<fun\>" nextgroup=crystalFunctionDeclaration 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 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
|
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')
|
if !exists('g:crystal_minlines')
|
||||||
let crystal_minlines = 500
|
let g:crystal_minlines = 500
|
||||||
endif
|
endif
|
||||||
exec 'syn sync minlines=' . crystal_minlines
|
exec 'syn sync minlines=' . g:crystal_minlines
|
||||||
|
|
||||||
else
|
else
|
||||||
syn match crystalControl "\<def\>[?!]\@!" nextgroup=crystalMethodDeclaration skipwhite skipnl
|
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
|
syn match crystalLinkAttr "]" contained containedin=crystalLinkAttrRegion display
|
||||||
|
|
||||||
" Special Methods
|
" Special Methods
|
||||||
if !exists('crystal_no_special_methods')
|
if !exists('g:crystal_no_special_methods')
|
||||||
syn keyword crystalAccess protected private
|
syn keyword crystalAccess protected private
|
||||||
" attr is a common variable name
|
" attr is a common variable name
|
||||||
syn keyword crystalAttribute getter setter property abstract
|
syn keyword crystalAttribute getter setter property abstract
|
||||||
@@ -293,7 +293,7 @@ syn match crystalMacro "\%({%\|%}\|{{\|}}\)" nextgroup=crystalMacroRegion skipwh
|
|||||||
syn match crystalSharpBang "\%^#!.*" display
|
syn match crystalSharpBang "\%^#!.*" display
|
||||||
syn keyword crystalTodo FIXME NOTE TODO OPTIMIZE XXX todo contained
|
syn keyword crystalTodo FIXME NOTE TODO OPTIMIZE XXX todo contained
|
||||||
syn match crystalComment "#.*" contains=crystalSharpBang,crystalSpaceError,crystalTodo,@Spell
|
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
|
syn region crystalMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=crystalComment transparent fold keepend
|
||||||
endif
|
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 "\<\%(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*\%(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*\%(loop\|private\|protected\)\>" transparent contains=NONE
|
||||||
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(require\|raise\)\>" transparent contains=NONE
|
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(require\|raise\)\>" transparent contains=NONE
|
||||||
syn match crystalKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(typeof\|pointerof\|sizeof\|instance_sizeof\|\)\>" 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 crystalFloat Float
|
||||||
hi def link crystalBoolean Boolean
|
hi def link crystalBoolean Boolean
|
||||||
hi def link crystalException Exception
|
hi def link crystalException Exception
|
||||||
if !exists('crystal_no_identifiers')
|
if !exists('g:crystal_no_identifiers')
|
||||||
hi def link crystalIdentifier Identifier
|
hi def link crystalIdentifier Identifier
|
||||||
else
|
else
|
||||||
hi def link crystalIdentifier NONE
|
hi def link crystalIdentifier NONE
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ syntax keyword dartTodo contained TODO FIXME XXX
|
|||||||
syntax region dartComment start="/\*" end="\*/" contains=dartComment,dartTodo,dartDocLink,@Spell
|
syntax region dartComment start="/\*" end="\*/" contains=dartComment,dartTodo,dartDocLink,@Spell
|
||||||
syntax match dartLineComment "//.*" contains=dartTodo,@Spell
|
syntax match dartLineComment "//.*" contains=dartTodo,@Spell
|
||||||
syntax match dartLineDocComment "///.*" contains=dartTodo,dartDocLink,@Spell
|
syntax match dartLineDocComment "///.*" contains=dartTodo,dartDocLink,@Spell
|
||||||
|
syntax match dartShebangLine /^\%1l#!.*/
|
||||||
syntax region dartDocLink oneline contained start=+\[+ end=+\]+
|
syntax region dartDocLink oneline contained start=+\[+ end=+\]+
|
||||||
|
|
||||||
" Strings
|
" Strings
|
||||||
@@ -83,8 +84,8 @@ endif
|
|||||||
syntax cluster dartStringContains contains=@dartRawStringContains,dartInterpolation,dartSpecialChar
|
syntax cluster dartStringContains contains=@dartRawStringContains,dartInterpolation,dartSpecialChar
|
||||||
syntax region dartString oneline start=+\z(["']\)+ end=+\z1+ contains=@dartStringContains keepend
|
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 dartRawString oneline start=+r\z(["']\)+ end=+\z1+ contains=@dartRawStringContains keepend
|
||||||
syntax region dartMultilineString start=+\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@dartStringContains
|
syntax region dartMultilineString start=+\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@dartStringContains keepend
|
||||||
syntax region dartRawMultilineString start=+r\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@dartSRawtringContains
|
syntax region dartRawMultilineString start=+r\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@dartSRawtringContains keepend
|
||||||
syntax match dartInterpolation contained "\$\(\w\+\|{[^}]\+}\)" extend
|
syntax match dartInterpolation contained "\$\(\w\+\|{[^}]\+}\)" extend
|
||||||
syntax match dartSpecialChar contained "\\\(u\x\{4\}\|u{\x\+}\|x\x\x\|x{\x\+}\|.\)" extend
|
syntax match dartSpecialChar contained "\\\(u\x\{4\}\|u{\x\+}\|x\x\x\|x{\x\+}\|.\)" extend
|
||||||
|
|
||||||
@@ -110,6 +111,7 @@ highlight default link dartOperator Operator
|
|||||||
highlight default link dartComment Comment
|
highlight default link dartComment Comment
|
||||||
highlight default link dartLineComment Comment
|
highlight default link dartLineComment Comment
|
||||||
highlight default link dartLineDocComment Comment
|
highlight default link dartLineDocComment Comment
|
||||||
|
highlight default link dartShebangLine Comment
|
||||||
highlight default link dartConstant Constant
|
highlight default link dartConstant Constant
|
||||||
highlight default link dartTypedef Typedef
|
highlight default link dartTypedef Typedef
|
||||||
highlight default link dartTodo Todo
|
highlight default link dartTodo Todo
|
||||||
|
|||||||
@@ -120,10 +120,10 @@ syn region elixirSigil matchgroup=elixirSigilDelimiter start=+\~\a\z('''\)+ end=
|
|||||||
" Documentation
|
" Documentation
|
||||||
if exists('g:elixir_use_markdown_for_docs') && g:elixir_use_markdown_for_docs
|
if exists('g:elixir_use_markdown_for_docs') && g:elixir_use_markdown_for_docs
|
||||||
syn include @markdown syntax/markdown.vim
|
syn include @markdown syntax/markdown.vim
|
||||||
syn cluster elixirDocStringContained contains=@markdown,@Spell
|
syn cluster elixirDocStringContained contains=@markdown,@Spell,elixirInterpolation
|
||||||
else
|
else
|
||||||
let g:elixir_use_markdown_for_docs = 0
|
let g:elixir_use_markdown_for_docs = 0
|
||||||
syn cluster elixirDocStringContained contains=elixirDocTest,elixirTodo,@Spell
|
syn cluster elixirDocStringContained contains=elixirDocTest,elixirTodo,@Spell,elixirInterpolation
|
||||||
|
|
||||||
" doctests
|
" doctests
|
||||||
syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained
|
syn region elixirDocTest start="^\s*\%(iex\|\.\.\.\)\%((\d*)\)\?>\s" end="^\s*$" contained
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ syntax match fishCommandSub /\v\(\s*\zs\k+>/
|
|||||||
|
|
||||||
syntax region fishLineContinuation matchgroup=fishStatement
|
syntax region fishLineContinuation matchgroup=fishStatement
|
||||||
\ start='\v^\s*\zs\k+>' skip='\\$' end='$'
|
\ 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 fishKeyword Keyword
|
||||||
highlight default link fishConditional Conditional
|
highlight default link fishConditional Conditional
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ syn sync minlines=50
|
|||||||
syn include @gitDiff syntax/diff.vim
|
syn include @gitDiff syntax/diff.vim
|
||||||
|
|
||||||
syn region gitHead start=/\%^/ end=/^$/
|
syn region gitHead start=/\%^/ end=/^$/
|
||||||
syn region gitHead start=/\%(^commit \x\{40\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/
|
syn region gitHead start=/\%(^commit\%( \x\{40\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/
|
||||||
|
|
||||||
" For git reflog and git show ...^{tree}, avoid sync issues
|
" For git reflog and git show ...^{tree}, avoid sync issues
|
||||||
syn match gitHead /^\d\{6\} \%(\w\{4} \)\=\x\{40\}\%( [0-3]\)\=\t.*/
|
syn match gitHead /^\d\{6\} \%(\w\{4} \)\=\x\{40\}\%( [0-3]\)\=\t.*/
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ if exists("b:current_syntax")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists("main_syntax")
|
if !exists("g:main_syntax")
|
||||||
let main_syntax = 'html'
|
let g:main_syntax = 'html'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
runtime! syntax/gotexttmpl.vim
|
runtime! syntax/gotexttmpl.vim
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ syn region haskellBlockComment start="{-" end="-}"
|
|||||||
\ haskellTodo,
|
\ haskellTodo,
|
||||||
\ @Spell
|
\ @Spell
|
||||||
syn region haskellPragma start="{-#" end="#-}"
|
syn region haskellPragma start="{-#" end="#-}"
|
||||||
|
syn region haskellLiquid start="{-@" end="@-}"
|
||||||
syn match haskellPreProc "^#.*$"
|
syn match haskellPreProc "^#.*$"
|
||||||
syn keyword haskellTodo TODO FIXME contained
|
syn keyword haskellTodo TODO FIXME contained
|
||||||
" Treat a shebang line at the start of the file as a comment
|
" Treat a shebang line at the start of the file as a comment
|
||||||
@@ -147,6 +148,7 @@ highlight def link haskellShebang Comment
|
|||||||
highlight def link haskellLineComment Comment
|
highlight def link haskellLineComment Comment
|
||||||
highlight def link haskellBlockComment Comment
|
highlight def link haskellBlockComment Comment
|
||||||
highlight def link haskellPragma SpecialComment
|
highlight def link haskellPragma SpecialComment
|
||||||
|
highlight def link haskellLiquid SpecialComment
|
||||||
highlight def link haskellString String
|
highlight def link haskellString String
|
||||||
highlight def link haskellChar String
|
highlight def link haskellChar String
|
||||||
highlight def link haskellBacktick Operator
|
highlight def link haskellBacktick Operator
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ syn keyword htmlArg contained integrity crossorigin
|
|||||||
" <link>
|
" <link>
|
||||||
syn keyword htmlArg contained prefetch
|
syn keyword htmlArg contained prefetch
|
||||||
" syn keyword htmlArg contained preload
|
" syn keyword htmlArg contained preload
|
||||||
|
" <img>
|
||||||
|
syn keyword htmlArg contained decoding
|
||||||
|
|
||||||
" Custom Data Attributes
|
" Custom Data Attributes
|
||||||
" http://w3c.github.io/html/single-page.html#embedding-custom-non-visible-data-with-the-data-attributes
|
" http://w3c.github.io/html/single-page.html#embedding-custom-non-visible-data-with-the-data-attributes
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ syn match i3NoStartupId '--no-startup-id' contained
|
|||||||
syn keyword i3WsSpecialParam next prev next_on_output prev_on_output back_and_forth current number
|
syn keyword i3WsSpecialParam next prev next_on_output prev_on_output back_and_forth current number
|
||||||
syn keyword i3BordersSpecialParam none vertical horizontal both
|
syn keyword i3BordersSpecialParam none vertical horizontal both
|
||||||
syn keyword i3ModeParam dock hide invisible skipwhite
|
syn keyword i3ModeParam dock hide invisible skipwhite
|
||||||
|
syn keyword i3GapsCommand gaps smart_gaps smart_borders
|
||||||
|
syn keyword i3GapsParam inner outer current all set plus minus no_gaps
|
||||||
|
|
||||||
" these are not keywords but we add them for consistency
|
" these are not keywords but we add them for consistency
|
||||||
syn keyword i3PseudoParam no false inactive
|
syn keyword i3PseudoParam no false inactive
|
||||||
@@ -99,6 +101,7 @@ highlight link i3ColorLast Constant
|
|||||||
highlight link i3WsSpecialParam Constant
|
highlight link i3WsSpecialParam Constant
|
||||||
highlight link i3BordersSpecialParam Constant
|
highlight link i3BordersSpecialParam Constant
|
||||||
highlight link i3ModeParam Constant
|
highlight link i3ModeParam Constant
|
||||||
|
highlight link i3GapsParam Constant
|
||||||
|
|
||||||
highlight link i3Var Identifier
|
highlight link i3Var Identifier
|
||||||
highlight link i3SetVar Identifier
|
highlight link i3SetVar Identifier
|
||||||
@@ -115,6 +118,7 @@ highlight link i3Font String
|
|||||||
highlight link i3ExecKeyword Keyword
|
highlight link i3ExecKeyword Keyword
|
||||||
highlight link i3Command Keyword
|
highlight link i3Command Keyword
|
||||||
highlight link i3WsKeyword Keyword
|
highlight link i3WsKeyword Keyword
|
||||||
|
highlight link i3GapsCommand Keyword
|
||||||
|
|
||||||
highlight link i3ColorDef1 Define
|
highlight link i3ColorDef1 Define
|
||||||
highlight link i3ColorDef3 Define
|
highlight link i3ColorDef3 Define
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ syntax sync fromstart
|
|||||||
" syntax case ignore
|
" syntax case ignore
|
||||||
syntax case match
|
syntax case match
|
||||||
|
|
||||||
syntax match jsNoise /[:,\;]\{1}/
|
syntax match jsNoise /[:,;]/
|
||||||
syntax match jsNoise /[\.]\{1}/ skipwhite skipempty nextgroup=jsObjectProp,jsFuncCall,jsPrototype,jsTaggedTemplate
|
syntax match jsNoise /\./ skipwhite skipempty nextgroup=jsObjectProp,jsFuncCall,jsPrototype,jsTaggedTemplate
|
||||||
syntax match jsObjectProp contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>/
|
syntax match jsObjectProp contained /\<\K\k*/
|
||||||
syntax match jsFuncCall /\k\+\%(\s*(\)\@=/
|
syntax match jsFuncCall /\<\K\k*\ze\s*(/
|
||||||
syntax match jsParensError /[)}\]]/
|
syntax match jsParensError /[)}\]]/
|
||||||
|
|
||||||
" Program Keywords
|
" Program Keywords
|
||||||
syntax keyword jsStorageClass const var let skipwhite skipempty nextgroup=jsDestructuringBlock,jsDestructuringArray,jsVariableDef
|
syntax keyword jsStorageClass const var let skipwhite skipempty nextgroup=jsDestructuringBlock,jsDestructuringArray,jsVariableDef
|
||||||
syntax match jsVariableDef contained /\k\+/ skipwhite skipempty nextgroup=jsFlowDefinition
|
syntax match jsVariableDef contained /\<\K\k*/ skipwhite skipempty nextgroup=jsFlowDefinition
|
||||||
syntax keyword jsOperator delete instanceof typeof void new in of skipwhite skipempty nextgroup=@jsExpression
|
syntax keyword jsOperator delete instanceof typeof void new in of skipwhite skipempty nextgroup=@jsExpression
|
||||||
syntax match jsOperator /[\!\|\&\+\-\<\>\=\%\/\*\~\^]\{1}/ skipwhite skipempty nextgroup=@jsExpression
|
syntax match jsOperator "[-!|&+<>=%/*~^]" skipwhite skipempty nextgroup=@jsExpression
|
||||||
syntax match jsOperator /::/ skipwhite skipempty nextgroup=@jsExpression
|
syntax match jsOperator /::/ skipwhite skipempty nextgroup=@jsExpression
|
||||||
syntax keyword jsBooleanTrue true
|
syntax keyword jsBooleanTrue true
|
||||||
syntax keyword jsBooleanFalse false
|
syntax keyword jsBooleanFalse false
|
||||||
@@ -44,7 +44,7 @@ syntax keyword jsBooleanFalse false
|
|||||||
" Modules
|
" Modules
|
||||||
syntax keyword jsImport import skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup,jsFlowImportType
|
syntax keyword jsImport import skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup,jsFlowImportType
|
||||||
syntax keyword jsExport export skipwhite skipempty nextgroup=@jsAll,jsModuleGroup,jsExportDefault,jsModuleAsterisk,jsModuleKeyword,jsFlowTypeStatement
|
syntax keyword jsExport export skipwhite skipempty nextgroup=@jsAll,jsModuleGroup,jsExportDefault,jsModuleAsterisk,jsModuleKeyword,jsFlowTypeStatement
|
||||||
syntax match jsModuleKeyword contained /\k\+/ skipwhite skipempty nextgroup=jsModuleAs,jsFrom,jsModuleComma
|
syntax match jsModuleKeyword contained /\<\K\k*/ skipwhite skipempty nextgroup=jsModuleAs,jsFrom,jsModuleComma
|
||||||
syntax keyword jsExportDefault contained default skipwhite skipempty nextgroup=@jsExpression
|
syntax keyword jsExportDefault contained default skipwhite skipempty nextgroup=@jsExpression
|
||||||
syntax keyword jsExportDefaultGroup contained default skipwhite skipempty nextgroup=jsModuleAs,jsFrom,jsModuleComma
|
syntax keyword jsExportDefaultGroup contained default skipwhite skipempty nextgroup=jsModuleAs,jsFrom,jsModuleComma
|
||||||
syntax match jsModuleAsterisk contained /\*/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAs,jsFrom
|
syntax match jsModuleAsterisk contained /\*/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAs,jsFrom
|
||||||
@@ -53,44 +53,37 @@ syntax keyword jsFrom contained from skipwhite skipempty nextgroup
|
|||||||
syntax match jsModuleComma contained /,/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAsterisk,jsModuleGroup,jsFlowTypeKeyword
|
syntax match jsModuleComma contained /,/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAsterisk,jsModuleGroup,jsFlowTypeKeyword
|
||||||
|
|
||||||
" Strings, Templates, Numbers
|
" Strings, Templates, Numbers
|
||||||
syntax region jsString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend
|
syntax region jsString start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial,@Spell extend
|
||||||
syntax region jsString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend
|
syntax region jsTemplateString start=+`+ skip=+\\`+ end=+`+ contains=jsTemplateExpression,jsSpecial,@Spell extend
|
||||||
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateExpression,jsSpecial,@Spell extend
|
syntax match jsTaggedTemplate /\<\K\k*\ze`/ nextgroup=jsTemplateString
|
||||||
syntax match jsTaggedTemplate /\k\+\%(`\)\@=/ nextgroup=jsTemplateString
|
syntax match jsNumber /\c\<\%(\d\+\%(e[+-]\=\d\+\)\=\|0b[01]\+\|0o\o\+\|0x\x\+\)\>/
|
||||||
syntax match jsNumber /\<\d\+\%([eE][+-]\=\d\+\)\=\>\|\<0[bB][01]\+\>\|\<0[oO]\o\+\>\|\<0[xX]\x\+\>/
|
|
||||||
syntax keyword jsNumber Infinity
|
syntax keyword jsNumber Infinity
|
||||||
syntax match jsFloat /\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
|
syntax match jsFloat /\c\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%(e[+-]\=\d\+\)\=\>/
|
||||||
|
|
||||||
" Regular Expressions
|
" Regular Expressions
|
||||||
syntax match jsSpecial contained "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)"
|
syntax match jsSpecial contained "\v\\%(x\x\x|u%(\x{4}|\{\x{4,5}})|c\u|.)"
|
||||||
syntax region jsTemplateExpression contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression keepend
|
syntax region jsTemplateExpression contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression keepend
|
||||||
syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+
|
syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+ contains=jsSpecial
|
||||||
syntax match jsRegexpBoundary contained "\v%(\<@![\^$]|\\[bB])"
|
syntax match jsRegexpBoundary contained "\v\c[$^]|\\b"
|
||||||
syntax match jsRegexpBackRef contained "\v\\[1-9][0-9]*"
|
syntax match jsRegexpBackRef contained "\v\\[1-9]\d*"
|
||||||
syntax match jsRegexpQuantifier contained "\v\\@<!%([?*+]|\{\d+%(,|,\d+)?})\??"
|
syntax match jsRegexpQuantifier contained "\v[^\\]%([?*+]|\{\d+%(,\d*)?})\??"lc=1
|
||||||
syntax match jsRegexpOr contained "\v\<@!\|"
|
syntax match jsRegexpOr contained "|"
|
||||||
syntax match jsRegexpMod contained "\v\(@<=\?[:=!>]"
|
syntax match jsRegexpMod contained "\v\(\?[:=!>]"lc=1
|
||||||
syntax region jsRegexpGroup contained start="\\\@<!(" skip="\\.\|\[\(\\.\|[^]]\)*\]" end="\\\@<!)" contains=jsRegexpCharClass,@jsRegexpSpecial keepend
|
syntax region jsRegexpGroup contained start="[^\\]("lc=1 skip="\\.\|\[\(\\.\|[^]]\+\)\]" end=")" contains=jsRegexpCharClass,@jsRegexpSpecial keepend
|
||||||
if v:version > 703 || v:version == 603 && has("patch1088")
|
syntax region jsRegexpString start=+\%(\%(\<return\|\<typeof\|\_[^)\]'"[:blank:][:alnum:]_$]\)\s*\)\@<=/\ze[^*/]+ skip=+\\.\|\[[^]]\{1,}\]+ end=+/[gimyus]\{,6}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
|
||||||
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@50<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@50<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimyu]\{,5}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
|
|
||||||
else
|
|
||||||
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimyu]\{,5}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
|
|
||||||
endif
|
|
||||||
syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod
|
syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod
|
||||||
|
|
||||||
" Objects
|
" Objects
|
||||||
syntax match jsObjectKey contained /\<[0-9a-zA-Z_$]*\>\(\s*:\)\@=/ contains=jsFunctionKey skipwhite skipempty nextgroup=jsObjectValue
|
syntax match jsObjectKey contained /\<\k*\ze\s*:/ contains=jsFunctionKey skipwhite skipempty nextgroup=jsObjectValue
|
||||||
syntax match jsObjectColon contained /:/ skipwhite skipempty
|
syntax match jsObjectColon contained /:/ skipwhite skipempty
|
||||||
syntax region jsObjectKeyString contained start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell skipwhite skipempty nextgroup=jsObjectValue
|
syntax region jsObjectKeyString contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial,@Spell skipwhite skipempty nextgroup=jsObjectValue
|
||||||
syntax region jsObjectKeyString contained start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell skipwhite skipempty nextgroup=jsObjectValue
|
|
||||||
syntax region jsObjectKeyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsObjectValue,jsFuncArgs extend
|
syntax region jsObjectKeyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsObjectValue,jsFuncArgs extend
|
||||||
syntax match jsObjectSeparator contained /,/
|
syntax match jsObjectSeparator contained /,/
|
||||||
syntax region jsObjectValue contained matchgroup=jsNoise start=/:/ end=/\%(,\|}\)\@=/ contains=@jsExpression extend
|
syntax region jsObjectValue contained matchgroup=jsNoise start=/:/ end=/[,}]\@=/ contains=@jsExpression extend
|
||||||
syntax match jsObjectFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>[\r\n\t ]*(\@=/ skipwhite skipempty nextgroup=jsFuncArgs
|
syntax match jsObjectFuncName contained /\<\K\k*\ze\_s*(/ skipwhite skipempty nextgroup=jsFuncArgs
|
||||||
syntax match jsFunctionKey contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function\s*\)\@=/
|
syntax match jsFunctionKey contained /\<\K\k*\ze\s*:\s*function\>/
|
||||||
syntax match jsObjectMethodType contained /\%(get\|set\)\%( \k\+\)\@=/ skipwhite skipempty nextgroup=jsObjectFuncName
|
syntax match jsObjectMethodType contained /\<[gs]et\ze\s\+\K\k*/ skipwhite skipempty nextgroup=jsObjectFuncName
|
||||||
syntax region jsObjectStringKey contained start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue
|
syntax region jsObjectStringKey contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue
|
||||||
syntax region jsObjectStringKey contained start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue
|
|
||||||
|
|
||||||
exe 'syntax keyword jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '')
|
exe 'syntax keyword jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '')
|
||||||
exe 'syntax keyword jsReturn return contained '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '').' skipwhite skipempty nextgroup=@jsExpression'
|
exe 'syntax keyword jsReturn return contained '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '').' skipwhite skipempty nextgroup=@jsExpression'
|
||||||
@@ -101,8 +94,8 @@ exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal
|
|||||||
exe 'syntax keyword jsSuper super contained '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
|
exe 'syntax keyword jsSuper super contained '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
|
||||||
|
|
||||||
" Statement Keywords
|
" Statement Keywords
|
||||||
syntax match jsBlockLabel /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\s*::\@!/ contains=jsNoise skipwhite skipempty nextgroup=jsBlock
|
syntax match jsBlockLabel /\<\K\k*\s*::\@!/ contains=jsNoise skipwhite skipempty nextgroup=jsBlock
|
||||||
syntax match jsBlockLabelKey contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\%(\s*\%(;\|\n\)\)\@=/
|
syntax match jsBlockLabelKey contained /\<\K\k*\ze\s*\_[;]/
|
||||||
syntax keyword jsStatement contained with yield debugger
|
syntax keyword jsStatement contained with yield debugger
|
||||||
syntax keyword jsStatement contained break continue skipwhite skipempty nextgroup=jsBlockLabelKey
|
syntax keyword jsStatement contained break continue skipwhite skipempty nextgroup=jsBlockLabelKey
|
||||||
syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
|
syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
|
||||||
@@ -119,7 +112,7 @@ syntax keyword jsAsyncKeyword async await
|
|||||||
syntax match jsSwitchColon contained /::\@!/ skipwhite skipempty nextgroup=jsSwitchBlock
|
syntax match jsSwitchColon contained /::\@!/ skipwhite skipempty nextgroup=jsSwitchBlock
|
||||||
|
|
||||||
" Keywords
|
" Keywords
|
||||||
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray JSON Math console document window Intl Collator DateTimeFormat NumberFormat fetch
|
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set WeakSet RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray JSON Math console document window Intl Collator DateTimeFormat NumberFormat fetch
|
||||||
syntax keyword jsGlobalNodeObjects module exports global process __dirname __filename
|
syntax keyword jsGlobalNodeObjects module exports global process __dirname __filename
|
||||||
syntax match jsGlobalNodeObjects /\<require\>/ containedin=jsFuncCall
|
syntax match jsGlobalNodeObjects /\<require\>/ containedin=jsFuncCall
|
||||||
syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError
|
syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError
|
||||||
@@ -164,68 +157,68 @@ syntax region jsBlock matchgroup=jsBraces s
|
|||||||
syntax region jsModuleGroup contained matchgroup=jsModuleBraces start=/{/ end=/}/ contains=jsModuleKeyword,jsModuleComma,jsModuleAs,jsComment,jsFlowTypeKeyword skipwhite skipempty nextgroup=jsFrom fold
|
syntax region jsModuleGroup contained matchgroup=jsModuleBraces start=/{/ end=/}/ contains=jsModuleKeyword,jsModuleComma,jsModuleAs,jsComment,jsFlowTypeKeyword skipwhite skipempty nextgroup=jsFrom fold
|
||||||
syntax region jsSpreadExpression contained matchgroup=jsSpreadOperator start=/\.\.\./ end=/[,}\]]\@=/ contains=@jsExpression
|
syntax region jsSpreadExpression contained matchgroup=jsSpreadOperator start=/\.\.\./ end=/[,}\]]\@=/ contains=@jsExpression
|
||||||
syntax region jsRestExpression contained matchgroup=jsRestOperator start=/\.\.\./ end=/[,)]\@=/
|
syntax region jsRestExpression contained matchgroup=jsRestOperator start=/\.\.\./ end=/[,)]\@=/
|
||||||
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|[\}]\@=\)/ contains=@jsExpression extend skipwhite skipempty nextgroup=@jsExpression
|
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|}\@=\)/ contains=@jsExpression extend skipwhite skipempty nextgroup=@jsExpression
|
||||||
|
syntax match jsOperator /?\.\ze\_D/
|
||||||
|
|
||||||
syntax match jsGenerator contained /\*/ skipwhite skipempty nextgroup=jsFuncName,jsFuncArgs,jsFlowFunctionGroup
|
syntax match jsGenerator contained /\*/ skipwhite skipempty nextgroup=jsFuncName,jsFuncArgs,jsFlowFunctionGroup
|
||||||
syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowFunctionGroup
|
syntax match jsFuncName contained /\<\K\k*/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowFunctionGroup
|
||||||
syntax region jsFuncArgExpression contained matchgroup=jsFuncArgOperator start=/=/ end=/[,)]\@=/ contains=@jsExpression extend
|
syntax region jsFuncArgExpression contained matchgroup=jsFuncArgOperator start=/=/ end=/[,)]\@=/ contains=@jsExpression extend
|
||||||
syntax match jsFuncArgCommas contained ','
|
syntax match jsFuncArgCommas contained ','
|
||||||
syntax keyword jsArguments contained arguments
|
syntax keyword jsArguments contained arguments
|
||||||
syntax keyword jsForAwait contained await skipwhite skipempty nextgroup=jsParenRepeat
|
syntax keyword jsForAwait contained await skipwhite skipempty nextgroup=jsParenRepeat
|
||||||
|
|
||||||
" Matches a single keyword argument with no parens
|
" Matches a single keyword argument with no parens
|
||||||
syntax match jsArrowFuncArgs /\k\+\s*\%(=>\)\@=/ skipwhite contains=jsFuncArgs skipwhite skipempty nextgroup=jsArrowFunction extend
|
syntax match jsArrowFuncArgs /\<\K\k*\ze\s*=>/ skipwhite contains=jsFuncArgs skipwhite skipempty nextgroup=jsArrowFunction extend
|
||||||
" Matches a series of arguments surrounded in parens
|
" Matches a series of arguments surrounded in parens
|
||||||
syntax match jsArrowFuncArgs /([^()]*)\s*\(=>\)\@=/ contains=jsFuncArgs skipempty skipwhite nextgroup=jsArrowFunction extend
|
syntax match jsArrowFuncArgs /([^()]*)\ze\s*=>/ contains=jsFuncArgs skipempty skipwhite nextgroup=jsArrowFunction extend
|
||||||
|
|
||||||
exe 'syntax match jsFunction /\<function\>/ skipwhite skipempty nextgroup=jsGenerator,jsFuncName,jsFuncArgs,jsFlowFunctionGroup skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '')
|
exe 'syntax match jsFunction /\<function\>/ skipwhite skipempty nextgroup=jsGenerator,jsFuncName,jsFuncArgs,jsFlowFunctionGroup skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '')
|
||||||
exe 'syntax match jsArrowFunction /=>/ skipwhite skipempty nextgroup=jsFuncBlock,jsCommentFunction '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '')
|
exe 'syntax match jsArrowFunction /=>/ skipwhite skipempty nextgroup=jsFuncBlock,jsCommentFunction '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '')
|
||||||
exe 'syntax match jsArrowFunction /()\s*\(=>\)\@=/ skipwhite skipempty nextgroup=jsArrowFunction '.(exists('g:javascript_conceal_noarg_arrow_function') ? 'conceal cchar='.g:javascript_conceal_noarg_arrow_function : '').(' contains=jsArrowFuncArgs')
|
exe 'syntax match jsArrowFunction /()\ze\s*=>/ skipwhite skipempty nextgroup=jsArrowFunction '.(exists('g:javascript_conceal_noarg_arrow_function') ? 'conceal cchar='.g:javascript_conceal_noarg_arrow_function : '')
|
||||||
exe 'syntax match jsArrowFunction /_\s*\(=>\)\@=/ skipwhite skipempty nextgroup=jsArrowFunction '.(exists('g:javascript_conceal_underscore_arrow_function') ? 'conceal cchar='.g:javascript_conceal_underscore_arrow_function : '')
|
exe 'syntax match jsArrowFunction /_\ze\s*=>/ skipwhite skipempty nextgroup=jsArrowFunction '.(exists('g:javascript_conceal_underscore_arrow_function') ? 'conceal cchar='.g:javascript_conceal_underscore_arrow_function : '')
|
||||||
|
|
||||||
" Classes
|
" Classes
|
||||||
syntax keyword jsClassKeyword contained class
|
syntax keyword jsClassKeyword contained class
|
||||||
syntax keyword jsExtendsKeyword contained extends skipwhite skipempty nextgroup=@jsExpression
|
syntax keyword jsExtendsKeyword contained extends skipwhite skipempty nextgroup=@jsExpression
|
||||||
syntax match jsClassNoise contained /\./
|
syntax match jsClassNoise contained /\./
|
||||||
syntax match jsClassMethodType contained /\%(get\|set\|static\)\%( \k\+\)\@=/ skipwhite skipempty nextgroup=jsAsyncKeyword,jsFuncName,jsClassProperty
|
syntax match jsClassMethodType contained /\<\%([gs]et\|static\)\ze\s\+\K\k*/ skipwhite skipempty nextgroup=jsAsyncKeyword,jsFuncName,jsClassProperty
|
||||||
syntax region jsClassDefinition start=/\<class\>/ end=/\(\<extends\>\s\+\)\@<!{\@=/ contains=jsClassKeyword,jsExtendsKeyword,jsClassNoise,@jsExpression,jsFlowClassGroup skipwhite skipempty nextgroup=jsCommentClass,jsClassBlock,jsFlowClassGroup
|
syntax region jsClassDefinition start=/\<class\>/ end=/\(\<extends\>\s\+\)\@<!{\@=/ contains=jsClassKeyword,jsExtendsKeyword,jsClassNoise,@jsExpression,jsFlowClassGroup skipwhite skipempty nextgroup=jsCommentClass,jsClassBlock,jsFlowClassGroup
|
||||||
syntax match jsClassProperty contained /\<[0-9a-zA-Z_$]*\>\(\s*[=:]\)\@=/ skipwhite skipempty nextgroup=jsClassValue,jsFlowClassDef
|
syntax match jsClassProperty contained /\<\K\k*\ze\s*=/ skipwhite skipempty nextgroup=jsClassValue,jsFlowClassDef
|
||||||
syntax region jsClassValue contained start=/=/ end=/\%(;\|}\|\n\)\@=/ contains=@jsExpression
|
syntax region jsClassValue contained start=/=/ end=/\_[;}]\@=/ contains=@jsExpression
|
||||||
syntax region jsClassPropertyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsFuncArgs,jsClassValue extend
|
syntax region jsClassPropertyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsFuncArgs,jsClassValue extend
|
||||||
syntax match jsClassFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\%(\s*(\)\@=/ skipwhite skipempty nextgroup=jsFuncArgs
|
syntax match jsClassFuncName contained /\<\K\k*\ze\s*(/ skipwhite skipempty nextgroup=jsFuncArgs
|
||||||
syntax region jsClassStringKey contained start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs
|
syntax region jsClassStringKey contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs
|
||||||
syntax region jsClassStringKey contained start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs
|
|
||||||
|
|
||||||
" Destructuring
|
" Destructuring
|
||||||
syntax match jsDestructuringPropertyValue contained /\<[0-9a-zA-Z_$]*\>/
|
syntax match jsDestructuringPropertyValue contained /\k\+/
|
||||||
syntax match jsDestructuringProperty contained /\<[0-9a-zA-Z_$]*\>\(\s*=\)\@=/ skipwhite skipempty nextgroup=jsDestructuringValue
|
syntax match jsDestructuringProperty contained /\k\+\ze\s*=/ skipwhite skipempty nextgroup=jsDestructuringValue
|
||||||
syntax match jsDestructuringAssignment contained /\<[0-9a-zA-Z_$]*\>\(\s*:\)\@=/ skipwhite skipempty nextgroup=jsDestructuringValueAssignment
|
syntax match jsDestructuringAssignment contained /\k\+\ze\s*:/ skipwhite skipempty nextgroup=jsDestructuringValueAssignment
|
||||||
syntax region jsDestructuringValue contained start=/=/ end=/[,}\]]\@=/ contains=@jsExpression extend
|
syntax region jsDestructuringValue contained start=/=/ end=/[,}\]]\@=/ contains=@jsExpression extend
|
||||||
syntax region jsDestructuringValueAssignment contained start=/:/ end=/[,}=]\@=/ contains=jsDestructuringPropertyValue,jsDestructuringBlock,jsNoise,jsDestructuringNoise skipwhite skipempty nextgroup=jsDestructuringValue extend
|
syntax region jsDestructuringValueAssignment contained start=/:/ end=/[,}=]\@=/ contains=jsDestructuringPropertyValue,jsDestructuringBlock,jsNoise,jsDestructuringNoise skipwhite skipempty nextgroup=jsDestructuringValue extend
|
||||||
syntax match jsDestructuringNoise contained /[,\[\]]/
|
syntax match jsDestructuringNoise contained /[,[\]]/
|
||||||
syntax region jsDestructuringPropertyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsDestructuringValue,jsDestructuringNoise extend fold
|
syntax region jsDestructuringPropertyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsDestructuringValue,jsDestructuringNoise extend fold
|
||||||
|
|
||||||
" Comments
|
" Comments
|
||||||
syntax keyword jsCommentTodo contained TODO FIXME XXX TBD
|
syntax keyword jsCommentTodo contained TODO FIXME XXX TBD
|
||||||
syntax region jsComment start=/\/\// end=/$/ contains=jsCommentTodo,@Spell extend keepend
|
syntax region jsComment start=+//+ end=/$/ contains=jsCommentTodo,@Spell extend keepend
|
||||||
syntax region jsComment start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell fold extend keepend
|
syntax region jsComment start=+/\*+ end=+\*/+ contains=jsCommentTodo,@Spell fold extend keepend
|
||||||
syntax region jsEnvComment start=/\%^#!/ end=/$/ display
|
syntax region jsEnvComment start=/\%^#!/ end=/$/ display
|
||||||
|
|
||||||
" Specialized Comments - These are special comment regexes that are used in
|
" Specialized Comments - These are special comment regexes that are used in
|
||||||
" odd places that maintain the proper nextgroup functionality. It sucks we
|
" odd places that maintain the proper nextgroup functionality. It sucks we
|
||||||
" can't make jsComment a skippable type of group for nextgroup
|
" can't make jsComment a skippable type of group for nextgroup
|
||||||
syntax region jsCommentFunction contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturn extend keepend
|
syntax region jsCommentFunction contained start=+//+ end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturn extend keepend
|
||||||
syntax region jsCommentFunction contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturn fold extend keepend
|
syntax region jsCommentFunction contained start=+/\*+ end=+\*/+ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturn fold extend keepend
|
||||||
syntax region jsCommentClass contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsClassBlock,jsFlowClassGroup extend keepend
|
syntax region jsCommentClass contained start=+//+ end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsClassBlock,jsFlowClassGroup extend keepend
|
||||||
syntax region jsCommentClass contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsClassBlock,jsFlowClassGroup fold extend keepend
|
syntax region jsCommentClass contained start=+/\*+ end=+\*/+ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsClassBlock,jsFlowClassGroup fold extend keepend
|
||||||
syntax region jsCommentIfElse contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsIfElseBlock extend keepend
|
syntax region jsCommentIfElse contained start=+//+ end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsIfElseBlock extend keepend
|
||||||
syntax region jsCommentIfElse contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsIfElseBlock fold extend keepend
|
syntax region jsCommentIfElse contained start=+/\*+ end=+\*/+ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsIfElseBlock fold extend keepend
|
||||||
syntax region jsCommentRepeat contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsRepeatBlock extend keepend
|
syntax region jsCommentRepeat contained start=+//+ end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsRepeatBlock extend keepend
|
||||||
syntax region jsCommentRepeat contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsRepeatBlock fold extend keepend
|
syntax region jsCommentRepeat contained start=+/\*+ end=+\*/+ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsRepeatBlock fold extend keepend
|
||||||
|
|
||||||
" Decorators
|
" Decorators
|
||||||
syntax match jsDecorator /^\s*@/ nextgroup=jsDecoratorFunction
|
syntax match jsDecorator /^\s*@/ nextgroup=jsDecoratorFunction
|
||||||
syntax match jsDecoratorFunction contained /[a-zA-Z_][a-zA-Z0-9_.]*/ nextgroup=jsParenDecorator
|
syntax match jsDecoratorFunction contained /\h[a-zA-Z0-9_.]*/ nextgroup=jsParenDecorator
|
||||||
|
|
||||||
if exists("javascript_plugin_jsdoc")
|
if exists("javascript_plugin_jsdoc")
|
||||||
runtime extras/jsdoc.vim
|
runtime extras/jsdoc.vim
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ if version >= 508 || !exists("did_json_syn_inits")
|
|||||||
hi def link jsonString String
|
hi def link jsonString String
|
||||||
hi def link jsonTest Label
|
hi def link jsonTest Label
|
||||||
hi def link jsonEscape Special
|
hi def link jsonEscape Special
|
||||||
hi def link jsonNumber Delimiter
|
hi def link jsonNumber Number
|
||||||
hi def link jsonBraces Delimiter
|
hi def link jsonBraces Delimiter
|
||||||
hi def link jsonNull Function
|
hi def link jsonNull Function
|
||||||
hi def link jsonBoolean Delimiter
|
hi def link jsonBoolean Boolean
|
||||||
hi def link jsonKeyword Label
|
hi def link jsonKeyword Label
|
||||||
|
|
||||||
if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1)
|
if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1)
|
||||||
|
|||||||
624
syntax/julia.vim
624
syntax/julia.vim
@@ -1,153 +1,551 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'julia') == -1
|
||||||
|
|
||||||
|
" Vim syntax file
|
||||||
|
" Language: julia
|
||||||
|
" Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
|
||||||
|
" Last Change: 2013 feb 11
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if version < 600
|
||||||
|
syntax clear
|
||||||
|
elseif exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if version < 704
|
||||||
|
" this is used to disable regex syntax like `\@3<='
|
||||||
|
" on older vim versions
|
||||||
|
function! s:d(x)
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
function! s:d(x)
|
||||||
|
return string(a:x)
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
|
||||||
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
if !exists("b:julia_syntax_version")
|
||||||
|
let b:julia_syntax_version = get(g:, "default_julia_version", "current")
|
||||||
|
endif
|
||||||
|
if !exists("b:julia_syntax_highlight_deprecated")
|
||||||
|
let b:julia_syntax_highlight_deprecated = get(g:, "julia_syntax_highlight_deprecated", 0)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if b:julia_syntax_version =~? '\<\%(curr\%(ent\)\?\|release\|6\|0\.6\)\>'
|
||||||
|
let b:julia_syntax_version = 6
|
||||||
|
elseif b:julia_syntax_version =~? '\<\%(next\|devel\|7\|0\.7\)\>'
|
||||||
|
let b:julia_syntax_version = 7
|
||||||
|
elseif b:julia_syntax_version =~? '\<\%(prev\%(ious\)\?\|legacy\|5\|0\.5\)\>'
|
||||||
|
let b:julia_syntax_version = 5
|
||||||
|
else
|
||||||
|
echohl WarningMsg | echomsg "Unrecognized or unsupported julia syntax version: " . b:julia_syntax_version | echohl None
|
||||||
|
let b:julia_syntax_version = 6
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:julia_spellcheck_strings = get(g:, "julia_spellcheck_strings", 0)
|
||||||
|
let s:julia_spellcheck_docstrings = get(g:, "julia_spellcheck_docstrings", 1)
|
||||||
|
let s:julia_spellcheck_comments = get(g:, "julia_spellcheck_comments", 1)
|
||||||
|
|
||||||
|
let s:julia_highlight_operators = get(g:, "julia_highlight_operators", 1)
|
||||||
|
|
||||||
|
" characters which cannot be used in identifiers. This list is very incomplete:
|
||||||
|
" 1) it only cares about charactes below 256
|
||||||
|
" 2) it doesn't distinguish between what's allowed as the 1st char vs in the
|
||||||
|
" rest of an identifier (e.g. digits, `!` and `?`)
|
||||||
|
" Despite these shortcomings, it seems to do a decent job.
|
||||||
|
" note: \U5B and \U5D are '[' and ']'
|
||||||
|
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 (TODO: the special case of a lone `?` should be
|
||||||
|
" removed as soon as the Julia parser is fixed)
|
||||||
|
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 . ']' .
|
||||||
|
\ '\)'
|
||||||
|
|
||||||
syn case match
|
syn case match
|
||||||
|
|
||||||
|
syntax cluster juliaExpressions contains=@juliaParItems,@juliaStringItems,@juliaKeywordItems,@juliaBlocksItems,@juliaTypesItems,@juliaConstItems,@juliaMacroItems,@juliaSymbolItems,@juliaOperatorItems,@juliaNumberItems,@juliaCommentItems,@juliaErrorItems
|
||||||
|
syntax cluster juliaExprsPrintf contains=@juliaExpressions,@juliaPrintfItems
|
||||||
|
|
||||||
syn keyword juliaDirective import importall export using require include
|
syntax cluster juliaParItems contains=juliaParBlock,juliaSqBraBlock,juliaCurBraBlock,juliaQuotedParBlock,juliaQuotedQMarkPar
|
||||||
|
syntax cluster juliaKeywordItems contains=juliaKeyword,juliaInfixKeyword,juliaRepKeyword,juliaTypedef
|
||||||
|
if b:julia_syntax_version == 5
|
||||||
|
syntax cluster juliaBlocksItems contains=@juliaBlocksItemsAll
|
||||||
|
else
|
||||||
|
syntax cluster juliaBlocksItems contains=@juliaBlocksItemsAll,@juliaBlocksItems0607
|
||||||
|
endif
|
||||||
|
syntax cluster juliaBlocksItemsAll contains=juliaConditionalBlock,juliaWhileBlock,juliaForBlock,juliaBeginBlock,juliaFunctionBlock,juliaMacroBlock,juliaQuoteBlock,juliaTypeBlock,juliaImmutableBlock,juliaExceptionBlock,juliaLetBlock,juliaDoBlock,juliaModuleBlock
|
||||||
|
syntax cluster juliaBlocksItems0607 contains=juliaStructBlock,juliaMutableStructBlock,juliaAbstractBlock,juliaPrimitiveBlock
|
||||||
|
if b:julia_syntax_version == 5
|
||||||
|
syntax cluster juliaTypesItems contains=@juliaTypesItemsAll,@juliaTypesItems05,@juliaTypesItems0506
|
||||||
|
elseif b:julia_syntax_version == 6
|
||||||
|
syntax cluster juliaTypesItems contains=@juliaTypesItemsAll,@juliaTypesItems05,@juliaTypesItems0506,@juliaTypesItems0607
|
||||||
|
else
|
||||||
|
syntax cluster juliaTypesItems contains=@juliaTypesItemsAll,@juliaTypesItems05,@juliaTypesItems0506,@juliaTypesItems0607,@juliaTypesItems07
|
||||||
|
endif
|
||||||
|
syntax cluster juliaTypesItemsAll contains=juliaBaseTypeBasic,juliaBaseTypeNum,juliaBaseTypeC,juliaBaseTypeError,juliaBaseTypeIter,juliaBaseTypeString,juliaBaseTypeArray,juliaBaseTypeDict,juliaBaseTypeSet,juliaBaseTypeIO,juliaBaseTypeProcess,juliaBaseTypeRange,juliaBaseTypeRegex,juliaBaseTypeFact,juliaBaseTypeFact,juliaBaseTypeSort,juliaBaseTypeRound,juliaBaseTypeSpecial,juliaBaseTypeRandom,juliaBaseTypeDisplay,juliaBaseTypeTime,juliaBaseTypeOther
|
||||||
|
syntax cluster juliaTypesItems05 contains=juliaBaseTypeIter05,juliaBaseTypeRange05
|
||||||
|
syntax cluster juliaTypesItems0506 contains=juliaBaseTypeRange0506,juliaBaseTypeSet0506
|
||||||
|
syntax cluster juliaTypesItems0607 contains=juliaBaseTypeBasic0607,juliaBaseTypeArray0607,juliaBaseTypeSet0607,juliaBaseTypeProcess0607,juliaBaseTypeRange0607,juliaBaseTypeTime0607
|
||||||
|
syntax cluster juliaTypesItems07 contains=juliaBaseTypeRange07,juliaBaseTypeSet07
|
||||||
|
|
||||||
hi def link juliaDirective Include
|
syntax cluster juliaConstItemsAll contains=juliaConstNum,juliaConstBool,juliaConstEnv,juliaConstIO,juliaConstMMap,juliaConstC,juliaConstGeneric
|
||||||
|
syntax cluster juliaConstItems0506 contains=juliaConstNum0506
|
||||||
|
syntax cluster juliaConstItems07 contains=juliaPossibleEuler
|
||||||
|
if b:julia_syntax_version <= 6
|
||||||
|
syntax cluster juliaConstItems contains=@juliaConstItemsAll,@juliaConstItems0506
|
||||||
|
else
|
||||||
|
syntax cluster juliaConstItems contains=@juliaConstItemsAll,@juliaConstItems0506,@juliaConstItems07
|
||||||
|
endif
|
||||||
|
|
||||||
syn region juliaDeclTypeBlock transparent matchgroup=juliaDeclType start="\<\%(type\|immutable\)\>" end="\<end\>" contains=ALL
|
syntax cluster juliaMacroItems contains=juliaPossibleMacro,juliaDollarVar,juliaDollarPar,juliaDollarSqBra
|
||||||
syn keyword juliaTypeAlias typealias
|
syntax cluster juliaSymbolItems contains=juliaPossibleSymbol
|
||||||
syn keyword juliaDeclAbstract abstract
|
syntax cluster juliaNumberItems contains=juliaNumbers
|
||||||
|
syntax cluster juliaStringItems contains=juliaChar,juliaString,juliabString,juliasString,juliavString,juliaipString,juliabigString,juliaMIMEString,juliaShellString,juliaDocString,juliaRegEx
|
||||||
|
syntax cluster juliaPrintfItems contains=juliaPrintfParBlock,juliaPrintfString
|
||||||
|
syntax cluster juliaOperatorItems contains=juliaOperator,juliaRangeOperator,juliaCTransOperator,juliaTernaryRegion,juliaColon,juliaSemicolon,juliaComma
|
||||||
|
syntax cluster juliaCommentItems contains=juliaCommentL,juliaCommentM
|
||||||
|
syntax cluster juliaErrorItems contains=juliaErrorPar,juliaErrorEnd,juliaErrorElse,juliaErrorCatch,juliaErrorFinally
|
||||||
|
|
||||||
hi def link juliaDeclType Structure
|
syntax cluster juliaSpellcheckStrings contains=@spell
|
||||||
hi def link juliaTypeAlias Typedef
|
syntax cluster juliaSpellcheckDocStrings contains=@spell
|
||||||
hi def link juliaDeclAbstract Structure
|
syntax cluster juliaSpellcheckComments contains=@spell
|
||||||
|
|
||||||
" Module
|
if !s:julia_spellcheck_docstrings
|
||||||
syn region juliaModuleBlock transparent matchgroup=juliaModule start="\<module\>" end="\<end\>" contains=ALL
|
syntax cluster juliaSpellcheckDocStrings remove=@spell
|
||||||
|
endif
|
||||||
|
if !s:julia_spellcheck_strings
|
||||||
|
syntax cluster juliaSpellcheckStrings remove=@spell
|
||||||
|
endif
|
||||||
|
if !s:julia_spellcheck_comments
|
||||||
|
syntax cluster juliaSpellcheckComments remove=@spell
|
||||||
|
endif
|
||||||
|
|
||||||
hi def link juliaModule Structure
|
syntax match juliaSemicolon display ";"
|
||||||
|
syntax match juliaComma display ","
|
||||||
|
syntax match juliaColon display ":"
|
||||||
|
|
||||||
|
syntax match juliaErrorPar display "[])}]"
|
||||||
|
syntax match juliaErrorEnd display "\<end\>"
|
||||||
|
syntax match juliaErrorElse display "\<\%(else\|elseif\)\>"
|
||||||
|
syntax match juliaErrorCatch display "\<catch\>"
|
||||||
|
syntax match juliaErrorFinally display "\<finally\>"
|
||||||
|
syntax match juliaErrorSemicol display contained ";"
|
||||||
|
|
||||||
|
syntax match juliaRangeEnd display contained "\<end\>"
|
||||||
|
|
||||||
|
syntax region juliaParBlock matchgroup=juliaParDelim start="(" end=")" contains=@juliaExpressions,juliaComprehensionFor
|
||||||
|
syntax region juliaParBlockInRange matchgroup=juliaParDelim contained start="(" end=")" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeEnd,juliaComprehensionFor
|
||||||
|
syntax region juliaSqBraBlock matchgroup=juliaParDelim start="\[" end="\]" contains=@juliaExpressions,juliaParBlockInRange,juliaRangeEnd,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS
|
||||||
|
syntax region juliaCurBraBlock matchgroup=juliaParDelim start="{" end="}" contains=@juliaExpressions
|
||||||
|
|
||||||
|
if b:julia_syntax_version >= 6
|
||||||
|
let s:keywords = '\<\%(return\|local\|global\|import\%(all\)\?\|export\|using\|const\|where\)\>'
|
||||||
|
let s:infixkeywords = '\<\%(in\|isa\)\>'
|
||||||
|
else
|
||||||
|
let s:keywords = '\<\%(return\|local\|global\|import\%(all\)\?\|export\|using\|const\)\>'
|
||||||
|
let s:infixkeywords = '\<\%(in\)\>'
|
||||||
|
endif
|
||||||
|
|
||||||
|
exec 'syntax match juliaKeyword display "' . s:keywords . '"'
|
||||||
|
exec 'syntax match juliaInfixKeyword display "\%(=\s*\)\@<!' . s:infixkeywords . '\S\@!\%(\s*=\)\@!"'
|
||||||
|
syntax match juliaRepKeyword display "\<\%(break\|continue\)\>"
|
||||||
|
syntax region juliaConditionalBlock matchgroup=juliaConditional start="\<if\>" end="\<end\>" contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock fold
|
||||||
|
syntax region juliaConditionalEIBlock matchgroup=juliaConditional transparent contained start="\<elseif\>" end="\<\%(end\|else\|elseif\)\>"me=s-1 contains=@juliaExpressions,juliaConditionalEIBlock,juliaConditionalEBlock
|
||||||
|
syntax region juliaConditionalEBlock matchgroup=juliaConditional transparent contained start="\<else\>" end="\<end\>"me=s-1 contains=@juliaExpressions
|
||||||
|
syntax region juliaWhileBlock matchgroup=juliaRepeat start="\<while\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaForBlock matchgroup=juliaRepeat start="\<for\>" end="\<end\>" contains=@juliaExpressions,juliaOuter fold
|
||||||
|
syntax region juliaBeginBlock matchgroup=juliaBlKeyword start="\<begin\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaFunctionBlock matchgroup=juliaBlKeyword start="\<function\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaMacroBlock matchgroup=juliaBlKeyword start="\<macro\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaQuoteBlock matchgroup=juliaBlKeyword start="\<quote\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaTypeBlock matchgroup=juliaBlKeyword start="\<type\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaImmutableBlock matchgroup=juliaBlKeyword start="\<immutable\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaStructBlock matchgroup=juliaBlKeyword start="\<struct\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaMutableStructBlock matchgroup=juliaBlKeyword start="\<mutable struct\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaLetBlock matchgroup=juliaBlKeyword start="\<let\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
syntax region juliaDoBlock matchgroup=juliaBlKeyword start="\<do\>" end="\<end\>" contains=@juliaExpressions fold
|
||||||
|
exec 'syntax region juliaModuleBlock matchgroup=juliaBlKeyword start="\%(\%(\.\s*\)\@'.s:d(6).'<!\|\%(@\s*\.\s*\)\@'.s:d(6).'<=\)\<\%(bare\)\?module\>" end="\<end\>" contains=@juliaExpressions fold'
|
||||||
|
syntax region juliaExceptionBlock matchgroup=juliaException start="\<try\>" end="\<end\>" contains=@juliaExpressions,juliaCatchBlock,juliaFinallyBlock fold
|
||||||
|
syntax region juliaCatchBlock matchgroup=juliaException transparent contained start="\<catch\>" end="\<end\>"me=s-1 contains=@juliaExpressions,juliaFinallyBlock
|
||||||
|
syntax region juliaFinallyBlock matchgroup=juliaException transparent contained start="\<finally\>" end="\<end\>"me=s-1 contains=@juliaExpressions
|
||||||
|
syntax match juliaTypedef "\<\%(abstract\|typealias\|bitstype\)\>"
|
||||||
|
" AbstractBlock needs to come after to take precedence
|
||||||
|
syntax region juliaAbstractBlock matchgroup=juliaBlKeyword start="\<abstract type\>" end="\<end\>" fold contains=@juliaExpressions
|
||||||
|
syntax region juliaPrimitiveBlock matchgroup=juliaBlKeyword start="\<primitive type\>" end="\<end\>" fold contains=@juliaExpressions
|
||||||
|
|
||||||
|
exec 'syntax region juliaComprehensionFor matchgroup=juliaComprehensionFor transparent contained start="\%([^[:space:],;:({[]\_s*\)\@'.s:d(80).'<=\<for\>" end="\ze[]);]" contains=@juliaExpressions,juliaComprehensionIf,juliaComprehensionFor'
|
||||||
|
syntax match juliaComprehensionIf contained "\<if\>"
|
||||||
|
|
||||||
|
exec 'syntax match juliaOuter contained "\<outer\ze\s\+' . s:idregex . '\>"'
|
||||||
|
|
||||||
|
syntax match juliaBaseTypeBasic display "\<\%(Tuple\|NTuple\|Symbol\|\%(Intrinsic\)\?Function\|Union\|Type\%(Name\|Constructor\|Var\)\?\|Any\|ANY\|Vararg\|Top\|None\|Nothing\|Ptr\|Void\|Exception\|Module\|Box\|Expr\|LambdaStaticData\|\%(Data\|Union\)Type\|\%(LineNumber\|Label\|Goto\|Quote\|Top\|Symbol\|Getfield\)Node\|\%(Weak\|Global\)\?Ref\|Associative\|Method\(Table\)\?\|GetfieldNode\|Nullable\|Pair\|Val\|TypeMap\%(Level\|Entry\)\)\>"
|
||||||
|
syntax match juliaBaseTypeBasic0607 display "\<\%(UnionAll\|CodeInfo\)\>"
|
||||||
|
syntax match juliaBaseTypeNum display "\<\%(U\?Int\%(8\|16\|32\|64\|128\)\?\|Float\%(16\|32\|64\)\|Complex\%(32\|64\|128\)\?\|Bool\|Char\|Number\|Signed\|Unsigned\|Integer\|AbstractFloat\|Real\|Rational\|Irrational\|Enum\|BigInt\|BigFloat\|MathConst\)\>"
|
||||||
|
syntax match juliaBaseTypeC display "\<\%(FileOffset\|C\%(u\?\%(char\|short\|int\|long\(long\)\?\|w\?string\)\|float\|double\|\%(ptrdiff\|s\?size\|wchar\|off\|u\?intmax\)_t\)\)\>"
|
||||||
|
syntax match juliaBaseTypeError display "\<\%(\%(Bounds\|Divide\|Domain\|\%(Stack\)\?Overflow\|EOF\|Undef\%(Ref\|Var\)\|System\|Type\|Parse\|Argument\|Key\|Load\|Method\|Inexact\|OutOfMemory\|Init\|Assertion\|Unicode\|ReadOnlyMemory\)Error\|\%(Interrupt\|Error\|ProcessExited\|Captured\|Composite\|InvalidState\|Null\|Remote\)Exception\|DimensionMismatch\|SegmentationFault\)\>"
|
||||||
|
syntax match juliaBaseTypeIter display "\<\%(EachLine\|Enumerate\|Cartesian\%(Index\|Range\)\|LinSpace\)\>"
|
||||||
|
syntax match juliaBaseTypeIter05 display "\<\%(Zip\|Filter\)\>"
|
||||||
|
syntax match juliaBaseTypeString display "\<\%(DirectIndex\|Sub\|Rep\|Rev\|Abstract\)\?String\>"
|
||||||
|
syntax match juliaBaseTypeArray display "\<\%(\%(Sub\)\?Array\|\%(Abstract\|Dense\|Strided\)\?\%(Array\|Matrix\|Vec\%(tor\|OrMat\)\)\|SparseMatrixCSC\|\%(AbstractSparse\|Bit\|Shared\)\%(Array\|Vector\|Matrix\)\|\%\(D\|Bid\|\%(Sym\)\?Trid\)iagonal\|Hermitian\|Symmetric\|UniformScaling\|\%(Lower\|Upper\)Triangular\|SparseVector\|VecElement\)\>"
|
||||||
|
syntax match juliaBaseTypeArray0607 display "\<\%(Conj\%(Array\|Matrix\|Vector\)\|Index\%(Cartesian\|Linear\|Style\)\|PermutedDimsArray\|RowVector\)\>"
|
||||||
|
syntax match juliaBaseTypeDict display "\<\%(WeakKey\|ObjectId\)\?Dict\>"
|
||||||
|
syntax match juliaBaseTypeSet display "\<Set\>"
|
||||||
|
syntax match juliaBaseTypeSet0506 display "\<IntSet\>"
|
||||||
|
syntax match juliaBaseTypeSet0607 display "\<AbstractSet\>"
|
||||||
|
syntax match juliaBaseTypeSet07 display "\<BitSet\>"
|
||||||
|
syntax match juliaBaseTypeIO display "\<\%(IO\%(Stream\|Buffer\|Context\)\?\|RawFD\|StatStruct\|DevNull\|FileMonitor\|PollingFileWatcher\|Timer\|Base64\%(Decode\|Encode\)Pipe\|\%(UDP\|TCP\)Socket\|\%(Abstract\)\?Channel\|BufferStream\|ReentrantLock\)\>"
|
||||||
|
syntax match juliaBaseTypeProcess display "\<\%(ProcessGroup\|Pipe\|Cmd\)\>"
|
||||||
|
syntax match juliaBaseTypeProcess0607 display "\<PipeBuffer\>"
|
||||||
|
syntax match juliaBaseTypeRange display "\<\%(Dims\|RangeIndex\|\%(Ordinal\|Step\|\%(Abstract\)\?Unit\)Range\|Colon\)\>"
|
||||||
|
syntax match juliaBaseTypeRange05 display "\<FloatRange\>"
|
||||||
|
syntax match juliaBaseTypeRange0506 display "\<Range\>"
|
||||||
|
syntax match juliaBaseTypeRange0607 display "\<\%(ExponentialBackOff\|StepRangeLen\)\>"
|
||||||
|
syntax match juliaBaseTypeRange07 display "\<AbstractRange\>"
|
||||||
|
syntax match juliaBaseTypeRegex display "\<Regex\%(Match\)\?\>"
|
||||||
|
syntax match juliaBaseTypeFact display "\<Factorization\>"
|
||||||
|
syntax match juliaBaseTypeSort display "\<\%(Insertion\|\(Partial\)\?Quick\|Merge\)Sort\>"
|
||||||
|
syntax match juliaBaseTypeRound display "\<Round\%(ingMode\|FromZero\|Down\|Nearest\%(Ties\%(Away\|Up\)\)\?\|ToZero\|Up\)\>"
|
||||||
|
syntax match juliaBaseTypeSpecial display "\<\%(LocalProcess\|ClusterManager\)\>"
|
||||||
|
syntax match juliaBaseTypeRandom display "\<\%(AbstractRNG\|MersenneTwister\|RandomDevice\)\>"
|
||||||
|
syntax match juliaBaseTypeDisplay display "\<\%(Text\(Display\)\?\|Display\|MIME\|HTML\)\>"
|
||||||
|
syntax match juliaBaseTypeTime display "\<\%(Date\%(Time\)\?\)\>"
|
||||||
|
syntax match juliaBaseTypeTime0607 display "\<DateFormat\>"
|
||||||
|
syntax match juliaBaseTypeOther display "\<\%(RemoteRef\|Task\|Condition\|VersionNumber\|IPv[46]\|SerializationState\|WorkerConfig\|Future\|RemoteChannel\|IPAddr\|Stack\%(Trace\|Frame\)\|\(Caching\|Worker\)Pool\|AbstractSerializer\)\>"
|
||||||
|
|
||||||
|
syntax match juliaConstNum display "\%(\<\%(\%(NaN\|Inf\)\%(16\|32\|64\)\?\|pi\|π\)\>\)"
|
||||||
|
syntax match juliaConstNum0506 display "\%(\<\%(eu\?\|eulergamma\|γ\|catalan\|φ\|golden\)\>\)"
|
||||||
|
" Note: recognition of ℯ, which Vim does not consider a valid identifier, is
|
||||||
|
" complicated. We detect possible uses by just looking for the character (for
|
||||||
|
" performance) and then check that it's actually used by its own.
|
||||||
|
" (This also tries to detect preceding number constants; it does so in a crude
|
||||||
|
" way.)
|
||||||
|
syntax match juliaPossibleEuler "ℯ" contains=juliaEuler
|
||||||
|
exec 'syntax match juliaEuler contained "\%(\%(^\|[' . s:nonidS_chars . ']\|' . s:operators . '\)\%([.0-9eEf_]*\d\)\?\)\@'.s:d(80).'<=ℯ\ze\%($\|[' . s:nonidS_chars . ']\|' . s:operators . '\)"'
|
||||||
|
syntax match juliaConstBool display "\<\%(true\|false\)\>"
|
||||||
|
syntax match juliaConstEnv display "\<\%(ARGS\|ENV\|CPU_CORES\|OS_NAME\|ENDIAN_BOM\|LOAD_PATH\|VERSION\|JULIA_HOME\|PROGRAM_FILE\)\>"
|
||||||
|
syntax match juliaConstIO display "\<\%(STD\%(OUT\|IN\|ERR\)\)\>"
|
||||||
|
syntax match juliaConstC display "\<\%(WORD_SIZE\|C_NULL\)\>"
|
||||||
|
syntax match juliaConstGeneric display "\<\%(nothing\|Main\)\>"
|
||||||
|
|
||||||
|
syntax match juliaPossibleMacro transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro
|
||||||
|
|
||||||
|
exec 'syntax match juliaMacro contained "@' . s:idregex . '\%(\.' . s:idregex . '\)*"'
|
||||||
|
syntax match juliaMacro contained "@\.\ze[^0-9]"
|
||||||
|
exec 'syntax region juliaMacroCallP contained transparent start="@' . s:idregex . '\%(\.' . s:idregex . '\)*(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock'
|
||||||
|
exec 'syntax region juliaMacroCallP contained transparent start="@.(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaParBlock'
|
||||||
|
exec 'syntax region juliaMacroCall contained transparent start="\(@' . s:idregex . '\%(\.' . s:idregex . '\)*\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS'
|
||||||
|
exec 'syntax region juliaMacroCall contained transparent start="\(@.\)\@=\1\%([^(]\|$\)" end="\ze\%([])};#]\|$\|\<for\>\)" contains=@juliaExpressions,juliaMacro,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS'
|
||||||
|
|
||||||
|
syntax match juliaNumbers transparent "\<\d\|\.\d\|\<im\>" contains=juliaNumber,juliaFloat,juliaComplexUnit
|
||||||
|
|
||||||
|
"integer regexes
|
||||||
|
let s:dec_regex = '\d\%(_\?\d\)*\%(\>\|im\>\|\ze\D\)'
|
||||||
|
let s:hex_regex = '0x\x\%(_\?\x\)*\%(\>\|im\>\|\ze\X\)'
|
||||||
|
let s:bin_regex = '0b[01]\%(_\?[01]\)*\%(\>\|im\>\|\ze[^01]\)'
|
||||||
|
let s:oct_regex = '0o\o\%(_\?\o\)*\%(\>\|im\>\|\ze\O\)'
|
||||||
|
|
||||||
|
let s:int_regex = '\%(' . s:hex_regex .
|
||||||
|
\ '\|' . s:bin_regex .
|
||||||
|
\ '\|' . s:oct_regex .
|
||||||
|
\ '\|' . s:dec_regex .
|
||||||
|
\ '\)'
|
||||||
|
|
||||||
|
"floating point regexes
|
||||||
|
" starting with a dot, optional exponent
|
||||||
|
let s:float_regex1 = '\.\d\%(_\?\d\)*\%([eEf][-+]\?\d\+\)\?\%(\>\|im\>\|\ze\D\)'
|
||||||
|
" with dot, optional exponent
|
||||||
|
let s:float_regex2 = '\d\%(_\?\d\)*\.\%(\d\%(_\?\d\)*\)\?\%([eEf][-+]\?\d\+\)\?\%(\>\|im\>\|\ze\D\)'
|
||||||
|
" without dot, with exponent
|
||||||
|
let s:float_regex3 = '\d\%(_\?\d\)*[eEf][-+]\?\d\+\%(\>\|im\>\|\ze\D\)'
|
||||||
|
|
||||||
|
"hex floating point numbers
|
||||||
|
" starting with a dot
|
||||||
|
let s:hexfloat_regex1 = '0x\.\%\(\x\%(_\?\x\)*\)\?[pP][-+]\?\d\+\%(\>\|im\>\|\ze\X\)'
|
||||||
|
" starting with a digit
|
||||||
|
let s:hexfloat_regex2 = '0x\x\%(_\?\x\)*\%\(\.\%\(\x\%(_\?\x\)*\)\?\)\?[pP][-+]\?\d\+\%(\>\|im\>\|\ze\X\)'
|
||||||
|
|
||||||
|
let s:float_regex = '\%(' . s:float_regex3 .
|
||||||
|
\ '\|' . s:float_regex2 .
|
||||||
|
\ '\|' . s:float_regex1 .
|
||||||
|
\ '\|' . s:hexfloat_regex2 .
|
||||||
|
\ '\|' . s:hexfloat_regex1 .
|
||||||
|
\ '\)'
|
||||||
|
|
||||||
|
exec 'syntax match juliaNumber contained "' . s:int_regex . '" contains=juliaComplexUnit'
|
||||||
|
exec 'syntax match juliaFloat contained "' . s:float_regex . '" contains=juliaComplexUnit'
|
||||||
|
syntax match juliaComplexUnit display contained "\<im\>"
|
||||||
|
|
||||||
|
exec 'syntax match juliaOperator "' . s:operators . '"'
|
||||||
|
syntax match juliaRangeOperator display ":"
|
||||||
|
exec 'syntax region juliaTernaryRegion matchgroup=juliaTernaryOperator start="\s\zs?\ze\s" skip="\%(:\(:\|[^:[:space:]'."'".'"({[]\+\s*\ze:\)\|^\s*:\|\%(?\s*\)\@'.s:d(6).'<=:(\)" end=":" contains=@juliaExpressions,juliaErrorSemicol'
|
||||||
|
|
||||||
|
let s:interp_dollar = '\([' . s:nonidS_chars . s:uniop_chars . s:binop_chars . '!?]\|^\)\@'.s:d(1).'<=\$'
|
||||||
|
|
||||||
|
exec 'syntax match juliaDollarVar display contained "' . s:interp_dollar . s:idregex . '"'
|
||||||
|
exec 'syntax region juliaDollarPar matchgroup=juliaDollarVar contained start="' .s:interp_dollar . '(" end=")" contains=@juliaExpressions'
|
||||||
|
exec 'syntax region juliaDollarSqBra matchgroup=juliaDollarVar contained start="' .s:interp_dollar . '\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS'
|
||||||
|
|
||||||
|
syntax match juliaChar "'\\\?.'" contains=juliaSpecialChar
|
||||||
|
syntax match juliaChar display "'\\\o\{3\}'" contains=juliaOctalEscapeChar
|
||||||
|
syntax match juliaChar display "'\\x\x\{2\}'" contains=juliaHexEscapeChar
|
||||||
|
syntax match juliaChar display "'\\u\x\{1,4\}'" contains=juliaUniCharSmall
|
||||||
|
syntax match juliaChar display "'\\U\x\{1,8\}'" contains=juliaUniCharLarge
|
||||||
|
|
||||||
|
exec 'syntax match juliaCTransOperator "[[:space:]}' . s:nonid_chars . s:uniop_chars . s:binop_chars . '!?]\@'.s:d(1).'<!\.\?' . "'" . '"'
|
||||||
|
|
||||||
|
syntax region juliaString matchgroup=juliaStringDelim start=+\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaStringVars,@juliaSpecialChars,@juliaSpellcheckStrings
|
||||||
|
syntax region juliabString matchgroup=juliaStringDelim start=+\<b\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpecialChars
|
||||||
|
syntax region juliasString matchgroup=juliaStringDelim start=+\<s\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpecialChars
|
||||||
|
syntax region juliavString matchgroup=juliaStringDelim start=+\<v\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+
|
||||||
|
syntax region juliaipString matchgroup=juliaStringDelim start=+\<ip\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+
|
||||||
|
syntax region juliabigString matchgroup=juliaStringDelim start=+\<big\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+
|
||||||
|
syntax region juliaMIMEString matchgroup=juliaStringDelim start=+\<MIME\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1+ contains=@juliaSpecialChars
|
||||||
|
|
||||||
|
syntax region juliaDocString matchgroup=juliaStringDelim start=+^"""+ skip=+\%(\\\\\)*\\"+ end=+"""+ contains=@juliaStringVars,@juliaSpecialChars,@juliaSpellcheckDocStrings
|
||||||
|
|
||||||
|
exec 'syntax region juliaPrintfMacro contained transparent start="@s\?printf(" end=")\@'.s:d(1).'<=" contains=juliaMacro,juliaPrintfParBlock'
|
||||||
|
syntax region juliaPrintfMacro contained transparent start="@s\?printf\s\+" end="\ze\%([])};#]\|$\|\<for\>\)" contains=@juliaExprsPrintf,juliaMacro,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS
|
||||||
|
syntax region juliaPrintfParBlock contained matchgroup=juliaParDelim start="(" end=")" contains=@juliaExprsPrintf
|
||||||
|
syntax region juliaPrintfString contained matchgroup=juliaStringDelim start=+"+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=@juliaSpecialChars,@juliaPrintfChars
|
||||||
|
|
||||||
|
syntax region juliaShellString matchgroup=juliaStringDelim start=+`+ skip=+\%(\\\\\)*\\`+ end=+`+ contains=@juliaStringVars,juliaSpecialChar
|
||||||
|
|
||||||
|
syntax cluster juliaStringVars contains=juliaStringVarsPar,juliaStringVarsSqBra,juliaStringVarsCurBra,juliaStringVarsPla
|
||||||
|
syntax region juliaStringVarsPar contained matchgroup=juliaStringVarDelim start="$(" end=")" contains=@juliaExpressions
|
||||||
|
syntax region juliaStringVarsSqBra contained matchgroup=juliaStringVarDelim start="$\[" end="\]" contains=@juliaExpressions,juliaComprehensionFor,juliaSymbolS,juliaQuotedParBlockS,juliaQuotedQMarkParS
|
||||||
|
syntax region juliaStringVarsCurBra contained matchgroup=juliaStringVarDelim start="${" end="}" contains=@juliaExpressions
|
||||||
|
exec 'syntax match juliaStringVarsPla contained "\$' . s:idregex . '"'
|
||||||
|
|
||||||
|
" TODO improve RegEx
|
||||||
|
syntax region juliaRegEx matchgroup=juliaStringDelim start=+\<r\z("\(""\)\?\)+ skip=+\%(\\\\\)*\\"+ end=+\z1[imsx]*+
|
||||||
|
|
||||||
|
syntax cluster juliaSpecialChars contains=juliaSpecialChar,juliaOctalEscapeChar,juliaHexEscapeChar,juliaUniCharSmall,juliaUniCharLarge
|
||||||
|
syntax match juliaSpecialChar display contained "\\."
|
||||||
|
syntax match juliaOctalEscapeChar display contained "\\\o\{3\}"
|
||||||
|
syntax match juliaHexEscapeChar display contained "\\x\x\{2\}"
|
||||||
|
syntax match juliaUniCharSmall display contained "\\u\x\{1,4\}"
|
||||||
|
syntax match juliaUniCharLarge display contained "\\U\x\{1,8\}"
|
||||||
|
|
||||||
|
syntax cluster juliaPrintfChars contains=juliaErrorPrintfFmt,juliaPrintfFmt
|
||||||
|
syntax match juliaErrorPrintfFmt display contained "\\\?%."
|
||||||
|
syntax match juliaPrintfFmt display contained "%\%(\d\+\$\)\=[-+' #0]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjqzt]\|ll\|hh\)\=[aAbdiuoxXDOUfFeEgGcCsSpn]"
|
||||||
|
syntax match juliaPrintfFmt display contained "%%"
|
||||||
|
syntax match juliaPrintfFmt display contained "\\%\%(\d\+\$\)\=[-+' #0]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjqzt]\|ll\|hh\)\=[aAbdiuoxXDOUfFeEgGcCsSpn]"hs=s+1
|
||||||
|
syntax match juliaPrintfFmt display contained "\\%%"hs=s+1
|
||||||
|
|
||||||
|
" this is used to restrict the search for Symbols to when colons appear at all
|
||||||
|
" (for performance reasons)
|
||||||
|
syntax match juliaPossibleSymbol transparent ":\ze[^:]" contains=juliaSymbol,juliaQuotedParBlock,juliaQuotedQMarkPar,juliaColon
|
||||||
|
|
||||||
|
let s:quotable = '\%(' . s:idregex . '\|?\|' . s:operators . '\|' . s:float_regex . '\|' . s:int_regex . '\)'
|
||||||
|
let s:quoting_colon = '\%(\%(^\s*\|\s\{6,\}\|[' . s:nonid_chars . s:uniop_chars . s:binop_chars . '?]\s*\)\@'.s:d(6).'<=\|\%(\<\%(return\|if\|else\%(if\)\?\|while\|try\|begin\)\s*\)\@'.s:d(9).'<=\)\zs:'
|
||||||
|
let s:quoting_colonS = '\s\@'.s:d(1).'<=:'
|
||||||
|
|
||||||
|
" note: juliaSymbolS only works within whitespace-sensitive contexts,
|
||||||
|
" such as in macro calls without parentheses, or within square brackets.
|
||||||
|
" It is used to override the recognition of expressions like `a :b` as
|
||||||
|
" ranges rather than symbols in those contexts.
|
||||||
|
" (Note that such `a :b` expressions only allows at most 5 spaces between
|
||||||
|
" the identifier and the colon anyway.)
|
||||||
|
|
||||||
|
exec 'syntax match juliaSymbol contained "' .s:quoting_colon . s:quotable . '"'
|
||||||
|
exec 'syntax match juliaSymbolS contained "' . s:quoting_colonS . s:quotable . '"'
|
||||||
|
|
||||||
|
" same as above for quoted expressions such as :(expr)
|
||||||
|
" (includes :(?) as a special case, although it really shouldn't work...)
|
||||||
|
exec 'syntax region juliaQuotedParBlock matchgroup=juliaQParDelim start="' . s:quoting_colon . '(" end=")" contains=@juliaExpressions'
|
||||||
|
exec 'syntax match juliaQuotedQMarkPar "' . s:quoting_colon . '(\s*?\s*)" contains=juliaQuotedQMark'
|
||||||
|
exec 'syntax region juliaQuotedParBlockS matchgroup=juliaQParDelim contained start="' . s:quoting_colonS . '(" end=")" contains=@juliaExpressions'
|
||||||
|
exec 'syntax match juliaQuotedQMarkParS contained "' . s:quoting_colonS . '(\s*?\s*)" contains=juliaQuotedQMark'
|
||||||
|
|
||||||
|
" force precedence over Symbols
|
||||||
|
syntax match juliaOperator display "::"
|
||||||
|
|
||||||
|
syntax region juliaCommentL matchgroup=juliaCommentDelim start="#\ze\%([^=]\|$\)" end="$" keepend contains=juliaTodo,@juliaSpellcheckComments
|
||||||
|
syntax region juliaCommentM matchgroup=juliaCommentDelim start="#=\ze\%([^#]\|$\)" end="=#" contains=juliaTodo,juliaCommentM,@juliaSpellcheckComments
|
||||||
|
syntax keyword juliaTodo contained TODO FIXME XXX
|
||||||
|
|
||||||
|
|
||||||
" Misc. blocks
|
" the following are disabled by default, but
|
||||||
syn region juliaMiscBlockBlock transparent matchgroup=juliaMiscBlock start="\<\%(quote\|do\|begin\|let\)\>" end="\<end\>" contains=ALL
|
" can be enabled by entering e.g.
|
||||||
|
" :hi link juliaParDelim Delimiter
|
||||||
|
hi def link juliaParDelim juliaNone
|
||||||
|
hi def link juliaSemicolon juliaNone
|
||||||
|
hi def link juliaComma juliaNone
|
||||||
|
|
||||||
hi def link juliaMiscBlock Repeat
|
hi def link juliaColon juliaOperator
|
||||||
|
|
||||||
" Braces and Brackets
|
|
||||||
syn region juliaBracketsBlock matchgroup=juliaBrackets start='\[' end='\]' contains=ALLBUT,juliaRepeatBlock contained
|
|
||||||
syn region juliaBracesBlock matchgroup=juliaBraces start='{' end='}' contains=ALLBUT,juliaRepeatBlock contained
|
|
||||||
|
|
||||||
" Repeat
|
|
||||||
syn region juliaRepeatBlock transparent matchgroup=juliaRepeat start="\<\%(while\|for\)\>" end="\<end\>" contains=@juliaTop
|
|
||||||
|
|
||||||
hi def link juliaRepeat Repeat
|
|
||||||
|
|
||||||
" Conditional
|
|
||||||
syn keyword juliaElse else elseif
|
|
||||||
syn region juliaIfBlock transparent matchgroup=juliaIf start="\<if\>" end="\<end\>" contains=@juliaTop
|
|
||||||
|
|
||||||
hi def link juliaElse Conditional
|
|
||||||
hi def link juliaIf Conditional
|
|
||||||
|
|
||||||
|
|
||||||
" try catch end
|
hi def link juliaKeyword Keyword
|
||||||
syn keyword juliaCatch catch contained
|
hi def link juliaInfixKeyword Keyword
|
||||||
syn region juliaTryBlock transparent matchgroup=juliaTry start="\<try\>" end="\<end\>" contains=@juliaTop
|
hi def link juliaRepKeyword Keyword
|
||||||
|
hi def link juliaBlKeyword Keyword
|
||||||
|
hi def link juliaConditional Conditional
|
||||||
|
hi def link juliaRepeat Repeat
|
||||||
|
hi def link juliaException Exception
|
||||||
|
hi def link juliaTypedef Keyword
|
||||||
|
exec 'hi! def link juliaOuter ' . (b:julia_syntax_version >= 7 ? 'Keyword' : 'NONE')
|
||||||
|
hi def link juliaBaseTypeBasic Type
|
||||||
|
hi def link juliaBaseTypeNum Type
|
||||||
|
hi def link juliaBaseTypeC Type
|
||||||
|
hi def link juliaBaseTypeError Type
|
||||||
|
hi def link juliaBaseTypeIter Type
|
||||||
|
hi def link juliaBaseTypeString Type
|
||||||
|
hi def link juliaBaseTypeArray Type
|
||||||
|
hi def link juliaBaseTypeDict Type
|
||||||
|
hi def link juliaBaseTypeSet Type
|
||||||
|
hi def link juliaBaseTypeIO Type
|
||||||
|
hi def link juliaBaseTypeProcess Type
|
||||||
|
hi def link juliaBaseTypeRange Type
|
||||||
|
hi def link juliaBaseTypeRegex Type
|
||||||
|
hi def link juliaBaseTypeFact Type
|
||||||
|
hi def link juliaBaseTypeSort Type
|
||||||
|
hi def link juliaBaseTypeRound Type
|
||||||
|
hi def link juliaBaseTypeSpecial Type
|
||||||
|
hi def link juliaBaseTypeRandom Type
|
||||||
|
hi def link juliaBaseTypeDisplay Type
|
||||||
|
hi def link juliaBaseTypeTime Type
|
||||||
|
hi def link juliaBaseTypeOther Type
|
||||||
|
for t in ["Basic", "Array", "Set", "Range", "Time", "Process"]
|
||||||
|
let h = b:julia_syntax_version >= 6 ? "Type" : "NONE"
|
||||||
|
exec "hi! def link juliaBaseType" . t . "0607 " . h
|
||||||
|
endfor
|
||||||
|
for t in ["Iter", "Range"]
|
||||||
|
let h = b:julia_syntax_version == 5 ? "Type" : b:julia_syntax_version == 6 ? "juliaDeprecated" : "NONE"
|
||||||
|
exec "hi! def link juliaBaseType" . t . "05 " . h
|
||||||
|
endfor
|
||||||
|
for t in ["Range", "Set"]
|
||||||
|
let h = b:julia_syntax_version <= 6 ? "Type" : "juliaDeprecated"
|
||||||
|
exec "hi! def link juliaBaseType" . t . "0506 " . h
|
||||||
|
endfor
|
||||||
|
for t in ["Range", "Set"]
|
||||||
|
let h = b:julia_syntax_version >= 7 ? "Type" : "NONE"
|
||||||
|
exec "hi! def link juliaBaseType" . t . "07 " . h
|
||||||
|
endfor
|
||||||
|
|
||||||
hi def link juliaTry Exception
|
" NOTE: deprecated constants are not highlighted as such. For once,
|
||||||
hi def link juliaCatch Exception
|
" one can still legitimately use them by importing Base.MathConstants.
|
||||||
|
" Plus, one-letter variables like `e` and `γ` can be used with other
|
||||||
|
" meanings.
|
||||||
|
hi def link juliaConstNum Constant
|
||||||
|
let h = b:julia_syntax_version <= 6 ? "Constant" : "NONE"
|
||||||
|
exec "hi! def link juliaConstNum0506 " . h
|
||||||
|
let h = b:julia_syntax_version >= 7 ? "Constant" : "NONE"
|
||||||
|
exec "hi! def link juliaEuler " . h
|
||||||
|
|
||||||
|
hi def link juliaConstEnv Constant
|
||||||
|
hi def link juliaConstIO Constant
|
||||||
|
hi def link juliaConstC Constant
|
||||||
|
hi def link juliaConstLimits Constant
|
||||||
|
hi def link juliaConstGeneric Constant
|
||||||
|
hi def link juliaRangeEnd Constant
|
||||||
|
hi def link juliaConstBool Boolean
|
||||||
|
|
||||||
" one word statements
|
hi def link juliaComprehensionFor Keyword
|
||||||
syn keyword juliaStatement return continue break
|
hi def link juliaComprehensionIf Keyword
|
||||||
|
|
||||||
hi def link juliaStatement Statement
|
hi def link juliaDollarVar Identifier
|
||||||
|
|
||||||
" misc
|
hi def link juliaMacro Macro
|
||||||
syn keyword juliaDeclaration const global local
|
hi def link juliaSymbol Identifier
|
||||||
syn keyword juliaComprehensionFor for
|
hi def link juliaSymbolS Identifier
|
||||||
|
hi def link juliaQParDelim Identifier
|
||||||
|
hi def link juliaQuotedQMarkPar Identifier
|
||||||
|
hi def link juliaQuotedQMarkParS Identifier
|
||||||
|
hi def link juliaQuotedQMark juliaOperatorHL
|
||||||
|
|
||||||
hi def link juliaDeclaration Keyword
|
hi def link juliaNumber Number
|
||||||
hi def link juliaComprehensionFor Keyword
|
hi def link juliaFloat Float
|
||||||
|
hi def link juliaComplexUnit Constant
|
||||||
|
|
||||||
" Built in types
|
hi def link juliaChar Character
|
||||||
syn keyword juliaType Uint Uint8 Uint16 Uint32 Uint64 Uint128
|
|
||||||
syn keyword juliaType Int Int8 Int16 Int32 Int64 Int128
|
|
||||||
syn keyword juliaType Float Float16 Float32 Float64
|
|
||||||
syn keyword juliaType AbstractArray AbstractMatrix AbstractVector Array Vector Matrix
|
|
||||||
syn keyword juliaType String ByteString UTF8String SubString
|
|
||||||
syn keyword juliaType Bool Nothing Union Type
|
|
||||||
|
|
||||||
|
hi def link juliaString String
|
||||||
|
hi def link juliabString String
|
||||||
|
hi def link juliasString String
|
||||||
|
hi def link juliavString String
|
||||||
|
hi def link juliarString String
|
||||||
|
hi def link juliaipString String
|
||||||
|
hi def link juliabigString String
|
||||||
|
hi def link juliaMIMEString String
|
||||||
|
hi def link juliaPrintfString String
|
||||||
|
hi def link juliaShellString String
|
||||||
|
hi def link juliaDocString String
|
||||||
|
hi def link juliaStringDelim String
|
||||||
|
hi def link juliaStringVarsPla Identifier
|
||||||
|
hi def link juliaStringVarDelim Identifier
|
||||||
|
|
||||||
hi def link juliaType Type
|
hi def link juliaRegEx String
|
||||||
|
|
||||||
|
hi def link juliaSpecialChar SpecialChar
|
||||||
|
hi def link juliaOctalEscapeChar SpecialChar
|
||||||
|
hi def link juliaHexEscapeChar SpecialChar
|
||||||
|
hi def link juliaUniCharSmall SpecialChar
|
||||||
|
hi def link juliaUniCharLarge SpecialChar
|
||||||
|
|
||||||
" Comments
|
hi def link juliaPrintfFmt SpecialChar
|
||||||
syn keyword juliaTodo contained TODO FIXME XXX
|
|
||||||
syn cluster juliaCommentGroup contains=juliaTodo
|
|
||||||
syn region juliaComment start="#" end="$" contains=@juliaCommentGroup,@Spell
|
|
||||||
|
|
||||||
hi def link juliaComment Comment
|
if s:julia_highlight_operators
|
||||||
hi def link juliaTodo Todo
|
hi! def link juliaOperatorHL Operator
|
||||||
|
else
|
||||||
|
hi! def link juliaOperatorHL juliaNone
|
||||||
|
endif
|
||||||
|
hi def link juliaOperator juliaOperatorHL
|
||||||
|
hi def link juliaRangeOperator juliaOperatorHL
|
||||||
|
hi def link juliaCTransOperator juliaOperatorHL
|
||||||
|
hi def link juliaTernaryOperator juliaOperatorHL
|
||||||
|
|
||||||
|
hi def link juliaCommentL Comment
|
||||||
|
hi def link juliaCommentM Comment
|
||||||
|
hi def link juliaCommentDelim Comment
|
||||||
|
hi def link juliaTodo Todo
|
||||||
|
|
||||||
" Strings
|
hi def link juliaErrorPar juliaError
|
||||||
syn region juliaString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@juliaStringGroup,@Spell
|
hi def link juliaErrorEnd juliaError
|
||||||
syn region juliaTripleString start=+"""+ end=+"""+
|
hi def link juliaErrorElse juliaError
|
||||||
syn region juliaCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@juliaCharacterGroup
|
hi def link juliaErrorCatch juliaError
|
||||||
|
hi def link juliaErrorFinally juliaError
|
||||||
|
hi def link juliaErrorSemicol juliaError
|
||||||
|
hi def link juliaErrorPrintfFmt juliaError
|
||||||
|
|
||||||
hi def link juliaString String
|
hi def link juliaError Error
|
||||||
hi def link juliaTripleString String
|
|
||||||
hi def link juliaCharacter Character
|
|
||||||
|
|
||||||
|
if b:julia_syntax_highlight_deprecated == 1
|
||||||
|
hi! def link juliaDeprecated Todo
|
||||||
|
else
|
||||||
|
hi! def link juliaDeprecated NONE
|
||||||
|
end
|
||||||
|
|
||||||
" Functions
|
syntax sync fromstart
|
||||||
syn region juliaFunctionBlock transparent matchgroup=juliaFunction start="\<\%\(function\|macro\)\>" end="\<end\>" contains=@juliaTop
|
|
||||||
hi def link juliaFunction Function
|
|
||||||
|
|
||||||
|
|
||||||
" Numbers
|
|
||||||
syn match juliaNumber "\<\d\+\([Ee]\d\+\)\?\>"
|
|
||||||
syn match juliaNumber "\<0x\x\+\>"
|
|
||||||
syn match juliaNumber "\<0\o\+\>"
|
|
||||||
|
|
||||||
syn match juliaFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
|
|
||||||
syn match juliaFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
|
|
||||||
syn match juliaFloat "\<\d\+[Ee][-+]\d\+\>"
|
|
||||||
syn keyword juliaFloatSpecial NaN Inf
|
|
||||||
|
|
||||||
hi def link juliaNumber Number
|
|
||||||
hi def link juliaFloat Float
|
|
||||||
hi def link juliaFloatSpecial Float
|
|
||||||
|
|
||||||
|
|
||||||
" Operators
|
|
||||||
syn keyword juliaIn in
|
|
||||||
hi def link juliaIn Operator
|
|
||||||
|
|
||||||
|
|
||||||
" Constants
|
|
||||||
syn keyword juliaBool true false nothing
|
|
||||||
hi def link juliaBool Boolean
|
|
||||||
|
|
||||||
syn keyword juliaIdentifierSpecial STDOUT, STDIN, STDERR
|
|
||||||
|
|
||||||
hi def link juliaIdentifierSpecial Identifier
|
|
||||||
|
|
||||||
|
|
||||||
" Macros
|
|
||||||
syn match juliaMacro display "@[_[:alpha:]][_[:alnum:]!]*\%(\.[_[:alpha:]][_[:alnum:]!]*\)*"
|
|
||||||
|
|
||||||
hi def link juliaMacro Macro
|
|
||||||
|
|
||||||
|
|
||||||
syn cluster juliaTop contains=ALLBUT,juliaComprehensionFor
|
|
||||||
|
|
||||||
" Ragel
|
|
||||||
syn include @ragel syntax/ragel.vim
|
|
||||||
syn region ragelLine start="%%" end="$" contains=@ragel
|
|
||||||
|
|
||||||
|
|
||||||
let b:current_syntax = "julia"
|
let b:current_syntax = "julia"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'kotlin') == -1
|
|||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: Kotlin
|
" Language: Kotlin
|
||||||
" Maintainer: Alexander Udalov
|
" Maintainer: Alexander Udalov
|
||||||
" Latest Revision: 18 September 2017
|
" Latest Revision: 23 November 2017
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
@@ -39,7 +39,7 @@ syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contai
|
|||||||
syn match ktSpecialCharError "\v\\." contained
|
syn match ktSpecialCharError "\v\\." contained
|
||||||
syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained
|
syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained
|
||||||
syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
|
syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
|
||||||
syn region ktString start='"""' end='"""' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
|
syn region ktString start='"""' end='""""*' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
|
||||||
syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError
|
syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError
|
||||||
syn match ktCharacter "\v'\\''" contains=ktSpecialChar
|
syn match ktCharacter "\v'\\''" contains=ktSpecialChar
|
||||||
syn match ktCharacter "\v'[^\\]'"
|
syn match ktCharacter "\v'[^\\]'"
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1
|
|
||||||
|
|
||||||
syntax match helpText /^.*: .*/
|
|
||||||
syntax match secNum /^\S\+\(\.\S\+\)\?\s*/ contained conceal
|
|
||||||
syntax match secLine /^\S\+\t.\+/ contains=secNum
|
|
||||||
syntax match mainSecLine /^[^\.]\+\t.*/ contains=secNum
|
|
||||||
syntax match ssubSecLine /^[^\.]\+\.[^\.]\+\.[^\.]\+\t.*/ contains=secNum
|
|
||||||
highlight link helpText PreProc
|
|
||||||
highlight link secNum Number
|
|
||||||
highlight link mainSecLine Title
|
|
||||||
highlight link ssubSecLine Comment
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -13,12 +13,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'perl') == -1
|
|||||||
" - Fix <%text> blocks to show HTML tags but ignore Mason tags.
|
" - Fix <%text> blocks to show HTML tags but ignore Mason tags.
|
||||||
"
|
"
|
||||||
|
|
||||||
" Clear previous syntax settings unless this is v6 or above, in which case just
|
" quit when a syntax file was already loaded
|
||||||
" exit without doing anything.
|
if exists("b:current_syntax")
|
||||||
"
|
|
||||||
if version < 600
|
|
||||||
syn clear
|
|
||||||
elseif exists("b:current_syntax")
|
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -30,26 +26,16 @@ endif
|
|||||||
|
|
||||||
" First pull in the HTML syntax.
|
" First pull in the HTML syntax.
|
||||||
"
|
"
|
||||||
if version < 600
|
runtime! syntax/html.vim
|
||||||
so <sfile>:p:h/html.vim
|
unlet b:current_syntax
|
||||||
else
|
|
||||||
runtime! syntax/html.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
endif
|
|
||||||
|
|
||||||
syn cluster htmlPreproc add=@masonTop
|
syn cluster htmlPreproc add=@masonTop
|
||||||
|
|
||||||
" Now pull in the Perl syntax.
|
" Now pull in the Perl syntax.
|
||||||
"
|
"
|
||||||
if version < 600
|
syn include @perlTop syntax/perl.vim
|
||||||
syn include @perlTop <sfile>:p:h/perl.vim
|
unlet b:current_syntax
|
||||||
unlet b:current_syntax
|
syn include @podTop syntax/pod.vim
|
||||||
syn include @podTop <sfile>:p:h/pod.vim
|
|
||||||
else
|
|
||||||
syn include @perlTop syntax/perl.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
syn include @podTop syntax/pod.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
" It's hard to reduce down to the correct sub-set of Perl to highlight in some
|
" It's hard to reduce down to the correct sub-set of Perl to highlight in some
|
||||||
" of these cases so I've taken the safe option of just using perlTop in all of
|
" of these cases so I've taken the safe option of just using perlTop in all of
|
||||||
@@ -88,21 +74,9 @@ syn cluster masonTop contains=masonLine,masonExpr,masonPerl,masonComp,masonArgs,
|
|||||||
|
|
||||||
" Set up default highlighting. Almost all of this is done in the included
|
" Set up default highlighting. Almost all of this is done in the included
|
||||||
" syntax files.
|
" syntax files.
|
||||||
"
|
hi def link masonDoc Comment
|
||||||
if version >= 508 || !exists("did_mason_syn_inits")
|
hi def link masonPod Comment
|
||||||
if version < 508
|
hi def link masonPerlComment perlComment
|
||||||
let did_mason_syn_inits = 1
|
|
||||||
com -nargs=+ HiLink hi link <args>
|
|
||||||
else
|
|
||||||
com -nargs=+ HiLink hi def link <args>
|
|
||||||
endif
|
|
||||||
|
|
||||||
HiLink masonDoc Comment
|
|
||||||
HiLink masonPod Comment
|
|
||||||
HiLink masonPerlComment perlComment
|
|
||||||
|
|
||||||
delc HiLink
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:current_syntax = "mason"
|
let b:current_syntax = "mason"
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ syn keyword nimKeyword ptr
|
|||||||
syn keyword nimKeyword raise ref return
|
syn keyword nimKeyword raise ref return
|
||||||
syn keyword nimKeyword shared shl shr static
|
syn keyword nimKeyword shared shl shr static
|
||||||
syn keyword nimKeyword try tuple type
|
syn keyword nimKeyword try tuple type
|
||||||
syn keyword nimKeyword var
|
syn keyword nimKeyword var vtref vtptr
|
||||||
syn keyword nimKeyword when while with without
|
syn keyword nimKeyword when while with without
|
||||||
syn keyword nimKeyword xor
|
syn keyword nimKeyword xor
|
||||||
syn keyword nimKeyword yield
|
syn keyword nimKeyword yield
|
||||||
@@ -92,32 +92,33 @@ endif
|
|||||||
|
|
||||||
if nim_highlight_builtins == 1
|
if nim_highlight_builtins == 1
|
||||||
" builtin functions, types and objects, not really part of the syntax
|
" builtin functions, types and objects, not really part of the syntax
|
||||||
syn keyword nimBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool
|
syn keyword nimBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64
|
||||||
syn keyword nimBuiltin char string cstring pointer range array openarray seq
|
syn keyword nimBuiltin bool void chr char string cstring pointer range array openarray openArray seq varargs varArgs
|
||||||
syn keyword nimBuiltin set Byte Natural Positive Conversion
|
syn keyword nimBuiltin set Byte Natural Positive Conversion
|
||||||
syn keyword nimBuiltin BiggestInt BiggestFloat cchar cschar cshort cint csize cuchar cushort
|
syn keyword nimBuiltin BiggestInt BiggestFloat cchar cschar cshort cint csize cuchar cushort
|
||||||
syn keyword nimBuiltin clong clonglong cfloat cdouble clongdouble cuint culong culonglong cchar
|
syn keyword nimBuiltin clong clonglong cfloat cdouble clongdouble cuint culong culonglong cchar
|
||||||
syn keyword nimBuiltin CompileDate CompileTime nimVersion nimMajor
|
syn keyword nimBuiltin CompileDate CompileTime nimversion nimVersion nimmajor nimMajor
|
||||||
syn keyword nimBuiltin nimMinor nimPatch cpuEndian hostOS hostCPU inf
|
syn keyword nimBuiltin nimminor nimMinor nimpatch nimPatch cpuendian cpuEndian hostos hostOS hostcpu hostCPU inf
|
||||||
syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbgLineHook stdin
|
syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbglinehook dbgLineHook stdin
|
||||||
syn keyword nimBuiltin stdout stderr defined new high low sizeof succ pred
|
syn keyword nimBuiltin stdout stderr defined new high low sizeof succ pred
|
||||||
syn keyword nimBuiltin inc dec newSeq len incl excl card ord chr ze ze64
|
syn keyword nimBuiltin inc dec newseq newSeq len incl excl card ord chr ze ze64
|
||||||
syn keyword nimBuiltin toU8 toU16 toU32 abs min max add repr
|
syn keyword nimBuiltin tou8 toU8 tou16 toU16 tou32 toU32 abs min max add repr
|
||||||
syn match nimBuiltin "\<contains\>"
|
syn match nimBuiltin "\<contains\>"
|
||||||
syn keyword nimBuiltin toFloat toBiggestFloat toInt toBiggestInt addQuitProc
|
syn keyword nimBuiltin tofloat toFloat tobiggestfloat toBiggestFloat toint toInt tobiggestint toBiggestInt
|
||||||
syn keyword nimBuiltin copy setLen newString zeroMem copyMem moveMem
|
syn keyword nimBuiltin addquitproc addQuitProc
|
||||||
syn keyword nimBuiltin equalMem alloc alloc0 realloc dealloc setLen assert
|
syn keyword nimBuiltin copy setlen setLen newstring newString zeromem zeroMem copymem copyMem movemem moveMem
|
||||||
syn keyword nimBuiltin swap getRefcount getCurrentException Msg
|
syn keyword nimBuiltin equalmem equalMem alloc alloc0 realloc dealloc assert
|
||||||
syn keyword nimBuiltin getOccupiedMem getFreeMem getTotalMem isNil seqToPtr
|
syn keyword nimBuiltin echo swap getrefcount getRefcount getcurrentexception getCurrentException Msg
|
||||||
|
syn keyword nimBuiltin getoccupiedmem getOccupiedMem getfreemem getFreeMem gettotalmem getTotalMem isnil isNil seqtoptr seqToPtr
|
||||||
syn keyword nimBuiltin find pop GC_disable GC_enable GC_fullCollect
|
syn keyword nimBuiltin find pop GC_disable GC_enable GC_fullCollect
|
||||||
syn keyword nimBuiltin GC_setStrategy GC_enableMarkAndSweep GC_Strategy
|
syn keyword nimBuiltin GC_setStrategy GC_enableMarkAndSweep GC_Strategy
|
||||||
syn keyword nimBuiltin GC_disableMarkAnd Sweep GC_getStatistics GC_ref
|
syn keyword nimBuiltin GC_disableMarkAnd Sweep GC_getStatistics GC_ref
|
||||||
syn keyword nimBuiltin GC_ref GC_ref GC_unref GC_unref GC_unref quit
|
syn keyword nimBuiltin GC_ref GC_ref GC_unref GC_unref GC_unref quit
|
||||||
syn keyword nimBuiltin OpenFile OpenFile CloseFile EndOfFile readChar
|
syn keyword nimBuiltin OpenFile OpenFile CloseFile EndOfFile readChar
|
||||||
syn keyword nimBuiltin FlushFile readFile write readLine writeln writeln
|
syn keyword nimBuiltin FlushFile readfile readFile readline readLine write writeln writeLn writeline writeLine
|
||||||
syn keyword nimBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes
|
syn keyword nimBuiltin getfilesize getFileSize ReadBytes ReadChars readbuffer readBuffer writebytes writeBytes
|
||||||
syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos
|
syn keyword nimBuiltin writechars writeChars writebuffer writeBuffer setfilepos setFilePos getfilepos getFilePos
|
||||||
syn keyword nimBuiltin fileHandle countdown countup items lines
|
syn keyword nimBuiltin filehandle fileHandle countdown countup items lines
|
||||||
syn keyword nimBuiltin FileMode File RootObj FileHandle ByteAddress Endianness
|
syn keyword nimBuiltin FileMode File RootObj FileHandle ByteAddress Endianness
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
260
syntax/nix.vim
260
syntax/nix.vim
@@ -1,131 +1,187 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nix') == -1
|
||||||
|
|
||||||
"
|
" Vim syntax file
|
||||||
" Syntax file for Nix
|
" Language: Nix
|
||||||
"
|
" Maintainer: Daiderd Jordan <daiderd@gmail.com>
|
||||||
" TODO:
|
" URL: https://github.com/LnL7/vim-nix
|
||||||
" Emphasize :
|
|
||||||
" Deemphasize ;
|
|
||||||
" Consistent ()
|
|
||||||
" rec (red?)
|
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Operators
|
syn keyword nixBoolean true false
|
||||||
syn match nixOperator "\V++"
|
syn keyword nixNull null
|
||||||
syn match nixOperator "\V+"
|
syn keyword nixRecKeyword rec
|
||||||
syn match nixOperator "\V!"
|
|
||||||
syn match nixOperator "\V=="
|
|
||||||
syn match nixOperator "\V!="
|
|
||||||
syn match nixOperator "\V&&"
|
|
||||||
syn match nixOperator "\V||"
|
|
||||||
syn match nixOperator "\V->"
|
|
||||||
|
|
||||||
syn match nixOperator "\V-"
|
syn keyword nixOperator or
|
||||||
syn match nixOperator "\V*"
|
syn match nixOperator '!=\|!'
|
||||||
syn match nixOperator "\V/"
|
syn match nixOperator '<=\?'
|
||||||
syn match nixOperator "\V>"
|
syn match nixOperator '>=\?'
|
||||||
syn match nixOperator "\V<"
|
syn match nixOperator '&&'
|
||||||
|
syn match nixOperator '//\='
|
||||||
|
syn match nixOperator '=='
|
||||||
|
syn match nixOperator '?'
|
||||||
|
syn match nixOperator '||'
|
||||||
|
syn match nixOperator '++\='
|
||||||
|
syn match nixOperator '-'
|
||||||
|
syn match nixOperator '\*'
|
||||||
|
syn match nixOperator '->'
|
||||||
|
|
||||||
" Keywords
|
syn match nixParen '[()]'
|
||||||
syn keyword nixKeyword let in or assert inherit null with rec
|
syn match nixInteger '\d\+'
|
||||||
syn keyword nixConditional if else then
|
|
||||||
syn keyword nixBoolean true false
|
|
||||||
|
|
||||||
" Builtins
|
syn keyword nixTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained
|
||||||
syn keyword nixBuiltin builtins abort add attrNames attrValues
|
syn match nixComment '#.*' contains=nixTodo,@Spell
|
||||||
\ baseNameOf compareVersions concatLists currentSystem deepSeq
|
syn region nixComment start=+/\*+ end=+\*/+ contains=nixTodo,@Spell
|
||||||
\ derivation dirOf div elem elemAt filter filterSource fromJSON
|
|
||||||
\ getAttr getEnv hasAttr hashString head import intersectAttrs
|
|
||||||
\ isAttrs isList isFunction isString isInt isBool isNull length
|
|
||||||
\ lessThan listToAttrs map mul parseDrvNames pathExists readDir
|
|
||||||
\ readFile removeAttrs seq stringLength sub substring tail throw
|
|
||||||
\ toFile toJSON toPath toString toXML trace typeOf tryEval
|
|
||||||
|
|
||||||
syn match nixpkgs "<nixpkgs>"
|
syn region nixInterpolation matchgroup=nixInterpolationDelimiter start="\${" end="}" contained contains=@nixExpr,nixInterpolationParam
|
||||||
syn match nixSpecialOper "\V@\|;\|,\|?\|..."
|
|
||||||
|
|
||||||
" Attribute Lists
|
syn match nixSimpleStringSpecial /\\["nrt\\$]/ contained
|
||||||
"syn match nixBrace "\v[(){}\[\]]|rec\s*\{"
|
syn match nixInterpolationSpecial /''['$]/ contained
|
||||||
syn region nixSet matchgroup=nixBraces start="{" end="}" contains=ALL
|
|
||||||
syn region nixRecSet matchgroup=nixBraces start="rec\s*{" end="}" contains=ALL
|
|
||||||
syn region nixList matchgroup=nixBraces start="\[" end="\]" contains=ALLBUT,nixAttr
|
|
||||||
syn match nixAttr "\v[0-9A-Za-z\-\_]+\ze\s*\=" contained
|
|
||||||
|
|
||||||
syn match nixInteger "\v<\d+>"
|
syn region nixSimpleString matchgroup=nixStringDelimiter start=+"+ skip=+\\"+ end=+"+ contains=nixInterpolation,nixSimpleStringSpecial
|
||||||
|
syn region nixString matchgroup=nixStringDelimiter start=+''+ skip=+''['$]+ end=+''+ contains=nixInterpolation,nixInterpolationSpecial
|
||||||
|
|
||||||
" Functions
|
syn match nixFunctionCall "[a-zA-Z_][a-zA-Z0-9_'-]*"
|
||||||
syn match nixFuncArg "\v\zs\w+\ze\s*:"
|
|
||||||
|
|
||||||
" TODO: Exclude ; and other illegal characters
|
syn match nixPath "[a-zA-Z0-9._+-]*\%(/[a-zA-Z0-9._+-]\+\)\+"
|
||||||
syn match nixPath "\v\S*/\S+|\S+/\S*"
|
syn match nixHomePath "\~\%(/[a-zA-Z0-9._+-]\+\)\+"
|
||||||
|
syn match nixSearchPath "[a-zA-Z0-9._+-]\+\%(\/[a-zA-Z0-9._+-]\+\)*" contained
|
||||||
|
syn match nixPathDelimiter "[<>]" contained
|
||||||
|
syn match nixSearchPathRef "<[a-zA-Z0-9._+-]\+\%(\/[a-zA-Z0-9._+-]\+\)*>" contains=nixSearchPath,nixPathDelimiter
|
||||||
|
syn match nixURI "[a-zA-Z][a-zA-Z0-9.+-]*:[a-zA-Z0-9%/?:@&=$,_.!~*'+-]\+"
|
||||||
|
|
||||||
" This operator is placed after nixPath to override nixPath's highlighting
|
syn match nixAttributeDot "\." contained
|
||||||
syn match nixOperator "\V//"
|
syn match nixAttribute "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%([^a-zA-Z0-9_'-.]\|$\)" contained
|
||||||
|
syn region nixAttributeAssignment start="=" end="\ze;" contained contains=@nixExpr
|
||||||
|
syn region nixAttributeDefinition start=/\ze[a-zA-Z_"$]/ end=";" contained contains=nixComment,nixAttribute,nixInterpolation,nixSimpleString,nixAttributeDot,nixAttributeAssignment
|
||||||
|
|
||||||
" Strings
|
syn region nixInheritAttributeScope start="(" end=")" contained contains=nixComment,nixAttributeDot
|
||||||
syn match nixStringIndentedEscapes +'''\|''\${\|''\\n\|''\\r\|''\\t+
|
syn region nixAttributeDefinition matchgroup=nixInherit start="\<inherit\>" end=";" contained contains=nixComment,nixInheritAttributeScope,nixAttribute
|
||||||
syn match nixStringEscapes +\\"\|\\\${\|\\n\|\\r\|\\t\|\\\\+
|
|
||||||
syn region nixStringIndented
|
|
||||||
\ start=+''+
|
|
||||||
\ skip=+'''+
|
|
||||||
\ end=+''+
|
|
||||||
\ contains=nixAntiquotation,nixStringIndentedEscapes
|
|
||||||
syn region nixString
|
|
||||||
\ start=+"+
|
|
||||||
\ skip=+\\"+
|
|
||||||
\ end=+"+
|
|
||||||
\ contains=nixAntiquotation,nixStringEscapes
|
|
||||||
|
|
||||||
" If this contains nixBrace, it ignores its own closing brace and syntax gets
|
syn region nixAttributeSet start="{" end="}" contains=nixComment,nixAttributeDefinition
|
||||||
" thrown way off contains=ALLBUT,nixBrace
|
|
||||||
syn region nixAntiquotation start=+\${+ end=+}+ contains=nixAntiQuotation
|
|
||||||
|
|
||||||
" Comments
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
syn region nixMultiLineComment start=+/\*+ skip=+\\"+ end=+\*/+ contains=nixTodos
|
syn region nixArgumentDefinitionWithDefault matchgroup=nixArgumentDefinition start="[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*?\@=" matchgroup=NONE end="[,}]\@=" transparent contained contains=@nixExpr
|
||||||
syn match nixEndOfLineComment "#.*$" contains=nixTodos
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
syntax keyword nixTodos TODO XXX FIXME NOTE TODOS contained
|
syn match nixArgumentDefinition "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[,}]\@=" contained
|
||||||
|
syn match nixArgumentEllipsis "\.\.\." contained
|
||||||
|
syn match nixArgumentSeparator "," contained
|
||||||
|
|
||||||
" Special (Delimiter
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
hi def link nixBraces Delimiter
|
syn match nixArgOperator '@\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:'he=s+1 contained contains=nixAttribute
|
||||||
hi def link nixpkgs Special
|
|
||||||
hi def link nixSpecialOper Special
|
|
||||||
hi def link nixStringIndentedEscapes SpecialChar
|
|
||||||
hi def link nixStringEscapes SpecialChar
|
|
||||||
hi def link nixBuiltin Special
|
|
||||||
hi def link nixOperator Operator
|
|
||||||
|
|
||||||
" Constants
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
hi def link nixBoolean Boolean
|
syn match nixArgOperator '[a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*@'hs=e-1 contains=nixAttribute nextgroup=nixFunctionArgument
|
||||||
hi def link nixInteger Number
|
|
||||||
hi def link nixString String
|
|
||||||
hi def link nixStringIndented String
|
|
||||||
|
|
||||||
" Comments
|
" This is a bit more complicated, because function arguments can be passed in a
|
||||||
hi def link nixMultiLineComment Comment
|
" very similar form on how attribute sets are defined and two regions with the
|
||||||
hi def link nixEndOfLineComment Comment
|
" same start patterns will shadow each other. Instead of a region we could use a
|
||||||
|
" match on {\_.\{-\}}, which unfortunately doesn't take nesting into account.
|
||||||
|
"
|
||||||
|
" So what we do instead is that we look forward until we are sure that it's a
|
||||||
|
" function argument. Unfortunately, we need to catch comments and both vertical
|
||||||
|
" and horizontal white space, which the following regex should hopefully do:
|
||||||
|
"
|
||||||
|
" "\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*"
|
||||||
|
"
|
||||||
|
" It is also used throught the whole file and is marked with 'v's as well.
|
||||||
|
"
|
||||||
|
" Fortunately the matching rules for function arguments are much simpler than
|
||||||
|
" for real attribute sets, because we can stop when we hit the first ellipsis or
|
||||||
|
" default value operator, but we also need to paste the "whitespace & comments
|
||||||
|
" eating" regex all over the place (marked with 'v's):
|
||||||
|
"
|
||||||
|
" Region match 1: { foo ? ... } or { foo, ... } or { ... } (ellipsis)
|
||||||
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv {----- identifier -----}vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
|
syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*\%([a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[,?}]\|\.\.\.\)" end="}" contains=nixComment,nixArgumentDefinitionWithDefault,nixArgumentDefinition,nixArgumentEllipsis,nixArgumentSeparator nextgroup=nixArgOperator
|
||||||
|
|
||||||
" Identifiers
|
" Now it gets more tricky, because we need to look forward for the colon, but
|
||||||
hi def link nixConditional Conditional
|
" there could be something like "{}@foo:", even though it's highly unlikely.
|
||||||
hi def link nixKeyword Keyword
|
"
|
||||||
hi def link nixOperator Operator
|
" Region match 2: {}
|
||||||
hi def link nixException Exception
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv@vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv{----- identifier -----} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
hi def link nixAttr Identifier
|
syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*}\%(\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*@\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[a-zA-Z_][a-zA-Z0-9_'-]*\)\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:" end="}" contains=nixComment nextgroup=nixArgOperator
|
||||||
hi def link nixFuncArg Identifier
|
|
||||||
|
|
||||||
" PreProc
|
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||||
hi def link nixAntiquotation Macro
|
syn match nixSimpleFunctionArgument "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:/\@!"
|
||||||
|
|
||||||
" Underlined (html links)
|
syn region nixList matchgroup=nixListBracket start="\[" end="\]" contains=@nixExpr
|
||||||
hi def link nixPath Underlined
|
|
||||||
|
|
||||||
" Error
|
syn region nixLetExpr matchgroup=nixLetExprKeyword start="\<let\>" end="\<in\>" contains=nixComment,nixAttributeDefinition
|
||||||
|
|
||||||
syn sync maxlines=20000
|
syn keyword nixIfExprKeyword then contained
|
||||||
syn sync minlines=50000
|
syn region nixIfExpr matchgroup=nixIfExprKeyword start="\<if\>" end="\<else\>" contains=@nixExpr,nixIfExprKeyword
|
||||||
|
|
||||||
let b:current_syntax = 'nix'
|
syn region nixWithExpr matchgroup=nixWithExprKeyword start="\<with\>" matchgroup=NONE end=";" contains=@nixExpr
|
||||||
|
|
||||||
|
syn region nixAssertExpr matchgroup=nixAssertKeyword start="\<assert\>" matchgroup=NONE end=";" contains=@nixExpr
|
||||||
|
|
||||||
|
syn cluster nixExpr contains=nixBoolean,nixNull,nixOperator,nixParen,nixInteger,nixRecKeyword,nixConditional,nixBuiltin,nixSimpleBuiltin,nixComment,nixFunctionCall,nixFunctionArgument,nixSimpleFunctionArgument,nixPath,nixHomePath,nixSearchPathRef,nixURI,nixAttributeSet,nixList,nixSimpleString,nixString,nixLetExpr,nixIfExpr,nixWithExpr,nixAssertExpr
|
||||||
|
|
||||||
|
" These definitions override @nixExpr and have to come afterwards:
|
||||||
|
|
||||||
|
syn match nixInterpolationParam "[a-zA-Z_][a-zA-Z0-9_'-]*\%(\.[a-zA-Z_][a-zA-Z0-9_'-]*\)*" contained
|
||||||
|
|
||||||
|
" Non-namespaced Nix builtins as of version 1.10:
|
||||||
|
syn keyword nixSimpleBuiltin
|
||||||
|
\ abort baseNameOf derivation dirOf fetchTarball import map removeAttrs
|
||||||
|
\ throw toString
|
||||||
|
|
||||||
|
" Namespaced and non-namespaced Nix builtins as of version 1.10:
|
||||||
|
syn keyword nixNamespacedBuiltin contained
|
||||||
|
\ abort add all any attrNames attrValues baseNameOf compareVersions
|
||||||
|
\ concatLists currentSystem deepSeq derivation dirOf div elem elemAt
|
||||||
|
\ fetchTarball fetchurl filter filterSource foldl' fromJSON genList
|
||||||
|
\ getAttr getEnv hasAttr hashString head import intersectAttrs isAttrs
|
||||||
|
\ isBool isFunction isInt isList isString length lessThan listToAttrs map
|
||||||
|
\ mul parseDrvName pathExists readDir readFile removeAttrs replaceStrings
|
||||||
|
\ seq sort stringLength sub substring tail throw toFile toJSON toPath
|
||||||
|
\ toString toXML trace typeOf
|
||||||
|
|
||||||
|
syn match nixBuiltin "builtins\.[a-zA-Z']\+"he=s+9 contains=nixComment,nixNamespacedBuiltin
|
||||||
|
|
||||||
|
hi def link nixArgOperator Operator
|
||||||
|
hi def link nixArgumentDefinition Identifier
|
||||||
|
hi def link nixArgumentEllipsis Operator
|
||||||
|
hi def link nixAssertKeyword Keyword
|
||||||
|
hi def link nixAttribute Identifier
|
||||||
|
hi def link nixAttributeDot Operator
|
||||||
|
hi def link nixBoolean Boolean
|
||||||
|
hi def link nixBuiltin Special
|
||||||
|
hi def link nixComment Comment
|
||||||
|
hi def link nixConditional Conditional
|
||||||
|
hi def link nixHomePath Include
|
||||||
|
hi def link nixIfExprKeyword Keyword
|
||||||
|
hi def link nixInherit Keyword
|
||||||
|
hi def link nixInteger Integer
|
||||||
|
hi def link nixInterpolation Macro
|
||||||
|
hi def link nixInterpolationDelimiter Delimiter
|
||||||
|
hi def link nixInterpolationParam Macro
|
||||||
|
hi def link nixInterpolationSpecial Special
|
||||||
|
hi def link nixLetExprKeyword Keyword
|
||||||
|
hi def link nixNamespacedBuiltin Special
|
||||||
|
hi def link nixNull Constant
|
||||||
|
hi def link nixOperator Operator
|
||||||
|
hi def link nixPath Include
|
||||||
|
hi def link nixPathDelimiter Delimiter
|
||||||
|
hi def link nixRecKeyword Keyword
|
||||||
|
hi def link nixSearchPath Include
|
||||||
|
hi def link nixSimpleBuiltin Keyword
|
||||||
|
hi def link nixSimpleFunctionArgument Identifier
|
||||||
|
hi def link nixSimpleString String
|
||||||
|
hi def link nixSimpleStringSpecial SpecialChar
|
||||||
|
hi def link nixString String
|
||||||
|
hi def link nixStringDelimiter Delimiter
|
||||||
|
hi def link nixTodo Todo
|
||||||
|
hi def link nixURI Include
|
||||||
|
hi def link nixWithExprKeyword Keyword
|
||||||
|
|
||||||
|
" This could lead up to slow syntax highlighting for large files, but usually
|
||||||
|
" large files such as all-packages.nix are one large attribute set, so if we'd
|
||||||
|
" use sync patterns we'd have to go back to the start of the file anyway
|
||||||
|
syn sync fromstart
|
||||||
|
|
||||||
|
let b:current_syntax = "nix"
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,93 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'openscad') == -1
|
|
||||||
|
|
||||||
" Vim syntax file
|
|
||||||
" Language: OpenSCAD
|
|
||||||
" Maintainer: Sirtaj Singh Kang <sirtaj-vim@sirtaj.net>
|
|
||||||
" Last Changed: 2013 March 05
|
|
||||||
|
|
||||||
if version < 600
|
|
||||||
syntax clear
|
|
||||||
elseif exists("b:current_syntax")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
"syn keyword openscadFunctionDef function
|
|
||||||
syn keyword openscadFunctionDef function nextgroup=openscadFunction skipwhite skipempty
|
|
||||||
syn match openscadFunction /\<\h\w*\>/ contained display
|
|
||||||
|
|
||||||
"syn keyword openscadModuleDef module
|
|
||||||
syn keyword openscadModuleDef module nextgroup=openscadModule skipwhite skipempty
|
|
||||||
syn match openscadModule /\<\h\w*\>/ contained display
|
|
||||||
|
|
||||||
syn keyword openscadStatement echo assign let
|
|
||||||
syn keyword openscadConditional if else
|
|
||||||
syn keyword openscadRepeat for intersection_for
|
|
||||||
syn keyword openscadInclude include use
|
|
||||||
syn keyword openscadCsgKeyword union difference intersection render intersection_for
|
|
||||||
syn keyword openscadTransform scale rotate translate mirror multmatrix color minkowski hull projection linear_extrude rotate_extrude offset
|
|
||||||
syn keyword openscadPrimitiveSolid cube sphere cylinder polyhedron surface
|
|
||||||
syn keyword openscadPrimitive2D square circle polygon import_dxf text
|
|
||||||
syn keyword openscadPrimitiveImport import child children
|
|
||||||
|
|
||||||
syn match openscadSpecialVariable "\$[a-zA-Z]\+\>" display
|
|
||||||
syn match openscadModifier "^\s*[\*\!\#\%]" display
|
|
||||||
|
|
||||||
syn match openscadNumbers "\<\d\|\.\d" contains=openscadNumber display transparent
|
|
||||||
syn match openscadNumber "\d\+" display contained
|
|
||||||
syn match openscadNumber "\.\d\+" display contained
|
|
||||||
|
|
||||||
syn region openscadString start=/"/ skip=/\\"/ end=/"/
|
|
||||||
|
|
||||||
syn keyword openscadBoolean true false
|
|
||||||
|
|
||||||
syn keyword openscadCommentTodo TODO FIXME XXX contained display
|
|
||||||
syn match openscadInlineComment ://.*$: contains=openscadCommentTodo
|
|
||||||
syn region openscadBlockComment start=:/\*: end=:\*/: fold contains=openscadCommentTodo
|
|
||||||
|
|
||||||
syn region openscadBlock start="{" end="}" transparent fold
|
|
||||||
syn region openscadVector start="\[" end="\]" transparent fold
|
|
||||||
|
|
||||||
syn keyword openscadBuiltin abs acos asin atan atan2 ceil cos exp floor ln log
|
|
||||||
syn keyword openscadBuiltin lookup max min pow rands round sign sin sqrt tan
|
|
||||||
syn keyword openscadBuiltin str len search version version_num concat chr
|
|
||||||
syn keyword openscadBuiltin dxf_cross dxf_dim
|
|
||||||
|
|
||||||
hi def link openscadFunctionDef Structure
|
|
||||||
hi def link openscadFunction Function
|
|
||||||
hi def link openscadModuleDef Structure
|
|
||||||
hi def link openscadModule Function
|
|
||||||
hi def link openscadBlockComment Comment
|
|
||||||
hi def link openscadBoolean Boolean
|
|
||||||
hi def link openscadBuiltin Function
|
|
||||||
hi def link openscadConditional Conditional
|
|
||||||
hi def link openscadCsgKeyword Structure
|
|
||||||
hi def link openscadInclude Include
|
|
||||||
hi def link openscadInlineComment Comment
|
|
||||||
hi def link openscadModifier Special
|
|
||||||
hi def link openscadStatement Statement
|
|
||||||
hi def link openscadNumbers Number
|
|
||||||
hi def link openscadNumber Number
|
|
||||||
hi def link openscadPrimitiveSolid Keyword
|
|
||||||
hi def link openscadPrimitive2D Keyword
|
|
||||||
hi def link openscadPrimitiveImport Keyword
|
|
||||||
hi def link openscadRepeat Repeat
|
|
||||||
hi def link openscadSpecialVariable Special
|
|
||||||
hi def link openscadString String
|
|
||||||
hi def link openscadTransform Statement
|
|
||||||
hi def link openscadCommentTodo Todo
|
|
||||||
|
|
||||||
" Blatantly stolen from vim74\syntax\c.vim
|
|
||||||
"when wanted, highlight trailing white space
|
|
||||||
if exists("openscad_space_errors")
|
|
||||||
if !exists("openscad_no_trail_space_error")
|
|
||||||
syn match openscadSpaceError display excludenl "\s\+$"
|
|
||||||
endif
|
|
||||||
if !exists("openscad_no_tab_space_error")
|
|
||||||
syn match openscadSpaceError display " \+\t"me=e-1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:current_syntax = "openscad"
|
|
||||||
|
|
||||||
endif
|
|
||||||
198
syntax/perl.vim
198
syntax/perl.vim
@@ -435,125 +435,121 @@ else
|
|||||||
syn sync minlines=0
|
syn sync minlines=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
command -nargs=+ HiLink hi def link <args>
|
|
||||||
|
|
||||||
" NOTE: If you're linking new highlight groups to perlString, please also put
|
" NOTE: If you're linking new highlight groups to perlString, please also put
|
||||||
" them into b:match_skip in ftplugin/perl.vim.
|
" them into b:match_skip in ftplugin/perl.vim.
|
||||||
|
|
||||||
" The default highlighting.
|
" The default highlighting.
|
||||||
HiLink perlSharpBang PreProc
|
hi def link perlSharpBang PreProc
|
||||||
HiLink perlControl PreProc
|
hi def link perlControl PreProc
|
||||||
HiLink perlInclude Include
|
hi def link perlInclude Include
|
||||||
HiLink perlSpecial Special
|
hi def link perlSpecial Special
|
||||||
HiLink perlString String
|
hi def link perlString String
|
||||||
HiLink perlCharacter Character
|
hi def link perlCharacter Character
|
||||||
HiLink perlNumber Number
|
hi def link perlNumber Number
|
||||||
HiLink perlFloat Float
|
hi def link perlFloat Float
|
||||||
HiLink perlType Type
|
hi def link perlType Type
|
||||||
HiLink perlIdentifier Identifier
|
hi def link perlIdentifier Identifier
|
||||||
HiLink perlLabel Label
|
hi def link perlLabel Label
|
||||||
HiLink perlStatement Statement
|
hi def link perlStatement Statement
|
||||||
HiLink perlConditional Conditional
|
hi def link perlConditional Conditional
|
||||||
HiLink perlRepeat Repeat
|
hi def link perlRepeat Repeat
|
||||||
HiLink perlOperator Operator
|
hi def link perlOperator Operator
|
||||||
HiLink perlFunction Keyword
|
hi def link perlFunction Keyword
|
||||||
HiLink perlSubName Function
|
hi def link perlSubName Function
|
||||||
HiLink perlSubPrototype Type
|
hi def link perlSubPrototype Type
|
||||||
HiLink perlSignature Type
|
hi def link perlSignature Type
|
||||||
HiLink perlSubAttributes PreProc
|
hi def link perlSubAttributes PreProc
|
||||||
HiLink perlSubAttributesCont perlSubAttributes
|
hi def link perlSubAttributesCont perlSubAttributes
|
||||||
HiLink perlComment Comment
|
hi def link perlComment Comment
|
||||||
HiLink perlTodo Todo
|
hi def link perlTodo Todo
|
||||||
if exists("perl_string_as_statement")
|
if exists("perl_string_as_statement")
|
||||||
HiLink perlStringStartEnd perlStatement
|
hi def link perlStringStartEnd perlStatement
|
||||||
else
|
else
|
||||||
HiLink perlStringStartEnd perlString
|
hi def link perlStringStartEnd perlString
|
||||||
endif
|
endif
|
||||||
HiLink perlVStringV perlStringStartEnd
|
hi def link perlVStringV perlStringStartEnd
|
||||||
HiLink perlList perlStatement
|
hi def link perlList perlStatement
|
||||||
HiLink perlMisc perlStatement
|
hi def link perlMisc perlStatement
|
||||||
HiLink perlVarPlain perlIdentifier
|
hi def link perlVarPlain perlIdentifier
|
||||||
HiLink perlVarPlain2 perlIdentifier
|
hi def link perlVarPlain2 perlIdentifier
|
||||||
HiLink perlArrow perlIdentifier
|
hi def link perlArrow perlIdentifier
|
||||||
HiLink perlFiledescRead perlIdentifier
|
hi def link perlFiledescRead perlIdentifier
|
||||||
HiLink perlFiledescStatement perlIdentifier
|
hi def link perlFiledescStatement perlIdentifier
|
||||||
HiLink perlVarSimpleMember perlIdentifier
|
hi def link perlVarSimpleMember perlIdentifier
|
||||||
HiLink perlVarSimpleMemberName perlString
|
hi def link perlVarSimpleMemberName perlString
|
||||||
HiLink perlVarNotInMatches perlIdentifier
|
hi def link perlVarNotInMatches perlIdentifier
|
||||||
HiLink perlVarSlash perlIdentifier
|
hi def link perlVarSlash perlIdentifier
|
||||||
HiLink perlQQ perlString
|
hi def link perlQQ perlString
|
||||||
HiLink perlHereDoc perlString
|
hi def link perlHereDoc perlString
|
||||||
HiLink perlStringUnexpanded perlString
|
hi def link perlStringUnexpanded perlString
|
||||||
HiLink perlSubstitutionSQ perlString
|
hi def link perlSubstitutionSQ perlString
|
||||||
HiLink perlSubstitutionGQQ perlString
|
hi def link perlSubstitutionGQQ perlString
|
||||||
HiLink perlTranslationGQ perlString
|
hi def link perlTranslationGQ perlString
|
||||||
HiLink perlMatch perlString
|
hi def link perlMatch perlString
|
||||||
HiLink perlMatchStartEnd perlStatement
|
hi def link perlMatchStartEnd perlStatement
|
||||||
HiLink perlFormatName perlIdentifier
|
hi def link perlFormatName perlIdentifier
|
||||||
HiLink perlFormatField perlString
|
hi def link perlFormatField perlString
|
||||||
HiLink perlPackageDecl perlType
|
hi def link perlPackageDecl perlType
|
||||||
HiLink perlStorageClass perlType
|
hi def link perlStorageClass perlType
|
||||||
HiLink perlPackageRef perlType
|
hi def link perlPackageRef perlType
|
||||||
HiLink perlStatementPackage perlStatement
|
hi def link perlStatementPackage perlStatement
|
||||||
HiLink perlStatementStorage perlStatement
|
hi def link perlStatementStorage perlStatement
|
||||||
HiLink perlStatementControl perlStatement
|
hi def link perlStatementControl perlStatement
|
||||||
HiLink perlStatementScalar perlStatement
|
hi def link perlStatementScalar perlStatement
|
||||||
HiLink perlStatementRegexp perlStatement
|
hi def link perlStatementRegexp perlStatement
|
||||||
HiLink perlStatementNumeric perlStatement
|
hi def link perlStatementNumeric perlStatement
|
||||||
HiLink perlStatementList perlStatement
|
hi def link perlStatementList perlStatement
|
||||||
HiLink perlStatementHash perlStatement
|
hi def link perlStatementHash perlStatement
|
||||||
HiLink perlStatementIOfunc perlStatement
|
hi def link perlStatementIOfunc perlStatement
|
||||||
HiLink perlStatementFiledesc perlStatement
|
hi def link perlStatementFiledesc perlStatement
|
||||||
HiLink perlStatementVector perlStatement
|
hi def link perlStatementVector perlStatement
|
||||||
HiLink perlStatementFiles perlStatement
|
hi def link perlStatementFiles perlStatement
|
||||||
HiLink perlStatementFlow perlStatement
|
hi def link perlStatementFlow perlStatement
|
||||||
HiLink perlStatementInclude perlStatement
|
hi def link perlStatementInclude perlStatement
|
||||||
HiLink perlStatementProc perlStatement
|
hi def link perlStatementProc perlStatement
|
||||||
HiLink perlStatementSocket perlStatement
|
hi def link perlStatementSocket perlStatement
|
||||||
HiLink perlStatementIPC perlStatement
|
hi def link perlStatementIPC perlStatement
|
||||||
HiLink perlStatementNetwork perlStatement
|
hi def link perlStatementNetwork perlStatement
|
||||||
HiLink perlStatementPword perlStatement
|
hi def link perlStatementPword perlStatement
|
||||||
HiLink perlStatementTime perlStatement
|
hi def link perlStatementTime perlStatement
|
||||||
HiLink perlStatementMisc perlStatement
|
hi def link perlStatementMisc perlStatement
|
||||||
HiLink perlStatementIndirObj perlStatement
|
hi def link perlStatementIndirObj perlStatement
|
||||||
HiLink perlFunctionName perlIdentifier
|
hi def link perlFunctionName perlIdentifier
|
||||||
HiLink perlMethod perlIdentifier
|
hi def link perlMethod perlIdentifier
|
||||||
HiLink perlPostDeref perlIdentifier
|
hi def link perlPostDeref perlIdentifier
|
||||||
HiLink perlFunctionPRef perlType
|
hi def link perlFunctionPRef perlType
|
||||||
if !get(g:, 'perl_include_pod', 1)
|
if !get(g:, 'perl_include_pod', 1)
|
||||||
HiLink perlPOD perlComment
|
hi def link perlPOD perlComment
|
||||||
endif
|
endif
|
||||||
HiLink perlShellCommand perlString
|
hi def link perlShellCommand perlString
|
||||||
HiLink perlSpecialAscii perlSpecial
|
hi def link perlSpecialAscii perlSpecial
|
||||||
HiLink perlSpecialDollar perlSpecial
|
hi def link perlSpecialDollar perlSpecial
|
||||||
HiLink perlSpecialString perlSpecial
|
hi def link perlSpecialString perlSpecial
|
||||||
HiLink perlSpecialStringU perlSpecial
|
hi def link perlSpecialStringU perlSpecial
|
||||||
HiLink perlSpecialMatch perlSpecial
|
hi def link perlSpecialMatch perlSpecial
|
||||||
HiLink perlDATA perlComment
|
hi def link perlDATA perlComment
|
||||||
|
|
||||||
" NOTE: Due to a bug in Vim (or more likely, a misunderstanding on my part),
|
" NOTE: Due to a bug in Vim (or more likely, a misunderstanding on my part),
|
||||||
" I had to remove the transparent property from the following regions
|
" I had to remove the transparent property from the following regions
|
||||||
" in order to get them to highlight correctly. Feel free to remove
|
" in order to get them to highlight correctly. Feel free to remove
|
||||||
" these and reinstate the transparent property if you know how.
|
" these and reinstate the transparent property if you know how.
|
||||||
HiLink perlParensSQ perlString
|
hi def link perlParensSQ perlString
|
||||||
HiLink perlBracketsSQ perlString
|
hi def link perlBracketsSQ perlString
|
||||||
HiLink perlBracesSQ perlString
|
hi def link perlBracesSQ perlString
|
||||||
HiLink perlAnglesSQ perlString
|
hi def link perlAnglesSQ perlString
|
||||||
|
|
||||||
HiLink perlParensDQ perlString
|
hi def link perlParensDQ perlString
|
||||||
HiLink perlBracketsDQ perlString
|
hi def link perlBracketsDQ perlString
|
||||||
HiLink perlBracesDQ perlString
|
hi def link perlBracesDQ perlString
|
||||||
HiLink perlAnglesDQ perlString
|
hi def link perlAnglesDQ perlString
|
||||||
|
|
||||||
HiLink perlSpecialStringU2 perlString
|
hi def link perlSpecialStringU2 perlString
|
||||||
|
|
||||||
" Possible errors
|
" Possible errors
|
||||||
HiLink perlNotEmptyLine Error
|
hi def link perlNotEmptyLine Error
|
||||||
HiLink perlElseIfError Error
|
hi def link perlElseIfError Error
|
||||||
HiLink perlSubPrototypeError Error
|
hi def link perlSubPrototypeError Error
|
||||||
HiLink perlSubError Error
|
hi def link perlSubError Error
|
||||||
|
|
||||||
delcommand HiLink
|
|
||||||
|
|
||||||
" Syncing to speed up processing
|
" Syncing to speed up processing
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -621,8 +621,9 @@ if !exists("php_ignore_phpdoc") || !php_ignore_phpdoc
|
|||||||
|
|
||||||
syn region phpDocTags start="{@\(example\|id\|internal\|inheritdoc\|link\|source\|toc\|tutorial\)" end="}" containedin=phpDocComment
|
syn region phpDocTags start="{@\(example\|id\|internal\|inheritdoc\|link\|source\|toc\|tutorial\)" end="}" containedin=phpDocComment
|
||||||
syn match phpDocTags "@\%(abstract\|access\|api\|author\|brief\|bug\|category\|class\|copyright\|created\|date\|deprecated\|details\|example\|exception\|file\|filesource\|final\|global\|id\|ignore\|inheritdoc\|internal\|license\|link\|magic\|method\|name\|package\|param\|property\|return\|see\|since\|source\|static\|staticvar\|struct\|subpackage\|throws\|toc\|todo\|tutorial\|type\|uses\|var\|version\|warning\)" containedin=phpDocComment nextgroup=phpDocParam,phpDocIdentifier skipwhite contained
|
syn match phpDocTags "@\%(abstract\|access\|api\|author\|brief\|bug\|category\|class\|copyright\|created\|date\|deprecated\|details\|example\|exception\|file\|filesource\|final\|global\|id\|ignore\|inheritdoc\|internal\|license\|link\|magic\|method\|name\|package\|param\|property\|return\|see\|since\|source\|static\|staticvar\|struct\|subpackage\|throws\|toc\|todo\|tutorial\|type\|uses\|var\|version\|warning\)" containedin=phpDocComment nextgroup=phpDocParam,phpDocIdentifier skipwhite contained
|
||||||
syn match phpDocParam "\s\+\zs\%(\h\w*|\?\)\+" nextgroup=phpDocIdentifier skipwhite contained
|
syn match phpDocParam "\s\+\zs\(|\|\\\|\h\w*\)*\h\w*" nextgroup=phpDocIdentifier skipwhite contained contains=phpDocNamespaceSeparator
|
||||||
syn match phpDocIdentifier "\s\+\zs$\h\w*" contained
|
syn match phpDocIdentifier "\s\+\zs$\h\w*" contained
|
||||||
|
syn match phpDocNamespaceSeparator "\\" contained display
|
||||||
|
|
||||||
syn case match
|
syn case match
|
||||||
endif
|
endif
|
||||||
@@ -651,26 +652,26 @@ endif
|
|||||||
" HereDoc
|
" HereDoc
|
||||||
syn case match
|
syn case match
|
||||||
|
|
||||||
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\I\i*\)$" end="^\z1\(;\=$\)\@=" contained contains=@Spell,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@3<=\z(\I\i*\)$" end="^\z1\(;\=$\)\@=" contained contains=@Spell,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
SynFold syn region phpHereDoc matchgroup=Delimiter start=+\(<<<\)\@<="\z(\I\i*\)"$+ end="^\z1\(;\=$\)\@=" contained contains=@Spell,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpHereDoc matchgroup=Delimiter start=+\(<<<\)\@3<="\z(\I\i*\)"$+ end="^\z1\(;\=$\)\@=" contained contains=@Spell,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
" including HTML,JavaScript,SQL if enabled via options
|
" including HTML,JavaScript,SQL if enabled via options
|
||||||
if (exists("php_html_in_heredoc") && php_html_in_heredoc)
|
if (exists("php_html_in_heredoc") && php_html_in_heredoc)
|
||||||
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@3<=\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@3<=\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
endif
|
endif
|
||||||
if (exists("php_sql_heredoc") && php_sql_heredoc)
|
if (exists("php_sql_heredoc") && php_sql_heredoc)
|
||||||
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@3<=\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" NowDoc
|
" NowDoc
|
||||||
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@<='\z(\I\i*\)'$+ end="^\z1\(;\=$\)\@=" contained keepend extend
|
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@3<='\z(\I\i*\)'$+ end="^\z1\(;\=$\)\@=" contained keepend extend
|
||||||
|
|
||||||
if (exists("php_sql_nowdoc") && php_sql_nowdoc)
|
if (exists("php_sql_nowdoc") && php_sql_nowdoc)
|
||||||
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@<='\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@3<='\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
endif
|
endif
|
||||||
if (exists("php_html_in_nowdoc") && php_html_in_nowdoc)
|
if (exists("php_html_in_nowdoc") && php_html_in_nowdoc)
|
||||||
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@<='\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@3<='\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@<='\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
SynFold syn region phpNowDoc matchgroup=Delimiter start=+\(<<<\)\@3<='\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)'$+ end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpSpecialChar,phpMethodsVar,phpStrEsc keepend extend
|
||||||
endif
|
endif
|
||||||
|
|
||||||
syn case ignore
|
syn case ignore
|
||||||
@@ -695,25 +696,28 @@ syn keyword phpKeyword class contained
|
|||||||
\ nextgroup=phpClass skipwhite skipempty
|
\ nextgroup=phpClass skipwhite skipempty
|
||||||
syn match phpClass /\h\w*/ contained
|
syn match phpClass /\h\w*/ contained
|
||||||
|
|
||||||
|
syn match phpClassNamespaceSeparator "\\" contained display
|
||||||
|
|
||||||
" Class extends
|
" Class extends
|
||||||
syn keyword phpKeyword extends contained
|
syn keyword phpKeyword extends contained
|
||||||
\ nextgroup=phpClassExtends skipwhite skipempty
|
\ nextgroup=phpClassExtends skipwhite skipempty
|
||||||
syn match phpClassExtends /\(\\\|\h\w*\)*\h\w*/ contained
|
syn match phpClassExtends /\(\\\|\h\w*\)*\h\w*/ contained contains=phpClassNamespaceSeparator
|
||||||
|
|
||||||
" Class implements
|
" Class implements
|
||||||
syntax keyword phpKeyword implements contained
|
syntax keyword phpKeyword implements contained
|
||||||
\ nextgroup=phpClassImplements skipwhite skipempty
|
\ nextgroup=phpClassImplements skipwhite skipempty
|
||||||
syntax match phpClassImplements contained
|
syntax match phpClassImplements contained contains=phpClassNamespaceSeparator
|
||||||
\ nextgroup=phpClassDelimiter skipwhite skipempty /\(\\\|\h\w*\)*\h\w*/
|
\ nextgroup=phpClassDelimiter skipwhite skipempty /\(\\\|\h\w*\)*\h\w*/
|
||||||
syntax match phpClassDelimiter contained
|
syntax match phpClassDelimiter contained
|
||||||
\ nextgroup=phpClassImplements skipwhite skipempty /,/
|
\ nextgroup=phpClassImplements skipwhite skipempty /,/
|
||||||
|
|
||||||
" use statement
|
" use statement
|
||||||
|
syn match phpUseNamespaceSeparator "\\" contained display
|
||||||
syn keyword phpInclude use contained
|
syn keyword phpInclude use contained
|
||||||
\ nextgroup=phpUseFunction,phpUseClass skipwhite skipempty
|
\ nextgroup=phpUseFunction,phpUseClass skipwhite skipempty
|
||||||
syn match phpUseFunction /function\_s\+\(\\\|\h\w*\)*\h\w*/ contained contains=phpUseKeyword
|
syn match phpUseFunction /function\_s\+\(\\\|\h\w*\)*\h\w*/ contained contains=phpUseKeyword
|
||||||
\ nextgroup=phpUseAlias skipwhite skipempty
|
\ nextgroup=phpUseAlias skipwhite skipempty
|
||||||
syn match phpUseClass /\(function\_s\+\)\@!\(\\\|\h\w*\)*\h\w*/ contained
|
syn match phpUseClass /\(function\_s\+\)\@!\(\\\|\h\w*\)*\h\w*/ contained contains=phpUseNamespaceSeparator
|
||||||
\ nextgroup=phpUseAlias skipwhite skipempty
|
\ nextgroup=phpUseAlias skipwhite skipempty
|
||||||
syn match phpUseAlias /as\_s\+\h\w*/ contained contains=phpUseKeyword
|
syn match phpUseAlias /as\_s\+\h\w*/ contained contains=phpUseKeyword
|
||||||
syn match phpUseKeyword /\(function\|as\)\_s\+/ contained contains=phpKeyword
|
syn match phpUseKeyword /\(function\|as\)\_s\+/ contained contains=phpKeyword
|
||||||
@@ -865,6 +869,10 @@ if !exists("did_php_syn_inits")
|
|||||||
hi def link phpClassImplements phpClass
|
hi def link phpClassImplements phpClass
|
||||||
hi def link phpClassDelimiter phpRegion
|
hi def link phpClassDelimiter phpRegion
|
||||||
|
|
||||||
|
hi def link phpDocNamespaceSeparator phpComment
|
||||||
|
hi def link phpClassNamespaceSeparator phpClass
|
||||||
|
hi def link phpUseNamespaceSeparator phpRegion
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Cleanup: {{{
|
" Cleanup: {{{
|
||||||
|
|||||||
@@ -21,11 +21,8 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'perl') == -1
|
|||||||
|
|
||||||
" Remove any old syntax stuff hanging around (this is suppressed
|
" Remove any old syntax stuff hanging around (this is suppressed
|
||||||
" automatically by ":syn include" if necessary).
|
" automatically by ":syn include" if necessary).
|
||||||
" For version 5.x: Clear all syntax items
|
" quit when a syntax file was already loaded
|
||||||
" For version 6.x: Quit when a syntax file was already loaded
|
if exists("b:current_syntax")
|
||||||
if version < 600
|
|
||||||
syntax clear
|
|
||||||
elseif exists("b:current_syntax")
|
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -69,28 +66,17 @@ syn match podEscape "\I\i*>"me=e-1 contained contains=@NoSpell
|
|||||||
syn match podEscape2 "\d\+>"me=e-1 contained contains=@NoSpell
|
syn match podEscape2 "\d\+>"me=e-1 contained contains=@NoSpell
|
||||||
|
|
||||||
" Define the default highlighting.
|
" Define the default highlighting.
|
||||||
" For version 5.7 and earlier: only when not done already
|
" Only when an item doesn't have highlighting yet
|
||||||
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
||||||
if version >= 508 || !exists("did_pod_syntax_inits")
|
|
||||||
if version < 508
|
|
||||||
let did_pod_syntax_inits = 1
|
|
||||||
command -nargs=+ HiLink hi link <args>
|
|
||||||
else
|
|
||||||
command -nargs=+ HiLink hi def link <args>
|
|
||||||
endif
|
|
||||||
|
|
||||||
HiLink podCommand Statement
|
hi def link podCommand Statement
|
||||||
HiLink podCmdText String
|
hi def link podCmdText String
|
||||||
HiLink podOverIndent Number
|
hi def link podOverIndent Number
|
||||||
HiLink podForKeywd Identifier
|
hi def link podForKeywd Identifier
|
||||||
HiLink podFormat Identifier
|
hi def link podFormat Identifier
|
||||||
HiLink podVerbatimLine PreProc
|
hi def link podVerbatimLine PreProc
|
||||||
HiLink podSpecial Identifier
|
hi def link podSpecial Identifier
|
||||||
HiLink podEscape String
|
hi def link podEscape String
|
||||||
HiLink podEscape2 Number
|
hi def link podEscape2 Number
|
||||||
|
|
||||||
delcommand HiLink
|
|
||||||
endif
|
|
||||||
|
|
||||||
if exists("perl_pod_spellcheck_headings")
|
if exists("perl_pod_spellcheck_headings")
|
||||||
" Spell-check headings
|
" Spell-check headings
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ syn keyword purescriptBoolean true false
|
|||||||
syn match purescriptDelimiter "[,;|.()[\]{}]"
|
syn match purescriptDelimiter "[,;|.()[\]{}]"
|
||||||
|
|
||||||
" Constructor
|
" Constructor
|
||||||
syn match purescriptConstructor "\<[A-Z]\w*\>"
|
syn match purescriptConstructor "\%(\<class\s\+\)\@15<!\<[A-Z]\w*\>"
|
||||||
syn region purescriptConstructorDecl matchgroup=purescriptConstructor start="\<[A-Z]\w*\>" end="\(|\|$\)"me=e-1,re=e-1 contained
|
syn region purescriptConstructorDecl matchgroup=purescriptConstructor start="\<[A-Z]\w*\>" end="\(|\|$\)"me=e-1,re=e-1 contained
|
||||||
\ containedin=purescriptData,purescriptNewtype
|
\ containedin=purescriptData,purescriptNewtype
|
||||||
\ contains=purescriptType,purescriptTypeVar,purescriptDelimiter,purescriptOperatorType,purescriptOperatorTypeSig,@purescriptComment
|
\ contains=purescriptType,purescriptTypeVar,purescriptDelimiter,purescriptOperatorType,purescriptOperatorTypeSig,@purescriptComment
|
||||||
|
|
||||||
" Type
|
" Type
|
||||||
syn match purescriptType "\<[A-Z]\w*\>" contained
|
syn match purescriptType "\%(\<class\s\+\)\@15<!\<[A-Z]\w*\>" contained
|
||||||
\ containedin=purescriptTypeAlias
|
\ containedin=purescriptTypeAlias
|
||||||
\ nextgroup=purescriptType,purescriptTypeVar skipwhite
|
\ nextgroup=purescriptType,purescriptTypeVar skipwhite
|
||||||
syn match purescriptTypeVar "\<[_a-z]\(\w\|\'\)*\>" contained
|
syn match purescriptTypeVar "\<[_a-z]\(\w\|\'\)*\>" contained
|
||||||
@@ -36,9 +36,20 @@ syn region purescriptTypeExport matchgroup=purescriptType start="\<[A-Z]\(\S\&[^
|
|||||||
\ contains=purescriptConstructor,purescriptDelimiter
|
\ contains=purescriptConstructor,purescriptDelimiter
|
||||||
|
|
||||||
" Function
|
" Function
|
||||||
syn match purescriptFunction "\<[_a-z]\(\w\|\'\)*\>" contained
|
syn match purescriptFunction "\%(\<instance\s\+\|\<class\s\+\)\@18<!\<[_a-z]\(\w\|\'\)*\>" contained
|
||||||
syn match purescriptFunction "(\(\W\&[^(),\"]\)\+)" contained extend
|
" syn match purescriptFunction "\<[_a-z]\(\w\|\'\)*\>" contained
|
||||||
syn match purescriptBacktick "`[_A-Za-z][A-Za-z0-9_]*`"
|
syn match purescriptFunction "(\%(\<class\s\+\)\@18<!\(\W\&[^(),\"]\)\+)" contained extend
|
||||||
|
syn match purescriptBacktick "`[_A-Za-z][A-Za-z0-9_\.]*`"
|
||||||
|
|
||||||
|
" Class
|
||||||
|
syn region purescriptClassDecl start="^\%(\s*\)class\>"ms=e-5 end="\<where\>\|$"
|
||||||
|
\ contains=purescriptClass,purescriptClassName,purescriptOperatorType,purescriptOperator,purescriptType,purescriptWhere
|
||||||
|
\ nextgroup=purescriptClass
|
||||||
|
\ skipnl
|
||||||
|
syn match purescriptClass "\<class\>" containedin=purescriptClassDecl contained
|
||||||
|
\ nextgroup=purescriptClassName
|
||||||
|
\ skipnl
|
||||||
|
syn match purescriptClassName "\<[A-Z]\w*\>" containedin=purescriptClassDecl contained
|
||||||
|
|
||||||
" Module
|
" Module
|
||||||
syn match purescriptModuleName "\(\w\+\.\?\)*" contained excludenl
|
syn match purescriptModuleName "\(\w\+\.\?\)*" contained excludenl
|
||||||
@@ -46,8 +57,8 @@ syn match purescriptModuleKeyword "\<module\>"
|
|||||||
syn match purescriptModule "^module\>\s\+\<\(\w\+\.\?\)*\>"
|
syn match purescriptModule "^module\>\s\+\<\(\w\+\.\?\)*\>"
|
||||||
\ contains=purescriptModuleKeyword,purescriptModuleName
|
\ contains=purescriptModuleKeyword,purescriptModuleName
|
||||||
\ nextgroup=purescriptModuleParams skipwhite skipnl skipempty
|
\ nextgroup=purescriptModuleParams skipwhite skipnl skipempty
|
||||||
syn region purescriptModuleParams start="(" end=")" fold contained keepend
|
syn region purescriptModuleParams start="(" skip="([^)]\{-})" end=")" fold contained keepend
|
||||||
\ contains=purescriptDelimiter,purescriptType,purescriptTypeExport,purescriptFunction,purescriptStructure,purescriptModuleKeyword,@purescriptComment
|
\ contains=purescriptClassDecl,purescriptClass,purescriptClassName,purescriptDelimiter,purescriptType,purescriptTypeExport,purescriptFunction,purescriptStructure,purescriptModuleKeyword,@purescriptComment
|
||||||
\ nextgroup=purescriptImportParams skipwhite
|
\ nextgroup=purescriptImportParams skipwhite
|
||||||
|
|
||||||
" Import
|
" Import
|
||||||
@@ -86,8 +97,9 @@ syn match purescriptForall "∀"
|
|||||||
syn keyword purescriptConditional if then else
|
syn keyword purescriptConditional if then else
|
||||||
syn keyword purescriptStatement do case of in
|
syn keyword purescriptStatement do case of in
|
||||||
syn keyword purescriptLet let
|
syn keyword purescriptLet let
|
||||||
|
" syn keyword purescriptClass class
|
||||||
syn keyword purescriptWhere where
|
syn keyword purescriptWhere where
|
||||||
syn match purescriptStructure "\<\(data\|newtype\|type\|class\|kind\)\>"
|
syn match purescriptStructure "\<\(data\|newtype\|type\|kind\)\>"
|
||||||
\ nextgroup=purescriptType skipwhite
|
\ nextgroup=purescriptType skipwhite
|
||||||
syn keyword purescriptStructure derive
|
syn keyword purescriptStructure derive
|
||||||
syn keyword purescriptStructure instance
|
syn keyword purescriptStructure instance
|
||||||
@@ -101,7 +113,7 @@ syn match purescriptInfix "^\(infix\|infixl\|infixr\)\>\s\+\([0-9]\+\)\s\+\(type
|
|||||||
|
|
||||||
" Operators
|
" Operators
|
||||||
syn match purescriptOperator "\([-!#$%&\*\+/<=>\?@\\^|~:]\|\<_\>\)"
|
syn match purescriptOperator "\([-!#$%&\*\+/<=>\?@\\^|~:]\|\<_\>\)"
|
||||||
syn match purescriptOperatorType "\(::\|∷\)"
|
syn match purescriptOperatorType "\%(\<instance\>.*\)\@40<!\(::\|∷\)"
|
||||||
\ nextgroup=purescriptForall,purescriptType skipwhite skipnl skipempty
|
\ nextgroup=purescriptForall,purescriptType skipwhite skipnl skipempty
|
||||||
syn match purescriptOperatorFunction "\(->\|<-\|[\\→←]\)"
|
syn match purescriptOperatorFunction "\(->\|<-\|[\\→←]\)"
|
||||||
syn match purescriptOperatorTypeSig "\(->\|<-\|=>\|<=\|::\|[∷∀→←⇒⇐]\)" contained
|
syn match purescriptOperatorTypeSig "\(->\|<-\|=>\|<=\|::\|[∷∀→←⇒⇐]\)" contained
|
||||||
@@ -176,6 +188,8 @@ highlight def link purescriptLineComment purescriptComment
|
|||||||
highlight def link purescriptBlockComment purescriptComment
|
highlight def link purescriptBlockComment purescriptComment
|
||||||
|
|
||||||
" purescript general highlights
|
" purescript general highlights
|
||||||
|
highlight def link purescriptClass purescriptKeyword
|
||||||
|
highlight def link purescriptClassName Type
|
||||||
highlight def link purescriptStructure purescriptKeyword
|
highlight def link purescriptStructure purescriptKeyword
|
||||||
highlight def link purescriptKeyword Keyword
|
highlight def link purescriptKeyword Keyword
|
||||||
highlight def link purescriptStatement Statement
|
highlight def link purescriptStatement Statement
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'qml') == -1
|
|||||||
|
|
||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: QML
|
" Language: QML
|
||||||
" Maintainer: Warwick Allison <warwick.allison@nokia.com>
|
" Maintainer: Peter Hoeg <peter@hoeg.com>
|
||||||
" Updaters:
|
" Updaters: Refer to CONTRIBUTORS.md
|
||||||
" URL:
|
" URL: https://github.com/peterhoeg/vim-qml
|
||||||
" Changes:
|
" Changes: `git log` is your friend
|
||||||
" Last Change: 2009 Apr 30
|
" Last Change: 2017-11-11
|
||||||
|
"
|
||||||
|
" This file is bassed on the original work done by Warwick Allison
|
||||||
|
" <warwick.allison@nokia.com> whose did about 99% of the work here.
|
||||||
|
|
||||||
" Based on javascript syntax (as is QML)
|
" Based on javascript syntax (as is QML)
|
||||||
|
|
||||||
@@ -26,20 +29,20 @@ endif
|
|||||||
|
|
||||||
syn case ignore
|
syn case ignore
|
||||||
|
|
||||||
|
syn cluster qmlExpr contains=qmlStringD,qmlString,SqmlCharacter,qmlNumber,qmlObjectLiteralType,qmlBoolean,qmlType,qmlJsType,qmlNull,qmlGlobal,qmlFunction
|
||||||
syn keyword qmlCommentTodo TODO FIXME XXX TBD contained
|
syn keyword qmlCommentTodo TODO FIXME XXX TBD contained
|
||||||
syn match qmlLineComment "\/\/.*" contains=@Spell,qmlCommentTodo
|
syn match qmlLineComment "\/\/.*" contains=@Spell,qmlCommentTodo
|
||||||
syn match qmlCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
|
syn match qmlCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
|
||||||
syn region qmlComment start="/\*" end="\*/" contains=@Spell,qmlCommentTodo fold
|
syn region qmlComment start="/\*" end="\*/" contains=@Spell,qmlCommentTodo fold
|
||||||
syn match qmlSpecial "\\\d\d\d\|\\."
|
syn match qmlSpecial "\\\d\d\d\|\\."
|
||||||
syn region qmlStringD start=+"+ skip=+\\\\\|\\"\|\\$+ end=+"\|$+ contains=qmlSpecial,@htmlPreproc
|
syn region qmlStringD start=+"+ skip=+\\\\\|\\"\|\\$+ end=+"\|$+ contains=qmlSpecial,@htmlPreproc,@Spell
|
||||||
syn region qmlStringS start=+'+ skip=+\\\\\|\\'\|\\$+ end=+'\|$+ contains=qmlSpecial,@htmlPreproc
|
syn region qmlStringS start=+'+ skip=+\\\\\|\\'\|\\$+ end=+'\|$+ contains=qmlSpecial,@htmlPreproc,@Spell
|
||||||
|
|
||||||
syn match qmlCharacter "'\\.'"
|
syn match qmlCharacter "'\\.'"
|
||||||
syn match qmlNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
|
syn match qmlNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
|
||||||
syn region qmlRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
|
syn region qmlRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
|
||||||
syn match qmlObjectLiteralType "[A-Za-z][_A-Za-z0-9]*\s*\({\)\@="
|
syn match qmlObjectLiteralType "[A-Za-z][_A-Za-z0-9]*\s*\({\)\@="
|
||||||
syn match qmlNonBindingColon "?[^;]*:"
|
syn region qmlTernaryColon start="?" end=":" contains=@qmlExpr,qmlBraces,qmlParens
|
||||||
syn match qmlBindingProperty "\<[A-Za-z][_A-Za-z.0-9]*\s*:"
|
syn match qmlBindingProperty "\<[A-Za-z][_A-Za-z.0-9]*\s*:"
|
||||||
|
|
||||||
syn keyword qmlConditional if else switch
|
syn keyword qmlConditional if else switch
|
||||||
@@ -122,7 +125,6 @@ if version >= 508 || !exists("did_qml_syn_inits")
|
|||||||
HiLink qmlReserved Keyword
|
HiLink qmlReserved Keyword
|
||||||
HiLink qmlDebug Debug
|
HiLink qmlDebug Debug
|
||||||
HiLink qmlConstant Label
|
HiLink qmlConstant Label
|
||||||
HiLink qmlNonBindingColon NONE
|
|
||||||
HiLink qmlBindingProperty Label
|
HiLink qmlBindingProperty Label
|
||||||
HiLink qmlDeclaration Function
|
HiLink qmlDeclaration Function
|
||||||
|
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ syn match scalaTypeTypeDeclaration /(/ contained nextgroup=scalaTypeTypeExtensio
|
|||||||
syn match scalaTypeTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeTypeDeclaration contains=scalaTypeTypeExtension skipwhite
|
syn match scalaTypeTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeTypeDeclaration contains=scalaTypeTypeExtension skipwhite
|
||||||
syn match scalaTypeTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypeExtension,scalaTypeTypeEquals skipwhite
|
syn match scalaTypeTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypeExtension,scalaTypeTypeEquals skipwhite
|
||||||
syn match scalaTypeTypeEquals /=\ze[^>]/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
|
syn match scalaTypeTypeEquals /=\ze[^>]/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
|
||||||
syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained nextgroup=scalaTypeTypeDeclaration skipwhite
|
syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypeDeclaration skipwhite
|
||||||
syn match scalaTypeTypePostDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypePostExtension skipwhite
|
syn match scalaTypeTypePostDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypePostExtension skipwhite
|
||||||
syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained nextgroup=scalaTypeTypePostDeclaration skipwhite
|
syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypePostDeclaration skipwhite
|
||||||
hi link scalaTypeTypeDeclaration Type
|
hi link scalaTypeTypeDeclaration Type
|
||||||
hi link scalaTypeTypeExtension Keyword
|
hi link scalaTypeTypeExtension Keyword
|
||||||
hi link scalaTypeTypePostDeclaration Special
|
hi link scalaTypeTypePostDeclaration Special
|
||||||
@@ -113,7 +113,7 @@ hi link scalaTypeTypePostExtension Keyword
|
|||||||
syn match scalaTypeDeclaration /(/ contained nextgroup=scalaTypeExtension contains=scalaRoundBrackets skipwhite
|
syn match scalaTypeDeclaration /(/ contained nextgroup=scalaTypeExtension contains=scalaRoundBrackets skipwhite
|
||||||
syn match scalaTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeDeclaration contains=scalaTypeExtension skipwhite
|
syn match scalaTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeDeclaration contains=scalaTypeExtension skipwhite
|
||||||
syn match scalaTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeExtension skipwhite
|
syn match scalaTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeExtension skipwhite
|
||||||
syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained nextgroup=scalaTypeDeclaration skipwhite
|
syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeDeclaration skipwhite
|
||||||
hi link scalaTypeDeclaration Type
|
hi link scalaTypeDeclaration Type
|
||||||
hi link scalaTypeExtension Keyword
|
hi link scalaTypeExtension Keyword
|
||||||
hi link scalaTypePostExtension Keyword
|
hi link scalaTypePostExtension Keyword
|
||||||
@@ -122,12 +122,14 @@ syn match scalaTypeAnnotation /\%([_a-zA-Z0-9$\s]:\_s*\)\ze[_=(\.A-Za-z0-9$]\+/
|
|||||||
syn match scalaTypeAnnotation /)\_s*:\_s*\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration
|
syn match scalaTypeAnnotation /)\_s*:\_s*\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration
|
||||||
hi link scalaTypeAnnotation Normal
|
hi link scalaTypeAnnotation Normal
|
||||||
|
|
||||||
syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained
|
syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained contains=scalaCapitalWord
|
||||||
syn match scalaCaseFollowing /`[^`]\+`/ contained
|
syn match scalaCaseFollowing /`[^`]\+`/ contained contains=scalaCapitalWord
|
||||||
hi link scalaCaseFollowing Special
|
hi link scalaCaseFollowing Special
|
||||||
|
|
||||||
syn keyword scalaKeywordModifier abstract override final lazy implicit implicitly private protected sealed null require super
|
syn keyword scalaKeywordModifier abstract override final lazy implicit private protected sealed null super
|
||||||
|
syn keyword scalaSpecialFunction implicitly require
|
||||||
hi link scalaKeywordModifier Function
|
hi link scalaKeywordModifier Function
|
||||||
|
hi link scalaSpecialFunction Function
|
||||||
|
|
||||||
syn keyword scalaSpecial this true false ne eq
|
syn keyword scalaSpecial this true false ne eq
|
||||||
syn keyword scalaSpecial new nextgroup=scalaInstanceDeclaration skipwhite
|
syn keyword scalaSpecial new nextgroup=scalaInstanceDeclaration skipwhite
|
||||||
@@ -199,7 +201,6 @@ hi link scalaDocLinks Function
|
|||||||
hi link scalaParameterAnnotation Function
|
hi link scalaParameterAnnotation Function
|
||||||
hi link scalaParamAnnotationValue Keyword
|
hi link scalaParamAnnotationValue Keyword
|
||||||
hi link scalaCommentAnnotation Function
|
hi link scalaCommentAnnotation Function
|
||||||
hi link scalaCommentCodeBlockBrackets String
|
|
||||||
hi link scalaCommentCodeBlock String
|
hi link scalaCommentCodeBlock String
|
||||||
hi link scalaTodo Todo
|
hi link scalaTodo Todo
|
||||||
|
|
||||||
|
|||||||
106
syntax/slime.vim
Normal file
106
syntax/slime.vim
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'slime') == -1
|
||||||
|
|
||||||
|
" Vim syntax file
|
||||||
|
" Language: slime
|
||||||
|
" Maintainer: Andrew Stone <andy@stonean.com>
|
||||||
|
" Version: 1
|
||||||
|
" Last Change: 2010 Sep 25
|
||||||
|
" TODO: Feedback is welcomed.
|
||||||
|
|
||||||
|
" Quit when a syntax file is already loaded.
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists("main_syntax")
|
||||||
|
let main_syntax = 'slime'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Allows a per line syntax evaluation.
|
||||||
|
let b:elixir_no_expensive = 1
|
||||||
|
|
||||||
|
" Include Elixir syntax highlighting
|
||||||
|
syn include @slimeElixirTop syntax/elixir.vim
|
||||||
|
unlet! b:current_syntax
|
||||||
|
" Include Haml syntax highlighting
|
||||||
|
syn include @slimeHaml syntax/haml.vim
|
||||||
|
unlet! b:current_syntax
|
||||||
|
|
||||||
|
syn match slimeBegin "^\s*\(&[^= ]\)\@!" nextgroup=slimeTag,slimeClassChar,slimeIdChar,slimeElixir
|
||||||
|
|
||||||
|
syn region elixirCurlyBlock start="{" end="}" contains=@slimeElixirTop contained
|
||||||
|
syn cluster slimeElixirTop add=elixirCurlyBlock
|
||||||
|
|
||||||
|
syn cluster slimeComponent contains=slimeClassChar,slimeIdChar,slimeWrappedAttrs,slimeElixir,slimeAttr,slimeInlineTagChar
|
||||||
|
|
||||||
|
syn keyword slimeDocType contained html 5 1.1 strict frameset mobile basic transitional
|
||||||
|
syn match slimeDocTypeKeyword "^\s*\(doctype\)\s\+" nextgroup=slimeDocType
|
||||||
|
|
||||||
|
syn keyword slimeTodo FIXME TODO NOTE OPTIMIZE XXX contained
|
||||||
|
syn keyword htmlTagName contained script
|
||||||
|
|
||||||
|
syn match slimeTag "\w\+[><]*" contained contains=htmlTagName nextgroup=@slimeComponent
|
||||||
|
syn match slimeIdChar "#{\@!" contained nextgroup=slimeId
|
||||||
|
syn match slimeId "\%(\w\|-\)\+" contained nextgroup=@slimeComponent
|
||||||
|
syn match slimeClassChar "\." contained nextgroup=slimeClass
|
||||||
|
syn match slimeClass "\%(\w\|-\)\+" contained nextgroup=@slimeComponent
|
||||||
|
syn match slimeInlineTagChar "\s*:\s*" contained nextgroup=slimeTag,slimeClassChar,slimeIdChar
|
||||||
|
|
||||||
|
syn region slimeWrappedAttrs matchgroup=slimeWrappedAttrsDelimiter start="\s*{\s*" skip="}\s*\"" end="\s*}\s*" contained contains=slimeAttr nextgroup=slimeElixir
|
||||||
|
syn region slimeWrappedAttrs matchgroup=slimeWrappedAttrsDelimiter start="\s*\[\s*" end="\s*\]\s*" contained contains=slimeAttr nextgroup=slimeElixir
|
||||||
|
syn region slimeWrappedAttrs matchgroup=slimeWrappedAttrsDelimiter start="\s*(\s*" end="\s*)\s*" contained contains=slimeAttr nextgroup=slimeElixir
|
||||||
|
|
||||||
|
syn match slimeAttr /\s*\%(\w\|-\)\+\s*=/me=e-1 contained contains=htmlArg nextgroup=slimeAttrAssignment
|
||||||
|
syn match slimeAttrAssignment "\s*=\s*" contained nextgroup=slimeWrappedAttrValue,slimeAttrString
|
||||||
|
|
||||||
|
syn region slimeWrappedAttrValue start="[^"']" end="\s\|$" contained contains=slimeAttrString,@slimeElixirTop nextgroup=slimeAttr,slimeElixir,slimeInlineTagChar
|
||||||
|
syn region slimeWrappedAttrValue matchgroup=slimeWrappedAttrValueDelimiter start="{" end="}" contained contains=slimeAttrString,@slimeElixirTop nextgroup=slimeAttr,slimeElixir,slimeInlineTagChar
|
||||||
|
syn region slimeWrappedAttrValue matchgroup=slimeWrappedAttrValueDelimiter start="\[" end="\]" contained contains=slimeAttrString,@slimeElixirTop nextgroup=slimeAttr,slimeElixir,slimeInlineTagChar
|
||||||
|
syn region slimeWrappedAttrValue matchgroup=slimeWrappedAttrValueDelimiter start="(" end=")" contained contains=slimeAttrString,@slimeElixirTop nextgroup=slimeAttr,slimeElixir,slimeInlineTagChar
|
||||||
|
|
||||||
|
syn region slimeAttrString start=+\s*"+ skip=+\%(\\\\\)*\\"+ end=+"\s*+ contained contains=slimeInterpolation,slimeInterpolationEscape nextgroup=slimeAttr,slimeElixir,slimeInlineTagChar
|
||||||
|
syn region slimeAttrString start=+\s*'+ skip=+\%(\\\\\)*\\"+ end=+'\s*+ contained contains=slimeInterpolation,slimeInterpolationEscape nextgroup=slimeAttr,slimeElixir,slimeInlineTagChar
|
||||||
|
|
||||||
|
syn region slimeInnerAttrString start=+\s*"+ skip=+\%(\\\\\)*\\"+ end=+"\s*+ contained contains=slimeInterpolation,slimeInterpolationEscape nextgroup=slimeAttr
|
||||||
|
syn region slimeInnerAttrString start=+\s*'+ skip=+\%(\\\\\)*\\"+ end=+'\s*+ contained contains=slimeInterpolation,slimeInterpolationEscape nextgroup=slimeAttr
|
||||||
|
|
||||||
|
syn region slimeInterpolation matchgroup=slimeInterpolationDelimiter start="#{" end="}" contains=@slimeElixirTop containedin=javascriptStringS,javascriptStringD,slimeWrappedAttrs
|
||||||
|
syn region slimeInterpolation matchgroup=slimeInterpolationDelimiter start="#{{" end="}}" contains=@slimeElixirTop containedin=javascriptStringS,javascriptStringD,slimeWrappedAttrs
|
||||||
|
syn match slimeInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
|
||||||
|
|
||||||
|
syn region slimeElixir matchgroup=slimeElixirOutputChar start="\s*[=]\==[']\=" skip="\%\(,\s*\|\\\)$" end="$" contained contains=@slimeElixirTop keepend
|
||||||
|
syn region slimeElixir matchgroup=slimeElixirChar start="\s*-" skip="\%\(,\s*\|\\\)$" end="$" contained contains=@slimeElixirTop keepend
|
||||||
|
|
||||||
|
syn match slimeComment /^\(\s*\)[/].*\(\n\1\s.*\)*/ contains=slimeTodo
|
||||||
|
syn match slimeText /^\(\s*\)[`|'].*\(\n\1\s.*\)*/ contains=slimeInterpolation
|
||||||
|
|
||||||
|
syn match slimeFilter /\s*\w\+:\s*/ contained
|
||||||
|
syn match slimeHaml /^\(\s*\)\<haml:\>.*\(\n\1\s.*\)*/ contains=@slimeHaml,slimeFilter
|
||||||
|
|
||||||
|
syn match slimeIEConditional "\%(^\s*/\)\@<=\[\s*if\>[^]]*]" contained containedin=slimeComment
|
||||||
|
|
||||||
|
hi def link slimeAttrString String
|
||||||
|
hi def link slimeBegin String
|
||||||
|
hi def link slimeClass Type
|
||||||
|
hi def link slimeAttr Type
|
||||||
|
hi def link slimeClassChar Type
|
||||||
|
hi def link slimeComment Comment
|
||||||
|
hi def link slimeDocType Identifier
|
||||||
|
hi def link slimeDocTypeKeyword Keyword
|
||||||
|
hi def link slimeFilter Keyword
|
||||||
|
hi def link slimeIEConditional SpecialComment
|
||||||
|
hi def link slimeId Identifier
|
||||||
|
hi def link slimeIdChar Identifier
|
||||||
|
hi def link slimeInnerAttrString String
|
||||||
|
hi def link slimeInterpolationDelimiter Delimiter
|
||||||
|
hi def link slimeElixirChar Special
|
||||||
|
hi def link slimeElixirOutputChar Special
|
||||||
|
hi def link slimeText String
|
||||||
|
hi def link slimeTodo Todo
|
||||||
|
hi def link slimeWrappedAttrValueDelimiter Delimiter
|
||||||
|
hi def link slimeWrappedAttrsDelimiter Delimiter
|
||||||
|
hi def link slimeInlineTagChar Delimiter
|
||||||
|
|
||||||
|
let b:current_syntax = "slime"
|
||||||
|
|
||||||
|
endif
|
||||||
@@ -55,9 +55,11 @@ delfunction s:CommentKeywordMatch
|
|||||||
|
|
||||||
" Literals
|
" Literals
|
||||||
" Strings
|
" Strings
|
||||||
syntax region swiftString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=swiftInterpolatedWrapper oneline
|
syntax region swiftString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=swiftMultilineInterpolatedWrapper oneline
|
||||||
|
syntax region swiftMultilineString start=/"""/ end=/"""/ contains=swiftMultilineInterpolatedWrapper
|
||||||
|
syntax region swiftMultilineInterpolatedWrapper start="\v\\\(\s*" end="\v\s*\)" contained containedin=swiftMultilineString contains=swiftInterpolatedString oneline
|
||||||
syntax region swiftInterpolatedWrapper start="\v[^\\]\zs\\\(\s*" end="\v\s*\)" contained containedin=swiftString contains=swiftInterpolatedString,swiftString oneline
|
syntax region swiftInterpolatedWrapper start="\v[^\\]\zs\\\(\s*" end="\v\s*\)" contained containedin=swiftString contains=swiftInterpolatedString,swiftString oneline
|
||||||
syntax match swiftInterpolatedString "\v\w+(\(\))?" contained containedin=swiftInterpolatedWrapper oneline
|
syntax match swiftInterpolatedString "\v\w+(\(\))?" contained containedin=swiftInterpolatedWrapper,swiftMultilineInterpolatedWrapper oneline
|
||||||
|
|
||||||
" Numbers
|
" Numbers
|
||||||
syntax match swiftNumber "\v<\d+>"
|
syntax match swiftNumber "\v<\d+>"
|
||||||
@@ -222,7 +224,7 @@ syntax keyword swiftDebugIdentifier
|
|||||||
|
|
||||||
syntax keyword swiftLineDirective #setline
|
syntax keyword swiftLineDirective #setline
|
||||||
|
|
||||||
syntax region swiftTypeWrapper start=":\s*\(\.\)\@!\<\u" skip="\s*,\s*$*\s*" end="$\|/"me=e-1 contains=ALLBUT,swiftInterpolatedWrapper transparent
|
syntax region swiftTypeWrapper start=":\s*\(\.\)\@!\<\u" skip="\s*,\s*$*\s*" end="$\|/"me=e-1 contains=ALLBUT,swiftInterpolatedWrapper,swiftMultilineInterpolatedWrapper transparent
|
||||||
syntax region swiftTypeCastWrapper start="\(as\|is\)\(!\|?\)\=\s\+" end="\v(\s|$|\{)" contains=swiftType,swiftCastKeyword keepend transparent oneline
|
syntax region swiftTypeCastWrapper start="\(as\|is\)\(!\|?\)\=\s\+" end="\v(\s|$|\{)" contains=swiftType,swiftCastKeyword keepend transparent oneline
|
||||||
syntax region swiftGenericsWrapper start="\v\<" end="\v\>" contains=swiftType transparent oneline
|
syntax region swiftGenericsWrapper start="\v\<" end="\v\>" contains=swiftType transparent oneline
|
||||||
syntax region swiftLiteralWrapper start="\v\=\s*" skip="\v[^\[\]]\(\)" end="\v(\[\]|\(\))" contains=ALL transparent oneline
|
syntax region swiftLiteralWrapper start="\v\=\s*" skip="\v[^\[\]]\(\)" end="\v(\[\]|\(\))" contains=ALL transparent oneline
|
||||||
@@ -257,7 +259,9 @@ highlight default link swiftComment Comment
|
|||||||
highlight default link swiftMarker Comment
|
highlight default link swiftMarker Comment
|
||||||
|
|
||||||
highlight default link swiftString String
|
highlight default link swiftString String
|
||||||
|
highlight default link swiftMultilineString String
|
||||||
highlight default link swiftInterpolatedWrapper Delimiter
|
highlight default link swiftInterpolatedWrapper Delimiter
|
||||||
|
highlight default link swiftMultilineInterpolatedWrapper Delimiter
|
||||||
highlight default link swiftTypeDeclaration Delimiter
|
highlight default link swiftTypeDeclaration Delimiter
|
||||||
highlight default link swiftNumber Number
|
highlight default link swiftNumber Number
|
||||||
highlight default link swiftBoolean Boolean
|
highlight default link swiftBoolean Boolean
|
||||||
|
|||||||
@@ -16,13 +16,16 @@ syn keyword terraValueBool true false on off yes no
|
|||||||
syn keyword terraDataTypeBI
|
syn keyword terraDataTypeBI
|
||||||
\ alicloud_images
|
\ alicloud_images
|
||||||
\ alicloud_instance_types
|
\ alicloud_instance_types
|
||||||
|
\ alicloud_key_pairs
|
||||||
\ alicloud_regions
|
\ alicloud_regions
|
||||||
|
\ alicloud_vpcs
|
||||||
\ alicloud_zones
|
\ alicloud_zones
|
||||||
\ archive_file
|
\ archive_file
|
||||||
\ atlas_artifact
|
\ atlas_artifact
|
||||||
\ aws_acm_certificate
|
\ aws_acm_certificate
|
||||||
\ aws_alb
|
\ aws_alb
|
||||||
\ aws_alb_listener
|
\ aws_alb_listener
|
||||||
|
\ aws_alb_target_group
|
||||||
\ aws_ami
|
\ aws_ami
|
||||||
\ aws_ami_ids
|
\ aws_ami_ids
|
||||||
\ aws_autoscaling_groups
|
\ aws_autoscaling_groups
|
||||||
@@ -32,36 +35,52 @@ syn keyword terraDataTypeBI
|
|||||||
\ aws_caller_identity
|
\ aws_caller_identity
|
||||||
\ aws_canonical_user_id
|
\ aws_canonical_user_id
|
||||||
\ aws_cloudformation_stack
|
\ aws_cloudformation_stack
|
||||||
|
\ aws_cloudtrail_service_account
|
||||||
\ aws_db_instance
|
\ aws_db_instance
|
||||||
\ aws_db_snapshot
|
\ aws_db_snapshot
|
||||||
|
\ aws_dynamodb_table
|
||||||
\ aws_ebs_snapshot
|
\ aws_ebs_snapshot
|
||||||
\ aws_ebs_snapshot_ids
|
\ aws_ebs_snapshot_ids
|
||||||
\ aws_ebs_volume
|
\ aws_ebs_volume
|
||||||
|
\ aws_ecr_repository
|
||||||
\ aws_ecs_cluster
|
\ aws_ecs_cluster
|
||||||
\ aws_ecs_container_definition
|
\ aws_ecs_container_definition
|
||||||
\ aws_ecs_task_definition
|
\ aws_ecs_task_definition
|
||||||
\ aws_efs_file_system
|
\ aws_efs_file_system
|
||||||
|
\ aws_efs_mount_target
|
||||||
\ aws_eip
|
\ aws_eip
|
||||||
\ aws_elastic_beanstalk_solution_stack
|
\ aws_elastic_beanstalk_solution_stack
|
||||||
\ aws_elasticache_cluster
|
\ aws_elasticache_cluster
|
||||||
|
\ aws_elasticache_replication_group
|
||||||
\ aws_elb_hosted_zone_id
|
\ aws_elb_hosted_zone_id
|
||||||
\ aws_elb_service_account
|
\ aws_elb_service_account
|
||||||
\ aws_iam_account_alias
|
\ aws_iam_account_alias
|
||||||
|
\ aws_iam_group
|
||||||
|
\ aws_iam_instance_profile
|
||||||
\ aws_iam_policy_document
|
\ aws_iam_policy_document
|
||||||
\ aws_iam_role
|
\ aws_iam_role
|
||||||
\ aws_iam_server_certificate
|
\ aws_iam_server_certificate
|
||||||
|
\ aws_iam_user
|
||||||
\ aws_instance
|
\ aws_instance
|
||||||
|
\ aws_instances
|
||||||
|
\ aws_internet_gateway
|
||||||
\ aws_ip_ranges
|
\ aws_ip_ranges
|
||||||
\ aws_kinesis_stream
|
\ aws_kinesis_stream
|
||||||
\ aws_kms_alias
|
\ aws_kms_alias
|
||||||
\ aws_kms_ciphertext
|
\ aws_kms_ciphertext
|
||||||
\ aws_kms_secret
|
\ aws_kms_secret
|
||||||
|
\ aws_lb
|
||||||
|
\ aws_lb_listener
|
||||||
|
\ aws_lb_target_group
|
||||||
|
\ aws_nat_gateway
|
||||||
\ aws_partition
|
\ aws_partition
|
||||||
\ aws_prefix_list
|
\ aws_prefix_list
|
||||||
|
\ aws_rds_cluster
|
||||||
\ aws_redshift_service_account
|
\ aws_redshift_service_account
|
||||||
\ aws_region
|
\ aws_region
|
||||||
\ aws_route53_zone
|
\ aws_route53_zone
|
||||||
\ aws_route_table
|
\ aws_route_table
|
||||||
|
\ aws_s3_bucket
|
||||||
\ aws_s3_bucket_object
|
\ aws_s3_bucket_object
|
||||||
\ aws_security_group
|
\ aws_security_group
|
||||||
\ aws_sns_topic
|
\ aws_sns_topic
|
||||||
@@ -73,10 +92,21 @@ syn keyword terraDataTypeBI
|
|||||||
\ aws_vpc_endpoint_service
|
\ aws_vpc_endpoint_service
|
||||||
\ aws_vpc_peering_connection
|
\ aws_vpc_peering_connection
|
||||||
\ aws_vpn_gateway
|
\ aws_vpn_gateway
|
||||||
|
\ azurerm_builtin_role_definition
|
||||||
\ azurerm_client_config
|
\ azurerm_client_config
|
||||||
|
\ azurerm_image
|
||||||
|
\ azurerm_key_vault_access_policy
|
||||||
|
\ azurerm_managed_disk
|
||||||
|
\ azurerm_platform_image
|
||||||
\ azurerm_public_ip
|
\ azurerm_public_ip
|
||||||
|
\ azurerm_resource_group
|
||||||
|
\ azurerm_role_definition
|
||||||
|
\ azurerm_snapshot
|
||||||
|
\ azurerm_subnet
|
||||||
|
\ azurerm_subscription
|
||||||
\ circonus_account
|
\ circonus_account
|
||||||
\ circonus_collector
|
\ circonus_collector
|
||||||
|
\ cloudstack_template
|
||||||
\ consul_agent_self
|
\ consul_agent_self
|
||||||
\ consul_catalog_nodes
|
\ consul_catalog_nodes
|
||||||
\ consul_catalog_service
|
\ consul_catalog_service
|
||||||
@@ -84,28 +114,50 @@ syn keyword terraDataTypeBI
|
|||||||
\ consul_keys
|
\ consul_keys
|
||||||
\ digitalocean_image
|
\ digitalocean_image
|
||||||
\ dns_a_record_set
|
\ dns_a_record_set
|
||||||
|
\ dns_aaaa_record_set
|
||||||
\ dns_cname_record_set
|
\ dns_cname_record_set
|
||||||
|
\ dns_ns_record_set
|
||||||
\ dns_txt_record_set
|
\ dns_txt_record_set
|
||||||
\ docker_registry_image
|
\ docker_registry_image
|
||||||
\ external
|
\ external
|
||||||
\ fastly_ip_ranges
|
\ fastly_ip_ranges
|
||||||
\ github_team
|
\ github_team
|
||||||
\ github_user
|
\ github_user
|
||||||
|
\ google_active_folder
|
||||||
|
\ google_client_config
|
||||||
|
\ google_compute_address
|
||||||
|
\ google_compute_global_address
|
||||||
|
\ google_compute_instance_group
|
||||||
|
\ google_compute_lb_ip_ranges
|
||||||
\ google_compute_network
|
\ google_compute_network
|
||||||
\ google_compute_subnetwork
|
\ google_compute_subnetwork
|
||||||
\ google_compute_zones
|
\ google_compute_zones
|
||||||
\ google_container_engine_versions
|
\ google_container_engine_versions
|
||||||
|
\ google_dns_managed_zone
|
||||||
\ google_iam_policy
|
\ google_iam_policy
|
||||||
\ google_storage_object_signed_url
|
\ google_storage_object_signed_url
|
||||||
\ http
|
\ http
|
||||||
|
\ kubernetes_service
|
||||||
|
\ kubernetes_storage_class
|
||||||
|
\ logicmonitor_collectors
|
||||||
|
\ logicmonitor_device_group
|
||||||
\ newrelic_application
|
\ newrelic_application
|
||||||
\ ns1_datasource
|
\ ns1_datasource
|
||||||
\ null_data_source
|
\ null_data_source
|
||||||
|
\ oneandone_instance_size
|
||||||
|
\ opc_compute_image_list_entry
|
||||||
|
\ opc_compute_network_interface
|
||||||
|
\ opc_compute_storage_volume_snapshot
|
||||||
|
\ opc_compute_vnic
|
||||||
|
\ openstack_dns_zone_v2
|
||||||
\ openstack_images_image_v2
|
\ openstack_images_image_v2
|
||||||
\ openstack_networking_network_v2
|
\ openstack_networking_network_v2
|
||||||
|
\ openstack_networking_secgroup_v2
|
||||||
|
\ openstack_networking_subnet_v2
|
||||||
\ opsgenie_user
|
\ opsgenie_user
|
||||||
\ ovh_publiccloud_region
|
\ ovh_publiccloud_region
|
||||||
\ ovh_publiccloud_regions
|
\ ovh_publiccloud_regions
|
||||||
|
\ packet_precreated_ip_block
|
||||||
\ pagerduty_escalation_policy
|
\ pagerduty_escalation_policy
|
||||||
\ pagerduty_schedule
|
\ pagerduty_schedule
|
||||||
\ pagerduty_user
|
\ pagerduty_user
|
||||||
@@ -113,11 +165,25 @@ syn keyword terraDataTypeBI
|
|||||||
\ profitbricks_datacenter
|
\ profitbricks_datacenter
|
||||||
\ profitbricks_image
|
\ profitbricks_image
|
||||||
\ profitbricks_location
|
\ profitbricks_location
|
||||||
|
\ profitbricks_resource
|
||||||
|
\ profitbricks_snapshot
|
||||||
|
\ rancher_certificate
|
||||||
|
\ rancher_environment
|
||||||
|
\ rancher_setting
|
||||||
\ scaleway_bootscript
|
\ scaleway_bootscript
|
||||||
\ scaleway_image
|
\ scaleway_image
|
||||||
\ template_cloudinit_config
|
\ template_cloudinit_config
|
||||||
\ template_file
|
\ template_file
|
||||||
\ terraform_remote_state
|
\ terraform_remote_state
|
||||||
|
\ triton_image
|
||||||
|
\ triton_network
|
||||||
|
\ vsphere_datacenter
|
||||||
|
\ vsphere_distributed_virtual_switch
|
||||||
|
\ vsphere_host
|
||||||
|
\ vsphere_network
|
||||||
|
\ vsphere_tag
|
||||||
|
\ vsphere_tag_category
|
||||||
|
\ vsphere_vmfs_disks
|
||||||
""" end data sources
|
""" end data sources
|
||||||
|
|
||||||
""" resource
|
""" resource
|
||||||
@@ -133,8 +199,13 @@ syn keyword terraResourceTypeBI
|
|||||||
\ alicloud_ess_schedule
|
\ alicloud_ess_schedule
|
||||||
\ alicloud_forward_entry
|
\ alicloud_forward_entry
|
||||||
\ alicloud_instance
|
\ alicloud_instance
|
||||||
|
\ alicloud_key_pair
|
||||||
|
\ alicloud_key_pair_attachment
|
||||||
\ alicloud_nat_gateway
|
\ alicloud_nat_gateway
|
||||||
|
\ alicloud_oss_bucket
|
||||||
|
\ alicloud_oss_bucket_object
|
||||||
\ alicloud_route_entry
|
\ alicloud_route_entry
|
||||||
|
\ alicloud_router_interface
|
||||||
\ alicloud_security_group
|
\ alicloud_security_group
|
||||||
\ alicloud_security_group_rule
|
\ alicloud_security_group_rule
|
||||||
\ alicloud_slb
|
\ alicloud_slb
|
||||||
@@ -161,12 +232,14 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_api_gateway_client_certificate
|
\ aws_api_gateway_client_certificate
|
||||||
\ aws_api_gateway_deployment
|
\ aws_api_gateway_deployment
|
||||||
\ aws_api_gateway_domain_name
|
\ aws_api_gateway_domain_name
|
||||||
|
\ aws_api_gateway_gateway_response
|
||||||
\ aws_api_gateway_integration
|
\ aws_api_gateway_integration
|
||||||
\ aws_api_gateway_integration_response
|
\ aws_api_gateway_integration_response
|
||||||
\ aws_api_gateway_method
|
\ aws_api_gateway_method
|
||||||
\ aws_api_gateway_method_response
|
\ aws_api_gateway_method_response
|
||||||
\ aws_api_gateway_method_settings
|
\ aws_api_gateway_method_settings
|
||||||
\ aws_api_gateway_model
|
\ aws_api_gateway_model
|
||||||
|
\ aws_api_gateway_request_validator
|
||||||
\ aws_api_gateway_resource
|
\ aws_api_gateway_resource
|
||||||
\ aws_api_gateway_rest_api
|
\ aws_api_gateway_rest_api
|
||||||
\ aws_api_gateway_stage
|
\ aws_api_gateway_stage
|
||||||
@@ -175,16 +248,22 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_app_cookie_stickiness_policy
|
\ aws_app_cookie_stickiness_policy
|
||||||
\ aws_appautoscaling_policy
|
\ aws_appautoscaling_policy
|
||||||
\ aws_appautoscaling_target
|
\ aws_appautoscaling_target
|
||||||
|
\ aws_athena_database
|
||||||
|
\ aws_athena_named_query
|
||||||
\ aws_autoscaling_attachment
|
\ aws_autoscaling_attachment
|
||||||
\ aws_autoscaling_group
|
\ aws_autoscaling_group
|
||||||
\ aws_autoscaling_lifecycle_hook
|
\ aws_autoscaling_lifecycle_hook
|
||||||
\ aws_autoscaling_notification
|
\ aws_autoscaling_notification
|
||||||
\ aws_autoscaling_policy
|
\ aws_autoscaling_policy
|
||||||
\ aws_autoscaling_schedule
|
\ aws_autoscaling_schedule
|
||||||
|
\ aws_batch_compute_environment
|
||||||
|
\ aws_batch_job_definition
|
||||||
|
\ aws_batch_job_queue
|
||||||
\ aws_cloudformation_stack
|
\ aws_cloudformation_stack
|
||||||
\ aws_cloudfront_distribution
|
\ aws_cloudfront_distribution
|
||||||
\ aws_cloudfront_origin_access_identity
|
\ aws_cloudfront_origin_access_identity
|
||||||
\ aws_cloudtrail
|
\ aws_cloudtrail
|
||||||
|
\ aws_cloudwatch_dashboard
|
||||||
\ aws_cloudwatch_event_rule
|
\ aws_cloudwatch_event_rule
|
||||||
\ aws_cloudwatch_event_target
|
\ aws_cloudwatch_event_target
|
||||||
\ aws_cloudwatch_log_destination
|
\ aws_cloudwatch_log_destination
|
||||||
@@ -202,6 +281,8 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_codedeploy_deployment_group
|
\ aws_codedeploy_deployment_group
|
||||||
\ aws_codepipeline
|
\ aws_codepipeline
|
||||||
\ aws_cognito_identity_pool
|
\ aws_cognito_identity_pool
|
||||||
|
\ aws_cognito_identity_pool_roles_attachment
|
||||||
|
\ aws_cognito_user_pool
|
||||||
\ aws_config_config_rule
|
\ aws_config_config_rule
|
||||||
\ aws_config_configuration_recorder
|
\ aws_config_configuration_recorder
|
||||||
\ aws_config_configuration_recorder_status
|
\ aws_config_configuration_recorder_status
|
||||||
@@ -227,9 +308,12 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_dms_replication_instance
|
\ aws_dms_replication_instance
|
||||||
\ aws_dms_replication_subnet_group
|
\ aws_dms_replication_subnet_group
|
||||||
\ aws_dms_replication_task
|
\ aws_dms_replication_task
|
||||||
|
\ aws_dx_connection
|
||||||
|
\ aws_dx_lag
|
||||||
\ aws_dynamodb_table
|
\ aws_dynamodb_table
|
||||||
\ aws_ebs_snapshot
|
\ aws_ebs_snapshot
|
||||||
\ aws_ebs_volume
|
\ aws_ebs_volume
|
||||||
|
\ aws_ecr_lifecycle_policy
|
||||||
\ aws_ecr_repository
|
\ aws_ecr_repository
|
||||||
\ aws_ecr_repository_policy
|
\ aws_ecr_repository_policy
|
||||||
\ aws_ecs_cluster
|
\ aws_ecs_cluster
|
||||||
@@ -286,6 +370,8 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_inspector_resource_group
|
\ aws_inspector_resource_group
|
||||||
\ aws_instance
|
\ aws_instance
|
||||||
\ aws_internet_gateway
|
\ aws_internet_gateway
|
||||||
|
\ aws_iot_certificate
|
||||||
|
\ aws_iot_policy
|
||||||
\ aws_key_pair
|
\ aws_key_pair
|
||||||
\ aws_kinesis_firehose_delivery_stream
|
\ aws_kinesis_firehose_delivery_stream
|
||||||
\ aws_kinesis_stream
|
\ aws_kinesis_stream
|
||||||
@@ -296,8 +382,13 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_lambda_function
|
\ aws_lambda_function
|
||||||
\ aws_lambda_permission
|
\ aws_lambda_permission
|
||||||
\ aws_launch_configuration
|
\ aws_launch_configuration
|
||||||
|
\ aws_lb
|
||||||
\ aws_lb_cookie_stickiness_policy
|
\ aws_lb_cookie_stickiness_policy
|
||||||
|
\ aws_lb_listener
|
||||||
|
\ aws_lb_listener_rule
|
||||||
\ aws_lb_ssl_negotiation_policy
|
\ aws_lb_ssl_negotiation_policy
|
||||||
|
\ aws_lb_target_group
|
||||||
|
\ aws_lb_target_group_attachment
|
||||||
\ aws_lightsail_domain
|
\ aws_lightsail_domain
|
||||||
\ aws_lightsail_instance
|
\ aws_lightsail_instance
|
||||||
\ aws_lightsail_key_pair
|
\ aws_lightsail_key_pair
|
||||||
@@ -312,6 +403,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_network_acl_rule
|
\ aws_network_acl_rule
|
||||||
\ aws_network_interface
|
\ aws_network_interface
|
||||||
\ aws_network_interface_attachment
|
\ aws_network_interface_attachment
|
||||||
|
\ aws_network_interface_sg_attachment
|
||||||
\ aws_opsworks_application
|
\ aws_opsworks_application
|
||||||
\ aws_opsworks_custom_layer
|
\ aws_opsworks_custom_layer
|
||||||
\ aws_opsworks_ganglia_layer
|
\ aws_opsworks_ganglia_layer
|
||||||
@@ -351,13 +443,16 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_s3_bucket_policy
|
\ aws_s3_bucket_policy
|
||||||
\ aws_security_group
|
\ aws_security_group
|
||||||
\ aws_security_group_rule
|
\ aws_security_group_rule
|
||||||
|
\ aws_servicecatalog_portfolio
|
||||||
\ aws_ses_active_receipt_rule_set
|
\ aws_ses_active_receipt_rule_set
|
||||||
\ aws_ses_configuration_set
|
\ aws_ses_configuration_set
|
||||||
|
\ aws_ses_domain_dkim
|
||||||
\ aws_ses_domain_identity
|
\ aws_ses_domain_identity
|
||||||
\ aws_ses_event_destination
|
\ aws_ses_event_destination
|
||||||
\ aws_ses_receipt_filter
|
\ aws_ses_receipt_filter
|
||||||
\ aws_ses_receipt_rule
|
\ aws_ses_receipt_rule
|
||||||
\ aws_ses_receipt_rule_set
|
\ aws_ses_receipt_rule_set
|
||||||
|
\ aws_ses_template
|
||||||
\ aws_sfn_activity
|
\ aws_sfn_activity
|
||||||
\ aws_sfn_state_machine
|
\ aws_sfn_state_machine
|
||||||
\ aws_simpledb_domain
|
\ aws_simpledb_domain
|
||||||
@@ -379,6 +474,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_ssm_parameter
|
\ aws_ssm_parameter
|
||||||
\ aws_ssm_patch_baseline
|
\ aws_ssm_patch_baseline
|
||||||
\ aws_ssm_patch_group
|
\ aws_ssm_patch_group
|
||||||
|
\ aws_ssm_resource_data_sync
|
||||||
\ aws_subnet
|
\ aws_subnet
|
||||||
\ aws_volume_attachment
|
\ aws_volume_attachment
|
||||||
\ aws_vpc
|
\ aws_vpc
|
||||||
@@ -392,8 +488,10 @@ syn keyword terraResourceTypeBI
|
|||||||
\ aws_vpn_connection_route
|
\ aws_vpn_connection_route
|
||||||
\ aws_vpn_gateway
|
\ aws_vpn_gateway
|
||||||
\ aws_vpn_gateway_attachment
|
\ aws_vpn_gateway_attachment
|
||||||
|
\ aws_vpn_gateway_route_propagation
|
||||||
\ aws_waf_byte_match_set
|
\ aws_waf_byte_match_set
|
||||||
\ aws_waf_ipset
|
\ aws_waf_ipset
|
||||||
|
\ aws_waf_rate_based_rule
|
||||||
\ aws_waf_rule
|
\ aws_waf_rule
|
||||||
\ aws_waf_size_constraint_set
|
\ aws_waf_size_constraint_set
|
||||||
\ aws_waf_sql_injection_match_set
|
\ aws_waf_sql_injection_match_set
|
||||||
@@ -417,25 +515,41 @@ syn keyword terraResourceTypeBI
|
|||||||
\ azure_storage_queue
|
\ azure_storage_queue
|
||||||
\ azure_storage_service
|
\ azure_storage_service
|
||||||
\ azure_virtual_network
|
\ azure_virtual_network
|
||||||
|
\ azurerm_app_service
|
||||||
|
\ azurerm_app_service_plan
|
||||||
|
\ azurerm_application_gateway
|
||||||
|
\ azurerm_application_insights
|
||||||
|
\ azurerm_automation_account
|
||||||
|
\ azurerm_automation_credential
|
||||||
|
\ azurerm_automation_runbook
|
||||||
|
\ azurerm_automation_schedule
|
||||||
\ azurerm_availability_set
|
\ azurerm_availability_set
|
||||||
\ azurerm_cdn_endpoint
|
\ azurerm_cdn_endpoint
|
||||||
\ azurerm_cdn_profile
|
\ azurerm_cdn_profile
|
||||||
|
\ azurerm_container_group
|
||||||
\ azurerm_container_registry
|
\ azurerm_container_registry
|
||||||
\ azurerm_container_service
|
\ azurerm_container_service
|
||||||
|
\ azurerm_cosmosdb_account
|
||||||
\ azurerm_dns_a_record
|
\ azurerm_dns_a_record
|
||||||
\ azurerm_dns_aaaa_record
|
\ azurerm_dns_aaaa_record
|
||||||
\ azurerm_dns_cname_record
|
\ azurerm_dns_cname_record
|
||||||
\ azurerm_dns_mx_record
|
\ azurerm_dns_mx_record
|
||||||
\ azurerm_dns_ns_record
|
\ azurerm_dns_ns_record
|
||||||
|
\ azurerm_dns_ptr_record
|
||||||
\ azurerm_dns_srv_record
|
\ azurerm_dns_srv_record
|
||||||
\ azurerm_dns_txt_record
|
\ azurerm_dns_txt_record
|
||||||
\ azurerm_dns_zone
|
\ azurerm_dns_zone
|
||||||
|
\ azurerm_eventgrid_topic
|
||||||
\ azurerm_eventhub
|
\ azurerm_eventhub
|
||||||
\ azurerm_eventhub_authorization_rule
|
\ azurerm_eventhub_authorization_rule
|
||||||
\ azurerm_eventhub_consumer_group
|
\ azurerm_eventhub_consumer_group
|
||||||
\ azurerm_eventhub_namespace
|
\ azurerm_eventhub_namespace
|
||||||
\ azurerm_express_route_circuit
|
\ azurerm_express_route_circuit
|
||||||
|
\ azurerm_image
|
||||||
\ azurerm_key_vault
|
\ azurerm_key_vault
|
||||||
|
\ azurerm_key_vault_certificate
|
||||||
|
\ azurerm_key_vault_key
|
||||||
|
\ azurerm_key_vault_secret
|
||||||
\ azurerm_lb
|
\ azurerm_lb
|
||||||
\ azurerm_lb_backend_address_pool
|
\ azurerm_lb_backend_address_pool
|
||||||
\ azurerm_lb_nat_pool
|
\ azurerm_lb_nat_pool
|
||||||
@@ -443,19 +557,33 @@ syn keyword terraResourceTypeBI
|
|||||||
\ azurerm_lb_probe
|
\ azurerm_lb_probe
|
||||||
\ azurerm_lb_rule
|
\ azurerm_lb_rule
|
||||||
\ azurerm_local_network_gateway
|
\ azurerm_local_network_gateway
|
||||||
|
\ azurerm_log_analytics_workspace
|
||||||
\ azurerm_managed_disk
|
\ azurerm_managed_disk
|
||||||
|
\ azurerm_mysql_configuration
|
||||||
|
\ azurerm_mysql_database
|
||||||
|
\ azurerm_mysql_firewall_rule
|
||||||
|
\ azurerm_mysql_server
|
||||||
\ azurerm_network_interface
|
\ azurerm_network_interface
|
||||||
\ azurerm_network_security_group
|
\ azurerm_network_security_group
|
||||||
\ azurerm_network_security_rule
|
\ azurerm_network_security_rule
|
||||||
|
\ azurerm_postgresql_configuration
|
||||||
|
\ azurerm_postgresql_database
|
||||||
|
\ azurerm_postgresql_firewall_rule
|
||||||
|
\ azurerm_postgresql_server
|
||||||
\ azurerm_public_ip
|
\ azurerm_public_ip
|
||||||
\ azurerm_redis_cache
|
\ azurerm_redis_cache
|
||||||
|
\ azurerm_redis_firewall_rule
|
||||||
\ azurerm_resource_group
|
\ azurerm_resource_group
|
||||||
|
\ azurerm_role_assignment
|
||||||
|
\ azurerm_role_definition
|
||||||
\ azurerm_route
|
\ azurerm_route
|
||||||
\ azurerm_route_table
|
\ azurerm_route_table
|
||||||
\ azurerm_search_service
|
\ azurerm_search_service
|
||||||
\ azurerm_servicebus_namespace
|
\ azurerm_servicebus_namespace
|
||||||
|
\ azurerm_servicebus_queue
|
||||||
\ azurerm_servicebus_subscription
|
\ azurerm_servicebus_subscription
|
||||||
\ azurerm_servicebus_topic
|
\ azurerm_servicebus_topic
|
||||||
|
\ azurerm_snapshot
|
||||||
\ azurerm_sql_database
|
\ azurerm_sql_database
|
||||||
\ azurerm_sql_elasticpool
|
\ azurerm_sql_elasticpool
|
||||||
\ azurerm_sql_firewall_rule
|
\ azurerm_sql_firewall_rule
|
||||||
@@ -498,6 +626,8 @@ syn keyword terraResourceTypeBI
|
|||||||
\ clc_public_ip
|
\ clc_public_ip
|
||||||
\ clc_server
|
\ clc_server
|
||||||
\ cloudflare_record
|
\ cloudflare_record
|
||||||
|
\ cloudscale_floating_ip
|
||||||
|
\ cloudscale_server
|
||||||
\ cloudstack_affinity_group
|
\ cloudstack_affinity_group
|
||||||
\ cloudstack_disk
|
\ cloudstack_disk
|
||||||
\ cloudstack_egress_firewall
|
\ cloudstack_egress_firewall
|
||||||
@@ -525,6 +655,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ cobbler_distro
|
\ cobbler_distro
|
||||||
\ cobbler_kickstart_file
|
\ cobbler_kickstart_file
|
||||||
\ cobbler_profile
|
\ cobbler_profile
|
||||||
|
\ cobbler_repo
|
||||||
\ cobbler_snippet
|
\ cobbler_snippet
|
||||||
\ cobbler_system
|
\ cobbler_system
|
||||||
\ consul_agent_service
|
\ consul_agent_service
|
||||||
@@ -535,12 +666,14 @@ syn keyword terraResourceTypeBI
|
|||||||
\ consul_prepared_query
|
\ consul_prepared_query
|
||||||
\ consul_service
|
\ consul_service
|
||||||
\ datadog_downtime
|
\ datadog_downtime
|
||||||
|
\ datadog_metric_metadata
|
||||||
\ datadog_monitor
|
\ datadog_monitor
|
||||||
\ datadog_timeboard
|
\ datadog_timeboard
|
||||||
\ datadog_user
|
\ datadog_user
|
||||||
\ digitalocean_certificate
|
\ digitalocean_certificate
|
||||||
\ digitalocean_domain
|
\ digitalocean_domain
|
||||||
\ digitalocean_droplet
|
\ digitalocean_droplet
|
||||||
|
\ digitalocean_firewall
|
||||||
\ digitalocean_floating_ip
|
\ digitalocean_floating_ip
|
||||||
\ digitalocean_loadbalancer
|
\ digitalocean_loadbalancer
|
||||||
\ digitalocean_record
|
\ digitalocean_record
|
||||||
@@ -551,6 +684,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ dns_a_record_set
|
\ dns_a_record_set
|
||||||
\ dns_aaaa_record_set
|
\ dns_aaaa_record_set
|
||||||
\ dns_cname_record
|
\ dns_cname_record
|
||||||
|
\ dns_ns_record_set
|
||||||
\ dns_ptr_record
|
\ dns_ptr_record
|
||||||
\ dnsimple_record
|
\ dnsimple_record
|
||||||
\ docker_container
|
\ docker_container
|
||||||
@@ -565,16 +699,21 @@ syn keyword terraResourceTypeBI
|
|||||||
\ github_organization_webhook
|
\ github_organization_webhook
|
||||||
\ github_repository
|
\ github_repository
|
||||||
\ github_repository_collaborator
|
\ github_repository_collaborator
|
||||||
|
\ github_repository_deploy_key
|
||||||
\ github_repository_webhook
|
\ github_repository_webhook
|
||||||
\ github_team
|
\ github_team
|
||||||
\ github_team_membership
|
\ github_team_membership
|
||||||
\ github_team_repository
|
\ github_team_repository
|
||||||
\ gitlab_deploy_key
|
\ gitlab_deploy_key
|
||||||
\ gitlab_group
|
\ gitlab_group
|
||||||
|
\ gitlab_label
|
||||||
\ gitlab_project
|
\ gitlab_project
|
||||||
\ gitlab_project_hook
|
\ gitlab_project_hook
|
||||||
|
\ gitlab_user
|
||||||
\ google_bigquery_dataset
|
\ google_bigquery_dataset
|
||||||
\ google_bigquery_table
|
\ google_bigquery_table
|
||||||
|
\ google_bigtable_instance
|
||||||
|
\ google_bigtable_table
|
||||||
\ google_compute_address
|
\ google_compute_address
|
||||||
\ google_compute_autoscaler
|
\ google_compute_autoscaler
|
||||||
\ google_compute_backend_bucket
|
\ google_compute_backend_bucket
|
||||||
@@ -593,31 +732,59 @@ syn keyword terraResourceTypeBI
|
|||||||
\ google_compute_instance_group_manager
|
\ google_compute_instance_group_manager
|
||||||
\ google_compute_instance_template
|
\ google_compute_instance_template
|
||||||
\ google_compute_network
|
\ google_compute_network
|
||||||
|
\ google_compute_network_peering
|
||||||
\ google_compute_project_metadata
|
\ google_compute_project_metadata
|
||||||
|
\ google_compute_project_metadata_item
|
||||||
|
\ google_compute_region_autoscaler
|
||||||
\ google_compute_region_backend_service
|
\ google_compute_region_backend_service
|
||||||
|
\ google_compute_region_instance_group_manager
|
||||||
\ google_compute_route
|
\ google_compute_route
|
||||||
\ google_compute_router
|
\ google_compute_router
|
||||||
\ google_compute_router_interface
|
\ google_compute_router_interface
|
||||||
\ google_compute_router_peer
|
\ google_compute_router_peer
|
||||||
|
\ google_compute_shared_vpc_host_project
|
||||||
|
\ google_compute_shared_vpc_service_project
|
||||||
\ google_compute_snapshot
|
\ google_compute_snapshot
|
||||||
\ google_compute_ssl_certificate
|
\ google_compute_ssl_certificate
|
||||||
\ google_compute_subnetwork
|
\ google_compute_subnetwork
|
||||||
\ google_compute_target_http_proxy
|
\ google_compute_target_http_proxy
|
||||||
\ google_compute_target_https_proxy
|
\ google_compute_target_https_proxy
|
||||||
\ google_compute_target_pool
|
\ google_compute_target_pool
|
||||||
|
\ google_compute_target_ssl_proxy
|
||||||
|
\ google_compute_target_tcp_proxy
|
||||||
\ google_compute_url_map
|
\ google_compute_url_map
|
||||||
\ google_compute_vpn_gateway
|
\ google_compute_vpn_gateway
|
||||||
\ google_compute_vpn_tunnel
|
\ google_compute_vpn_tunnel
|
||||||
\ google_container_cluster
|
\ google_container_cluster
|
||||||
\ google_container_node_pool
|
\ google_container_node_pool
|
||||||
|
\ google_dataproc_cluster
|
||||||
\ google_dns_managed_zone
|
\ google_dns_managed_zone
|
||||||
\ google_dns_record_set
|
\ google_dns_record_set
|
||||||
|
\ google_folder
|
||||||
|
\ google_folder_iam_policy
|
||||||
|
\ google_kms_crypto_key
|
||||||
|
\ google_kms_key_ring
|
||||||
|
\ google_logging_billing_account_sink
|
||||||
|
\ google_logging_folder_sink
|
||||||
|
\ google_logging_project_sink
|
||||||
|
\ google_organization_iam_custom_role
|
||||||
|
\ google_organization_policy
|
||||||
\ google_project
|
\ google_project
|
||||||
|
\ google_project_iam_binding
|
||||||
|
\ google_project_iam_custom_role
|
||||||
|
\ google_project_iam_member
|
||||||
\ google_project_iam_policy
|
\ google_project_iam_policy
|
||||||
|
\ google_project_service
|
||||||
\ google_project_services
|
\ google_project_services
|
||||||
\ google_pubsub_subscription
|
\ google_pubsub_subscription
|
||||||
\ google_pubsub_topic
|
\ google_pubsub_topic
|
||||||
|
\ google_runtimeconfig_config
|
||||||
|
\ google_runtimeconfig_variable
|
||||||
\ google_service_account
|
\ google_service_account
|
||||||
|
\ google_service_account_key
|
||||||
|
\ google_sourcerepo_repository
|
||||||
|
\ google_spanner_database
|
||||||
|
\ google_spanner_instance
|
||||||
\ google_sql_database
|
\ google_sql_database
|
||||||
\ google_sql_database_instance
|
\ google_sql_database_instance
|
||||||
\ google_sql_user
|
\ google_sql_user
|
||||||
@@ -626,6 +793,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ google_storage_bucket_object
|
\ google_storage_bucket_object
|
||||||
\ google_storage_object_acl
|
\ google_storage_object_acl
|
||||||
\ heroku_addon
|
\ heroku_addon
|
||||||
|
\ heroku_addon_attachment
|
||||||
\ heroku_app
|
\ heroku_app
|
||||||
\ heroku_app_feature
|
\ heroku_app_feature
|
||||||
\ heroku_cert
|
\ heroku_cert
|
||||||
@@ -639,10 +807,12 @@ syn keyword terraResourceTypeBI
|
|||||||
\ icinga2_hostgroup
|
\ icinga2_hostgroup
|
||||||
\ icinga2_service
|
\ icinga2_service
|
||||||
\ ignition_config
|
\ ignition_config
|
||||||
|
\ ignition_directory
|
||||||
\ ignition_disk
|
\ ignition_disk
|
||||||
\ ignition_file
|
\ ignition_file
|
||||||
\ ignition_filesystem
|
\ ignition_filesystem
|
||||||
\ ignition_group
|
\ ignition_group
|
||||||
|
\ ignition_link
|
||||||
\ ignition_networkd_unit
|
\ ignition_networkd_unit
|
||||||
\ ignition_raid
|
\ ignition_raid
|
||||||
\ ignition_systemd_unit
|
\ ignition_systemd_unit
|
||||||
@@ -656,9 +826,13 @@ syn keyword terraResourceTypeBI
|
|||||||
\ kubernetes_namespace
|
\ kubernetes_namespace
|
||||||
\ kubernetes_persistent_volume
|
\ kubernetes_persistent_volume
|
||||||
\ kubernetes_persistent_volume_claim
|
\ kubernetes_persistent_volume_claim
|
||||||
|
\ kubernetes_pod
|
||||||
|
\ kubernetes_replication_controller
|
||||||
\ kubernetes_resource_quota
|
\ kubernetes_resource_quota
|
||||||
\ kubernetes_secret
|
\ kubernetes_secret
|
||||||
\ kubernetes_service
|
\ kubernetes_service
|
||||||
|
\ kubernetes_service_account
|
||||||
|
\ kubernetes_storage_class
|
||||||
\ librato_alert
|
\ librato_alert
|
||||||
\ librato_metric
|
\ librato_metric
|
||||||
\ librato_service
|
\ librato_service
|
||||||
@@ -667,6 +841,9 @@ syn keyword terraResourceTypeBI
|
|||||||
\ local_file
|
\ local_file
|
||||||
\ logentries_log
|
\ logentries_log
|
||||||
\ logentries_logset
|
\ logentries_logset
|
||||||
|
\ logicmonitor_collector_group
|
||||||
|
\ logicmonitor_device
|
||||||
|
\ logicmonitor_device_group
|
||||||
\ mailgun_domain
|
\ mailgun_domain
|
||||||
\ mysql_database
|
\ mysql_database
|
||||||
\ mysql_grant
|
\ mysql_grant
|
||||||
@@ -675,6 +852,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ newrelic_alert_condition
|
\ newrelic_alert_condition
|
||||||
\ newrelic_alert_policy
|
\ newrelic_alert_policy
|
||||||
\ newrelic_alert_policy_channel
|
\ newrelic_alert_policy_channel
|
||||||
|
\ newrelic_nrql_alert_condition
|
||||||
\ nomad_job
|
\ nomad_job
|
||||||
\ null_resource
|
\ null_resource
|
||||||
\ oneandone_firewall_policy
|
\ oneandone_firewall_policy
|
||||||
@@ -685,9 +863,37 @@ syn keyword terraResourceTypeBI
|
|||||||
\ oneandone_server
|
\ oneandone_server
|
||||||
\ oneandone_shared_storage
|
\ oneandone_shared_storage
|
||||||
\ oneandone_vpn
|
\ oneandone_vpn
|
||||||
|
\ opc_compute_acl
|
||||||
|
\ opc_compute_image_list
|
||||||
|
\ opc_compute_image_list_entry
|
||||||
|
\ opc_compute_instance
|
||||||
|
\ opc_compute_ip_address_association
|
||||||
|
\ opc_compute_ip_address_prefix_set
|
||||||
|
\ opc_compute_ip_address_reservation
|
||||||
|
\ opc_compute_ip_association
|
||||||
|
\ opc_compute_ip_network
|
||||||
|
\ opc_compute_ip_network_exchange
|
||||||
|
\ opc_compute_ip_reservation
|
||||||
|
\ opc_compute_route
|
||||||
|
\ opc_compute_sec_rule
|
||||||
|
\ opc_compute_security_application
|
||||||
|
\ opc_compute_security_association
|
||||||
|
\ opc_compute_security_ip_list
|
||||||
|
\ opc_compute_security_list
|
||||||
|
\ opc_compute_security_protocol
|
||||||
|
\ opc_compute_security_rule
|
||||||
|
\ opc_compute_snapshot
|
||||||
|
\ opc_compute_ssh_key
|
||||||
|
\ opc_compute_storage_volume
|
||||||
|
\ opc_compute_storage_volume_snapshot
|
||||||
|
\ opc_compute_vnic_set
|
||||||
|
\ opc_database_service_instance
|
||||||
|
\ opc_storage_container
|
||||||
|
\ opc_storage_object
|
||||||
\ openstack_blockstorage_volume_attach_v2
|
\ openstack_blockstorage_volume_attach_v2
|
||||||
\ openstack_blockstorage_volume_v1
|
\ openstack_blockstorage_volume_v1
|
||||||
\ openstack_blockstorage_volume_v2
|
\ openstack_blockstorage_volume_v2
|
||||||
|
\ openstack_compute_flavor_v2
|
||||||
\ openstack_compute_floatingip_associate_v2
|
\ openstack_compute_floatingip_associate_v2
|
||||||
\ openstack_compute_floatingip_v2
|
\ openstack_compute_floatingip_v2
|
||||||
\ openstack_compute_instance_v2
|
\ openstack_compute_instance_v2
|
||||||
@@ -700,6 +906,8 @@ syn keyword terraResourceTypeBI
|
|||||||
\ openstack_fw_firewall_v1
|
\ openstack_fw_firewall_v1
|
||||||
\ openstack_fw_policy_v1
|
\ openstack_fw_policy_v1
|
||||||
\ openstack_fw_rule_v1
|
\ openstack_fw_rule_v1
|
||||||
|
\ openstack_identity_project_v3
|
||||||
|
\ openstack_identity_user_v3
|
||||||
\ openstack_images_image_v2
|
\ openstack_images_image_v2
|
||||||
\ openstack_lb_listener_v2
|
\ openstack_lb_listener_v2
|
||||||
\ openstack_lb_loadbalancer_v2
|
\ openstack_lb_loadbalancer_v2
|
||||||
@@ -720,6 +928,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ openstack_networking_secgroup_v2
|
\ openstack_networking_secgroup_v2
|
||||||
\ openstack_networking_subnet_v2
|
\ openstack_networking_subnet_v2
|
||||||
\ openstack_objectstorage_container_v1
|
\ openstack_objectstorage_container_v1
|
||||||
|
\ openstack_objectstorage_object_v1
|
||||||
\ opsgenie_team
|
\ opsgenie_team
|
||||||
\ opsgenie_user
|
\ opsgenie_user
|
||||||
\ ovh_publiccloud_private_network
|
\ ovh_publiccloud_private_network
|
||||||
@@ -727,15 +936,20 @@ syn keyword terraResourceTypeBI
|
|||||||
\ ovh_publiccloud_user
|
\ ovh_publiccloud_user
|
||||||
\ ovh_vrack_publiccloud_attachment
|
\ ovh_vrack_publiccloud_attachment
|
||||||
\ packet_device
|
\ packet_device
|
||||||
|
\ packet_ip_attachment
|
||||||
\ packet_project
|
\ packet_project
|
||||||
|
\ packet_reserved_ip_block
|
||||||
\ packet_ssh_key
|
\ packet_ssh_key
|
||||||
\ packet_volume
|
\ packet_volume
|
||||||
|
\ packet_volume_attachment
|
||||||
\ pagerduty_addon
|
\ pagerduty_addon
|
||||||
\ pagerduty_escalation_policy
|
\ pagerduty_escalation_policy
|
||||||
|
\ pagerduty_maintenance_window
|
||||||
\ pagerduty_schedule
|
\ pagerduty_schedule
|
||||||
\ pagerduty_service
|
\ pagerduty_service
|
||||||
\ pagerduty_service_integration
|
\ pagerduty_service_integration
|
||||||
\ pagerduty_team
|
\ pagerduty_team
|
||||||
|
\ pagerduty_team_membership
|
||||||
\ pagerduty_user
|
\ pagerduty_user
|
||||||
\ postgresql_database
|
\ postgresql_database
|
||||||
\ postgresql_extension
|
\ postgresql_extension
|
||||||
@@ -744,11 +958,16 @@ syn keyword terraResourceTypeBI
|
|||||||
\ powerdns_record
|
\ powerdns_record
|
||||||
\ profitbricks_datacenter
|
\ profitbricks_datacenter
|
||||||
\ profitbricks_firewall
|
\ profitbricks_firewall
|
||||||
|
\ profitbricks_group
|
||||||
\ profitbricks_ipblock
|
\ profitbricks_ipblock
|
||||||
|
\ profitbricks_ipfailover
|
||||||
\ profitbricks_lan
|
\ profitbricks_lan
|
||||||
\ profitbricks_loadbalancer
|
\ profitbricks_loadbalancer
|
||||||
\ profitbricks_nic
|
\ profitbricks_nic
|
||||||
\ profitbricks_server
|
\ profitbricks_server
|
||||||
|
\ profitbricks_share
|
||||||
|
\ profitbricks_snapshot
|
||||||
|
\ profitbricks_user
|
||||||
\ profitbricks_volume
|
\ profitbricks_volume
|
||||||
\ rabbitmq_binding
|
\ rabbitmq_binding
|
||||||
\ rabbitmq_exchange
|
\ rabbitmq_exchange
|
||||||
@@ -763,10 +982,13 @@ syn keyword terraResourceTypeBI
|
|||||||
\ rancher_registration_token
|
\ rancher_registration_token
|
||||||
\ rancher_registry
|
\ rancher_registry
|
||||||
\ rancher_registry_credential
|
\ rancher_registry_credential
|
||||||
|
\ rancher_secret
|
||||||
\ rancher_stack
|
\ rancher_stack
|
||||||
\ random_id
|
\ random_id
|
||||||
|
\ random_integer
|
||||||
\ random_pet
|
\ random_pet
|
||||||
\ random_shuffle
|
\ random_shuffle
|
||||||
|
\ random_string
|
||||||
\ rundeck_job
|
\ rundeck_job
|
||||||
\ rundeck_private_key
|
\ rundeck_private_key
|
||||||
\ rundeck_project
|
\ rundeck_project
|
||||||
@@ -792,6 +1014,7 @@ syn keyword terraResourceTypeBI
|
|||||||
\ triton_firewall_rule
|
\ triton_firewall_rule
|
||||||
\ triton_key
|
\ triton_key
|
||||||
\ triton_machine
|
\ triton_machine
|
||||||
|
\ triton_snapshot
|
||||||
\ triton_vlan
|
\ triton_vlan
|
||||||
\ ultradns_dirpool
|
\ ultradns_dirpool
|
||||||
\ ultradns_probe_http
|
\ ultradns_probe_http
|
||||||
@@ -805,10 +1028,22 @@ syn keyword terraResourceTypeBI
|
|||||||
\ vcd_network
|
\ vcd_network
|
||||||
\ vcd_snat
|
\ vcd_snat
|
||||||
\ vcd_vapp
|
\ vcd_vapp
|
||||||
|
\ vcd_vapp_vm
|
||||||
|
\ vsphere_datacenter
|
||||||
|
\ vsphere_distributed_port_group
|
||||||
|
\ vsphere_distributed_virtual_switch
|
||||||
\ vsphere_file
|
\ vsphere_file
|
||||||
\ vsphere_folder
|
\ vsphere_folder
|
||||||
|
\ vsphere_host_port_group
|
||||||
|
\ vsphere_host_virtual_switch
|
||||||
|
\ vsphere_license
|
||||||
|
\ vsphere_nas_datastore
|
||||||
|
\ vsphere_tag
|
||||||
|
\ vsphere_tag_category
|
||||||
\ vsphere_virtual_disk
|
\ vsphere_virtual_disk
|
||||||
\ vsphere_virtual_machine
|
\ vsphere_virtual_machine
|
||||||
|
\ vsphere_virtual_machine_snapshot
|
||||||
|
\ vsphere_vmfs_datastore
|
||||||
""" end resources
|
""" end resources
|
||||||
|
|
||||||
syn keyword terraTodo contained TODO FIXME XXX BUG
|
syn keyword terraTodo contained TODO FIXME XXX BUG
|
||||||
|
|||||||
@@ -41,10 +41,16 @@ hi def link tomlBoolean Boolean
|
|||||||
syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}T\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)/ display
|
syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}T\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)/ display
|
||||||
hi def link tomlDate Constant
|
hi def link tomlDate Constant
|
||||||
|
|
||||||
syn match tomlTable /^\s*\[[^#\[\]]\+\]\s*\(#.*\)\?$/ contains=tomlComment
|
syn region tomlKeyDq oneline start=/"/ end=/"/ contains=tomlEscape contained
|
||||||
|
hi def link tomlKeyDq Identifier
|
||||||
|
|
||||||
|
syn region tomlKeySq oneline start=/'/ end=/'/ contained
|
||||||
|
hi def link tomlKeySq Identifier
|
||||||
|
|
||||||
|
syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKeyDq,tomlKeySq
|
||||||
hi def link tomlTable Identifier
|
hi def link tomlTable Identifier
|
||||||
|
|
||||||
syn match tomlTableArray /^\s*\[\[[^#\[\]]\+\]\]\s*\(#.*\)\?$/ contains=tomlComment
|
syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKeyDq,tomlKeySq
|
||||||
hi def link tomlTableArray Identifier
|
hi def link tomlTableArray Identifier
|
||||||
|
|
||||||
syn keyword tomlTodo TODO FIXME XXX BUG contained
|
syn keyword tomlTodo TODO FIXME XXX BUG contained
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'twig') == -1
|
|||||||
" 2011 July 27: Changed all references of jinja tp twig
|
" 2011 July 27: Changed all references of jinja tp twig
|
||||||
" 2014 December 4: Do not assume that the base filetype is HTML.
|
" 2014 December 4: Do not assume that the base filetype is HTML.
|
||||||
|
|
||||||
if exists('b:main_syntax')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
if exists('b:current_syntax')
|
if exists('b:current_syntax')
|
||||||
let b:main_syntax = b:current_syntax
|
let b:main_syntax = b:current_syntax
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,20 +7,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'perl') == -1
|
|||||||
" Previous: Vincent Pit <perl@profvince.com>
|
" Previous: Vincent Pit <perl@profvince.com>
|
||||||
" Last Change: 2016-02-01
|
" Last Change: 2016-02-01
|
||||||
|
|
||||||
" For version 5.x: Clear all syntax items
|
if exists("b:current_syntax")
|
||||||
" For version 6.x: Quit when a syntax file was already loaded
|
|
||||||
if version < 600
|
|
||||||
syntax clear
|
|
||||||
elseif exists("b:current_syntax")
|
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Read the C syntax to start with
|
runtime! syntax/c.vim
|
||||||
if version < 600
|
|
||||||
source <sfile>:p:h/c.vim
|
|
||||||
else
|
|
||||||
runtime! syntax/c.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Configuration:
|
" Configuration:
|
||||||
" let xs_superseded = 0 " mark C functions superseded by Perl replacements (ex. memcpy vs Copy)
|
" let xs_superseded = 0 " mark C functions superseded by Perl replacements (ex. memcpy vs Copy)
|
||||||
@@ -3672,29 +3663,16 @@ syn keyword xsMacro whichsig write xio_any xio_dirp xiv_iv xlv_targoff
|
|||||||
syn keyword xsMacro xpv_len xuv_uv yystype
|
syn keyword xsMacro xpv_len xuv_uv yystype
|
||||||
|
|
||||||
" Define the default highlighting.
|
" Define the default highlighting.
|
||||||
" For version 5.7 and earlier: only when not done already
|
hi def link xsPrivate Error
|
||||||
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
hi def link xsSuperseded Error
|
||||||
if version >= 508 || !exists("did_xs_syntax_inits")
|
hi def link xsType Type
|
||||||
if version < 508
|
hi def link xsString String
|
||||||
let did_xs_syntax_inits = 1
|
hi def link xsConstant Constant
|
||||||
command -nargs=+ HiLink hi link <args>
|
hi def link xsException Exception
|
||||||
else
|
hi def link xsKeyword Keyword
|
||||||
command -nargs=+ HiLink hi def link <args>
|
hi def link xsFunction Function
|
||||||
endif
|
hi def link xsVariable Identifier
|
||||||
|
hi def link xsMacro Macro
|
||||||
HiLink xsPrivate Error
|
|
||||||
HiLink xsSuperseded Error
|
|
||||||
HiLink xsType Type
|
|
||||||
HiLink xsString String
|
|
||||||
HiLink xsConstant Constant
|
|
||||||
HiLink xsException Exception
|
|
||||||
HiLink xsKeyword Keyword
|
|
||||||
HiLink xsFunction Function
|
|
||||||
HiLink xsVariable Identifier
|
|
||||||
HiLink xsMacro Macro
|
|
||||||
|
|
||||||
delcommand HiLink
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:current_syntax = "xs"
|
let b:current_syntax = "xs"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user