diff --git a/README.md b/README.md index ac744574b..dc2b86a2b 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,11 @@ If you need full functionality of any plugin, please use it directly with your p - [emberscript](https://github.com/yalesov/vim-ember-script) (syntax, indent, ftplugin) - [emblem](https://github.com/yalesov/vim-emblem) (syntax, indent, ftplugin) - [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent) -- [fish](https://github.com/dag/vim-fish) () -- [fsharp](https://github.com/fsharp/vim-fsharp) () -- [git](https://github.com/tpope/vim-git) () -- [glsl](https://github.com/tikhomirov/vim-glsl) () -- [gmpl](https://github.com/maelvalais/gmpl.vim) () +- [fish](https://github.com/dag/vim-fish) (syntax, indent, compiler, autoload, ftplugin) +- [fsharp](https://github.com/fsharp/vim-fsharp) (syntax, indent) +- [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin) +- [glsl](https://github.com/tikhomirov/vim-glsl) (syntax, indent) +- [gmpl](https://github.com/maelvalais/gmpl.vim) (syntax) - [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) (syntax) - [go](https://github.com/fatih/vim-go) (syntax, compiler, indent) - [groovy](https://github.com/vim-scripts/groovy.vim) (syntax) @@ -83,7 +83,7 @@ If you need full functionality of any plugin, please use it directly with your p - [jsx](https://github.com/mxw/vim-jsx) (after) - [julia](https://github.com/JuliaEditorSupport/julia-vim) (syntax, indent, autoload, ftplugin) - [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent) -- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin) +- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) () - [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin) - [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, 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) - [scss](https://github.com/cakebaker/scss-syntax.vim) (syntax, autoload, 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) - [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin) - [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin) diff --git a/after/syntax/html.vim b/after/syntax/html.vim index 0ba2c14d0..43c0c41e9 100644 --- a/after/syntax/html.vim +++ b/after/syntax/html.vim @@ -21,6 +21,19 @@ if exists('s:current_syntax_save') unlet s:current_syntax_save endif +endif +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'glsl') == -1 + +" Language: OpenGL Shading Language +" Maintainer: Sergey Tikhomirov + +syn include @GLSL syntax/glsl.vim +syn region ShaderScript + \ start=""me=s-1 + \ contains=@GLSL,htmlScriptTag,@htmlPreproc + endif if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1 diff --git a/after/syntax/tex.vim b/after/syntax/tex.vim deleted file mode 100644 index f066fbe8d..000000000 --- a/after/syntax/tex.vim +++ /dev/null @@ -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 diff --git a/autoload/fish.vim b/autoload/fish.vim new file mode 100644 index 000000000..d4e63cdcb --- /dev/null +++ b/autoload/fish.vim @@ -0,0 +1,71 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1 + +function! fish#Indent() + let l:shiftwidth = shiftwidth() + let l:prevlnum = prevnonblank(v:lnum - 1) + if l:prevlnum ==# 0 + return 0 + endif + let l:indent = 0 + let l:prevline = getline(l:prevlnum) + if l:prevline =~# '\v^\s*switch>' + let l:indent = l:shiftwidth * 2 + elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>' + let l:indent = l:shiftwidth + endif + let l:line = getline(v:lnum) + if l:line =~# '\v^\s*end>' + return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent) + elseif l:line =~# '\v^\s*%(case|else)>' + return indent(v:lnum) - l:shiftwidth + endif + return indent(l:prevlnum) + l:indent +endfunction + +function! fish#Format() + if mode() =~# '\v^%(i|R)$' + return 1 + else + let l:command = v:lnum.','.(v:lnum+v:count-1).'!fish_indent' + echo l:command + execute l:command + endif +endfunction + +function! fish#Fold() + let l:line = getline(v:lnum) + if l:line =~# '\v^\s*%(begin|if|while|for|function|switch)>' + return 'a1' + elseif l:line =~# '\v^\s*end>' + return 's1' + else + return '=' + end +endfunction + +function! fish#Complete(findstart, base) + if a:findstart + return getline('.') =~# '\v^\s*$' ? -1 : 0 + else + if empty(a:base) + return [] + endif + let l:results = [] + let l:completions = + \ system('fish -c "complete -C'.shellescape(a:base).'"') + let l:cmd = substitute(a:base, '\v\S+$', '', '') + for l:line in split(l:completions, '\n') + let l:tokens = split(l:line, '\t') + call add(l:results, {'word': l:cmd.l:tokens[0], + \'abbr': l:tokens[0], + \'menu': get(l:tokens, 1, '')}) + endfor + return l:results + endif +endfunction + +function! fish#errorformat() + return '%Afish: %m,%-G%*\\ ^,%-Z%f (line %l):%s' +endfunction + +endif diff --git a/build b/build index 3a6eb6ac6..774a449f5 100755 --- a/build +++ b/build @@ -193,6 +193,7 @@ PACKS=" scala:derekwyatt/vim-scala scss:cakebaker/scss-syntax.vim slim:slim-template/vim-slim + slime:slime-lang/vim-slime-syntax solidity:tomlion/vim-solidity stylus:wavded/vim-stylus swift:keith/swift.vim diff --git a/compiler/fish.vim b/compiler/fish.vim new file mode 100644 index 000000000..11fad0c61 --- /dev/null +++ b/compiler/fish.vim @@ -0,0 +1,11 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1 + +if exists('current_compiler') + finish +endif +let current_compiler = 'fish' + +CompilerSet makeprg=fish\ --no-execute\ % +execute 'CompilerSet errorformat='.escape(fish#errorformat(), ' ') + +endif diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 44c70eea8..dc9520508 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -242,22 +242,77 @@ augroup END augroup filetypedetect " fish:dag/vim-fish +autocmd BufRead,BufNewFile *.fish setfiletype fish + +" Detect fish scripts by the shebang line. +autocmd BufRead * + \ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' | + \ setlocal filetype=fish | + \ endif + +" Move cursor to first empty line when using funced. +autocmd BufRead fish_funced_*_*.fish call search('^$') + +" Fish histories are YAML documents. +autocmd BufRead,BufNewFile ~/.config/fish/fish_{read_,}history setfiletype yaml + +" Universal variable storages should not be hand edited. +autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly + +" Mimic `funced` when manually creating functions. +autocmd BufNewFile ~/.config/fish/functions/*.fish + \ call append(0, ['function '.expand('%:t:r'), + \'', + \'end']) | + \ 2 augroup END augroup filetypedetect " fsharp:fsharp/vim-fsharp:_BASIC +" F#, fsharp +autocmd BufNewFile,BufRead *.fs,*.fsi,*.fsx set filetype=fsharp augroup END augroup filetypedetect " git:tpope/vim-git +" Git +autocmd BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG set ft=gitcommit +autocmd BufNewFile,BufRead *.git/config,.gitconfig,gitconfig,.gitmodules set ft=gitconfig +autocmd BufNewFile,BufRead */.config/git/config set ft=gitconfig +autocmd BufNewFile,BufRead *.git/modules/**/config set ft=gitconfig +autocmd BufNewFile,BufRead git-rebase-todo set ft=gitrebase +autocmd BufNewFile,BufRead .gitsendemail.* set ft=gitsendemail +autocmd BufNewFile,BufRead *.git/** + \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' | + \ set ft=git | + \ endif + +" This logic really belongs in scripts.vim +autocmd BufNewFile,BufRead,StdinReadPost * + \ if getline(1) =~ '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' | + \ set ft=git | + \ endif +autocmd BufNewFile,BufRead * + \ if getline(1) =~ '^From \x\{40\} Mon Sep 17 00:00:00 2001$' | + \ set filetype=gitsendemail | + \ endif augroup END augroup filetypedetect " gmpl:maelvalais/gmpl.vim +au BufRead,BufNewFile *.mod set filetype=gmpl augroup END augroup filetypedetect " glsl:tikhomirov/vim-glsl +" Language: OpenGL Shading Language +" Maintainer: Sergey Tikhomirov + +" Extensions supported by Khronos reference compiler (with one exception, ".glsl") +" https://github.com/KhronosGroup/glslang +autocmd! BufNewFile,BufRead *.vert,*.tesc,*.tese,*.glsl,*.geom,*.frag,*.comp set filetype=glsl + +" vim:set sts=2 sw=2 : augroup END augroup filetypedetect @@ -909,6 +964,11 @@ augroup filetypedetect autocmd BufNewFile,BufRead *.slim setfiletype slim augroup END +augroup filetypedetect +" slime:slime-lang/vim-slime-syntax +autocmd BufNewFile,BufRead *.slime set filetype=slime +augroup END + augroup filetypedetect " solidity:tomlion/vim-solidity au BufNewFile,BufRead *.sol setf solidity diff --git a/ftplugin/fish.vim b/ftplugin/fish.vim new file mode 100644 index 000000000..c6c1f6d89 --- /dev/null +++ b/ftplugin/fish.vim @@ -0,0 +1,43 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1 + +setlocal comments=:# +setlocal commentstring=#%s +setlocal define=\\v^\\s*function> +setlocal foldexpr=fish#Fold() +setlocal formatoptions+=ron1 +setlocal formatoptions-=t +setlocal include=\\v^\\s*\\.> +setlocal iskeyword=@,48-57,-,_,.,/ +setlocal suffixesadd^=.fish + +" Use the 'j' format option when available. +if v:version ># 703 || v:version ==# 703 && has('patch541') + setlocal formatoptions+=j +endif + +if executable('fish_indent') + setlocal formatexpr=fish#Format() +endif + +if executable('fish') + setlocal omnifunc=fish#Complete + for s:path in split(system("fish -c 'echo $fish_function_path'")) + execute 'setlocal path+='.s:path + endfor +else + setlocal omnifunc=syntaxcomplete#Complete +endif + +" Use the 'man' wrapper function in fish to include fish's man pages. +" Have to use a script for this; 'fish -c man' would make the the man page an +" argument to fish instead of man. +execute 'setlocal keywordprg=fish\ '.fnameescape(expand(':p:h:h').'/bin/man.fish') + +let b:match_words = + \ escape('<%(begin|function|if|switch|while|for)>:', '<>%|)') + +let b:endwise_addition = 'end' +let b:endwise_words = 'begin,function,if,switch,while,for' +let b:endwise_syngroups = 'fishKeyword,fishConditional,fishRepeat' + +endif diff --git a/ftplugin/git.vim b/ftplugin/git.vim new file mode 100644 index 000000000..38b9493b1 --- /dev/null +++ b/ftplugin/git.vim @@ -0,0 +1,45 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim filetype plugin +" Language: generic git output +" Maintainer: Tim Pope +" Last Change: 2013 May 30 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) + finish +endif +let b:did_ftplugin = 1 + +if !exists('b:git_dir') + if expand('%:p') =~# '[\/]\.git[\/]modules[\/]' + " Stay out of the way + elseif expand('%:p') =~# '[\/]\.git[\/]worktrees' + let b:git_dir = matchstr(expand('%:p'),'.*\.git[\/]worktrees[\/][^\/]\+\>') + elseif expand('%:p') =~# '\.git\>' + let b:git_dir = matchstr(expand('%:p'),'.*\.git\>') + elseif $GIT_DIR != '' + let b:git_dir = $GIT_DIR + endif + if (has('win32') || has('win64')) && exists('b:git_dir') + let b:git_dir = substitute(b:git_dir,'\\','/','g') + endif +endif + +if exists('*shellescape') && exists('b:git_dir') && b:git_dir != '' + if b:git_dir =~# '/\.git$' " Not a bare repository + let &l:path = escape(fnamemodify(b:git_dir,':h'),'\, ').','.&l:path + endif + let &l:path = escape(b:git_dir,'\, ').','.&l:path + let &l:keywordprg = 'git --git-dir='.shellescape(b:git_dir).' show' +else + setlocal keywordprg=git\ show +endif +if has('gui_running') + let &l:keywordprg = substitute(&l:keywordprg,'^git\>','git --no-pager','') +endif + +setlocal includeexpr=substitute(v:fname,'^[^/]\\+/','','') +let b:undo_ftplugin = "setl keywordprg< path< includeexpr<" + +endif diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim new file mode 100644 index 000000000..dc6a581a6 --- /dev/null +++ b/ftplugin/gitcommit.vim @@ -0,0 +1,68 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim filetype plugin +" Language: git commit file +" Maintainer: Tim Pope +" Last Change: 2013 May 30 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) + finish +endif + +runtime! ftplugin/git.vim +let b:did_ftplugin = 1 + +setlocal comments=:# commentstring=#\ %s +setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 +setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q +let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms<' + +if exists("g:no_gitcommit_commands") || v:version < 700 + finish +endif + +if !exists("b:git_dir") + let b:git_dir = expand("%:p:h") +endif + +command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0,b:git_dir,) + +let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached" + +function! s:diffcomplete(A,L,P) + let args = "" + if a:P <= match(a:L." -- "," -- ")+3 + let args = args . "-p\n--stat\n--shortstat\n--summary\n--patch-with-stat\n--no-renames\n-B\n-M\n-C\n" + end + if exists("b:git_dir") && a:A !~ '^-' + let tree = fnamemodify(b:git_dir,':h') + if strpart(getcwd(),0,strlen(tree)) == tree + let args = args."\n".system("git diff --cached --name-only") + endif + endif + return args +endfunction + +function! s:gitdiffcached(bang,gitdir,...) + let tree = fnamemodify(a:gitdir,':h') + let name = tempname() + let git = "git" + if strpart(getcwd(),0,strlen(tree)) != tree + let git .= " --git-dir=".(exists("*shellescape") ? shellescape(a:gitdir) : '"'.a:gitdir.'"') + endif + if a:0 + let extra = join(map(copy(a:000),exists("*shellescape") ? 'shellescape(v:val)' : "'\"'.v:val.'\"'")) + else + let extra = "-p --stat=".&columns + endif + call system(git." diff --cached --no-color --no-ext-diff ".extra." > ".(exists("*shellescape") ? shellescape(name) : name)) + exe "pedit ".(exists("*fnameescape") ? fnameescape(name) : name) + wincmd P + let b:git_dir = a:gitdir + command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0,b:git_dir,) + nnoremap q :q + setlocal buftype=nowrite nobuflisted noswapfile nomodifiable filetype=git +endfunction + +endif diff --git a/ftplugin/gitconfig.vim b/ftplugin/gitconfig.vim new file mode 100644 index 000000000..232825229 --- /dev/null +++ b/ftplugin/gitconfig.vim @@ -0,0 +1,19 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim filetype plugin +" Language: git config file +" Maintainer: Tim Pope +" Last Change: 2009 Dec 24 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) + finish +endif +let b:did_ftplugin = 1 + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:#,:; commentstring=;\ %s + +let b:undo_ftplugin = "setl fo< com< cms<" + +endif diff --git a/ftplugin/gitrebase.vim b/ftplugin/gitrebase.vim new file mode 100644 index 000000000..032aba31d --- /dev/null +++ b/ftplugin/gitrebase.vim @@ -0,0 +1,49 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim filetype plugin +" Language: git rebase --interactive +" Maintainer: Tim Pope +" Last Change: 2010 May 21 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) + finish +endif + +runtime! ftplugin/git.vim +let b:did_ftplugin = 1 + +setlocal comments=:# commentstring=#\ %s formatoptions-=t +setlocal nomodeline +if !exists("b:undo_ftplugin") + let b:undo_ftplugin = "" +endif +let b:undo_ftplugin = b:undo_ftplugin."|setl com< cms< fo< ml<" + +function! s:choose(word) + s/^\(\w\+\>\)\=\(\s*\)\ze\x\{4,40\}\>/\=(strlen(submatch(1)) == 1 ? a:word[0] : a:word) . substitute(submatch(2),'^$',' ','')/e +endfunction + +function! s:cycle() + call s:choose(get({'s':'edit','p':'squash','e':'reword','r':'fixup'},getline('.')[0],'pick')) +endfunction + +command! -buffer -bar -range Pick :,call s:choose('pick') +command! -buffer -bar -range Squash :,call s:choose('squash') +command! -buffer -bar -range Edit :,call s:choose('edit') +command! -buffer -bar -range Reword :,call s:choose('reword') +command! -buffer -bar -range Fixup :,call s:choose('fixup') +command! -buffer -bar -range Drop :,call s:choose('drop') +command! -buffer -bar Cycle :call s:cycle() +" The above are more useful when they are mapped; for example: +"nnoremap S :Cycle + +if exists("g:no_plugin_maps") || exists("g:no_gitrebase_maps") + finish +endif + +nnoremap K col('.') < 7 && expand('cword>') =~ '\X' && getline('.') =~ '^\w\+\s\+\x\+\>' ? 'wK' : 'K' + +let b:undo_ftplugin = b:undo_ftplugin . "|nunmap K" + +endif diff --git a/ftplugin/gitsendemail.vim b/ftplugin/gitsendemail.vim new file mode 100644 index 000000000..69e0360e2 --- /dev/null +++ b/ftplugin/gitsendemail.vim @@ -0,0 +1,10 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim filetype plugin +" Language: git send-email message +" Maintainer: Tim Pope +" Last Change: 2009 Dec 24 + +runtime! ftplugin/mail.vim + +endif diff --git a/ftplugin/latex-box/common.vim b/ftplugin/latex-box/common.vim deleted file mode 100644 index 204888469..000000000 --- a/ftplugin/latex-box/common.vim +++ /dev/null @@ -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\ %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('') -" }}} - -" 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*{[^}]*}\|\\\@ 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 diff --git a/ftplugin/latex-box/complete.vim b/ftplugin/latex-box/complete.vim deleted file mode 100644 index aecb0d8d3..000000000 --- a/ftplugin/latex-box/complete.vim +++ /dev/null @@ -1,936 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1 - -" LaTeX Box completion - -setlocal omnifunc=LatexBox_Complete - -" Wrap {{{ -function! s:GetSID() - return matchstr(expand(''), '\zs\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(':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 = '\%(\%(\\\@= 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! `o\end{' . env . '}' - execute 'keepjumps normal! ` - normal! gvgq - endif - else - execute 'keepjumps normal! `>a\end{' . env . '}' - execute 'keepjumps normal! `= 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('$', "/q: close") - call append('$', ": jump") - call append('$', ": 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 LatexCloseCurEnv =CloseCurEnv() -vnoremap LatexWrapSelection :call WrapSelection('')i -vnoremap LatexEnvWrapSelection :call PromptEnvWrapSelection() -vnoremap LatexEnvWrapFmtSelection :call PromptEnvWrapSelection(1) -nnoremap LatexChangeEnv :call ChangeEnvPrompt() -nnoremap LatexToggleStarEnv :call LatexToggleStarEnv() -" }}} - -" Commands {{{ -command! LatexLabels call PromptLabelList() -" }}} - -" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 - -endif diff --git a/ftplugin/latex-box/findmain.vim b/ftplugin/latex-box/findmain.vim deleted file mode 100644 index 3b81b0d7b..000000000 --- a/ftplugin/latex-box/findmain.vim +++ /dev/null @@ -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 diff --git a/ftplugin/latex-box/folding.vim b/ftplugin/latex-box/folding.vim deleted file mode 100644 index d6f362724..000000000 --- a/ftplugin/latex-box/folding.vim +++ /dev/null @@ -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 = '\%(\\\@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 diff --git a/ftplugin/latex-box/latexmk.vim b/ftplugin/latex-box/latexmk.vim deleted file mode 100644 index 15db3686d..000000000 --- a/ftplugin/latex-box/latexmk.vim +++ /dev/null @@ -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(''), '\zs\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( == "!") -command! -bang LatexmkClean call LatexBox_LatexmkClean( == "!") -command! -bang LatexmkStatus call LatexBox_LatexmkStatus( == "!") -command! LatexmkStop call LatexBox_LatexmkStop(0) -command! LatexErrors call LatexBox_LatexErrors(-1) - -if g:LatexBox_latexmk_async || g:LatexBox_latexmk_preview_continuously - autocmd BufUnload call LatexBox_LatexmkStop(1) - autocmd VimLeave * call kill_all_latexmk_processes() -endif - -" }}} - -" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 - -endif diff --git a/ftplugin/latex-box/mappings.vim b/ftplugin/latex-box/mappings.vim deleted file mode 100644 index 7141635ea..000000000 --- a/ftplugin/latex-box/mappings.vim +++ /dev/null @@ -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 ll :Latexmk -noremap lL :Latexmk! -noremap lc :LatexmkClean -noremap lC :LatexmkClean! -noremap lg :LatexmkStatus -noremap lG :LatexmkStatus! -noremap lk :LatexmkStop -noremap le :LatexErrors -" }}} - -" View {{{ -noremap lv :LatexView -" }}} - -" TOC {{{ -noremap lt :LatexTOC -" }}} - -" List of labels {{{ -noremap lj :LatexLabels -" }}} - -" Folding {{{ -if g:LatexBox_Folding == 1 - noremap lf :LatexFold -endif -" }}} - -" Jump to match {{{ -if !exists('g:LatexBox_loaded_matchparen') - nmap % LatexBox_JumpToMatch - vmap % LatexBox_JumpToMatch - omap % LatexBox_JumpToMatch -endif -" }}} - -" Define text objects {{{ -vmap ie LatexBox_SelectCurrentEnvInner -vmap ae LatexBox_SelectCurrentEnvOuter -onoremap ie :normal vie -onoremap ae :normal vae -vmap i$ LatexBox_SelectInlineMathInner -vmap a$ LatexBox_SelectInlineMathOuter -onoremap i$ :normal vi$ -onoremap a$ :normal va$ -" }}} - -" 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 = '\%(\%(\\\@' - 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 ]] :call LatexBoxNextSection(0,0,0) -noremap ][ :call LatexBoxNextSection(1,0,0) -noremap [] :call LatexBoxNextSection(1,1,0) -noremap [[ :call LatexBoxNextSection(0,1,0) -vnoremap ]] :call LatexBoxNextSection(0,0,1) -vnoremap ][ :call LatexBoxNextSection(1,0,1) -vnoremap [] :call LatexBoxNextSection(1,1,1) -vnoremap [[ :call LatexBoxNextSection(0,1,1) -" }}} - -" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 - -endif diff --git a/ftplugin/latex-box/motion.vim b/ftplugin/latex-box/motion.vim deleted file mode 100644 index 2053149c9..000000000 --- a/ftplugin/latex-box/motion.vim +++ /dev/null @@ -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 = '\%(\\\@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 LatexBox_JumpToMatch :call FindMatchingPair('n') -vnoremap LatexBox_JumpToMatch :call FindMatchingPair('v') -onoremap LatexBox_JumpToMatch v:call FindMatchingPair('o') - -" }}} - -" select inline math {{{ -" s:SelectInlineMath(seltype) -" where seltype is either 'inner' or 'outer' -function! s:SelectInlineMath(seltype) - - let dollar_pat = '\\\@ LatexBox_SelectInlineMathInner - \ :call SelectInlineMath('inner') -vnoremap LatexBox_SelectInlineMathOuter - \ :call SelectInlineMath('outer') -" }}} - -" 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 LatexBox_SelectCurrentEnvInner :call SelectCurrentEnv('inner') -vnoremap LatexBox_SelectCurrentEnvOuter :call SelectCurrentEnv('outer') -" }}} - -" 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 "\" - 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('$', "/q: close") - call append('$', ": jump") - call append('$', ": 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 diff --git a/ftplugin/latextoc.vim b/ftplugin/latextoc.vim deleted file mode 100644 index bfb8658ea..000000000 --- a/ftplugin/latextoc.vim +++ /dev/null @@ -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' - 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 s :call TOCToggleNumbers() -nnoremap q :call TOCClose() -nnoremap :call TOCClose() -nnoremap :call TOCActivate(0) -nnoremap :call TOCActivate(1) -nnoremap :call TOCActivate(0) -nnoremap <2-leftmouse> :call TOCActivate(1) -nnoremap G G4k -nnoremap OA k -nnoremap OB j -nnoremap OC l -nnoremap OD h -" }}}1 - -" vim:fdm=marker:ff=unix:et:ts=4:sw=4 - -endif diff --git a/ftplugin/tex_LatexBox.vim b/ftplugin/tex_LatexBox.vim deleted file mode 100644 index 6c8899a6a..000000000 --- a/ftplugin/tex_LatexBox.vim +++ /dev/null @@ -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(':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 diff --git a/indent/fish.vim b/indent/fish.vim new file mode 100644 index 000000000..c5f8e50e5 --- /dev/null +++ b/indent/fish.vim @@ -0,0 +1,6 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1 + +setlocal indentexpr=fish#Indent() +setlocal indentkeys+==end,=else,=case + +endif diff --git a/indent/fsharp.vim b/indent/fsharp.vim new file mode 100644 index 000000000..bdc3e3f9b --- /dev/null +++ b/indent/fsharp.vim @@ -0,0 +1,253 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fsharp') == -1 + +" Vim indent file +" Language: FSharp +" Maintainers: Jean-Francois Yuen +" Mike Leary +" Markus Mottl +" Rudi Grinberg +" Gregor Uhlenheuer +" Last Change: 2013 Jun 29 +" 2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working +" 2005 May 09 - Added an option to not indent OCaml-indents specially (MM) +" 2013 June - commented textwidth (Marc Weber) +" 2014 August - Ported to F# +" 2014 August - F# specific cleanup +" +" Marc Weber's comment: This file may contain a lot of (very custom) stuff +" which eventually should be moved somewhere else .. + +" Only load this indent file when no other was loaded. + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=GetFsharpIndent() +setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0;;,0>\],0\|\],0>},0\|,0},0\],0) + +" Only define the function once. +if exists("*GetFsharpIndent") + finish +endif + +" Skipping pattern, for comments +function! s:GetLineWithoutFullComment(lnum) + let lnum = prevnonblank(a:lnum - 1) + let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') + while lline =~ '^\s*$' && lnum > 0 + let lnum = prevnonblank(lnum - 1) + let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') + endwhile + return lnum +endfunction + +" Indent for ';;' to match multiple 'let' +function! s:GetInd(lnum, pat, lim) + let llet = search(a:pat, 'bW') + let old = indent(a:lnum) + while llet > 0 + let old = indent(llet) + let nb = s:GetLineWithoutFullComment(llet) + if getline(nb) =~ a:lim + return old + endif + let llet = search(a:pat, 'bW') + endwhile + return old +endfunction + +" Indent pairs +function! s:FindPair(pstart, pmid, pend) + call search(a:pend, 'bW') + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')) +endfunction + +" Indent 'let' +function! s:FindLet(pstart, pmid, pend) + call search(a:pend, 'bW') + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\\s*$' + " return ind + &sw + " endif + + let line = getline(v:lnum) + + " Indent if current line begins with 'end': + if line =~ '^\s*end\>' + return s:FindPair(s:module, '','\') + + " Indent if current line begins with 'done' for 'do': + elseif line =~ '^\s*done\>' + return s:FindPair('\', '','\') + + " Indent if current line begins with '}' or '>}': + elseif line =~ '^\s*\(\|>\)}' + return s:FindPair('{', '','}') + + " Indent if current line begins with ']', '|]' or '>]': + elseif line =~ '^\s*\(\||\|>\)\]' + return s:FindPair('\[', '','\]') + + " Indent if current line begins with ')': + elseif line =~ '^\s*)' + return s:FindPair('(', '',')') + + " Indent if current line begins with 'let': + elseif line =~ '^\s*let\>' + if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet + return s:FindLet(s:type, '','\' + if lline !~ s:lim . '\|\\)\|\<\(function\|private\|with\)\s*$' + call search('|', 'bW') + return indent(searchpair('^\s*\(match\|type\)\>\|\<\(function\|private\|with\)\s*$', '', '^\s*|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") !~ "^\\s*|.*->"')) + endif + + " Indent if current line begins with ';;': + elseif line =~ '^\s*;;' + if lline !~ ';;\s*$' + return s:GetInd(v:lnum, s:letpat, s:letlim) + endif + + " Indent if current line begins with 'in': + elseif line =~ '^\s*in\>' + if lline !~ '^\s*\(let\|and\)\>' + return s:FindPair('\', '', '\') + endif + + " Indent if current line begins with 'else': + elseif line =~ '^\s*else\>' + if lline !~ '^\s*\(if\|then\)\>' + return s:FindPair('\', '', '\') + endif + + " Indent if current line begins with 'then': + elseif line =~ '^\s*then\>' + if lline !~ '^\s*\(if\|else\)\>' + return s:FindPair('\', '', '\') + endif + + " Indent if current line begins with 'and': + elseif line =~ '^\s*and\>' + if lline !~ '^\s*\(and\|let\|type\)\>\|\' + if lline !~ '^\s*\(match\|try\)\>' + return s:FindPair('\<\%(match\|try\)\>', '','\') + endif + + " Indent if current line begins with 'exception', 'external', 'include' or + " 'open': + elseif line =~ '^\s*\(exception\|external\|include\|open\)\>' + if lline !~ s:lim . '\|' . s:letlim + call search(line) + return indent(search('^\s*\(\(exception\|external\|include\|open\|type\)\>\|val\>.*:\)', 'bW')) + endif + + " Indent if current line begins with 'val': + elseif line =~ '^\s*val\>' + if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim + return indent(search('^\s*\(\(exception\|include\|initializer\|method\|open\|type\|val\)\>\|external\>.*:\)', 'bW')) + endif + + " Indent if current line begins with 'constraint', 'inherit', 'initializer' + " or 'method': + elseif line =~ '^\s*\(constraint\|inherit\|initializer\|method\)\>' + if lline !~ s:obj + return indent(search('\<\(object\|object\s*(.*)\)\s*$', 'bW')) + &sw + endif + + endif + + " Add a 'shiftwidth' after lines ending with: + if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|else\|fun\|function\|functor\|if\|initializer\|object\|private\|sig\|struct\|then\|try\)\|\') + + " Back to normal indent after lines ending with 'in': + elseif lline =~ '\' + let ind = s:FindPair('\', '', '\') + + " Back to normal indent after lines ending with 'done': + elseif lline =~ '\', '','\') + + " Back to normal indent after lines ending with '}' or '>}': + elseif lline =~ '\(\|>\)}\s*$' + let ind = s:FindPair('{', '','}') + + " Back to normal indent after lines ending with ']', '|]' or '>]': + elseif lline =~ '\(\||\|>\)\]\s*$' + let ind = s:FindPair('\[', '','\]') + + " Back to normal indent after comments: + elseif lline =~ '\*)\s*$' + call search('\*)', 'bW') + let ind = indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')) + + " Back to normal indent after lines ending with ')': + elseif lline =~ ')\s*$' + let ind = s:FindPair('(', '',')') + + " If this is a multiline comment then align '*': + elseif lline =~ '^\s*(\*' && line =~ '^\s*\*' + let ind = ind + 1 + + else + " Don't change indentation of this line + " for new lines (indent==0) use indentation of previous line + + " This is for preventing removing indentation of these args: + " let f x = + " let y = x + 1 in + " Printf.printf + " "o" << here + " "oeuth" << don't touch indentation + + let i = indent(v:lnum) + return i == 0 ? ind : i + + endif + + return ind + +endfunction + +" vim: sw=4 et sts=4 + +endif diff --git a/indent/gitconfig.vim b/indent/gitconfig.vim new file mode 100644 index 000000000..e0e4a4560 --- /dev/null +++ b/indent/gitconfig.vim @@ -0,0 +1,42 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim indent file +" Language: git config file +" Maintainer: Tim Pope +" Last Change: 2013 May 30 + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetGitconfigIndent() +setlocal indentkeys=o,O,*,0[,],0;,0#,=,!^F + +let b:undo_indent = 'setl ai< inde< indk<' + +" Only define the function once. +if exists("*GetGitconfigIndent") + finish +endif + +function! GetGitconfigIndent() + let sw = exists('*shiftwidth') ? shiftwidth() : &sw + let line = getline(prevnonblank(v:lnum-1)) + let cline = getline(v:lnum) + if line =~ '\\\@ + +if exists("b:did_indent") + finish +endif + +setlocal autoindent cindent +setlocal formatoptions+=roq + +" vim:set sts=2 sw=2 : + +endif diff --git a/indent/slime.vim b/indent/slime.vim new file mode 100644 index 000000000..59eea5094 --- /dev/null +++ b/indent/slime.vim @@ -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,*,},],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\)\>\%(.*\\)\@!\|.*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 diff --git a/indent/tex.vim b/indent/tex.vim deleted file mode 100644 index 14af7b28e..000000000 --- a/indent/tex.vim +++ /dev/null @@ -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 = '\\\@ 703 || (v:version == 703 && has('patch598')) - augroup LatexBox_Completion - autocmd! - autocmd CompleteDone call Latexbox_CallIndent() - augroup END -endif - -" vim:fdm=marker:ff=unix:noet:ts=4:sw=4 - -endif diff --git a/syntax/fish.vim b/syntax/fish.vim new file mode 100644 index 000000000..f198dbaab --- /dev/null +++ b/syntax/fish.vim @@ -0,0 +1,41 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1 + +if exists('b:current_syntax') + finish +endif + +syntax case match + +syntax keyword fishKeyword begin function end +syntax keyword fishConditional if else switch +syntax keyword fishRepeat while for in +syntax keyword fishLabel case + +syntax match fishComment /#.*/ +syntax match fishSpecial /\\$/ +syntax match fishIdentifier /\$[[:alnum:]_]\+/ +syntax region fishString start=/'/ skip=/\\'/ end=/'/ +syntax region fishString start=/"/ skip=/\\"/ end=/"/ contains=fishIdentifier +syntax match fishCharacter /\v\\[abefnrtv *?~%#(){}\[\]<>&;"']|\\[xX][0-9a-f]{1,2}|\\o[0-7]{1,2}|\\u[0-9a-f]{1,4}|\\U[0-9a-f]{1,8}|\\c[a-z]/ +syntax match fishStatement /\v;\s*\zs\k+>/ +syntax match fishCommandSub /\v\(\s*\zs\k+>/ + +syntax region fishLineContinuation matchgroup=fishStatement + \ start='\v^\s*\zs\k+>' skip='\\$' end='$' + \ contains=fishSpecial,fishIdentifier,fishString,fishCharacter,fishStatement,fishCommandSub,fishComment + +highlight default link fishKeyword Keyword +highlight default link fishConditional Conditional +highlight default link fishRepeat Repeat +highlight default link fishLabel Label +highlight default link fishComment Comment +highlight default link fishSpecial Special +highlight default link fishIdentifier Identifier +highlight default link fishString String +highlight default link fishCharacter Character +highlight default link fishStatement Statement +highlight default link fishCommandSub fishStatement + +let b:current_syntax = 'fish' + +endif diff --git a/syntax/fsharp.vim b/syntax/fsharp.vim new file mode 100644 index 000000000..f66daa017 --- /dev/null +++ b/syntax/fsharp.vim @@ -0,0 +1,269 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fsharp') == -1 + +" Vim syntax file +" Language: F# +" Last Change: Sun 19 Oct 2014 11:11:44 PM CEST +" Maintainer: Gregor Uhlenheuer +" +" Note: This syntax file is a complete rewrite of the original version +" of fs.vim from Choy Rim and a slight +" modified version from Thomas Schank + +if version < 600 + syntax clear +elseif exists('b:current_syntax') + finish +endif + +" F# is case sensitive. +syn case match + +" reset 'iskeyword' setting +setl isk&vim + +" Scripting/preprocessor directives +syn match fsharpSScript "^\s*#\S\+" transparent contains=fsharpScript,fsharpRegion,fsharpPreCondit + +syn match fsharpScript contained "#" +syn keyword fsharpScript contained quitlabels warnings directory cd load use +syn keyword fsharpScript contained install_printer remove_printer requirethread +syn keyword fsharpScript contained trace untrace untrace_all print_depth +syn keyword fsharpScript contained print_length define undef if elif else endif +syn keyword fsharpScript contained line error warning light nowarn + + +" comments +syn match fsharpSingleLineComment "//.*$" contains=fsharpTodo,@Spell +syn region fsharpDocComment start="///" end="$" contains=fsharpTodo,fsharpXml,@Spell keepend oneline +syn region fsharpXml matchgroup=fsharpXmlDoc start="<[^>]\+>" end="]\+>" contained contains=fsharpXml + +" Double-backtick identifiers +syn region fsharpDoubleBacktick start="``" end="``" keepend oneline + + +" symbol names +syn match fsharpSymbol "\%(let\|use\|mutable\|rec\|and\|private\)\@<=!\=\s\+\zs\w\+\ze\s*[^=:]*[=:]" +syn match fsharpSymbol "\%(member\)\@<=\s\+\w\+\.\zs\w\+" + + +" types +syn match fsharpTypeName "\%(\" +syn match fsharpRefAssign ":=" +syn match fsharpTopStop ";;" +syn match fsharpOperator "\^" +syn match fsharpOperator "::" + +syn match fsharpLabel "\<_\>" + +syn match fsharpOperator "&&" +syn match fsharpOperator "<" +syn match fsharpOperator ">" +syn match fsharpOperator "|>" +syn match fsharpOperator ":>" +syn match fsharpOperator ":?>" +syn match fsharpOperator "&&&" +syn match fsharpOperator "|||" +syn match fsharpOperator "\.\." + +syn match fsharpKeyChar "|[^\]]"me=e-1 +syn match fsharpKeyChar ";" +syn match fsharpKeyChar "\~" +syn match fsharpKeyChar "?" +syn match fsharpKeyChar "\*" +syn match fsharpKeyChar "+" +syn match fsharpKeyChar "=" +syn match fsharpKeyChar "|" +syn match fsharpKeyChar "(\*)" + +syn match fsharpOperator "<-" + +syn match fsharpNumber "\<\d\+" +syn match fsharpNumber "\<-\=\d\(_\|\d\)*\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpNumber "\<-\=0[x|X]\(\x\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpNumber "\<-\=0[o|O]\(\o\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpNumber "\<-\=0[b|B]\([01]\|_\)\+\(u\|u\?[yslLn]\|UL\)\?\>" +syn match fsharpFloat "\<-\=\d\(_\|\d\)*\.\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>" +syn match fsharpFloat "\<-\=\d\(_\|\d\)*\.\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>" +syn match fsharpFloat "\<\d\+\.\d*" + +" modules +syn match fsharpModule "\%(\= 508 || !exists("did_fs_syntax_inits") + if version < 508 + let did_fs_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink fsharpBraceErr Error + HiLink fsharpBrackErr Error + HiLink fsharpParenErr Error + HiLink fsharpArrErr Error + HiLink fsharpCommentErr Error + + HiLink fsharpSingleLineComment Comment + HiLink fsharpMultiLineComment Comment + HiLink fsharpDocComment Comment + HiLink fsharpXml Comment + HiLink fsharpDoubleBacktick String + + HiLink fsharpOpen Include + HiLink fsharpModPath Include + HiLink fsharpScript Include + HiLink fsharpPreCondit Include + + HiLink fsharpKeyword Keyword + HiLink fsharpCoreMethod Keyword + + HiLink fsharpOCaml Statement + HiLink fsharpLinq Statement + + HiLink fsharpSymbol Function + + HiLink fsharpFunDef Operator + HiLink fsharpRefAssign Operator + HiLink fsharpTopStop Operator + HiLink fsharpKeyChar Operator + HiLink fsharpOperator Operator + + HiLink fsharpBoolean Boolean + HiLink fsharpConstant Constant + HiLink fsharpCharacter Character + HiLink fsharpNumber Number + HiLink fsharpFloat Float + + HiLink fsharpString String + HiLink fsharpFormat Special + + HiLink fsharpModifier StorageClass + + HiLink fsharpException Exception + + HiLink fsharpLabel Identifier + HiLink fsharpOption Identifier + HiLink fsharpTypeName Identifier + HiLink fsharpModule Identifier + + HiLink fsharpType Type + + HiLink fsharpCoreClass Typedef + HiLink fsharpAttrib Typedef + HiLink fsharpXmlDoc Typedef + + HiLink fsharpTodo Todo + + HiLink fsharpEncl Delimiter + HiLink fsharpAttribute Delimiter + + delcommand HiLink +endif + +let b:current_syntax = 'fsharp' + +" vim: sw=4 et sts=4 + +endif diff --git a/syntax/git.vim b/syntax/git.vim new file mode 100644 index 000000000..53f44d36e --- /dev/null +++ b/syntax/git.vim @@ -0,0 +1,82 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim syntax file +" Language: generic git output +" Maintainer: Tim Pope +" Last Change: 2010 May 21 + +if exists("b:current_syntax") + finish +endif + +syn case match +syn sync minlines=50 + +syn include @gitDiff syntax/diff.vim + +syn region gitHead start=/\%^/ end=/^$/ +syn region gitHead start=/\%(^commit\%( \x\{40\}\)\{1,\}\%(\s*(.*)\)\=$\)\@=/ end=/^$/ + +" For git reflog and git show ...^{tree}, avoid sync issues +syn match gitHead /^\d\{6\} \%(\w\{4} \)\=\x\{40\}\%( [0-3]\)\=\t.*/ +syn match gitHead /^\x\{40\} \x\{40}\t.*/ + +syn region gitDiff start=/^\%(diff --git \)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff fold +syn region gitDiff start=/^\%(@@ -\)\@=/ end=/^\%(diff --\%(git\|cc\|combined\) \|$\)\@=/ contains=@gitDiff + +syn region gitDiffMerge start=/^\%(diff --\%(cc\|combined\) \)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff +syn region gitDiffMerge start=/^\%(@@@@* -\)\@=/ end=/^\%(diff --\|$\)\@=/ contains=@gitDiff +syn match gitDiffAdded "^ \++.*" contained containedin=gitDiffMerge +syn match gitDiffRemoved "^ \+-.*" contained containedin=gitDiffMerge + +syn match gitKeyword /^\%(object\|type\|tag\|commit\|tree\|parent\|encoding\)\>/ contained containedin=gitHead nextgroup=gitHash,gitType skipwhite +syn match gitKeyword /^\%(tag\>\|ref:\)/ contained containedin=gitHead nextgroup=gitReference skipwhite +syn match gitKeyword /^Merge:/ contained containedin=gitHead nextgroup=gitHashAbbrev skipwhite +syn match gitMode /^\d\{6\}/ contained containedin=gitHead nextgroup=gitType,gitHash skipwhite +syn match gitIdentityKeyword /^\%(author\|committer\|tagger\)\>/ contained containedin=gitHead nextgroup=gitIdentity skipwhite +syn match gitIdentityHeader /^\%(Author\|Commit\|Tagger\):/ contained containedin=gitHead nextgroup=gitIdentity skipwhite +syn match gitDateHeader /^\%(AuthorDate\|CommitDate\|Date\):/ contained containedin=gitHead nextgroup=gitDate skipwhite + +syn match gitReflogHeader /^Reflog:/ contained containedin=gitHead nextgroup=gitReflogMiddle skipwhite +syn match gitReflogHeader /^Reflog message:/ contained containedin=gitHead skipwhite +syn match gitReflogMiddle /\S\+@{\d\+} (/he=e-2 nextgroup=gitIdentity + +syn match gitDate /\<\u\l\l \u\l\l \d\=\d \d\d:\d\d:\d\d \d\d\d\d [+-]\d\d\d\d/ contained +syn match gitDate /-\=\d\+ [+-]\d\d\d\d\>/ contained +syn match gitDate /\<\d\+ \l\+ ago\>/ contained +syn match gitType /\<\%(tag\|commit\|tree\|blob\)\>/ contained nextgroup=gitHash skipwhite +syn match gitStage /\<\d\t\@=/ contained +syn match gitReference /\S\+\S\@!/ contained +syn match gitHash /\<\x\{40\}\>/ contained nextgroup=gitIdentity,gitStage,gitHash skipwhite +syn match gitHash /^\<\x\{40\}\>/ containedin=gitHead contained nextgroup=gitHash skipwhite +syn match gitHashAbbrev /\<\x\{4,40\}\>/ contained nextgroup=gitHashAbbrev skipwhite +syn match gitHashAbbrev /\<\x\{4,39\}\.\.\./he=e-3 contained nextgroup=gitHashAbbrev skipwhite + +syn match gitIdentity /\S.\{-\} <[^>]*>/ contained nextgroup=gitDate skipwhite +syn region gitEmail matchgroup=gitEmailDelimiter start=// keepend oneline contained containedin=gitIdentity + +syn match gitNotesHeader /^Notes:\ze\n / + +hi def link gitDateHeader gitIdentityHeader +hi def link gitIdentityHeader gitIdentityKeyword +hi def link gitIdentityKeyword Label +hi def link gitNotesHeader gitKeyword +hi def link gitReflogHeader gitKeyword +hi def link gitKeyword Keyword +hi def link gitIdentity String +hi def link gitEmailDelimiter Delimiter +hi def link gitEmail Special +hi def link gitDate Number +hi def link gitMode Number +hi def link gitHashAbbrev gitHash +hi def link gitHash Identifier +hi def link gitReflogMiddle gitReference +hi def link gitReference Function +hi def link gitStage gitType +hi def link gitType Type +hi def link gitDiffAdded diffAdded +hi def link gitDiffRemoved diffRemoved + +let b:current_syntax = "git" + +endif diff --git a/syntax/gitcommit.vim b/syntax/gitcommit.vim new file mode 100644 index 000000000..74477b275 --- /dev/null +++ b/syntax/gitcommit.vim @@ -0,0 +1,88 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim syntax file +" Language: git commit file +" Maintainer: Tim Pope +" Filenames: *.git/COMMIT_EDITMSG +" Last Change: 2013 May 30 + +if exists("b:current_syntax") + finish +endif + +syn case match +syn sync minlines=50 + +if has("spell") + syn spell toplevel +endif + +syn include @gitcommitDiff syntax/diff.vim +syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff + +syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl +syn match gitcommitSummary "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell +syn match gitcommitOverflow ".*" contained contains=@Spell +syn match gitcommitBlank "^[^#].*" contained contains=@Spell +syn match gitcommitComment "^#.*" +syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent +syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite +syn match gitcommitOnBranch "\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite +syn match gitcommitBranch "[^ ']\+" contained +syn match gitcommitNoBranch "\%(^# \)\@<=Not currently on any branch." contained containedin=gitcommitComment +syn match gitcommitHeader "\%(^# \)\@<=.*:$" contained containedin=gitcommitComment +syn region gitcommitAuthor matchgroup=gitCommitHeader start=/\%(^# \)\@<=\%(Author\|Committer\):/ end=/$/ keepend oneline contained containedin=gitcommitComment transparent +syn match gitcommitNoChanges "\%(^# \)\@<=No changes$" contained containedin=gitcommitComment + +syn region gitcommitUntracked start=/^# Untracked files:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUntrackedFile fold +syn match gitcommitUntrackedFile "\t\@<=.*" contained + +syn region gitcommitDiscarded start=/^# Change\%(s not staged for commit\|d but not updated\):/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitDiscardedType fold +syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitSelectedType fold +syn region gitcommitUnmerged start=/^# Unmerged paths:/ end=/^#$\|^#\@!/ contains=gitcommitHeader,gitcommitHead,gitcommitUnmergedType fold + + +syn match gitcommitDiscardedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitDiscardedFile skipwhite +syn match gitcommitSelectedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite +syn match gitcommitUnmergedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitUnmergedFile skipwhite +syn match gitcommitDiscardedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitDiscardedArrow +syn match gitcommitSelectedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow +syn match gitcommitUnmergedFile ".\{-\}\%($\| -> \)\@=" contained nextgroup=gitcommitSelectedArrow +syn match gitcommitDiscardedArrow " -> " contained nextgroup=gitcommitDiscardedFile +syn match gitcommitSelectedArrow " -> " contained nextgroup=gitcommitSelectedFile +syn match gitcommitUnmergedArrow " -> " contained nextgroup=gitcommitSelectedFile + +syn match gitcommitWarning "\%^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl +syn match gitcommitWarning "^[^#].*: needs merge$" nextgroup=gitcommitWarning skipnl contained +syn match gitcommitWarning "^\%(no changes added to commit\|nothing \%(added \)\=to commit\)\>.*\%$" + +hi def link gitcommitSummary Keyword +hi def link gitcommitComment Comment +hi def link gitcommitUntracked gitcommitComment +hi def link gitcommitDiscarded gitcommitComment +hi def link gitcommitSelected gitcommitComment +hi def link gitcommitUnmerged gitcommitComment +hi def link gitcommitOnBranch Comment +hi def link gitcommitBranch Special +hi def link gitcommitNoBranch gitCommitBranch +hi def link gitcommitDiscardedType gitcommitType +hi def link gitcommitSelectedType gitcommitType +hi def link gitcommitUnmergedType gitcommitType +hi def link gitcommitType Type +hi def link gitcommitNoChanges gitcommitHeader +hi def link gitcommitHeader PreProc +hi def link gitcommitUntrackedFile gitcommitFile +hi def link gitcommitDiscardedFile gitcommitFile +hi def link gitcommitSelectedFile gitcommitFile +hi def link gitcommitUnmergedFile gitcommitFile +hi def link gitcommitFile Constant +hi def link gitcommitDiscardedArrow gitcommitArrow +hi def link gitcommitSelectedArrow gitcommitArrow +hi def link gitcommitUnmergedArrow gitcommitArrow +hi def link gitcommitArrow gitcommitComment +"hi def link gitcommitOverflow Error +hi def link gitcommitBlank Error + +let b:current_syntax = "gitcommit" + +endif diff --git a/syntax/gitconfig.vim b/syntax/gitconfig.vim new file mode 100644 index 000000000..49b992b04 --- /dev/null +++ b/syntax/gitconfig.vim @@ -0,0 +1,42 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim syntax file +" Language: git config file +" Maintainer: Tim Pope +" Filenames: gitconfig, .gitconfig, *.git/config +" Last Change: 2010 May 21 + +if exists("b:current_syntax") + finish +endif + +setlocal iskeyword+=- +setlocal iskeyword-=_ +syn case ignore +syn sync minlines=10 + +syn match gitconfigComment "[#;].*" +syn match gitconfigSection "\%(^\s*\)\@<=\[[a-z0-9.-]\+\]" +syn match gitconfigSection '\%(^\s*\)\@<=\[[a-z0-9.-]\+ \+\"\%([^\\"]\|\\.\)*"\]' +syn match gitconfigVariable "\%(^\s*\)\@<=\a\k*\%(\s*\%([=#;]\|$\)\)\@=" nextgroup=gitconfigAssignment skipwhite +syn region gitconfigAssignment matchgroup=gitconfigNone start=+=\s*+ skip=+\\+ end=+\s*$+ contained contains=gitconfigBoolean,gitconfigNumber,gitConfigString,gitConfigEscape,gitConfigError,gitconfigComment keepend +syn keyword gitconfigBoolean true false yes no contained +syn match gitconfigNumber "\d\+" contained +syn region gitconfigString matchgroup=gitconfigDelim start=+"+ skip=+\\+ end=+"+ matchgroup=gitconfigError end=+[^\\"]\%#\@!$+ contained contains=gitconfigEscape,gitconfigEscapeError +syn match gitconfigError +\\.+ contained +syn match gitconfigEscape +\\[\\"ntb]+ contained +syn match gitconfigEscape +\\$+ contained + +hi def link gitconfigComment Comment +hi def link gitconfigSection Keyword +hi def link gitconfigVariable Identifier +hi def link gitconfigBoolean Boolean +hi def link gitconfigNumber Number +hi def link gitconfigString String +hi def link gitconfigDelim Delimiter +hi def link gitconfigEscape Delimiter +hi def link gitconfigError Error + +let b:current_syntax = "gitconfig" + +endif diff --git a/syntax/gitrebase.vim b/syntax/gitrebase.vim new file mode 100644 index 000000000..3a66f0a22 --- /dev/null +++ b/syntax/gitrebase.vim @@ -0,0 +1,44 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim syntax file +" Language: git rebase --interactive +" Maintainer: Tim Pope +" Filenames: git-rebase-todo +" Last Change: 2013 May 30 + +if exists("b:current_syntax") + finish +endif + +syn case match + +syn match gitrebaseHash "\v<\x{7,40}>" contained +syn match gitrebaseCommit "\v<\x{7,40}>" nextgroup=gitrebaseSummary skipwhite +syn match gitrebasePick "\v^p%(ick)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseReword "\v^r%(eword)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseEdit "\v^e%(dit)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseSquash "\v^s%(quash)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseFixup "\v^f%(ixup)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseExec "\v^%(x|exec)>" nextgroup=gitrebaseCommand skipwhite +syn match gitrebaseDrop "\v^d%(rop)=>" nextgroup=gitrebaseCommit skipwhite +syn match gitrebaseSummary ".*" contains=gitrebaseHash contained +syn match gitrebaseCommand ".*" contained +syn match gitrebaseComment "^\s*#.*" contains=gitrebaseHash +syn match gitrebaseSquashError "\v%^%(s%(quash)=>|f%(ixup)=>)" nextgroup=gitrebaseCommit skipwhite + +hi def link gitrebaseCommit gitrebaseHash +hi def link gitrebaseHash Identifier +hi def link gitrebasePick Statement +hi def link gitrebaseReword Number +hi def link gitrebaseEdit PreProc +hi def link gitrebaseSquash Type +hi def link gitrebaseFixup Special +hi def link gitrebaseExec Function +hi def link gitrebaseDrop Comment +hi def link gitrebaseSummary String +hi def link gitrebaseComment Comment +hi def link gitrebaseSquashError Error + +let b:current_syntax = "gitrebase" + +endif diff --git a/syntax/gitsendemail.vim b/syntax/gitsendemail.vim new file mode 100644 index 000000000..756f5da22 --- /dev/null +++ b/syntax/gitsendemail.vim @@ -0,0 +1,27 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1 + +" Vim syntax file +" Language: git send-email message +" Maintainer: Tim Pope +" Filenames: .gitsendemail.* +" Last Change: 2010 May 21 + +if exists("b:current_syntax") + finish +endif + +runtime! syntax/mail.vim +unlet! b:current_syntax +syn include @gitsendemailDiff syntax/diff.vim +syn region gitsendemailDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^-- %/ fold contains=@gitsendemailDiff + +syn case match + +syn match gitsendemailComment "\%^From.*#.*" +syn match gitsendemailComment "^GIT:.*" + +hi def link gitsendemailComment Comment + +let b:current_syntax = "gitsendemail" + +endif diff --git a/syntax/glsl.vim b/syntax/glsl.vim new file mode 100644 index 000000000..73c2afa14 --- /dev/null +++ b/syntax/glsl.vim @@ -0,0 +1,679 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'glsl') == -1 + +" Language: OpenGL Shading Language +" Maintainer: Sergey Tikhomirov + +if exists("b:current_syntax") && b:current_syntax == "glsl" + finish +endif + +" Statements +syn keyword glslConditional if else switch case default +syn keyword glslRepeat for while do +syn keyword glslStatement discard return break continue + +" Comments +syn keyword glslTodo contained TODO FIXME XXX NOTE +syn region glslCommentL start="//" skip="\\$" end="$" keepend contains=glslTodo,@Spell +syn region glslComment matchgroup=glslCommentStart start="/\*" end="\*/" extend contains=glslTodo,@Spell + +" Preprocessor +syn region glslPreCondit start="^\s*#\s*\(if\|ifdef\|ifndef\|else\|elif\|endif\)" skip="\\$" end="$" keepend +syn region glslDefine start="^\s*#\s*\(define\|undef\)" skip="\\$" end="$" keepend +syn keyword glslTokenConcat ## +syn keyword glslPredefinedMacro __LINE__ __FILE__ __VERSION__ GL_ES +syn region glslPreProc start="^\s*#\s*\(error\|pragma\|extension\|version\|line\)" skip="\\$" end="$" keepend + +" Boolean Constants +syn keyword glslBoolean true false + +" Integer Numbers +syn match glslDecimalInt display "\<\(0\|[1-9]\d*\)[uU]\?" +syn match glslOctalInt display "\<0\o\+[uU]\?" +syn match glslHexInt display "\<0[xX]\x\+[uU]\?" + +" Float Numbers +syn match glslFloat display "\<\d\+\.\([eE][+-]\=\d\+\)\=\(lf\|LF\|f\|F\)\=" +syn match glslFloat display "\<\.\d\+\([eE][+-]\=\d\+\)\=\(lf\|LF\|f\|F\)\=" +syn match glslFloat display "\<\d\+[eE][+-]\=\d\+\(lf\|LF\|f\|F\)\=" +syn match glslFloat display "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=\(lf\|LF\|f\|F\)\=" + +" Swizzles +syn match glslSwizzle display /\.[xyzw]\{1,4\}\>/ +syn match glslSwizzle display /\.[rgba]\{1,4\}\>/ +syn match glslSwizzle display /\.[stpq]\{1,4\}\>/ + +" Structure +syn keyword glslStructure struct nextgroup=glslIdentifier skipwhite skipempty + +syn match glslIdentifier contains=glslIdentifierPrime "\%([a-zA-Z_]\)\%([a-zA-Z0-9_]\)*" display contained + +" Types +syn keyword glslType atomic_uint +syn keyword glslType bool +syn keyword glslType bvec2 +syn keyword glslType bvec3 +syn keyword glslType bvec4 +syn keyword glslType dmat2 +syn keyword glslType dmat2x2 +syn keyword glslType dmat2x3 +syn keyword glslType dmat2x4 +syn keyword glslType dmat3 +syn keyword glslType dmat3x2 +syn keyword glslType dmat3x3 +syn keyword glslType dmat3x4 +syn keyword glslType dmat4 +syn keyword glslType dmat4x2 +syn keyword glslType dmat4x3 +syn keyword glslType dmat4x4 +syn keyword glslType double +syn keyword glslType dvec2 +syn keyword glslType dvec3 +syn keyword glslType dvec4 +syn keyword glslType float +syn keyword glslType iimage1D +syn keyword glslType iimage1DArray +syn keyword glslType iimage2D +syn keyword glslType iimage2DArray +syn keyword glslType iimage2DMS +syn keyword glslType iimage2DMSArray +syn keyword glslType iimage2DRect +syn keyword glslType iimage3D +syn keyword glslType iimageBuffer +syn keyword glslType iimageCube +syn keyword glslType iimageCubeArray +syn keyword glslType image1D +syn keyword glslType image1DArray +syn keyword glslType image2D +syn keyword glslType image2DArray +syn keyword glslType image2DMS +syn keyword glslType image2DMSArray +syn keyword glslType image2DRect +syn keyword glslType image3D +syn keyword glslType imageBuffer +syn keyword glslType imageCube +syn keyword glslType imageCubeArray +syn keyword glslType int +syn keyword glslType isampler1D +syn keyword glslType isampler1DArray +syn keyword glslType isampler2D +syn keyword glslType isampler2DArray +syn keyword glslType isampler2DMS +syn keyword glslType isampler2DMSArray +syn keyword glslType isampler2DRect +syn keyword glslType isampler3D +syn keyword glslType isamplerBuffer +syn keyword glslType isamplerCube +syn keyword glslType isamplerCubeArray +syn keyword glslType ivec2 +syn keyword glslType ivec3 +syn keyword glslType ivec4 +syn keyword glslType mat2 +syn keyword glslType mat2x2 +syn keyword glslType mat2x3 +syn keyword glslType mat2x4 +syn keyword glslType mat3 +syn keyword glslType mat3x2 +syn keyword glslType mat3x3 +syn keyword glslType mat3x4 +syn keyword glslType mat4 +syn keyword glslType mat4x2 +syn keyword glslType mat4x3 +syn keyword glslType mat4x4 +syn keyword glslType sampler1D +syn keyword glslType sampler1DArray +syn keyword glslType sampler1DArrayShadow +syn keyword glslType sampler1DShadow +syn keyword glslType sampler2D +syn keyword glslType sampler2DArray +syn keyword glslType sampler2DArrayShadow +syn keyword glslType sampler2DMS +syn keyword glslType sampler2DMSArray +syn keyword glslType sampler2DRect +syn keyword glslType sampler2DRectShadow +syn keyword glslType sampler2DShadow +syn keyword glslType sampler3D +syn keyword glslType samplerBuffer +syn keyword glslType samplerCube +syn keyword glslType samplerCubeArray +syn keyword glslType samplerCubeArrayShadow +syn keyword glslType samplerCubeShadow +syn keyword glslType uimage1D +syn keyword glslType uimage1DArray +syn keyword glslType uimage2D +syn keyword glslType uimage2DArray +syn keyword glslType uimage2DMS +syn keyword glslType uimage2DMSArray +syn keyword glslType uimage2DRect +syn keyword glslType uimage3D +syn keyword glslType uimageBuffer +syn keyword glslType uimageCube +syn keyword glslType uimageCubeArray +syn keyword glslType uint +syn keyword glslType usampler1D +syn keyword glslType usampler1DArray +syn keyword glslType usampler2D +syn keyword glslType usampler2DArray +syn keyword glslType usampler2DMS +syn keyword glslType usampler2DMSArray +syn keyword glslType usampler2DRect +syn keyword glslType usampler3D +syn keyword glslType usamplerBuffer +syn keyword glslType usamplerCube +syn keyword glslType usamplerCubeArray +syn keyword glslType uvec2 +syn keyword glslType uvec3 +syn keyword glslType uvec4 +syn keyword glslType vec2 +syn keyword glslType vec3 +syn keyword glslType vec4 +syn keyword glslType void + +" Qualifiers +syn keyword glslQualifier align +syn keyword glslQualifier attribute +syn keyword glslQualifier binding +syn keyword glslQualifier buffer +syn keyword glslQualifier ccw +syn keyword glslQualifier centroid +syn keyword glslQualifier centroid varying +syn keyword glslQualifier coherent +syn keyword glslQualifier column_major +syn keyword glslQualifier const +syn keyword glslQualifier cw +syn keyword glslQualifier depth_any +syn keyword glslQualifier depth_greater +syn keyword glslQualifier depth_less +syn keyword glslQualifier depth_unchanged +syn keyword glslQualifier early_fragment_tests +syn keyword glslQualifier equal_spacing +syn keyword glslQualifier flat +syn keyword glslQualifier fractional_even_spacing +syn keyword glslQualifier fractional_odd_spacing +syn keyword glslQualifier highp +syn keyword glslQualifier in +syn keyword glslQualifier index +syn keyword glslQualifier inout +syn keyword glslQualifier invariant +syn keyword glslQualifier invocations +syn keyword glslQualifier isolines +syn keyword glslQualifier layout +syn keyword glslQualifier line_strip +syn keyword glslQualifier lines +syn keyword glslQualifier lines_adjacency +syn keyword glslQualifier local_size_x +syn keyword glslQualifier local_size_y +syn keyword glslQualifier local_size_z +syn keyword glslQualifier location +syn keyword glslQualifier lowp +syn keyword glslQualifier max_vertices +syn keyword glslQualifier mediump +syn keyword glslQualifier noperspective +syn keyword glslQualifier offset +syn keyword glslQualifier origin_upper_left +syn keyword glslQualifier out +syn keyword glslQualifier packed +syn keyword glslQualifier patch +syn keyword glslQualifier pixel_center_integer +syn keyword glslQualifier point_mode +syn keyword glslQualifier points +syn keyword glslQualifier precise +syn keyword glslQualifier precision +syn keyword glslQualifier quads +syn keyword glslQualifier r11f_g11f_b10f +syn keyword glslQualifier r16 +syn keyword glslQualifier r16_snorm +syn keyword glslQualifier r16f +syn keyword glslQualifier r16i +syn keyword glslQualifier r16ui +syn keyword glslQualifier r32f +syn keyword glslQualifier r32i +syn keyword glslQualifier r32ui +syn keyword glslQualifier r8 +syn keyword glslQualifier r8_snorm +syn keyword glslQualifier r8i +syn keyword glslQualifier r8ui +syn keyword glslQualifier readonly +syn keyword glslQualifier restrict +syn keyword glslQualifier rg16 +syn keyword glslQualifier rg16_snorm +syn keyword glslQualifier rg16f +syn keyword glslQualifier rg16i +syn keyword glslQualifier rg16ui +syn keyword glslQualifier rg32f +syn keyword glslQualifier rg32i +syn keyword glslQualifier rg32ui +syn keyword glslQualifier rg8 +syn keyword glslQualifier rg8_snorm +syn keyword glslQualifier rg8i +syn keyword glslQualifier rg8ui +syn keyword glslQualifier rgb10_a2 +syn keyword glslQualifier rgb10_a2ui +syn keyword glslQualifier rgba16 +syn keyword glslQualifier rgba16_snorm +syn keyword glslQualifier rgba16f +syn keyword glslQualifier rgba16i +syn keyword glslQualifier rgba16ui +syn keyword glslQualifier rgba32f +syn keyword glslQualifier rgba32i +syn keyword glslQualifier rgba32ui +syn keyword glslQualifier rgba8 +syn keyword glslQualifier rgba8_snorm +syn keyword glslQualifier rgba8i +syn keyword glslQualifier rgba8ui +syn keyword glslQualifier row_major +syn keyword glslQualifier sample +syn keyword glslQualifier shared +syn keyword glslQualifier smooth +syn keyword glslQualifier std140 +syn keyword glslQualifier std430 +syn keyword glslQualifier stream +syn keyword glslQualifier triangle_strip +syn keyword glslQualifier triangles +syn keyword glslQualifier triangles_adjacency +syn keyword glslQualifier uniform +syn keyword glslQualifier varying +syn keyword glslQualifier vertices +syn keyword glslQualifier volatile +syn keyword glslQualifier writeonly +syn keyword glslQualifier xfb_buffer +syn keyword glslQualifier xfb_stride +syn keyword glslQualifier xfb_offset + +" Built-in Constants +syn keyword glslBuiltinConstant gl_CullDistance +syn keyword glslBuiltinConstant gl_MaxAtomicCounterBindings +syn keyword glslBuiltinConstant gl_MaxAtomicCounterBufferSize +syn keyword glslBuiltinConstant gl_MaxClipDistances +syn keyword glslBuiltinConstant gl_MaxClipPlanes +syn keyword glslBuiltinConstant gl_MaxCombinedAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxCombinedAtomicCounters +syn keyword glslBuiltinConstant gl_MaxCombinedClipAndCullDistances +syn keyword glslBuiltinConstant gl_MaxCombinedImageUniforms +syn keyword glslBuiltinConstant gl_MaxCombinedImageUnitsAndFragmentOutputs +syn keyword glslBuiltinConstant gl_MaxCombinedShaderOutputResources +syn keyword glslBuiltinConstant gl_MaxCombinedTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxComputeAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxComputeAtomicCounters +syn keyword glslBuiltinConstant gl_MaxComputeImageUniforms +syn keyword glslBuiltinConstant gl_MaxComputeTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxComputeUniformComponents +syn keyword glslBuiltinConstant gl_MaxComputeWorkGroupCount +syn keyword glslBuiltinConstant gl_MaxComputeWorkGroupSize +syn keyword glslBuiltinConstant gl_MaxCullDistances +syn keyword glslBuiltinConstant gl_MaxDrawBuffers +syn keyword glslBuiltinConstant gl_MaxFragmentAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxFragmentAtomicCounters +syn keyword glslBuiltinConstant gl_MaxFragmentImageUniforms +syn keyword glslBuiltinConstant gl_MaxFragmentInputComponents +syn keyword glslBuiltinConstant gl_MaxFragmentInputVectors +syn keyword glslBuiltinConstant gl_MaxFragmentUniformComponents +syn keyword glslBuiltinConstant gl_MaxFragmentUniformVectors +syn keyword glslBuiltinConstant gl_MaxGeometryAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxGeometryAtomicCounters +syn keyword glslBuiltinConstant gl_MaxGeometryImageUniforms +syn keyword glslBuiltinConstant gl_MaxGeometryInputComponents +syn keyword glslBuiltinConstant gl_MaxGeometryOutputComponents +syn keyword glslBuiltinConstant gl_MaxGeometryOutputVertices +syn keyword glslBuiltinConstant gl_MaxGeometryTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxGeometryTotalOutputComponents +syn keyword glslBuiltinConstant gl_MaxGeometryUniformComponents +syn keyword glslBuiltinConstant gl_MaxGeometryVaryingComponents +syn keyword glslBuiltinConstant gl_MaxImageSamples +syn keyword glslBuiltinConstant gl_MaxImageUnits +syn keyword glslBuiltinConstant gl_MaxLights +syn keyword glslBuiltinConstant gl_MaxPatchVertices +syn keyword glslBuiltinConstant gl_MaxProgramTexelOffset +syn keyword glslBuiltinConstant gl_MaxSamples +syn keyword glslBuiltinConstant gl_MaxTessControlAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxTessControlAtomicCounters +syn keyword glslBuiltinConstant gl_MaxTessControlImageUniforms +syn keyword glslBuiltinConstant gl_MaxTessControlInputComponents +syn keyword glslBuiltinConstant gl_MaxTessControlOutputComponents +syn keyword glslBuiltinConstant gl_MaxTessControlTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxTessControlTotalOutputComponents +syn keyword glslBuiltinConstant gl_MaxTessControlUniformComponents +syn keyword glslBuiltinConstant gl_MaxTessEvaluationAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxTessEvaluationAtomicCounters +syn keyword glslBuiltinConstant gl_MaxTessEvaluationImageUniforms +syn keyword glslBuiltinConstant gl_MaxTessEvaluationInputComponents +syn keyword glslBuiltinConstant gl_MaxTessEvaluationOutputComponents +syn keyword glslBuiltinConstant gl_MaxTessEvaluationTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxTessEvaluationUniformComponents +syn keyword glslBuiltinConstant gl_MaxTessGenLevel +syn keyword glslBuiltinConstant gl_MaxTessPatchComponents +syn keyword glslBuiltinConstant gl_MaxTextureCoords +syn keyword glslBuiltinConstant gl_MaxTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxTextureUnits +syn keyword glslBuiltinConstant gl_MaxTransformFeedbackBuffers +syn keyword glslBuiltinConstant gl_MaxTransformFeedbackInterleavedComponents +syn keyword glslBuiltinConstant gl_MaxVaryingComponents +syn keyword glslBuiltinConstant gl_MaxVaryingFloats +syn keyword glslBuiltinConstant gl_MaxVaryingVectors +syn keyword glslBuiltinConstant gl_MaxVertexAtomicCounterBuffers +syn keyword glslBuiltinConstant gl_MaxVertexAtomicCounters +syn keyword glslBuiltinConstant gl_MaxVertexAttribs +syn keyword glslBuiltinConstant gl_MaxVertexImageUniforms +syn keyword glslBuiltinConstant gl_MaxVertexOutputComponents +syn keyword glslBuiltinConstant gl_MaxVertexOutputVectors +syn keyword glslBuiltinConstant gl_MaxVertexTextureImageUnits +syn keyword glslBuiltinConstant gl_MaxVertexUniformComponents +syn keyword glslBuiltinConstant gl_MaxVertexUniformVectors +syn keyword glslBuiltinConstant gl_MaxViewports +syn keyword glslBuiltinConstant gl_MinProgramTexelOffset + +" Built-in Variables +syn keyword glslBuiltinVariable gl_BackColor +syn keyword glslBuiltinVariable gl_BackLightModelProduct +syn keyword glslBuiltinVariable gl_BackLightProduct +syn keyword glslBuiltinVariable gl_BackLightProduct +syn keyword glslBuiltinVariable gl_BackMaterial +syn keyword glslBuiltinVariable gl_BackSecondaryColor +syn keyword glslBuiltinVariable gl_ClipDistance +syn keyword glslBuiltinVariable gl_ClipPlane +syn keyword glslBuiltinVariable gl_ClipVertex +syn keyword glslBuiltinVariable gl_Color +syn keyword glslBuiltinVariable gl_DepthRange +syn keyword glslBuiltinVariable gl_EyePlaneQ +syn keyword glslBuiltinVariable gl_EyePlaneR +syn keyword glslBuiltinVariable gl_EyePlaneS +syn keyword glslBuiltinVariable gl_EyePlaneT +syn keyword glslBuiltinVariable gl_Fog +syn keyword glslBuiltinVariable gl_FogCoord +syn keyword glslBuiltinVariable gl_FogFragCoord +syn keyword glslBuiltinVariable gl_FragColor +syn keyword glslBuiltinVariable gl_FragCoord +syn keyword glslBuiltinVariable gl_FragData +syn keyword glslBuiltinVariable gl_FragDepth +syn keyword glslBuiltinVariable gl_FrontColor +syn keyword glslBuiltinVariable gl_FrontFacing +syn keyword glslBuiltinVariable gl_FrontLightModelProduct +syn keyword glslBuiltinVariable gl_FrontLightProduct +syn keyword glslBuiltinVariable gl_FrontMaterial +syn keyword glslBuiltinVariable gl_FrontSecondaryColor +syn keyword glslBuiltinVariable gl_GlobalInvocationID +syn keyword glslBuiltinVariable gl_HelperInvocation +syn keyword glslBuiltinVariable gl_InstanceID +syn keyword glslBuiltinVariable gl_InvocationID +syn keyword glslBuiltinVariable gl_Layer +syn keyword glslBuiltinVariable gl_LightModel +syn keyword glslBuiltinVariable gl_LightSource +syn keyword glslBuiltinVariable gl_LocalInvocationID +syn keyword glslBuiltinVariable gl_LocalInvocationIndex +syn keyword glslBuiltinVariable gl_ModelViewMatrix +syn keyword glslBuiltinVariable gl_ModelViewMatrixInverse +syn keyword glslBuiltinVariable gl_ModelViewMatrixInverseTranspose +syn keyword glslBuiltinVariable gl_ModelViewMatrixTranspose +syn keyword glslBuiltinVariable gl_ModelViewProjectionMatrix +syn keyword glslBuiltinVariable gl_ModelViewProjectionMatrixInverse +syn keyword glslBuiltinVariable gl_ModelViewProjectionMatrixInverseTranspose +syn keyword glslBuiltinVariable gl_ModelViewProjectionMatrixTranspose +syn keyword glslBuiltinVariable gl_MultiTexCoord0 +syn keyword glslBuiltinVariable gl_MultiTexCoord1 +syn keyword glslBuiltinVariable gl_MultiTexCoord2 +syn keyword glslBuiltinVariable gl_MultiTexCoord3 +syn keyword glslBuiltinVariable gl_MultiTexCoord4 +syn keyword glslBuiltinVariable gl_MultiTexCoord5 +syn keyword glslBuiltinVariable gl_MultiTexCoord6 +syn keyword glslBuiltinVariable gl_MultiTexCoord7 +syn keyword glslBuiltinVariable gl_Normal +syn keyword glslBuiltinVariable gl_NormalMatrix +syn keyword glslBuiltinVariable gl_NormalScale +syn keyword glslBuiltinVariable gl_NumSamples +syn keyword glslBuiltinVariable gl_NumWorkGroups +syn keyword glslBuiltinVariable gl_ObjectPlaneQ +syn keyword glslBuiltinVariable gl_ObjectPlaneR +syn keyword glslBuiltinVariable gl_ObjectPlaneS +syn keyword glslBuiltinVariable gl_ObjectPlaneT +syn keyword glslBuiltinVariable gl_PatchVerticesIn +syn keyword glslBuiltinVariable gl_Point +syn keyword glslBuiltinVariable gl_PointCoord +syn keyword glslBuiltinVariable gl_PointSize +syn keyword glslBuiltinVariable gl_Position +syn keyword glslBuiltinVariable gl_PrimitiveID +syn keyword glslBuiltinVariable gl_PrimitiveIDIn +syn keyword glslBuiltinVariable gl_ProjectionMatrix +syn keyword glslBuiltinVariable gl_ProjectionMatrixInverse +syn keyword glslBuiltinVariable gl_ProjectionMatrixInverseTranspose +syn keyword glslBuiltinVariable gl_ProjectionMatrixTranspose +syn keyword glslBuiltinVariable gl_SampleID +syn keyword glslBuiltinVariable gl_SampleMask +syn keyword glslBuiltinVariable gl_SampleMaskIn +syn keyword glslBuiltinVariable gl_SamplePosition +syn keyword glslBuiltinVariable gl_SecondaryColor +syn keyword glslBuiltinVariable gl_TessCoord +syn keyword glslBuiltinVariable gl_TessLevelInner +syn keyword glslBuiltinVariable gl_TessLevelOuter +syn keyword glslBuiltinVariable gl_TexCoord +syn keyword glslBuiltinVariable gl_TextureEnvColor +syn keyword glslBuiltinVariable gl_TextureMatrix +syn keyword glslBuiltinVariable gl_TextureMatrixInverse +syn keyword glslBuiltinVariable gl_TextureMatrixInverseTranspose +syn keyword glslBuiltinVariable gl_TextureMatrixTranspose +syn keyword glslBuiltinVariable gl_Vertex +syn keyword glslBuiltinVariable gl_VertexID +syn keyword glslBuiltinVariable gl_ViewportIndex +syn keyword glslBuiltinVariable gl_WorkGroupID +syn keyword glslBuiltinVariable gl_WorkGroupSize +syn keyword glslBuiltinVariable gl_in +syn keyword glslBuiltinVariable gl_out + +" Built-in Functions +syn keyword glslBuiltinFunction EmitStreamVertex +syn keyword glslBuiltinFunction EmitVertex +syn keyword glslBuiltinFunction EndPrimitive +syn keyword glslBuiltinFunction EndStreamPrimitive +syn keyword glslBuiltinFunction abs +syn keyword glslBuiltinFunction acos +syn keyword glslBuiltinFunction acosh +syn keyword glslBuiltinFunction all +syn keyword glslBuiltinFunction any +syn keyword glslBuiltinFunction asin +syn keyword glslBuiltinFunction asinh +syn keyword glslBuiltinFunction atan +syn keyword glslBuiltinFunction atanh +syn keyword glslBuiltinFunction atomicAdd +syn keyword glslBuiltinFunction atomicAnd +syn keyword glslBuiltinFunction atomicCompSwap +syn keyword glslBuiltinFunction atomicCounter +syn keyword glslBuiltinFunction atomicCounterDecrement +syn keyword glslBuiltinFunction atomicCounterIncrement +syn keyword glslBuiltinFunction atomicExchange +syn keyword glslBuiltinFunction atomicMax +syn keyword glslBuiltinFunction atomicMin +syn keyword glslBuiltinFunction atomicOr +syn keyword glslBuiltinFunction atomicXor +syn keyword glslBuiltinFunction barrier +syn keyword glslBuiltinFunction bitCount +syn keyword glslBuiltinFunction bitfieldExtract +syn keyword glslBuiltinFunction bitfieldInsert +syn keyword glslBuiltinFunction bitfieldReverse +syn keyword glslBuiltinFunction ceil +syn keyword glslBuiltinFunction clamp +syn keyword glslBuiltinFunction cos +syn keyword glslBuiltinFunction cosh +syn keyword glslBuiltinFunction cross +syn keyword glslBuiltinFunction dFdx +syn keyword glslBuiltinFunction dFdxCoarse +syn keyword glslBuiltinFunction dFdxFine +syn keyword glslBuiltinFunction dFdy +syn keyword glslBuiltinFunction dFdyCoarse +syn keyword glslBuiltinFunction dFdyFine +syn keyword glslBuiltinFunction degrees +syn keyword glslBuiltinFunction determinant +syn keyword glslBuiltinFunction distance +syn keyword glslBuiltinFunction dot +syn keyword glslBuiltinFunction equal +syn keyword glslBuiltinFunction exp +syn keyword glslBuiltinFunction exp2 +syn keyword glslBuiltinFunction faceforward +syn keyword glslBuiltinFunction findLSB +syn keyword glslBuiltinFunction findMSB +syn keyword glslBuiltinFunction floatBitsToInt +syn keyword glslBuiltinFunction floatBitsToUint +syn keyword glslBuiltinFunction floor +syn keyword glslBuiltinFunction fma +syn keyword glslBuiltinFunction fract +syn keyword glslBuiltinFunction frexp +syn keyword glslBuiltinFunction ftransform +syn keyword glslBuiltinFunction fwidth +syn keyword glslBuiltinFunction fwidthCoarse +syn keyword glslBuiltinFunction fwidthFine +syn keyword glslBuiltinFunction greaterThan +syn keyword glslBuiltinFunction greaterThanEqual +syn keyword glslBuiltinFunction groupMemoryBarrier +syn keyword glslBuiltinFunction imageAtomicAdd +syn keyword glslBuiltinFunction imageAtomicAnd +syn keyword glslBuiltinFunction imageAtomicCompSwap +syn keyword glslBuiltinFunction imageAtomicExchange +syn keyword glslBuiltinFunction imageAtomicMax +syn keyword glslBuiltinFunction imageAtomicMin +syn keyword glslBuiltinFunction imageAtomicOr +syn keyword glslBuiltinFunction imageAtomicXor +syn keyword glslBuiltinFunction imageLoad +syn keyword glslBuiltinFunction imageSize +syn keyword glslBuiltinFunction imageStore +syn keyword glslBuiltinFunction imulExtended +syn keyword glslBuiltinFunction intBitsToFloat +syn keyword glslBuiltinFunction interpolateAtCentroid +syn keyword glslBuiltinFunction interpolateAtOffset +syn keyword glslBuiltinFunction interpolateAtSample +syn keyword glslBuiltinFunction inverse +syn keyword glslBuiltinFunction inversesqrt +syn keyword glslBuiltinFunction isinf +syn keyword glslBuiltinFunction isnan +syn keyword glslBuiltinFunction ldexp +syn keyword glslBuiltinFunction length +syn keyword glslBuiltinFunction lessThan +syn keyword glslBuiltinFunction lessThanEqual +syn keyword glslBuiltinFunction log +syn keyword glslBuiltinFunction log2 +syn keyword glslBuiltinFunction matrixCompMult +syn keyword glslBuiltinFunction max +syn keyword glslBuiltinFunction memoryBarrier +syn keyword glslBuiltinFunction memoryBarrierAtomicCounter +syn keyword glslBuiltinFunction memoryBarrierBuffer +syn keyword glslBuiltinFunction memoryBarrierImage +syn keyword glslBuiltinFunction memoryBarrierShared +syn keyword glslBuiltinFunction min +syn keyword glslBuiltinFunction mix +syn keyword glslBuiltinFunction mod +syn keyword glslBuiltinFunction modf +syn keyword glslBuiltinFunction noise1 +syn keyword glslBuiltinFunction noise2 +syn keyword glslBuiltinFunction noise3 +syn keyword glslBuiltinFunction noise4 +syn keyword glslBuiltinFunction normalize +syn keyword glslBuiltinFunction not +syn keyword glslBuiltinFunction notEqual +syn keyword glslBuiltinFunction outerProduct +syn keyword glslBuiltinFunction packDouble2x32 +syn keyword glslBuiltinFunction packHalf2x16 +syn keyword glslBuiltinFunction packSnorm2x16 +syn keyword glslBuiltinFunction packSnorm4x8 +syn keyword glslBuiltinFunction packUnorm2x16 +syn keyword glslBuiltinFunction packUnorm4x8 +syn keyword glslBuiltinFunction pow +syn keyword glslBuiltinFunction radians +syn keyword glslBuiltinFunction reflect +syn keyword glslBuiltinFunction refract +syn keyword glslBuiltinFunction round +syn keyword glslBuiltinFunction roundEven +syn keyword glslBuiltinFunction shadow1D +syn keyword glslBuiltinFunction shadow1DLod +syn keyword glslBuiltinFunction shadow1DProj +syn keyword glslBuiltinFunction shadow1DProjLod +syn keyword glslBuiltinFunction shadow2D +syn keyword glslBuiltinFunction shadow2DLod +syn keyword glslBuiltinFunction shadow2DProj +syn keyword glslBuiltinFunction shadow2DProjLod +syn keyword glslBuiltinFunction sign +syn keyword glslBuiltinFunction sin +syn keyword glslBuiltinFunction sinh +syn keyword glslBuiltinFunction smoothstep +syn keyword glslBuiltinFunction sqrt +syn keyword glslBuiltinFunction step +syn keyword glslBuiltinFunction tan +syn keyword glslBuiltinFunction tanh +syn keyword glslBuiltinFunction texelFetch +syn keyword glslBuiltinFunction texelFetchOffset +syn keyword glslBuiltinFunction texture +syn keyword glslBuiltinFunction texture1D +syn keyword glslBuiltinFunction texture1DLod +syn keyword glslBuiltinFunction texture1DProj +syn keyword glslBuiltinFunction texture1DProjLod +syn keyword glslBuiltinFunction texture2D +syn keyword glslBuiltinFunction texture2DLod +syn keyword glslBuiltinFunction texture2DProj +syn keyword glslBuiltinFunction texture2DProjLod +syn keyword glslBuiltinFunction texture3D +syn keyword glslBuiltinFunction texture3DLod +syn keyword glslBuiltinFunction texture3DProj +syn keyword glslBuiltinFunction texture3DProjLod +syn keyword glslBuiltinFunction textureCube +syn keyword glslBuiltinFunction textureCubeLod +syn keyword glslBuiltinFunction textureGather +syn keyword glslBuiltinFunction textureGatherOffset +syn keyword glslBuiltinFunction textureGatherOffsets +syn keyword glslBuiltinFunction textureGrad +syn keyword glslBuiltinFunction textureGradOffset +syn keyword glslBuiltinFunction textureLod +syn keyword glslBuiltinFunction textureLodOffset +syn keyword glslBuiltinFunction textureOffset +syn keyword glslBuiltinFunction textureProj +syn keyword glslBuiltinFunction textureProjGrad +syn keyword glslBuiltinFunction textureProjGradOffset +syn keyword glslBuiltinFunction textureProjLod +syn keyword glslBuiltinFunction textureProjLodOffset +syn keyword glslBuiltinFunction textureProjOffset +syn keyword glslBuiltinFunction textureQueryLevels +syn keyword glslBuiltinFunction textureQueryLod +syn keyword glslBuiltinFunction textureSize +syn keyword glslBuiltinFunction transpose +syn keyword glslBuiltinFunction trunc +syn keyword glslBuiltinFunction uaddCarry +syn keyword glslBuiltinFunction uintBitsToFloat +syn keyword glslBuiltinFunction umulExtended +syn keyword glslBuiltinFunction unpackDouble2x32 +syn keyword glslBuiltinFunction unpackHalf2x16 +syn keyword glslBuiltinFunction unpackSnorm2x16 +syn keyword glslBuiltinFunction unpackSnorm4x8 +syn keyword glslBuiltinFunction unpackUnorm2x16 +syn keyword glslBuiltinFunction unpackUnorm4x8 +syn keyword glslBuiltinFunction usubBorrow + +hi def link glslConditional Conditional +hi def link glslRepeat Repeat +hi def link glslStatement Statement +hi def link glslTodo Todo +hi def link glslCommentL glslComment +hi def link glslCommentStart glslComment +hi def link glslComment Comment +hi def link glslPreCondit PreCondit +hi def link glslDefine Define +hi def link glslTokenConcat glslPreProc +hi def link glslPredefinedMacro Macro +hi def link glslPreProc PreProc +hi def link glslBoolean Boolean +hi def link glslDecimalInt glslInteger +hi def link glslOctalInt glslInteger +hi def link glslHexInt glslInteger +hi def link glslInteger Number +hi def link glslFloat Float +hi def link glslIdentifierPrime glslIdentifier +hi def link glslIdentifier Identifier +hi def link glslStructure Structure +hi def link glslType Type +hi def link glslQualifier StorageClass +hi def link glslBuiltinConstant Constant +hi def link glslBuiltinFunction Function +hi def link glslBuiltinVariable Identifier +hi def link glslSwizzle Identifier + +if !exists("b:current_syntax") + let b:current_syntax = "glsl" +endif + +" vim:set sts=2 sw=2 : + +endif diff --git a/syntax/gmpl.vim b/syntax/gmpl.vim new file mode 100644 index 000000000..2b8d7128c --- /dev/null +++ b/syntax/gmpl.vim @@ -0,0 +1,122 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'gmpl') == -1 + +" Vim syntax file +" Language: GMPL +" Maintainer: Mark Mba Wright +" Latest Revision: 9 July 2012 + +if exists("b:current_syntax") + finish +endif + +syn sync fromstart + + +syn match gmplArithmeticSetOperator "\.\." + +" Integer with - + or nothing in front +syn match gmplNumber '\d\+' +syn match gmplNumber '[-+]\d\+' + +" Floating point gmplNumber with decimal no E or e (+,-) +syn match gmplNumber '\d*\.\d\+' +syn match gmplNumber '[-+]\d*\.\d\+' + +" Floating point like gmplNumber with E and no decimal point (+,-) +syn match gmplNumber '[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+' +syn match gmplNumber '\d[[:digit:]]*[eE][\-+]\=\d\+' + +" Floating point like gmplNumber with E and decimal point (+,-) +syn match gmplNumber '[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' +syn match gmplNumber '\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+' +syn match gmplIndex /\<\%(in\>\)\@!\w*/ contained contains=gmplKeyword,gmplNumber +syn match gmplLabel '[a-zA-Z][a-zA-Z0-9_]*' +syn match gmplArithmeticOperator "[-+]" +syn match gmplArithmeticOperator "\.\=[*/\\^]" +syn match gmplRelationalOperator "[=~]=" +syn match gmplRelationalOperator "[<>]=\=" +" syn match gmplLogicalOperator "[&|~] + +" match indeces + +" comments +syn match gmplComment /\/\*.\{-}\*\// +syn region gmplComment start="/\*" end="\*/" +syn match gmplComment '#.\{-}$' + +" strings +syn region gmplString start="\"" end="\"" +syn region gmplString start="\'" end="\'" contains=gmplStringToken +syn match gmplStringToken '\%[a-z]' contained + +" Keywords +syn keyword gmplKeyword and else by if cross in diff inter div less mod union not within or symdiff then +syn keyword gmplKeyword minimize maximize solve +syn keyword gmplType set var param nextgroup=gmplLabel skipwhite + +" Regions +syn region gmplIndexExpression start="{" end="}" transparent contains=gmplIndex,gmplIndexExpression +syn region gmplIndexGroup start="\[" end="\]" transparent contains=gmplIndex +" syn region gmplParen start="(" end=")" + +"" catch errors caused by wrong parenthesis +syn match gmplParensError ")\|}\|\]" +syn match gmplParensErrA contained "\]" +syn match gmplParensErrC contained "}" + + +hi level1c ctermfg=brown guifg=brown +hi level2c ctermfg=darkgreen guifg=darkgreen gui=bold +hi level3c ctermfg=Darkblue guifg=Darkblue +hi level4c ctermfg=darkmagenta guifg=darkmagenta gui=bold +hi level5c ctermfg=darkcyan guifg=darkcyan +hi level6c ctermfg=white guifg=white gui=bold +hi level7c ctermfg=darkred guifg=darkred +hi level8c ctermfg=blue guifg=blue gui=bold +hi level9c ctermfg=darkgray guifg=darkgray +hi level10c ctermfg=brown guifg=brown gui=bold +hi level11c ctermfg=darkgreen guifg=darkgreen +hi level12c ctermfg=Darkblue guifg=Darkblue gui=bold +hi level13c ctermfg=darkmagenta guifg=darkmagenta +hi level14c ctermfg=darkcyan guifg=darkcyan gui=bold +hi level15c ctermfg=gray guifg=gray + +" These are the regions for each pair. +" This could be improved, perhaps, by makeing them match [ and { also, +" but I'm not going to take the time to figure out haw to make the +" end pattern match only the proper type. +syn region level1 matchgroup=level1c start=/(/ end=/)/ contains=TOP,level1,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level2 matchgroup=level2c start=/(/ end=/)/ contains=TOP,level2,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level3 matchgroup=level3c start=/(/ end=/)/ contains=TOP,level3,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level4 matchgroup=level4c start=/(/ end=/)/ contains=TOP,level4,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level5 matchgroup=level5c start=/(/ end=/)/ contains=TOP,level5,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level6 matchgroup=level6c start=/(/ end=/)/ contains=TOP,level6,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level7 matchgroup=level7c start=/(/ end=/)/ contains=TOP,level7,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level8 matchgroup=level8c start=/(/ end=/)/ contains=TOP,level8,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level9 matchgroup=level9c start=/(/ end=/)/ contains=TOP,level9,level10,level11,level12,level13,level14,level15, NoInParens +syn region level10 matchgroup=level10c start=/(/ end=/)/ contains=TOP,level10,level11,level12,level13,level14,level15, NoInParens +syn region level11 matchgroup=level11c start=/(/ end=/)/ contains=TOP,level11,level12,level13,level14,level15, NoInParens +syn region level12 matchgroup=level12c start=/(/ end=/)/ contains=TOP,level12,level13,level14,level15, NoInParens +syn region level13 matchgroup=level13c start=/(/ end=/)/ contains=TOP,level13,level14,level15, NoInParens +syn region level14 matchgroup=level14c start=/(/ end=/)/ contains=TOP,level14,level15, NoInParens +syn region level15 matchgroup=level15c start=/(/ end=/)/ contains=TOP,level15, NoInParens + +let b:current_syntax = "gmpl" + +hi def link gmplKeyword Keyword +hi def link gmplParensError Error +hi def link gmplParensErrA Error +hi def link gmplParensErrB Error +hi def link gmplParensErrC Error +" hi def link gmplIndexExpression Label +" hi def link gmplParen Label +" hi def link gmplIndexGroup Label +hi def link gmplIndex Identifier +hi def link gmplNumber Number +hi def link gmplComment Comment +hi def link gmplType Type +hi def link gmplLabel Keyword +hi def link gmplString String +hi def link gmplStringToken Special + +endif diff --git a/syntax/latextoc.vim b/syntax/latextoc.vim deleted file mode 100644 index 0faca7085..000000000 --- a/syntax/latextoc.vim +++ /dev/null @@ -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 diff --git a/syntax/slime.vim b/syntax/slime.vim new file mode 100644 index 000000000..57926691e --- /dev/null +++ b/syntax/slime.vim @@ -0,0 +1,106 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'slime') == -1 + +" Vim syntax file +" Language: slime +" Maintainer: Andrew Stone +" 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 "\\\@.*\(\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