mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-09 12:03:53 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11f53253ad | ||
|
|
9fe009095a | ||
|
|
dce9e8dec5 |
@@ -81,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)
|
||||||
@@ -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,38 +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"
|
|
||||||
elseif match(thisline, '^locals') >= 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)
|
||||||
@@ -70,5 +75,4 @@ if get(g:, "terraform_align", 1)
|
|||||||
setlocal shiftwidth=2
|
setlocal shiftwidth=2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -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': [
|
||||||
\ [],
|
\ [],
|
||||||
|
|||||||
3
build
3
build
@@ -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
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -395,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
|
||||||
|
|
||||||
@@ -439,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
|
||||||
@@ -492,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
|
||||||
@@ -948,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
|
||||||
|
|||||||
@@ -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,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
|
|
||||||
@@ -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')
|
||||||
@@ -121,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
|
||||||
|
|
||||||
@@ -242,18 +245,18 @@ function s:Continues()
|
|||||||
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
|
||||||
@@ -266,8 +269,13 @@ 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()
|
||||||
@@ -358,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
|
||||||
@@ -385,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,
|
||||||
|
|||||||
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
|
||||||
|
|||||||
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
|
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -84,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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ syntax region jsRegexpString start=+\%(\%(\<return\|\<typeof\|\_[^)\]'"[:blan
|
|||||||
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 /\<\K\k*\ze\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=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ 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 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
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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*\)*\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: {{{
|
||||||
|
|||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user