diff --git a/README.md b/README.md index e0549b6..0bcd8f5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# vim-latex +# vimtex ## Introduction @@ -9,6 +9,8 @@ There exists several LaTeX plugins for vim, for instance: [vimscript#2945](http://www.vim.org/scripts/script.php?script_id=2945) - [LaTeX-Box](https://github.com/LaTeX-Box-Team/LaTeX-Box): [vimscript#3109](http://www.vim.org/scripts/script.php?script_id=3109) +- [vim-latex-live-preview](https://github.com/xuhdev/vim-latex-live-preview): + [vimscript#4524](http://www.vim.org/scripts/script.php?script_id=4524) I have been using both LaTeX-Suite and LaTeX-Box myself, but I found both of these to be relatively bulky and difficult to manage and extend. LaTeX-Box @@ -16,16 +18,12 @@ was supposed to be simple and lightweight, and I think it was close to being just that. However, after having worked on it for some time, I felt that much of the simplicity could be improved by a complete restructuring. -Enter vim-latex, which is a lightweight and simple plugin that provides LaTeX +Enter vimtex, which is a lightweight and simple plugin that provides LaTeX support for vim. It has most of the functionality of LaTeX-Box, but the idea -is to combine vim-latex with the strength of other plugins. I personally +is to combine vimtex with the strength of other plugins. I personally recommend [UltiSnips](https://github.com/SirVer/ultisnips) for snippets and [neocomplete](https://github.com/Shougo/neocomplete.vim) for completion. -Note that vim-latex should not be confused with LaTeX-Suite, which is also to -some extent known as vim-latex. The present plugin is not related to -LaTeX-Suite in any way. - Read the documentation for a more thorough introduction. ## Installation @@ -33,23 +31,23 @@ Read the documentation for a more thorough introduction. ### With gmarik vundle _https://github.com/gmarik/vundle_ -Add `Plugin 'lervag/vim-latex'` to your ~/.vimrc and run +Add `Plugin 'lervag/vimtex'` to your ~/.vimrc and run `:PluginInstall` in a vim buffer. Add `!` to the command to update. ### With neobundle _https://github.com/Shougo/neobundle.vim_ -Add `NeoBundle 'lervag/vim-latex'` to your ~/.vimrc and run +Add `NeoBundle 'lervag/vimtex'` to your ~/.vimrc and run `:NeoBundleInstall` in a vim buffer. Add `!` to the command to update. ### With pathogen _https://github.com/tpope/vim-pathogen_ -Add the vim-latex bundle to your bundle directory, for instance with `git +Add the vimtex bundle to your bundle directory, for instance with `git clone`. This will typically be enough: cd ~/.vim/bundle - git clone git://github.com/lervag/vim-latex + git clone git://github.com/lervag/vimtex ### Without a plugin manager diff --git a/after/syntax/tex.vim b/after/syntax/tex.vim index a4b2e5f..879af67 100644 --- a/after/syntax/tex.vim +++ b/after/syntax/tex.vim @@ -1,4 +1,4 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com diff --git a/autoload/latex/mappings.vim b/autoload/latex/mappings.vim deleted file mode 100644 index acd122d..0000000 --- a/autoload/latex/mappings.vim +++ /dev/null @@ -1,80 +0,0 @@ -" LaTeX plugin for Vim -" -" Maintainer: Karl Yngve Lervåg -" Email: karl.yngve@gmail.com -" - -function! latex#mappings#init(initialized) - call latex#util#set_default('g:latex_mappings_enabled', 1) - if !g:latex_mappings_enabled | return | endif - - nmap li (vl-info) - nmap lh (vl-help) - nmap lR (vl-reinit) - - nmap dse (vl-delete-env) - nmap dsc (vl-delete-cmd) - nmap cse (vl-change-env) - nmap csc (vl-change-cmd) - nmap tse (vl-toggle-star) - nmap tsd (vl-toggle-delim) - nmap (vl-create-cmd) - imap (vl-create-cmd) - imap ]] (vl-close-env) - - if g:latex_latexmk_enabled - nmap ll (vl-compile-toggle) - nmap lo (vl-compile-output) - nmap lk (vl-stop) - nmap lK (vl-stop-all) - nmap le (vl-errors) - nmap lc (vl-clean) - nmap lC (vl-clean-full) - nmap lg (vl-status) - nmap lG (vl-status-all) - endif - - if g:latex_motion_enabled - nmap % (vl-%) - xmap % (vl-%) - omap % (vl-%) - nmap ]] (vl-]]) - nmap ][ (vl-][) - nmap [] (vl-[]) - nmap [[ (vl-[[) - xmap ]] (vl-]]) - xmap ][ (vl-][) - xmap [] (vl-[]) - xmap [[ (vl-[[) - omap ]] (vl-]]) - omap ][ (vl-][) - omap [] (vl-[]) - omap [[ (vl-[[) - xmap ie (vl-ie) - xmap ae (vl-ae) - omap ie (vl-ie) - omap ae (vl-ae) - xmap i$ (vl-i$) - xmap a$ (vl-a$) - omap i$ (vl-i$) - omap a$ (vl-a$) - xmap id (vl-id) - xmap ad (vl-ad) - omap id (vl-id) - omap ad (vl-ad) - endif - - if g:latex_toc_enabled - nmap lt (vl-toc-open) - nmap lT (vl-toc-toggle) - endif - - if g:latex_view_enabled - nmap lv (vl-view) - if has_key(g:latex#data[b:latex.id], 'rsearch') - nmap lr (vl-reverse-search) - endif - endif -endfunction - -" vim: fdm=marker sw=2 diff --git a/autoload/latex.vim b/autoload/vimtex.vim similarity index 73% rename from autoload/latex.vim rename to autoload/vimtex.vim index 2a26016..1916839 100644 --- a/autoload/latex.vim +++ b/autoload/vimtex.vim @@ -1,25 +1,25 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -" vim-latex is not initialized until latex#init() has been run once +" vimtex is not initialized until vimtex#init() has been run once let s:initialized = 0 -function! latex#init() " {{{1 +function! vimtex#init() " {{{1 call s:init_options() call s:init_environment() - call latex#toc#init(s:initialized) - call latex#fold#init(s:initialized) - call latex#view#init(s:initialized) - call latex#motion#init(s:initialized) - call latex#labels#init(s:initialized) - call latex#change#init(s:initialized) - call latex#latexmk#init(s:initialized) - call latex#complete#init(s:initialized) - call latex#mappings#init(s:initialized) + call vimtex#toc#init(s:initialized) + call vimtex#fold#init(s:initialized) + call vimtex#view#init(s:initialized) + call vimtex#motion#init(s:initialized) + call vimtex#labels#init(s:initialized) + call vimtex#change#init(s:initialized) + call vimtex#latexmk#init(s:initialized) + call vimtex#complete#init(s:initialized) + call vimtex#mappings#init(s:initialized) " " This variable is used to allow a distinction between global and buffer @@ -28,19 +28,19 @@ function! latex#init() " {{{1 let s:initialized = 1 endfunction -function! latex#info() " {{{1 +function! vimtex#info() " {{{1 if !s:initialized - echoerr "Error: vim-latex has not been initialized!" + echoerr "Error: vimtex has not been initialized!" return endif " Print buffer data - echo "b:latex" - call s:print_dict(b:latex) + echo "b:vimtex" + call s:print_dict(b:vimtex) " Print global data let n = 0 - for data in g:latex#data + for data in g:vimtex#data " Prepare for printing let d = deepcopy(data) for f in ['aux', 'out', 'log'] @@ -49,14 +49,14 @@ function! latex#info() " {{{1 " Print data blob title line echo "\n" - echo "g:latex#data[" . n . "] : " . remove(d, 'name') + echo "g:vimtex#data[" . n . "] : " . remove(d, 'name') call s:print_dict(d) let n += 1 endfor endfunction -function! latex#help() " {{{1 - if g:latex_mappings_enabled +function! vimtex#help() " {{{1 + if g:vimtex_mappings_enabled nmap xmap omap @@ -65,25 +65,25 @@ function! latex#help() " {{{1 endif endfunction -function! latex#reinit() " {{{1 +function! vimtex#reinit() " {{{1 " " Stop latexmk processes (if running) " - call latex#latexmk#stop_all() + call vimtex#latexmk#stop_all() " " Reset global variables " let s:initialized = 0 - unlet g:latex#data + unlet g:vimtex#data " " Reset and reinitialize buffers " let n = bufnr('%') bufdo if getbufvar('%', '&filetype') == 'tex' | - \ unlet b:latex | - \ call latex#init() | + \ unlet b:vimtex | + \ call vimtex#init() | \ endif silent execute 'buffer ' . n endfunction @@ -91,8 +91,8 @@ endfunction function! s:init_environment() " {{{1 " Initialize global and local data blobs - call latex#util#set_default('g:latex#data', []) - call latex#util#set_default('b:latex', {}) + call vimtex#util#set_default('g:vimtex#data', []) + call vimtex#util#set_default('b:vimtex', {}) " Set some file type specific vim options setlocal suffixesadd+=.tex @@ -102,7 +102,7 @@ function! s:init_environment() " {{{1 let main = s:get_main() let id = s:get_id(main) if id >= 0 - let b:latex.id = id + let b:vimtex.id = id else let data = {} let data.tex = main @@ -119,35 +119,35 @@ function! s:init_environment() " {{{1 return s:get_main_out(self) endfunction - call add(g:latex#data, data) - let b:latex.id = len(g:latex#data) - 1 + call add(g:vimtex#data, data) + let b:vimtex.id = len(g:vimtex#data) - 1 endif " Define commands - command! -buffer VimLatexInfo call latex#info() - command! -buffer VimLatexHelp call latex#help() - command! -buffer VimLatexReinitialize call latex#reinit() + command! -buffer VimtexInfo call Vimtex#info() + command! -buffer VimtexHelp call vimtex#help() + command! -buffer VimtexReinitialize call vimtex#reinit() " Define mappings - nnoremap (vl-info) :call latex#info() - nnoremap (vl-help) :call latex#help() - nnoremap (vl-reinit) :call latex#reinit() + nnoremap (vimtex-info) :call vimtex#info() + nnoremap (vimtex-help) :call vimtex#help() + nnoremap (vimtex-reinit) :call vimtex#reinit() endfunction function! s:init_options() " {{{1 - call latex#util#set_default('g:latex_quickfix_ignore_all_warnings', 0) - call latex#util#set_default('g:latex_quickfix_ignored_warnings', []) + call vimtex#util#set_default('g:vimtex_quickfix_ignore_all_warnings', 0) + call vimtex#util#set_default('g:vimtex_quickfix_ignored_warnings', []) - call latex#util#error_deprecated('g:latex_errorformat_ignore_warnings') - call latex#util#error_deprecated('g:latex_errorformat_show_warnings') + call vimtex#util#error_deprecated('g:vimtex_errorformat_ignore_warnings') + call vimtex#util#error_deprecated('g:vimtex_errorformat_show_warnings') endfunction " }}}1 function! s:get_id(main) " {{{1 - if exists('g:latex#data') && !empty(g:latex#data) + if exists('g:vimtex#data') && !empty(g:vimtex#data) let id = 0 - while id < len(g:latex#data) - if g:latex#data[id].tex == a:main + while id < len(g:vimtex#data) + if g:vimtex#data[id].tex == a:main return id endif let id += 1 @@ -236,7 +236,7 @@ function! s:get_main_ext(texdata, ext) " {{{1 " Create set of candidates let candidates = [ \ a:texdata.name, - \ g:latex_latexmk_build_dir . '/' . a:texdata.name, + \ g:vimtex_latexmk_build_dir . '/' . a:texdata.name, \ ] " Search through the candidates @@ -255,7 +255,7 @@ function! s:get_main_out(texdata) " {{{1 " Create set of candidates let candidates = [ \ a:texdata.name, - \ g:latex_latexmk_build_dir . '/' . a:texdata.name, + \ g:vimtex_latexmk_build_dir . '/' . a:texdata.name, \ ] " Check for pdf files diff --git a/autoload/latex/change.vim b/autoload/vimtex/change.vim similarity index 71% rename from autoload/latex/change.vim rename to autoload/vimtex/change.vim index 2dce779..7942080 100644 --- a/autoload/latex/change.vim +++ b/autoload/vimtex/change.vim @@ -1,32 +1,32 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#change#init(initialized) " {{{1 +function! vimtex#change#init(initialized) " {{{1 " Define mappings - nnoremap (vl-delete-env) - \ :call latex#change#env('') - nnoremap (vl-delete-cmd) vaBom`oxg``xdF\ - \:silent! call repeat#set("\(vl-delete-cmd)", v:count) - nnoremap (vl-change-env) - \ :call latex#change#env_prompt() - nnoremap (vl-change-cmd) - \ :call latex#change#command() - nnoremap (vl-toggle-star) - \ :call latex#change#toggle_env_star() - nnoremap (vl-toggle-delim) - \ :call latex#change#toggle_delim() - nnoremap (vl-create-cmd) - \ :call latex#change#to_command()i - inoremap (vl-create-cmd) - \ =latex#change#to_command() - inoremap (vl-close-env) - \ =latex#change#close_environment() + nnoremap (vimtex-delete-env) + \ :call vimtex#change#env('') + nnoremap (vimtex-delete-cmd) vaBom`oxg``xdF\ + \:silent! call repeat#set("\(vimtex-delete-cmd)", v:count) + nnoremap (vimtex-change-env) + \ :call vimtex#change#env_prompt() + nnoremap (vimtex-change-cmd) + \ :call vimtex#change#command() + nnoremap (vimtex-toggle-star) + \ :call vimtex#change#toggle_env_star() + nnoremap (vimtex-toggle-delim) + \ :call vimtex#change#toggle_delim() + nnoremap (vimtex-create-cmd) + \ :call vimtex#change#to_command()i + inoremap (vimtex-create-cmd) + \ =vimtex#change#to_command() + inoremap (vimtex-close-env) + \ =vimtex#change#close_environment() endfunction -function! latex#change#command() " {{{1 +function! vimtex#change#command() " {{{1 let pos_save = getpos('.') let savereg = @a @@ -49,13 +49,13 @@ function! latex#change#command() " {{{1 let @a = savereg call setpos('.', pos_save) - silent! call repeat#set("\(vl-change-cmd)" . new . ' ', v:count) + silent! call repeat#set("\(vimtex-change-cmd)" . new . ' ', v:count) endfunction -function! latex#change#close_environment() " {{{1 +function! vimtex#change#close_environment() " {{{1 " Close delimiters let [lnum, cnum] = searchpairpos('\C\\left\>', '', '\C\\right\>', 'bnW', - \ 'latex#util#in_comment()') + \ 'vimtex#util#in_comment()') if lnum > 0 let line = strpart(getline(lnum), cnum - 1) let bracket = matchstr(line, '^\\left\zs\((\|\[\|\\{\||\|\.\)\ze') @@ -72,7 +72,7 @@ function! latex#change#close_environment() " {{{1 endif " Close environment - let env = latex#util#get_env() + let env = vimtex#util#get_env() if env == '\[' return '\]' elseif env == '\(' @@ -82,8 +82,8 @@ function! latex#change#close_environment() " {{{1 endif endfunction -function! latex#change#delim(open, close) " {{{1 - let [d1, l1, c1, d2, l2, c2] = latex#util#get_delim() +function! vimtex#change#delim(open, close) " {{{1 + let [d1, l1, c1, d2, l2, c2] = vimtex#util#get_delim() let line = getline(l1) let line = strpart(line,0,c1 - 1) . a:open . strpart(line, c1 + len(d1) - 1) @@ -102,8 +102,8 @@ function! latex#change#delim(open, close) " {{{1 call setline(l2, line) endfunction -function! latex#change#env(new) " {{{1 - let [env, l1, c1, l2, c2] = latex#util#get_env(1) +function! vimtex#change#env(new) " {{{1 + let [env, l1, c1, l2, c2] = vimtex#util#get_env(1) if a:new == '' let beg = '' @@ -134,23 +134,23 @@ function! latex#change#env(new) " {{{1 call setline(l2, line) if a:new == '' - silent! call repeat#set("\(vl-delete-env)", v:count) + silent! call repeat#set("\(vimtex-delete-env)", v:count) else - silent! call repeat#set("\(vl-change-env)" . a:new . " ", v:count) + silent! call repeat#set("\(vimtex-change-env)" . a:new . " ", v:count) endif endfunction -function! latex#change#env_prompt() " {{{1 - let new_env = input('Change ' . latex#util#get_env() . ' for: ', '', +function! vimtex#change#env_prompt() " {{{1 + let new_env = input('Change ' . vimtex#util#get_env() . ' for: ', '', \ 'customlist,' . s:sidwrap('input_complete')) if empty(new_env) return else - call latex#change#env(new_env) + call vimtex#change#env(new_env) endif endfunction -function! latex#change#to_command() " {{{1 +function! vimtex#change#to_command() " {{{1 " Get current line let line = getline('.') @@ -190,11 +190,11 @@ function! latex#change#to_command() " {{{1 return '' endfunction -function! latex#change#toggle_delim() " {{{1 +function! vimtex#change#toggle_delim() " {{{1 " " Toggle \left and \right variants of delimiters " - let [d1, l1, c1, d2, l2, c2] = latex#util#get_delim() + let [d1, l1, c1, d2, l2, c2] = vimtex#util#get_delim() if d1 == '' return 0 @@ -224,11 +224,11 @@ function! latex#change#toggle_delim() " {{{1 let line = strpart(line, 0, c2 - 1) . newd2 . strpart(line, c2 + len(d2) - 1) call setline(l2, line) - silent! call repeat#set("\(vl-toggle-delim)", v:count) + silent! call repeat#set("\(vimtex-toggle-delim)", v:count) endfunction -function! latex#change#toggle_env_star() " {{{1 - let env = latex#util#get_env() +function! vimtex#change#toggle_env_star() " {{{1 + let env = vimtex#util#get_env() if env == '\(' return @@ -240,18 +240,18 @@ function! latex#change#toggle_env_star() " {{{1 let new_env = env . '*' endif - call latex#change#env(new_env) + call vimtex#change#env(new_env) - silent! call repeat#set("\(vl-toggle-star)", v:count) + silent! call repeat#set("\(vimtex-toggle-star)", v:count) endfunction -function! latex#change#wrap_selection(wrapper) " {{{1 +function! vimtex#change#wrap_selection(wrapper) " {{{1 keepjumps normal! `>a} execute 'keepjumps normal! `'), '\zs\d\+_\ze.*$') function! s:input_complete(lead, cmdline, pos) " {{{1 let suggestions = [] - for entry in g:latex_complete_environments + for entry in g:vimtex_complete_environments let env = entry.word if env =~ '^' . a:lead call add(suggestions, env) @@ -310,7 +310,7 @@ function! s:search_and_skip_comments(pat, ...) " {{{1 let flags = substitute(flags, 'c', '', 'g') " keep searching while in comment - while latex#util#in_comment() + while vimtex#util#in_comment() let ret = search(a:pat, flags, stopline) if !ret break diff --git a/autoload/latex/complete.vim b/autoload/vimtex/complete.vim similarity index 84% rename from autoload/latex/complete.vim rename to autoload/vimtex/complete.vim index fcb7b2e..1e9e7b5 100644 --- a/autoload/latex/complete.vim +++ b/autoload/vimtex/complete.vim @@ -1,17 +1,17 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#complete#init(initialized) " {{{1 - call latex#util#set_default('g:latex_complete_enabled', 1) - if !g:latex_complete_enabled | return | endif +function! vimtex#complete#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_complete_enabled', 1) + if !g:vimtex_complete_enabled | return | endif " Set default options - call latex#util#set_default('g:latex_complete_close_braces', 0) - call latex#util#set_default('g:latex_complete_recursive_bib', 0) - call latex#util#set_default('g:latex_complete_patterns', + call vimtex#util#set_default('g:vimtex_complete_close_braces', 0) + call vimtex#util#set_default('g:vimtex_complete_recursive_bib', 0) + call vimtex#util#set_default('g:vimtex_complete_patterns', \ { \ 'ref' : '\C\\v\?\(eq\|page\|[cC]\|labelc\)\?ref\*\?\_\s*{[^{}]*', \ 'bib' : '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*', @@ -25,29 +25,29 @@ function! latex#complete#init(initialized) " {{{1 endif " Check if kpsewhich is required and available - if g:latex_complete_recursive_bib && !executable('kpsewhich') + if g:vimtex_complete_recursive_bib && !executable('kpsewhich') echom "Warning: bibtex completion not available" echom " Missing executable: kpsewhich" echom " You could try to turn off recursive bib functionality" let s:bibtex = 0 endif - setlocal omnifunc=latex#complete#omnifunc + setlocal omnifunc=vimtex#complete#omnifunc endfunction -function! latex#complete#omnifunc(findstart, base) " {{{1 +function! vimtex#complete#omnifunc(findstart, base) " {{{1 if a:findstart " " First call: Find start of text to be completed " - " Note: g:latex_complete_patterns is a dictionary where the keys are the + " Note: g:vimtex_complete_patterns is a dictionary where the keys are the " types of completion and the values are the patterns that must match for " the given type. Currently, it completes labels (e.g. \ref{...), bibtex " entries (e.g. \cite{...) and commands (e.g. \...). " let pos = col('.') - 1 let line = getline('.')[:pos-1] - for [type, pattern] in items(g:latex_complete_patterns) + for [type, pattern] in items(g:vimtex_complete_patterns) if line =~ pattern . '$' let s:completion_type = type while pos > 0 @@ -65,9 +65,9 @@ function! latex#complete#omnifunc(findstart, base) " {{{1 " Second call: Find list of matches " if s:completion_type == 'ref' - return latex#complete#labels(a:base) + return vimtex#complete#labels(a:base) elseif s:completion_type == 'bib' && s:bibtex - return latex#complete#bibtex(a:base) + return vimtex#complete#bibtex(a:base) endif endif endfunction @@ -76,8 +76,8 @@ endfunction let s:bibtex = 1 let s:completion_type = '' -function! latex#complete#labels(regex) " {{{1 - let labels = s:labels_get(g:latex#data[b:latex.id].aux()) +function! vimtex#complete#labels(regex) " {{{1 + let labels = s:labels_get(g:vimtex#data[b:vimtex.id].aux()) let matches = filter(copy(labels), 'v:val[0] =~ ''' . a:regex . '''') " Try to match label and number @@ -103,7 +103,7 @@ function! latex#complete#labels(regex) " {{{1 \ 'word': m[0], \ 'menu': printf("%7s [p. %s]", '('.m[1].')', m[2]) \ } - if g:latex_complete_close_braces && !s:next_chars_match('^\s*[,}]') + if g:vimtex_complete_close_braces && !s:next_chars_match('^\s*[,}]') let entry = copy(entry) let entry.abbr = entry.word let entry.word = entry.word . '}' @@ -114,7 +114,7 @@ function! latex#complete#labels(regex) " {{{1 return suggestions endfunction -function! latex#complete#bibtex(regexp) " {{{1 +function! vimtex#complete#bibtex(regexp) " {{{1 let res = [] let s:type_length = 4 @@ -135,7 +135,7 @@ function! latex#complete#bibtex(regexp) " {{{1 \ } " Close braces if desired - if g:latex_complete_close_braces && !s:next_chars_match('^\s*[,}]') + if g:vimtex_complete_close_braces && !s:next_chars_match('^\s*[,}]') let w.word = w.word . '}' endif @@ -166,7 +166,7 @@ function! s:bibtex_search(regexp) " {{{2 " The bibtex completion seems to require that we are in the project root let l:save_pwd = getcwd() - execute 'lcd ' . fnameescape(g:latex#data[b:latex.id].root) + execute 'lcd ' . fnameescape(g:vimtex#data[b:vimtex.id].root) " Find data from external bib files let bibfiles = join(s:bibtex_find_bibs(), ',') @@ -189,7 +189,7 @@ function! s:bibtex_search(regexp) " {{{2 let exe = {} let exe.cmd = 'bibtex -terse ' . tmp.aux let exe.bg = 0 - call latex#util#execute(exe) + call vimtex#util#execute(exe) " Parse temporary bbl file let lines = split(substitute(join(readfile(tmp.bbl), "\n"), @@ -220,7 +220,7 @@ function! s:bibtex_search(regexp) " {{{2 execute 'lcd ' . fnameescape(l:save_pwd) " Find data from 'thebibliography' environments - let lines = readfile(g:latex#data[b:latex.id].tex) + let lines = readfile(g:vimtex#data[b:vimtex.id].tex) if match(lines, '\C\\begin{thebibliography}') >= 0 for line in filter(filter(lines, 'v:val =~ ''\C\\bibitem'''), \ 'v:val =~ a:regexp') @@ -242,7 +242,7 @@ function! s:bibtex_find_bibs(...) " {{{2 if a:0 let file = a:1 else - let file = g:latex#data[b:latex.id].tex + let file = g:vimtex#data[b:vimtex.id].tex endif if !filereadable(file) @@ -265,11 +265,11 @@ function! s:bibtex_find_bibs(...) " {{{2 " " Recursively search included files " - if g:latex_complete_recursive_bib + if g:vimtex_complete_recursive_bib for entry in map(filter(lines, \ 'v:val =~ ' . s:re_incsearch), \ 'matchstr(v:val, ' . s:re_incsearch . ')') - let bibfiles += s:bibtex_find_bibs(latex#util#kpsewhich(entry)) + let bibfiles += s:bibtex_find_bibs(vimtex#util#kpsewhich(entry)) endfor endif @@ -336,14 +336,14 @@ function! s:labels_extract(file) " {{{2 let lines = readfile(a:file) let lines = filter(lines, 'v:val =~# ''\\newlabel{''') let lines = filter(lines, 'v:val !~# ''@cref''') - let lines = map(lines, 'latex#util#convert_back(v:val)') + let lines = map(lines, 'vimtex#util#convert_back(v:val)') for line in lines - let tree = latex#util#tex2tree(line) + let tree = vimtex#util#tex2tree(line) if !empty(tree[2][0]) call add(matches, [ - \ latex#util#tree2tex(tree[1][0]), - \ latex#util#tree2tex(tree[2][0][0]), - \ latex#util#tree2tex(tree[2][1][0]), + \ vimtex#util#tree2tex(tree[1][0]), + \ vimtex#util#tree2tex(tree[2][0][0]), + \ vimtex#util#tree2tex(tree[2][1][0]), \ ]) endif endfor diff --git a/autoload/latex/fold.vim b/autoload/vimtex/fold.vim similarity index 85% rename from autoload/latex/fold.vim rename to autoload/vimtex/fold.vim index a5d81eb..db9071d 100644 --- a/autoload/latex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -1,18 +1,18 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#fold#init(initialized) " {{{1 - call latex#util#set_default('g:latex_fold_enabled', 1) - if !g:latex_fold_enabled | return | endif +function! vimtex#fold#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_fold_enabled', 1) + if !g:vimtex_fold_enabled | return | endif " Set default options - call latex#util#set_default('g:latex_fold_automatic', 1) - call latex#util#set_default('g:latex_fold_preamble', 1) - call latex#util#set_default('g:latex_fold_envs', 1) - call latex#util#set_default('g:latex_fold_parts', + call vimtex#util#set_default('g:vimtex_fold_automatic', 1) + call vimtex#util#set_default('g:vimtex_fold_preamble', 1) + call vimtex#util#set_default('g:vimtex_fold_envs', 1) + call vimtex#util#set_default('g:vimtex_fold_parts', \ [ \ "part", \ "appendix", @@ -20,7 +20,7 @@ function! latex#fold#init(initialized) " {{{1 \ "mainmatter", \ "backmatter", \ ]) - call latex#util#set_default('g:latex_fold_sections', + call vimtex#util#set_default('g:vimtex_fold_sections', \ [ \ "chapter", \ "section", @@ -29,26 +29,26 @@ function! latex#fold#init(initialized) " {{{1 \ ]) " Define some script variables - let s:parts = '\v^\s*(\\|\% Fake)(' . join(g:latex_fold_parts, '|') . ')>' - let s:secs = '\v^\s*(\\|\% Fake)(' . join(g:latex_fold_sections, '|') . ')>' + let s:parts = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_parts, '|') . ')>' + let s:secs = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_sections, '|') . ')>' " Set fold options setl foldmethod=expr - setl foldexpr=latex#fold#level(v:lnum) - setl foldtext=latex#fold#text() + setl foldexpr=vimtex#fold#level(v:lnum) + setl foldtext=vimtex#fold#text() " Initalize folds - call latex#fold#refresh('zX') + call vimtex#fold#refresh('zX') " Remap zx to refresh fold levels - nnoremap zx :call latex#fold#refresh('zx') - nnoremap zX :call latex#fold#refresh('zX') + nnoremap zx :call vimtex#fold#refresh('zx') + nnoremap zX :call vimtex#fold#refresh('zX') " Define commands - command! -buffer VimLatexRefreshFolds call latex#fold#refresh('zx') + command! -buffer VimtexRefreshFolds call vimtex#fold#refresh('zx') " Set options for automatic/manual mode - if g:latex_fold_automatic + if g:vimtex_fold_automatic " For some reason, foldmethod=expr makes undo slow (at least in some cases) nnoremap u :call FdmSave()u:call FdmRestore() @@ -68,12 +68,12 @@ function! latex#fold#init(initialized) " {{{1 endif endfunction -function! latex#fold#refresh(map) " {{{1 +function! vimtex#fold#refresh(map) " {{{1 " Parse tex file to dynamically set the sectioning fold levels - let b:latex.fold_parts = s:parse_folded() + let b:vimtex.fold_parts = s:parse_folded() " Refresh folds - if g:latex_fold_automatic + if g:vimtex_fold_automatic execute 'normal! ' . a:map else setl foldmethod=expr @@ -82,7 +82,7 @@ function! latex#fold#refresh(map) " {{{1 endif endfunction -function! latex#fold#level(lnum) " {{{1 +function! vimtex#fold#level(lnum) " {{{1 " Check for normal lines first (optimization) let line = getline(a:lnum) if line !~ '\(% Fake\|\\\(document\|begin\|end\|' @@ -91,7 +91,7 @@ function! latex#fold#level(lnum) " {{{1 endif " Fold preamble - if g:latex_fold_preamble + if g:vimtex_fold_preamble if line =~# '^\s*\\documentclass' return ">1" elseif line =~# '^\s*\\begin\s*{\s*document\s*}' @@ -100,7 +100,7 @@ function! latex#fold#level(lnum) " {{{1 endif " Fold chapters and sections - for [part, level] in b:latex.fold_parts + for [part, level] in b:vimtex.fold_parts if line =~# part return ">" . level endif @@ -112,7 +112,7 @@ function! latex#fold#level(lnum) " {{{1 endif " Fold environments - if g:latex_fold_envs + if g:vimtex_fold_envs if line =~# s:notcomment . s:notbslash . '\\begin\s*{.\{-}}' if line !~# '\\end' return "a1" @@ -128,7 +128,7 @@ function! latex#fold#level(lnum) " {{{1 return "=" endfunction -function! latex#fold#text() " {{{1 +function! vimtex#fold#text() " {{{1 " Initialize let line = getline(v:foldstart) let level = v:foldlevel > 1 ? repeat('-', v:foldlevel-2) . '*' : '' @@ -236,7 +236,7 @@ function! s:parse_folded() " {{{1 " Parse part commands (frontmatter, appendix, part, etc) let lines = filter(copy(buffer), 'v:val =~ ''' . s:parts . '''') - for part in g:latex_fold_parts + for part in g:vimtex_fold_parts let partpattern = '^\s*\(\\\|% Fake\)' . part . '\>' for line in lines if line =~# partpattern @@ -256,7 +256,7 @@ function! s:parse_folded() " {{{1 " Parse section commands (chapter, [sub...]section) let lines = filter(copy(buffer), 'v:val =~ ''' . s:secs . '''') - for part in g:latex_fold_sections + for part in g:vimtex_fold_sections let partpattern = '^\s*\(\\\|% Fake\)' . part . '\>' for line in lines if line =~# partpattern diff --git a/autoload/latex/labels.vim b/autoload/vimtex/labels.vim similarity index 85% rename from autoload/latex/labels.vim rename to autoload/vimtex/labels.vim index aadfb0b..7839794 100644 --- a/autoload/latex/labels.vim +++ b/autoload/vimtex/labels.vim @@ -1,14 +1,14 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#labels#init(initialized) " {{{1 - call latex#util#set_default('g:latex_labels_enabled', 1) - if !g:latex_labels_enabled | return | endif +function! vimtex#labels#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_labels_enabled', 1) + if !g:vimtex_labels_enabled | return | endif - let g:latex#data[b:latex.id].labels = function('s:gather_labels') + let g:vimtex#data[b:vimtex.id].labels = function('s:gather_labels') endfunction " }}}1 diff --git a/autoload/latex/latexmk.vim b/autoload/vimtex/latexmk.vim similarity index 55% rename from autoload/latex/latexmk.vim rename to autoload/vimtex/latexmk.vim index 6e6e6f3..329b9e4 100644 --- a/autoload/latex/latexmk.vim +++ b/autoload/vimtex/latexmk.vim @@ -1,68 +1,68 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#latexmk#init(initialized) " {{{1 - call latex#util#set_default('g:latex_latexmk_enabled', 1) - if !g:latex_latexmk_enabled | return | endif +function! vimtex#latexmk#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_latexmk_enabled', 1) + if !g:vimtex_latexmk_enabled | return | endif if s:system_incompatible() | return | endif " Set default options - call latex#util#set_default('g:latex_latexmk_background', 0) - call latex#util#set_default('g:latex_latexmk_build_dir', '.') - call latex#util#set_default('g:latex_latexmk_callback', 1) - call latex#util#set_default('g:latex_latexmk_continuous', 1) - call latex#util#set_default('g:latex_latexmk_options', '-pdf') - call latex#util#set_default('g:latex_quickfix_autojump', '0') - call latex#util#set_default('g:latex_quickfix_mode', '2') - call latex#util#set_default('g:latex_quickfix_open_on_warning', '1') - call latex#util#error_deprecated('g:latex_build_dir') - call latex#util#error_deprecated('g:latex_latexmk_autojump') - call latex#util#error_deprecated('g:latex_latexmk_output') - call latex#util#error_deprecated('g:latex_latexmk_quickfix') + call vimtex#util#set_default('g:vimtex_latexmk_background', 0) + call vimtex#util#set_default('g:vimtex_latexmk_build_dir', '.') + call vimtex#util#set_default('g:vimtex_latexmk_callback', 1) + call vimtex#util#set_default('g:vimtex_latexmk_continuous', 1) + call vimtex#util#set_default('g:vimtex_latexmk_options', '-pdf') + call vimtex#util#set_default('g:vimtex_quickfix_autojump', '0') + call vimtex#util#set_default('g:vimtex_quickfix_mode', '2') + call vimtex#util#set_default('g:vimtex_quickfix_open_on_warning', '1') + call vimtex#util#error_deprecated('g:vimtex_build_dir') + call vimtex#util#error_deprecated('g:vimtex_latexmk_autojump') + call vimtex#util#error_deprecated('g:vimtex_latexmk_output') + call vimtex#util#error_deprecated('g:vimtex_latexmk_quickfix') " Set compiler (this defines the errorformat) compiler latexmk - let g:latex#data[b:latex.id].pid = 0 + let g:vimtex#data[b:vimtex.id].pid = 0 " Define commands - command! -buffer VimLatexCompile call latex#latexmk#compile() - command! -buffer -bang VimLatexCompileSS call latex#latexmk#compile_ss( == "!") - command! -buffer VimLatexCompileToggle call latex#latexmk#toggle() - command! -buffer VimLatexCompileOutput call latex#latexmk#output() - command! -buffer VimLatexStop call latex#latexmk#stop() - command! -buffer VimLatexStopAll call latex#latexmk#stop_all() - command! -buffer -bang VimLatexErrors call latex#latexmk#errors( == "!") - command! -buffer -bang VimLatexClean call latex#latexmk#clean( == "!") - command! -buffer -bang VimLatexStatus call latex#latexmk#status( == "!") - command! -buffer VimLatexLacheck call latex#latexmk#lacheck() + command! -buffer VimtexCompile call vimtex#latexmk#compile() + command! -buffer -bang VimtexCompileSS call vimtex#latexmk#compile_ss( == "!") + command! -buffer VimtexCompileToggle call vimtex#latexmk#toggle() + command! -buffer VimtexCompileOutput call vimtex#latexmk#output() + command! -buffer VimtexStop call vimtex#latexmk#stop() + command! -buffer VimtexStopAll call vimtex#latexmk#stop_all() + command! -buffer -bang VimtexErrors call vimtex#latexmk#errors( == "!") + command! -buffer -bang VimtexClean call vimtex#latexmk#clean( == "!") + command! -buffer -bang VimtexStatus call vimtex#latexmk#status( == "!") + command! -buffer VimtexLacheck call vimtex#latexmk#lacheck() " Define mappings - nnoremap (vl-compile) :call latex#latexmk#compile() - nnoremap (vl-compile-ss) :call latex#latexmk#compile_ss(0) - nnoremap (vl-compile-toggle) :call latex#latexmk#toggle() - nnoremap (vl-compile-output) :call latex#latexmk#output() - nnoremap (vl-stop) :call latex#latexmk#stop() - nnoremap (vl-stop-all) :call latex#latexmk#stop_all() - nnoremap (vl-errors) :call latex#latexmk#errors(1) - nnoremap (vl-clean) :call latex#latexmk#clean(0) - nnoremap (vl-clean-full) :call latex#latexmk#clean(1) - nnoremap (vl-status) :call latex#latexmk#status(0) - nnoremap (vl-status-all) :call latex#latexmk#status(1) - nnoremap (vl-lacheck) :call latex#latexmk#lacheck() + nnoremap (vimtex-compile) :call vimtex#latexmk#compile() + nnoremap (vimtex-compile-ss) :call vimtex#latexmk#compile_ss(0) + nnoremap (vimtex-compile-toggle) :call vimtex#latexmk#toggle() + nnoremap (vimtex-compile-output) :call vimtex#latexmk#output() + nnoremap (vimtex-stop) :call vimtex#latexmk#stop() + nnoremap (vimtex-stop-all) :call vimtex#latexmk#stop_all() + nnoremap (vimtex-errors) :call vimtex#latexmk#errors(1) + nnoremap (vimtex-clean) :call vimtex#latexmk#clean(0) + nnoremap (vimtex-clean-full) :call vimtex#latexmk#clean(1) + nnoremap (vimtex-status) :call vimtex#latexmk#status(0) + nnoremap (vimtex-status-all) :call vimtex#latexmk#status(1) + nnoremap (vimtex-lacheck) :call vimtex#latexmk#lacheck() " The remaining part is only relevant for continuous mode - if !g:latex_latexmk_continuous | return | endif + if !g:vimtex_latexmk_continuous | return | endif " Ensure that all latexmk processes are stopped when vim exits " Note: Only need to define this once, globally. if !a:initialized augroup latex_latexmk autocmd! - autocmd VimLeave * call latex#latexmk#stop_all() + autocmd VimLeave * call vimtex#latexmk#stop_all() augroup END endif @@ -75,8 +75,8 @@ function! latex#latexmk#init(initialized) " {{{1 endfunction " }}}1 -function! latex#latexmk#callback(status) " {{{1 - call latex#latexmk#errors(0) +function! vimtex#latexmk#callback(status) " {{{1 + call vimtex#latexmk#errors(0) redraw! echohl ModeMsg @@ -90,16 +90,16 @@ function! latex#latexmk#callback(status) " {{{1 endif echohl None - if has_key(g:latex#data[b:latex.id].viewer, 'latexmk_callback') - call g:latex#data[b:latex.id].viewer.latexmk_callback() + if has_key(g:vimtex#data[b:vimtex.id].viewer, 'latexmk_callback') + call g:vimtex#data[b:vimtex.id].viewer.latexmk_callback() endif return "" endfunction " }}}1 -function! latex#latexmk#clean(full) " {{{1 - let data = g:latex#data[b:latex.id] +function! vimtex#latexmk#clean(full) " {{{1 + let data = g:vimtex#data[b:vimtex.id] if data.pid echomsg "latexmk is already running" return @@ -113,15 +113,15 @@ function! latex#latexmk#clean(full) " {{{1 else let cmd = 'cd ' . shellescape(data.root) . '; ' endif - let cmd .= 'latexmk -outdir=' . g:latex_latexmk_build_dir + let cmd .= 'latexmk -outdir=' . g:vimtex_latexmk_build_dir let cmd .= a:full ? ' -C ' : ' -c' - let cmd .= latex#util#fnameescape(data.base) + let cmd .= vimtex#util#fnameescape(data.base) let exe = { \ 'cmd' : cmd, \ 'bg' : 0, \ } - call latex#util#execute(exe) - let g:latex#data[b:latex.id].cmd_latexmk_clean = cmd + call vimtex#util#execute(exe) + let g:vimtex#data[b:vimtex.id].cmd_latexmk_clean = cmd if a:full echomsg "latexmk full clean finished" @@ -131,7 +131,7 @@ function! latex#latexmk#clean(full) " {{{1 endfunction " }}}1 -function! latex#latexmk#lacheck() " {{{1 +function! vimtex#latexmk#lacheck() " {{{1 compiler lacheck silent lmake % @@ -143,19 +143,19 @@ function! latex#latexmk#lacheck() " {{{1 endfunction " }}}1 -function! latex#latexmk#toggle() " {{{1 - let data = g:latex#data[b:latex.id] +function! vimtex#latexmk#toggle() " {{{1 + let data = g:vimtex#data[b:vimtex.id] if data.pid - call latex#latexmk#stop() + call vimtex#latexmk#stop() else - call latex#latexmk#compile() + call vimtex#latexmk#compile() endif endfunction " }}}1 -function! latex#latexmk#compile() " {{{1 - let data = g:latex#data[b:latex.id] +function! vimtex#latexmk#compile() " {{{1 + let data = g:vimtex#data[b:vimtex.id] if data.pid echomsg "latexmk is already running for `" . data.base . "'" return @@ -163,13 +163,13 @@ function! latex#latexmk#compile() " {{{1 " Build command line and start latexmk let exe = s:latexmk_build_cmd(data) - if !g:latex_latexmk_continuous && !g:latex_latexmk_background + if !g:vimtex_latexmk_continuous && !g:vimtex_latexmk_background let exe.bg = 0 let exe.silent = 0 endif - call latex#util#execute(exe) + call vimtex#util#execute(exe) - if g:latex_latexmk_continuous + if g:vimtex_latexmk_continuous call s:latexmk_set_pid(data) echomsg 'latexmk started in continuous mode ...' @@ -179,29 +179,29 @@ function! latex#latexmk#compile() " {{{1 endfunction " }}}1 -function! latex#latexmk#compile_ss(verbose) " {{{1 - let data = g:latex#data[b:latex.id] +function! vimtex#latexmk#compile_ss(verbose) " {{{1 + let data = g:vimtex#data[b:vimtex.id] if data.pid echomsg "latexmk is already running for `" . data.base . "'" return endif - let l:latex_latexmk_continuous = g:latex_latexmk_continuous - let g:latex_latexmk_continuous = 0 + let l:vimtex_latexmk_continuous = g:vimtex_latexmk_continuous + let g:vimtex_latexmk_continuous = 0 let exe = s:latexmk_build_cmd(data) if a:verbose let exe.bg = 0 let exe.silent = 0 endif - call latex#util#execute(exe) - let g:latex_latexmk_continuous = l:latex_latexmk_continuous + call vimtex#util#execute(exe) + let g:vimtex_latexmk_continuous = l:vimtex_latexmk_continuous endfunction " }}}1 -function! latex#latexmk#errors(force) " {{{1 +function! vimtex#latexmk#errors(force) " {{{1 cclose - let log = g:latex#data[b:latex.id].log() + let log = g:vimtex#data[b:vimtex.id].log() if empty(log) if a:force echo "No log file found!" @@ -209,7 +209,7 @@ function! latex#latexmk#errors(force) " {{{1 return endif - if g:latex_quickfix_autojump + if g:vimtex_quickfix_autojump execute 'cfile ' . fnameescape(log) else execute 'cgetfile ' . fnameescape(log) @@ -222,13 +222,13 @@ function! latex#latexmk#errors(force) " {{{1 " normal mode mapping). Else the behaviour is based on the settings. " let open_quickfix_window = a:force - \ || (g:latex_quickfix_mode > 0 - \ && (g:latex_quickfix_open_on_warning + \ || (g:vimtex_quickfix_mode > 0 + \ && (g:vimtex_quickfix_open_on_warning \ || s:log_contains_error(log))) if open_quickfix_window botright cwindow - if g:latex_quickfix_mode == 2 + if g:vimtex_quickfix_mode == 2 wincmd p endif redraw! @@ -236,11 +236,11 @@ function! latex#latexmk#errors(force) " {{{1 endfunction " }}}1 -function! latex#latexmk#output() " {{{1 - if has_key(g:latex#data[b:latex.id], 'tmp') - let tmp = g:latex#data[b:latex.id].tmp +function! vimtex#latexmk#output() " {{{1 + if has_key(g:vimtex#data[b:vimtex.id], 'tmp') + let tmp = g:vimtex#data[b:vimtex.id].tmp else - echo "vim-latex: No output exists" + echo "vimtex: No output exists" return endif @@ -270,10 +270,10 @@ function! latex#latexmk#output() " {{{1 endfunction " }}}1 -function! latex#latexmk#status(detailed) " {{{1 +function! vimtex#latexmk#status(detailed) " {{{1 if a:detailed let running = 0 - for data in g:latex#data + for data in g:vimtex#data if data.pid if !running echo "latexmk is running" @@ -293,7 +293,7 @@ function! latex#latexmk#status(detailed) " {{{1 echo "latexmk is not running" endif else - if g:latex#data[b:latex.id].pid + if g:vimtex#data[b:vimtex.id].pid echo "latexmk is running" else echo "latexmk is not running" @@ -302,12 +302,12 @@ function! latex#latexmk#status(detailed) " {{{1 endfunction " }}}1 -function! latex#latexmk#stop() " {{{1 - let pid = g:latex#data[b:latex.id].pid - let base = g:latex#data[b:latex.id].base +function! vimtex#latexmk#stop() " {{{1 + let pid = g:vimtex#data[b:vimtex.id].pid + let base = g:vimtex#data[b:vimtex.id].base if pid call s:latexmk_kill_pid(pid) - let g:latex#data[b:latex.id].pid = 0 + let g:vimtex#data[b:vimtex.id].pid = 0 echo "latexmk stopped for `" . base . "'" else echo "latexmk is not running for `" . base . "'" @@ -315,8 +315,8 @@ function! latex#latexmk#stop() " {{{1 endfunction " }}}1 -function! latex#latexmk#stop_all() " {{{1 - for data in g:latex#data +function! vimtex#latexmk#stop_all() " {{{1 + for data in g:vimtex#data if data.pid call s:latexmk_kill_pid(data.pid) let data.pid = 0 @@ -327,7 +327,7 @@ endfunction " }}}1 " Helper function(s) for building the latexmk command -function! latex#latexmk#add_option(name, value) " {{{1 +function! vimtex#latexmk#add_option(name, value) " {{{1 if has('win32') return ' -e "$' . a:name . ' = ''' . a:value . '''"' else @@ -354,33 +354,33 @@ function! s:latexmk_build_cmd(data) " {{{1 let cmd .= ' && max_print_line=2000 latexmk' endif - let cmd .= ' ' . g:latex_latexmk_options + let cmd .= ' ' . g:vimtex_latexmk_options let cmd .= ' -e ' . shellescape('$pdflatex =~ s/ / -file-line-error /') - let cmd .= ' -outdir=' . g:latex_latexmk_build_dir + let cmd .= ' -outdir=' . g:vimtex_latexmk_build_dir - if g:latex_latexmk_continuous + if g:vimtex_latexmk_continuous let cmd .= ' -pvc' endif - if g:latex_latexmk_callback && has('clientserver') + if g:vimtex_latexmk_callback && has('clientserver') let success = v:progname let success .= ' --servername ' . v:servername - let success .= ' --remote-expr \"latex\#latexmk\#callback(1)\"' + let success .= ' --remote-expr \"vimtex\#latexmk\#callback(1)\"' let failed = v:progname let failed .= ' --servername ' . v:servername - let failed .= ' --remote-expr \"latex\#latexmk\#callback(0)\"' - let cmd .= latex#latexmk#add_option('success_cmd', success) - let cmd .= latex#latexmk#add_option('failure_cmd', failed) + let failed .= ' --remote-expr \"vimtex\#latexmk\#callback(0)\"' + let cmd .= vimtex#latexmk#add_option('success_cmd', success) + let cmd .= vimtex#latexmk#add_option('failure_cmd', failed) let s:first_callback = 1 endif - if has_key(g:latex#data[b:latex.id].viewer, 'latexmk_append_argument') - let cmd .= g:latex#data[b:latex.id].viewer.latexmk_append_argument() + if has_key(g:vimtex#data[b:vimtex.id].viewer, 'latexmk_append_argument') + let cmd .= g:vimtex#data[b:vimtex.id].viewer.latexmk_append_argument() endif - let cmd .= ' ' . latex#util#fnameescape(a:data.base) + let cmd .= ' ' . vimtex#util#fnameescape(a:data.base) - if g:latex_latexmk_continuous || g:latex_latexmk_background + if g:vimtex_latexmk_continuous || g:vimtex_latexmk_background if has('win32') let cmd .= ' >' . tmp let cmd = 'cmd /s /c "' . cmd . '"' @@ -418,7 +418,7 @@ function! s:latexmk_kill_pid(pid) " {{{1 let exe.cmd = 'kill ' . a:pid endif - call latex#util#execute(exe) + call vimtex#util#execute(exe) endfunction " }}}1 @@ -436,9 +436,9 @@ function! s:stop_buffer() " {{{1 " " Only run if latex variables are set " - if !exists('b:latex') | return | endif - let id = b:latex.id - let pid = g:latex#data[id].pid + if !exists('b:vimtex') | return | endif + let id = b:vimtex.id + let pid = g:vimtex#data[id].pid " " Only stop if latexmk is running @@ -449,7 +449,7 @@ function! s:stop_buffer() " {{{1 " let n = 0 for b in filter(range(1, bufnr("$")), 'buflisted(v:val)') - if id == getbufvar(b, 'latex', {'id' : -1}).id + if id == getbufvar(b, 'vimtex', {'id' : -1}).id let n += 1 endif endfor @@ -458,7 +458,7 @@ function! s:stop_buffer() " {{{1 " Only stop if current buffer is the last for current latex blob " if n == 1 - silent call latex#latexmk#stop() + silent call vimtex#latexmk#stop() endif endif endfunction @@ -475,7 +475,7 @@ function! s:system_incompatible() " {{{1 " for cmd in required if !executable(cmd) - echom "Warning: Could not initialize latex#latexmk" + echom "Warning: Could not initialize vimtex#latexmk" echom " Missing executable: " . cmd return 1 endif diff --git a/autoload/vimtex/mappings.vim b/autoload/vimtex/mappings.vim new file mode 100644 index 0000000..65af840 --- /dev/null +++ b/autoload/vimtex/mappings.vim @@ -0,0 +1,80 @@ +" vimtex - LaTeX plugin for Vim +" +" Maintainer: Karl Yngve Lervåg +" Email: karl.yngve@gmail.com +" + +function! vimtex#mappings#init(initialized) + call vimtex#util#set_default('g:vimtex_mappings_enabled', 1) + if !g:vimtex_mappings_enabled | return | endif + + nmap li (vimtex-info) + nmap lh (vimtex-help) + nmap lR (vimtex-reinit) + + nmap dse (vimtex-delete-env) + nmap dsc (vimtex-delete-cmd) + nmap cse (vimtex-change-env) + nmap csc (vimtex-change-cmd) + nmap tse (vimtex-toggle-star) + nmap tsd (vimtex-toggle-delim) + nmap (vimtex-create-cmd) + imap (vimtex-create-cmd) + imap ]] (vimtex-close-env) + + if g:vimtex_latexmk_enabled + nmap ll (vimtex-compile-toggle) + nmap lo (vimtex-compile-output) + nmap lk (vimtex-stop) + nmap lK (vimtex-stop-all) + nmap le (vimtex-errors) + nmap lc (vimtex-clean) + nmap lC (vimtex-clean-full) + nmap lg (vimtex-status) + nmap lG (vimtex-status-all) + endif + + if g:vimtex_motion_enabled + nmap % (vimtex-%) + xmap % (vimtex-%) + omap % (vimtex-%) + nmap ]] (vimtex-]]) + nmap ][ (vimtex-][) + nmap [] (vimtex-[]) + nmap [[ (vimtex-[[) + xmap ]] (vimtex-]]) + xmap ][ (vimtex-][) + xmap [] (vimtex-[]) + xmap [[ (vimtex-[[) + omap ]] (vimtex-]]) + omap ][ (vimtex-][) + omap [] (vimtex-[]) + omap [[ (vimtex-[[) + xmap ie (vimtex-ie) + xmap ae (vimtex-ae) + omap ie (vimtex-ie) + omap ae (vimtex-ae) + xmap i$ (vimtex-i$) + xmap a$ (vimtex-a$) + omap i$ (vimtex-i$) + omap a$ (vimtex-a$) + xmap id (vimtex-id) + xmap ad (vimtex-ad) + omap id (vimtex-id) + omap ad (vimtex-ad) + endif + + if g:vimtex_toc_enabled + nmap lt (vimtex-toc-open) + nmap lT (vimtex-toc-toggle) + endif + + if g:vimtex_view_enabled + nmap lv (vimtex-view) + if has_key(g:vimtex#data[b:vimtex.id], 'rsearch') + nmap lr (vimtex-reverse-search) + endif + endif +endfunction + +" vim: fdm=marker sw=2 diff --git a/autoload/latex/motion.vim b/autoload/vimtex/motion.vim similarity index 70% rename from autoload/latex/motion.vim rename to autoload/vimtex/motion.vim index b916efa..3682d57 100644 --- a/autoload/latex/motion.vim +++ b/autoload/vimtex/motion.vim @@ -1,47 +1,47 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#motion#init(initialized) " {{{1 - call latex#util#set_default('g:latex_motion_enabled', 1) - if !g:latex_motion_enabled | return | endif +function! vimtex#motion#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_motion_enabled', 1) + if !g:vimtex_motion_enabled | return | endif " Set default options - call latex#util#set_default('g:latex_motion_matchparen', 1) + call vimtex#util#set_default('g:vimtex_motion_matchparen', 1) " Define mappings - nnoremap (vl-%) :call latex#motion#find_matching_pair() - xnoremap (vl-%) :call latex#motion#find_matching_pair(1) - onoremap (vl-%) :normal v% - nnoremap (vl-]]) :call latex#motion#next_section(0,0,0) - nnoremap (vl-][) :call latex#motion#next_section(1,0,0) - nnoremap (vl-[]) :call latex#motion#next_section(1,1,0) - nnoremap (vl-[[) :call latex#motion#next_section(0,1,0) - xnoremap (vl-]]) :call latex#motion#next_section(0,0,1) - xnoremap (vl-][) :call latex#motion#next_section(1,0,1) - xnoremap (vl-[]) :call latex#motion#next_section(1,1,1) - xnoremap (vl-[[) :call latex#motion#next_section(0,1,1) - onoremap (vl-]]) :normal v]] - onoremap (vl-][) :normal v][ - onoremap (vl-[]) :normal v[] - onoremap (vl-[[) :normal v[[ - xnoremap (vl-ie) :call latex#motion#sel_environment(1) - xnoremap (vl-ae) :call latex#motion#sel_environment() - onoremap (vl-ie) :normal vie - onoremap (vl-ae) :normal vae - xnoremap (vl-i$) :call latex#motion#sel_inline_math(1) - xnoremap (vl-a$) :call latex#motion#sel_inline_math() - onoremap (vl-i$) :normal vi$ - onoremap (vl-a$) :normal va$ - xnoremap (vl-id) :call latex#motion#sel_delimiter(1) - xnoremap (vl-ad) :call latex#motion#sel_delimiter() - onoremap (vl-id) :normal vi( - onoremap (vl-ad) :normal va( + nnoremap (vimtex-%) :call vimtex#motion#find_matching_pair() + xnoremap (vimtex-%) :call vimtex#motion#find_matching_pair(1) + onoremap (vimtex-%) :normal v% + nnoremap (vimtex-]]) :call vimtex#motion#next_section(0,0,0) + nnoremap (vimtex-][) :call vimtex#motion#next_section(1,0,0) + nnoremap (vimtex-[]) :call vimtex#motion#next_section(1,1,0) + nnoremap (vimtex-[[) :call vimtex#motion#next_section(0,1,0) + xnoremap (vimtex-]]) :call vimtex#motion#next_section(0,0,1) + xnoremap (vimtex-][) :call vimtex#motion#next_section(1,0,1) + xnoremap (vimtex-[]) :call vimtex#motion#next_section(1,1,1) + xnoremap (vimtex-[[) :call vimtex#motion#next_section(0,1,1) + onoremap (vimtex-]]) :normal v]] + onoremap (vimtex-][) :normal v][ + onoremap (vimtex-[]) :normal v[] + onoremap (vimtex-[[) :normal v[[ + xnoremap (vimtex-ie) :call vimtex#motion#sel_environment(1) + xnoremap (vimtex-ae) :call vimtex#motion#sel_environment() + onoremap (vimtex-ie) :normal vie + onoremap (vimtex-ae) :normal vae + xnoremap (vimtex-i$) :call vimtex#motion#sel_inline_math(1) + xnoremap (vimtex-a$) :call vimtex#motion#sel_inline_math() + onoremap (vimtex-i$) :normal vi$ + onoremap (vimtex-a$) :normal va$ + xnoremap (vimtex-id) :call vimtex#motion#sel_delimiter(1) + xnoremap (vimtex-ad) :call vimtex#motion#sel_delimiter() + onoremap (vimtex-id) :normal vi( + onoremap (vimtex-ad) :normal va( " Highlight matching parens ($, (), ...) - if !a:initialized && g:latex_motion_matchparen + if !a:initialized && g:vimtex_motion_matchparen augroup latex_motion autocmd! " Disable matchparen autocommands @@ -59,12 +59,12 @@ function! latex#motion#init(initialized) " {{{1 endif endfunction -function! latex#motion#find_matching_pair(...) " {{{1 +function! vimtex#motion#find_matching_pair(...) " {{{1 if a:0 > 0 normal! gv endif - if latex#util#in_comment() | return | endif + if vimtex#util#in_comment() | return | endif " Save position let nl = line('.') @@ -90,7 +90,7 @@ function! latex#motion#find_matching_pair(...) " {{{1 if delim =~ '^\$' let inline = s:notcomment . s:notbslash . '\$' let [lnum0, cnum0] = searchpos('.', 'nW') - if lnum0 && latex#util#has_syntax('texMathZoneX', lnum0, cnum0) + if lnum0 && vimtex#util#has_syntax('texMathZoneX', lnum0, cnum0) let [lnum2, cnum2] = searchpos(inline, 'nW', 0, 200) else let [lnum2, cnum2] = searchpos(not_cursor . inline, 'bnW', 0, 200) @@ -104,19 +104,19 @@ function! latex#motion#find_matching_pair(...) " {{{1 if delim =~# '^' . open_pat call searchpairpos(open_pat, '', close_pat, - \ 'W', 'latex#util#in_comment()', 0, 200) + \ 'W', 'vimtex#util#in_comment()', 0, 200) call search(close_pat, 'ce') return elseif delim =~# '^' . close_pat call searchpairpos(open_pat, '', not_cursor . close_pat, - \ 'bW', 'latex#util#in_comment()', 0, 200) + \ 'bW', 'vimtex#util#in_comment()', 0, 200) return endif endfor endif endfunction -function! latex#motion#next_section(type, backwards, visual) " {{{1 +function! vimtex#motion#next_section(type, backwards, visual) " {{{1 " Restore visual mode if desired if a:visual normal! gv @@ -150,10 +150,10 @@ function! latex#motion#next_section(type, backwards, visual) " {{{1 endif endfunction -function! latex#motion#sel_delimiter(...) " {{{1 +function! vimtex#motion#sel_delimiter(...) " {{{1 let inner = a:0 > 0 - let [d1, l1, c1, d2, l2, c2] = latex#util#get_delim() + let [d1, l1, c1, d2, l2, c2] = vimtex#util#get_delim() if inner let c1 += len(d1) @@ -184,10 +184,10 @@ function! latex#motion#sel_delimiter(...) " {{{1 endif endfunction -function! latex#motion#sel_environment(...) " {{{1 +function! vimtex#motion#sel_environment(...) " {{{1 let inner = a:0 > 0 - let [env, lnum, cnum, lnum2, cnum2] = latex#util#get_env(1) + let [env, lnum, cnum, lnum2, cnum2] = vimtex#util#get_env(1) call cursor(lnum, cnum) if inner if env =~ '^\' @@ -213,12 +213,12 @@ function! latex#motion#sel_environment(...) " {{{1 endif endfunction -function! latex#motion#sel_inline_math(...) " {{{1 +function! vimtex#motion#sel_inline_math(...) " {{{1 let inner = a:0 > 0 let dollar_pat = '\\\@' " }}}1 function! s:highlight_matching_pair(...) " {{{1 - if latex#util#in_comment() | return | endif + if vimtex#util#in_comment() | return | endif let hmode = a:0 > 0 ? 1 : 0 2match none @@ -307,7 +307,7 @@ function! s:highlight_matching_pair(...) " {{{1 " Match inline math " let [lnum0, cnum0] = searchpos('.', 'nW') - if lnum0 && latex#util#has_syntax('texMathZoneX', lnum0, cnum0) + if lnum0 && vimtex#util#has_syntax('texMathZoneX', lnum0, cnum0) let [lnum2, cnum2] = searchpos(s:notcomment . s:notbslash . '\$', \ 'nW', line('w$'), 200) else @@ -328,7 +328,7 @@ function! s:highlight_matching_pair(...) " {{{1 if delim =~# '^' . open_pat let [lnum2, cnum2] = searchpairpos(open_pat, '', close_pat, - \ 'nW', 'latex#util#in_comment()', line('w$'), 200) + \ 'nW', 'vimtex#util#in_comment()', line('w$'), 200) execute '2match MatchParen /\%(\%' . nl . 'l\%' . cnum \ . 'c' . s:delimiters_open[i] . '\|\%' \ . lnum2 . 'l\%' . cnum2 . 'c' @@ -337,7 +337,7 @@ function! s:highlight_matching_pair(...) " {{{1 elseif delim =~# '^' . close_pat let [lnum2, cnum2] = searchpairpos(open_pat, '', \ '\C\%(\%'. nl . 'l\%' . cnum . 'c\)\@!' . close_pat, - \ 'bnW', 'latex#util#in_comment()', line('w0'), 200) + \ 'bnW', 'vimtex#util#in_comment()', line('w0'), 200) execute '2match MatchParen /\%(\%' . lnum2 . 'l\%' . cnum2 \ . 'c' . s:delimiters_open[i] . '\|\%' \ . nl . 'l\%' . cnum . 'c' @@ -362,7 +362,7 @@ function! s:search_and_skip_comments(pat, ...) " {{{1 let flags = substitute(flags, 'c', '', 'g') " keep searching while in comment - while latex#util#in_comment() + while vimtex#util#in_comment() let ret = search(a:pat, flags, stopline) if !ret break diff --git a/autoload/latex/toc.vim b/autoload/vimtex/toc.vim similarity index 81% rename from autoload/latex/toc.vim rename to autoload/vimtex/toc.vim index 26081b2..e74bd54 100644 --- a/autoload/latex/toc.vim +++ b/autoload/vimtex/toc.vim @@ -1,37 +1,37 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#toc#init(initialized) " {{{1 - call latex#util#set_default('g:latex_toc_enabled', 1) - if !g:latex_toc_enabled | return | endif +function! vimtex#toc#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_toc_enabled', 1) + if !g:vimtex_toc_enabled | return | endif " Set default options - call latex#util#set_default('g:latex_toc_fold', 0) - call latex#util#set_default('g:latex_toc_fold_levels', 10) - call latex#util#set_default('g:latex_toc_hide_help', 0) - call latex#util#set_default('g:latex_toc_hide_line_numbers', 1) - call latex#util#set_default('g:latex_toc_hide_preamble', 0) - call latex#util#set_default('g:latex_toc_numbers', 1) - call latex#util#set_default('g:latex_toc_numbers_width', 0) - call latex#util#set_default('g:latex_toc_resize', 1) - call latex#util#set_default('g:latex_toc_secnumdepth', 3) - call latex#util#set_default('g:latex_toc_split_pos', 'vert leftabove') - call latex#util#set_default('g:latex_toc_width', 30) - call latex#util#error_deprecated('g:latex_toc_split_side') + call vimtex#util#set_default('g:vimtex_toc_fold', 0) + call vimtex#util#set_default('g:vimtex_toc_fold_levels', 10) + call vimtex#util#set_default('g:vimtex_toc_hide_help', 0) + call vimtex#util#set_default('g:vimtex_toc_hide_line_numbers', 1) + call vimtex#util#set_default('g:vimtex_toc_hide_preamble', 0) + call vimtex#util#set_default('g:vimtex_toc_numbers', 1) + call vimtex#util#set_default('g:vimtex_toc_numbers_width', 0) + call vimtex#util#set_default('g:vimtex_toc_resize', 1) + call vimtex#util#set_default('g:vimtex_toc_secnumdepth', 3) + call vimtex#util#set_default('g:vimtex_toc_split_pos', 'vert leftabove') + call vimtex#util#set_default('g:vimtex_toc_width', 30) + call vimtex#util#error_deprecated('g:vimtex_toc_split_side') " Define commands - command! -buffer VimLatexTocOpen call latex#toc#open() - command! -buffer VimLatexTocToggle call latex#toc#toggle() + command! -buffer VimtexTocOpen call vimtex#toc#open() + command! -buffer VimtexTocToggle call vimtex#toc#toggle() " Define mappings - nnoremap (vl-toc-open) :call latex#toc#open() - nnoremap (vl-toc-toggle) :call latex#toc#toggle() + nnoremap (vimtex-toc-open) :call vimtex#toc#open() + nnoremap (vimtex-toc-toggle) :call vimtex#toc#toggle() endfunction -function! latex#toc#open() " {{{1 +function! vimtex#toc#open() " {{{1 " Go to TOC if it already exists let winnr = bufwinnr(bufnr('LaTeX TOC')) if winnr >= 0 @@ -46,17 +46,17 @@ function! latex#toc#open() " {{{1 let toc = s:parse_toc() " Resize vim session if wanted, then create TOC window - if g:latex_toc_resize - silent exe "set columns+=" . g:latex_toc_width + if g:vimtex_toc_resize + silent exe "set columns+=" . g:vimtex_toc_width endif - silent exe g:latex_toc_split_pos g:latex_toc_width . 'new LaTeX\ TOC' + silent exe g:vimtex_toc_split_pos g:vimtex_toc_width . 'new LaTeX\ TOC' " Set buffer local variables let b:toc = toc let b:toc_numbers = 1 let b:toc_max_level = s:max_level let b:toc_topmatters = s:count_matters - let b:toc_secnumdepth = g:latex_toc_secnumdepth + let b:toc_secnumdepth = g:vimtex_toc_secnumdepth let b:calling_winnr = bufwinnr(calling_buf) let b:calling_file = calling_file let b:calling_line = calling_line @@ -64,14 +64,14 @@ function! latex#toc#open() " {{{1 setlocal filetype=latextoc endfunction -function! latex#toc#toggle() " {{{1 +function! vimtex#toc#toggle() " {{{1 if bufwinnr(bufnr('LaTeX TOC')) >= 0 - if g:latex_toc_resize - silent exe "set columns-=" . g:latex_toc_width + if g:vimtex_toc_resize + silent exe "set columns-=" . g:vimtex_toc_width endif silent execute 'bwipeout' . bufnr('LaTeX TOC') else - call latex#toc#open() + call vimtex#toc#open() silent execute 'wincmd w' endif endfunction @@ -140,7 +140,7 @@ let s:re_other = { " }}}1 function! s:parse_toc() " {{{1 - let file = g:latex#data[b:latex.id].tex + let file = g:vimtex#data[b:vimtex.id].tex " Reset TOC numbering call s:number_reset('preamble') @@ -157,7 +157,7 @@ endfunction " }}}1 function! s:parse_limits(file) " {{{1 if !filereadable(a:file) - echoerr "Error in latex#toc s:parse_limits" + echoerr "Error in vimtex#toc s:parse_limits" echoerr "File not readable: " . a:file return '' endif @@ -191,7 +191,7 @@ function! s:parse_file(file) " {{{1 if a:file == '' return [] elseif !filereadable(a:file) - echoerr "Error in latex#toc s:parse_file" + echoerr "Error in vimtex#toc s:parse_file" echoerr "File not readable: " . a:file return [] endif @@ -210,7 +210,7 @@ function! s:parse_file(file) " {{{1 " 2. Parse preamble if s:number.preamble - if !g:latex_toc_hide_preamble && line =~# '\v^\s*\\documentclass' + if !g:vimtex_toc_hide_preamble && line =~# '\v^\s*\\documentclass' call add(toc, { \ 'title' : 'Preamble', \ 'number' : '', diff --git a/autoload/latex/util.vim b/autoload/vimtex/util.vim similarity index 87% rename from autoload/latex/util.vim rename to autoload/vimtex/util.vim index 2c89068..d1df747 100644 --- a/autoload/latex/util.vim +++ b/autoload/vimtex/util.vim @@ -1,12 +1,10 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -" Utility functions sorted by name -" -function! latex#util#convert_back(line) " {{{1 +function! vimtex#util#convert_back(line) " {{{1 " " Substitute stuff like '\IeC{\"u}' to corresponding unicode symbols " @@ -82,15 +80,15 @@ let s:convert_back_list = map([ \ ['\\\~n}' , 'ñ'], \], '[''\C\(\\IeC\s*{\)\?'' . v:val[0], v:val[1]]') -function! latex#util#error_deprecated(variable) " {{{1 +function! vimtex#util#error_deprecated(variable) " {{{1 if exists(a:variable) echoerr "Deprecation error: " . a:variable echoerr "Please read docs for more info!" - echoerr ":h vim-latex-changelog" + echoerr ":h vimtex-changelog" endif endfunction -function! latex#util#execute(exe) " {{{1 +function! vimtex#util#execute(exe) " {{{1 " Execute the given command on the current system. Wrapper function to make " it easier to run on both windows and unix. " @@ -108,7 +106,7 @@ function! latex#util#execute(exe) " {{{1 " Check and parse arguments if !has_key(a:exe, 'cmd') - echoerr "Error in latex#util#execute!" + echoerr "Error in vimtex#util#execute!" echoerr "Argument error, exe.cmd does not exist!" return endif @@ -171,19 +169,19 @@ function! latex#util#execute(exe) " {{{1 endif endfunction -function! latex#util#fnameescape(path) " {{{1 +function! vimtex#util#fnameescape(path) " {{{1 " " In a Windows environment, a path used in "cmd" only needs to be enclosed by " double quotes. shellscape() on Windows with "shellslash" set will produce " a path enclosed by single quotes, which "cmd" does not recognize and - " reports an error. Any path that goes into latex#util#execute() should be + " reports an error. Any path that goes into vimtex#util#execute() should be " processed through this function. " return has('win32') ? '"' . a:path . '"' : shellescape(a:path) endfunction -function! latex#util#get_env(...) " {{{1 - " latex#util#get_env([with_pos]) +function! vimtex#util#get_env(...) " {{{1 + " vimtex#util#get_env([with_pos]) " Returns: " - environment " if with_pos is not given @@ -209,7 +207,7 @@ function! latex#util#get_env(...) " {{{1 let flags .= 'c' endif let [lnum1, cnum1] = searchpairpos(begin_pat, '', end_pat, flags, - \ 'latex#util#in_comment()') + \ 'vimtex#util#in_comment()') let env = '' @@ -234,7 +232,7 @@ function! latex#util#get_env(...) " {{{1 endif let [lnum2, cnum2] = searchpairpos(begin_pat, '', end_pat, flags, - \ 'latex#util#in_comment()') + \ 'vimtex#util#in_comment()') call setpos('.', saved_pos) return [env, lnum1, cnum1, lnum2, cnum2] @@ -244,7 +242,7 @@ function! latex#util#get_env(...) " {{{1 endif endfunction -function! latex#util#get_delim() " {{{1 +function! vimtex#util#get_delim() " {{{1 " Save position in order to restore before finishing let pos_original = getpos('.') @@ -283,7 +281,7 @@ function! latex#util#get_delim() " {{{1 endif " Search for closing delimiter - let pos = searchpairpos(open, '', close, flags, 'latex#util#in_comment()') + let pos = searchpairpos(open, '', close, flags, 'vimtex#util#in_comment()') " Check if the current is pair is the closest pair if pos[0] && pos[0]*1000 + pos[1] < l2*1000 + c2 @@ -291,7 +289,7 @@ function! latex#util#get_delim() " {{{1 let c2=pos[1] let d2=matchstr(strpart(getline(l2), c2 - 1), close) - let pos = searchpairpos(open,'',close,'bW', 'latex#util#in_comment()') + let pos = searchpairpos(open,'',close,'bW', 'vimtex#util#in_comment()') let l1=pos[0] let c1=pos[1] let d1=matchstr(strpart(getline(l1), c1 - 1), open) @@ -318,7 +316,7 @@ let s:delimiters_close = [ \ '\\\cbigg\?\()\|\]\|\\}\)', \ ] -function! latex#util#get_os() " {{{1 +function! vimtex#util#get_os() " {{{1 if has("win32") return "win" elseif has("unix") @@ -330,19 +328,19 @@ function! latex#util#get_os() " {{{1 endif endfunction -function! latex#util#has_syntax(name, ...) " {{{1 - " Usage: latex#util#has_syntax(name, [line], [col]) +function! vimtex#util#has_syntax(name, ...) " {{{1 + " Usage: vimtex#util#has_syntax(name, [line], [col]) let line = a:0 >= 1 ? a:1 : line('.') let col = a:0 >= 2 ? a:2 : col('.') return 0 <= index(map(synstack(line, col), \ 'synIDattr(v:val, "name") == "' . a:name . '"'), 1) endfunction -function! latex#util#in_comment(...) " {{{1 +function! vimtex#util#in_comment(...) " {{{1 return synIDattr(synID(line('.'), col('.'), 0), "name") =~# '^texComment' endfunction -function! latex#util#kpsewhich(file, ...) " {{{1 +function! vimtex#util#kpsewhich(file, ...) " {{{1 let cmd = 'kpsewhich ' let cmd .= a:0 > 0 ? a:1 : '' let cmd .= ' "' . a:file . '"' @@ -358,19 +356,19 @@ function! latex#util#kpsewhich(file, ...) " {{{1 return out endfunction -function! latex#util#set_default(variable, default) " {{{1 +function! vimtex#util#set_default(variable, default) " {{{1 if !exists(a:variable) let {a:variable} = a:default endif endfunction -function! latex#util#set_default_os_specific(variable, default) " {{{1 +function! vimtex#util#set_default_os_specific(variable, default) " {{{1 if !exists(a:variable) - let {a:variable} = get(a:default, latex#util#get_os(), '') + let {a:variable} = get(a:default, vimtex#util#get_os(), '') endif endfunction -function! latex#util#tex2tree(str) " {{{1 +function! vimtex#util#tex2tree(str) " {{{1 let tree = [] let i1 = 0 let i2 = -1 @@ -393,7 +391,7 @@ function! latex#util#tex2tree(str) " {{{1 else let depth -= 1 if depth == 0 - call add(tree, latex#util#tex2tree(strpart(a:str, i1, i2 - i1))) + call add(tree, vimtex#util#tex2tree(strpart(a:str, i1, i2 - i1))) let i1 = i2 + 1 endif endif @@ -401,11 +399,11 @@ function! latex#util#tex2tree(str) " {{{1 return tree endfunction -function! latex#util#tree2tex(tree) " {{{1 +function! vimtex#util#tree2tex(tree) " {{{1 if type(a:tree) == type('') return a:tree else - return '{' . join(map(a:tree, 'latex#util#tree2tex(v:val)'), '') . '}' + return '{' . join(map(a:tree, 'vimtex#util#tree2tex(v:val)'), '') . '}' endif endfunction diff --git a/autoload/latex/view.vim b/autoload/vimtex/view.vim similarity index 70% rename from autoload/latex/view.vim rename to autoload/vimtex/view.vim index 45dd335..133d692 100644 --- a/autoload/latex/view.vim +++ b/autoload/vimtex/view.vim @@ -1,34 +1,34 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latex#view#init(initialized) " {{{1 - call latex#util#set_default('g:latex_view_enabled', 1) - if !g:latex_view_enabled | return | endif +function! vimtex#view#init(initialized) " {{{1 + call vimtex#util#set_default('g:vimtex_view_enabled', 1) + if !g:vimtex_view_enabled | return | endif - let data = g:latex#data[b:latex.id] + let data = g:vimtex#data[b:vimtex.id] " Initialize viewer options for viewer in s:viewers - call latex#util#set_default('g:latex_view_' . viewer . '_options', '') + call vimtex#util#set_default('g:vimtex_view_' . viewer . '_options', '') endfor " Initialize other options - call latex#util#set_default_os_specific('g:latex_view_general_viewer', + call vimtex#util#set_default_os_specific('g:vimtex_view_general_viewer', \ { \ 'linux' : 'xdg-open', \ 'mac' : 'open', \ }) - call latex#util#set_default('g:latex_view_method', 'general') - call latex#util#set_default('g:latex_view_mupdf_send_keys', '') - call latex#util#error_deprecated('g:latex_viewer') + call vimtex#util#set_default('g:vimtex_view_method', 'general') + call vimtex#util#set_default('g:vimtex_view_mupdf_send_keys', '') + call vimtex#util#error_deprecated('g:vimtex_viewer') - let viewer = 's:' . g:latex_view_method + let viewer = 's:' . g:vimtex_view_method if !exists(viewer) echoerr "Viewer does not exist!" - echoerr "Viewer: " . g:latex_view_method + echoerr "Viewer: " . g:vimtex_view_method return endif @@ -36,18 +36,18 @@ function! latex#view#init(initialized) " {{{1 call data.viewer.init() " Define commands - command! -buffer VimLatexView call g:latex#data[b:latex.id].viewer.view() + command! -buffer VimtexView call g:vimtex#data[b:vimtex.id].viewer.view() if has_key(data.viewer, 'reverse_search') - command! -buffer -nargs=* VimLatexRSearch - \ call g:latex#data[b:latex.id].viewer.reverse_search() + command! -buffer -nargs=* VimtexRSearch + \ call g:vimtex#data[b:vimtex.id].viewer.reverse_search() endif " Define mappings - nnoremap (vl-view) - \ :call g:latex#data[b:latex.id].viewer.view() + nnoremap (vimtex-view) + \ :call g:vimtex#data[b:vimtex.id].viewer.view() if has_key(data.viewer, 'reverse_search') - nnoremap (vl-reverse-search) - \ :call g:latex#data[b:latex.id].viewer.reverse_search() + nnoremap (vimtex-reverse-search) + \ :call g:vimtex#data[b:vimtex.id].viewer.reverse_search() endif endfunction @@ -67,27 +67,27 @@ endfor " {{{1 General function! s:general.init() dict " {{{2 - if !executable(g:latex_view_general_viewer) + if !executable(g:vimtex_view_general_viewer) echoerr "General viewer is not available!" - echoerr "g:latex_view_general_viewer = " - \ . g:latex_view_general_viewer + echoerr "g:vimtex_view_general_viewer = " + \ . g:vimtex_view_general_viewer endif endfunction " }}}2 function! s:general.view() dict " {{{2 let exe = {} - let exe.cmd = g:latex_view_general_viewer + let exe.cmd = g:vimtex_view_general_viewer - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return endif - let exe.cmd .= ' ' . g:latex_view_general_options - let exe.cmd .= ' ' . latex#util#fnameescape(outfile) + let exe.cmd .= ' ' . g:vimtex_view_general_options + let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile) - call latex#util#execute(exe) + call vimtex#util#execute(exe) let self.cmd_view = exe.cmd endfunction @@ -123,21 +123,21 @@ endfunction " }}}2 function! s:mupdf.start() dict " {{{2 - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return endif let exe = {} - let exe.cmd = 'mupdf ' . g:latex_view_mupdf_options - let exe.cmd .= ' ' . latex#util#fnameescape(outfile) - call latex#util#execute(exe) + let exe.cmd = 'mupdf ' . g:vimtex_view_mupdf_options + let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile) + call vimtex#util#execute(exe) let self.cmd_start = exe.cmd call self.xwin_get_id() - call self.xwin_send_keys(g:latex_view_mupdf_send_keys) + call self.xwin_send_keys(g:vimtex_view_mupdf_send_keys) call self.forward_search() endfunction @@ -146,7 +146,7 @@ function! s:mupdf.forward_search() dict " {{{2 if !executable('xdotool') | return | endif if !executable('synctex') | return | endif - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return @@ -155,8 +155,8 @@ function! s:mupdf.forward_search() dict " {{{2 let self.cmd_synctex_view = "synctex view -i " \ . (line(".") + 1) . ":" \ . (col(".") + 1) . ":" - \ . latex#util#fnameescape(expand("%:p")) - \ . " -o " . latex#util#fnameescape(outfile) + \ . vimtex#util#fnameescape(expand("%:p")) + \ . " -o " . vimtex#util#fnameescape(outfile) \ . " | grep -m1 'Page:' | sed 's/Page://' | tr -d '\n'" let self.page = system(self.cmd_synctex_view) @@ -165,7 +165,7 @@ function! s:mupdf.forward_search() dict " {{{2 let exe.cmd = 'xdotool' let exe.cmd .= ' type --window ' . self.xwin_id let exe.cmd .= ' "' . self.page . 'g"' - call latex#util#execute(exe) + call vimtex#util#execute(exe) let self.cmd_forward_search = exe.cmd endif @@ -177,7 +177,7 @@ function! s:mupdf.reverse_search() dict " {{{2 if !executable('xdotool') | return | endif if !executable('synctex') | return | endif - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return @@ -222,18 +222,18 @@ endfunction " }}}2 function! s:mupdf.latexmk_callback() dict " {{{2 call self.xwin_get_id() - call self.xwin_send_keys(g:latex_view_mupdf_send_keys) + call self.xwin_send_keys(g:vimtex_view_mupdf_send_keys) call self.forward_search() call self.focus_vim() endfunction " }}}2 function! s:mupdf.latexmk_append_argument() dict " {{{2 - let cmd = latex#latexmk#add_option('new_viewer_always', '0') - let cmd .= latex#latexmk#add_option('pdf_update_method', '2') - let cmd .= latex#latexmk#add_option('pdf_update_signal', 'SIGHUP') - let cmd .= latex#latexmk#add_option('pdf_previewer', - \ 'start mupdf ' . g:latex_view_mupdf_options) + let cmd = vimtex#latexmk#add_option('new_viewer_always', '0') + let cmd .= vimtex#latexmk#add_option('pdf_update_method', '2') + let cmd .= vimtex#latexmk#add_option('pdf_update_signal', 'SIGHUP') + let cmd .= vimtex#latexmk#add_option('pdf_previewer', + \ 'start mupdf ' . g:vimtex_view_mupdf_options) return cmd endfunction @@ -248,18 +248,18 @@ endfunction " }}}2 function! s:okular.view() dict " {{{2 - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return endif let exe = {} - let exe.cmd = 'okular ' . g:latex_view_okular_options - let exe.cmd .= ' --unique ' . latex#util#fnameescape(outfile) - let exe.cmd .= '\#src:' . line('.') . latex#util#fnameescape(expand('%:p')) + let exe.cmd = 'okular ' . g:vimtex_view_okular_options + let exe.cmd .= ' --unique ' . vimtex#util#fnameescape(outfile) + let exe.cmd .= '\#src:' . line('.') . vimtex#util#fnameescape(expand('%:p')) - call latex#util#execute(exe) + call vimtex#util#execute(exe) let self.cmd_view = exe.cmd endfunction @@ -274,20 +274,20 @@ endfunction " }}}2 function! s:qpdfview.view() dict " {{{2 - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return endif let exe = {} - let exe.cmd = 'qpdfview ' . g:latex_view_qpdfview_options - let exe.cmd .= ' --unique ' . latex#util#fnameescape(outfile) - let exe.cmd .= '\#src:' . latex#util#fnameescape(expand('%:p')) + let exe.cmd = 'qpdfview ' . g:vimtex_view_qpdfview_options + let exe.cmd .= ' --unique ' . vimtex#util#fnameescape(outfile) + let exe.cmd .= '\#src:' . vimtex#util#fnameescape(expand('%:p')) let exe.cmd .= ':' . line('.') let exe.cmd .= ':' . col('.') - call latex#util#execute(exe) + call vimtex#util#execute(exe) let self.cmd_view = exe.cmd endfunction @@ -302,19 +302,19 @@ endfunction " }}}2 function! s:sumatrapdf.view() dict " {{{2 - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return endif let exe = {} - let exe.cmd = 'SumatraPDF ' . g:latex_view_sumatrapdf_options - let exe.cmd .= ' -forward-search ' . latex#util#fnameescape(expand('%:p')) + let exe.cmd = 'SumatraPDF ' . g:vimtex_view_sumatrapdf_options + let exe.cmd .= ' -forward-search ' . vimtex#util#fnameescape(expand('%:p')) let exe.cmd .= ' ' . line('.') - let exe.cmd .= ' ' . latex#util#fnameescape(outfile) + let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile) - call latex#util#execute(exe) + call vimtex#util#execute(exe) let self.cmd_view = exe.cmd endfunction @@ -348,19 +348,19 @@ endfunction " }}}2 function! s:zathura.start() dict " {{{2 - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return endif let exe = {} - let exe.cmd = 'zathura ' . g:latex_view_zathura_options + let exe.cmd = 'zathura ' . g:vimtex_view_zathura_options let exe.cmd .= ' -x "' . exepath(v:progname) \ . ' --servername ' . v:servername \ . ' --remote +\%{line} \%{input}"' - let exe.cmd .= ' ' . latex#util#fnameescape(outfile) - call latex#util#execute(exe) + let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile) + call vimtex#util#execute(exe) let self.cmd_start = exe.cmd @@ -370,7 +370,7 @@ endfunction " }}}2 function! s:zathura.forward_search() dict " {{{2 - let outfile = g:latex#data[b:latex.id].out() + let outfile = g:vimtex#data[b:vimtex.id].out() if !filereadable(outfile) echomsg "Can't view: Output file is not readable!" return @@ -380,9 +380,9 @@ function! s:zathura.forward_search() dict " {{{2 let exe.cmd = 'zathura --synctex-forward ' let exe.cmd .= line(".") let exe.cmd .= ':' . col('.') - let exe.cmd .= ':' . latex#util#fnameescape(expand('%:p')) - let exe.cmd .= ' ' . latex#util#fnameescape(outfile) - call latex#util#execute(exe) + let exe.cmd .= ':' . vimtex#util#fnameescape(expand('%:p')) + let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile) + call vimtex#util#execute(exe) let self.cmd_forward_search = exe.cmd endfunction @@ -396,9 +396,9 @@ endfunction " }}}2 function! s:zathura.latexmk_append_argument() dict " {{{2 - let cmd = latex#latexmk#add_option('new_viewer_always', '0') - let cmd .= latex#latexmk#add_option('pdf_previewer', - \ 'start zathura ' . g:latex_view_zathura_options + let cmd = vimtex#latexmk#add_option('new_viewer_always', '0') + let cmd .= vimtex#latexmk#add_option('pdf_previewer', + \ 'start zathura ' . g:vimtex_view_zathura_options \ . ' -x \"' . exepath(v:progname) \ . ' --servername ' . v:servername \ . ' --remote +\%{line} \%{input}\" \%S') diff --git a/autoload/latex/vimcomplete.bst b/autoload/vimtex/vimcomplete.bst similarity index 99% rename from autoload/latex/vimcomplete.bst rename to autoload/vimtex/vimcomplete.bst index 9034a8d..4caa136 100644 --- a/autoload/latex/vimcomplete.bst +++ b/autoload/vimtex/vimcomplete.bst @@ -1,4 +1,4 @@ -% LaTeX plugin for Vim +% vimtex - LaTeX plugin for Vim % % Maintainer: Karl Yngve Lervåg % Email: karl.yngve@gmail.com diff --git a/autoload/latextoc.vim b/autoload/vimtex_toc.vim similarity index 87% rename from autoload/latextoc.vim rename to autoload/vimtex_toc.vim index 7cd03ea..4aebfbb 100644 --- a/autoload/latextoc.vim +++ b/autoload/vimtex_toc.vim @@ -1,10 +1,24 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -function! latextoc#fold_level(lnum) " {{{1 +function! vimtextoc#init() " {{{1 + if !exists('b:toc') | return | endif + + " Fill TOC entries + call s:add_start() + call s:add_entries() + call s:add_help() + call s:add_end() + + " Jump to closest index + call setpos('.', b:toc_pos_closest) +endfunction + +" }}}1 +function! vimtextoc#fold_level(lnum) " {{{1 let pline = getline(a:lnum - 1) let cline = getline(a:lnum) let nline = getline(a:lnum + 1) @@ -17,36 +31,24 @@ function! latextoc#fold_level(lnum) " {{{1 return 0 endif - if l:nn > l:cn && g:latex_toc_fold_levels >= l:nn + if l:nn > l:cn && g:vimtex_toc_fold_levels >= l:nn return '>' . l:nn endif - if l:cn < l:pn && l:cn >= l:nn && g:latex_toc_fold_levels >= l:cn + if l:cn < l:pn && l:cn >= l:nn && g:vimtex_toc_fold_levels >= l:cn return l:cn endif return '=' endfunction -function! latextoc#fold_text() " {{{1 +" }}}1 +function! vimtextoc#fold_text() " {{{1 return getline(v:foldstart) endfunction + " }}}1 - -function! latextoc#init() " {{{1 - if !exists('b:toc') | return | endif - - " Fill TOC entries - call s:add_start() - call s:add_entries() - call s:add_help() - call s:add_end() - - " Jump to closest index - call setpos('.', b:toc_pos_closest) -endfunction -" }}}1 -function! latextoc#refresh() " {{{1 +function! vimtextoc#refresh() " {{{1 if !exists('b:toc') | return | endif " Fill TOC entries @@ -58,6 +60,7 @@ function! latextoc#refresh() " {{{1 " Restore old position call setpos('.', b:toc_pos_saved) endfunction + " }}}1 function! s:add_start() " {{{1 @@ -69,8 +72,8 @@ endfunction " }}}1 function! s:add_entries() " {{{1 let closest_index = 0 - if g:latex_toc_numbers_width - let s:width = g:latex_toc_numbers_width + if g:vimtex_toc_numbers_width + let s:width = g:vimtex_toc_numbers_width else let s:width = 2*(b:toc_secnumdepth+2) endi @@ -90,7 +93,7 @@ function! s:add_entries() " {{{1 endfunction " }}}1 function! s:add_help() " {{{1 - if !g:latex_toc_hide_help + if !g:vimtex_toc_hide_help call append('$', "") call append('$', "/q: close") call append('$', ": jump") @@ -113,7 +116,7 @@ function! s:print_entry(entry) " {{{1 " Create entry string let entry = '' - if g:latex_toc_numbers + if g:vimtex_toc_numbers let entry .= printf(s:num_format, level >= b:toc_secnumdepth + 2 \ ? '' : strpart(s:print_number(a:entry.number), 0, s:width)) endif diff --git a/compiler/lacheck.vim b/compiler/lacheck.vim index 21092f4..4d26b5a 100644 --- a/compiler/lacheck.vim +++ b/compiler/lacheck.vim @@ -1,3 +1,9 @@ +" vimtex - LaTeX plugin for Vim +" +" Maintainer: Karl Yngve Lervåg +" Email: karl.yngve@gmail.com +" + if exists("current_compiler") | finish | endif let current_compiler = "lacheck" diff --git a/compiler/latexmk.vim b/compiler/latexmk.vim index dbfb8d8..057d1d7 100644 --- a/compiler/latexmk.vim +++ b/compiler/latexmk.vim @@ -1,3 +1,9 @@ +" vimtex - LaTeX plugin for Vim +" +" Maintainer: Karl Yngve Lervåg +" Email: karl.yngve@gmail.com +" + if exists("current_compiler") | finish | endif let current_compiler = "latexmk" @@ -24,11 +30,11 @@ CompilerSet errorformat+=%Z\ %m CompilerSet errorformat+=%Cl.%l\ %m " Show warnings -if exists("g:latex_quickfix_ignore_all_warnings") - \ && exists("g:latex_quickfix_ignored_warnings") - \ && !g:latex_quickfix_ignore_all_warnings +if exists("g:vimtex_quickfix_ignore_all_warnings") + \ && exists("g:vimtex_quickfix_ignored_warnings") + \ && !g:vimtex_quickfix_ignore_all_warnings " Ignore some warnings - for w in g:latex_quickfix_ignored_warnings + for w in g:vimtex_quickfix_ignored_warnings let warning = escape(substitute(w, '[\,]', '%\\\\&', 'g'), ' ') exe 'CompilerSet errorformat+=%-G%.%#'. warning .'%.%#' endfor diff --git a/doc/latex.txt b/doc/latex.txt deleted file mode 100644 index 55c0aae..0000000 --- a/doc/latex.txt +++ /dev/null @@ -1,1309 +0,0 @@ -*latex.txt* LaTeX plugin for Vim version 7.3 (and above) -*vim-latex* *latex* - -Author: Karl Yngve Lervåg -License: MIT license {{{ - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to - deal in the Software without restriction, including without limitation the - rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. -}}} - -============================================================================== -CONTENTS *vim-latex-contents* - - 1. Intro ................................ |vim-latex-intro| - 2. Main interface ....................... |vim-latex-main| - 3. Default mappings ..................... |vim-latex-mappings| - 4. Commands ............................. |vim-latex-commands| - 5. Options .............................. |vim-latex-options| - 6. Omni completion ...................... |vim-latex-completion| - 7. Folding .............................. |vim-latex-folding| - 8. Indentation .......................... |vim-latex-indent| - 9. Latexmk .............................. |vim-latex-latexmk| - Latexmk tricks ....................... |vim-latex-latexmk-tricks| - Lacheck .............................. |vim-latex-latexmk-lacheck| - 10. View ................................. |vim-latex-view| - synctex .............................. |vim-latex-synctex| - 11. Motion ............................... |vim-latex-motion| - 12. Change ............................... |vim-latex-change| - 13. Table of contents .................... |vim-latex-toc| - 14. Utility functions .................... |vim-latex-util| - 15. Function reference ................... |vim-latex-functions| - 16. FAQ .................................. |vim-latex-faq| - 17. Credits .............................. |vim-latex-credits| - 18. Changelog ............................ |vim-latex-changelog| - -============================================================================== -INTRO *vim-latex-intro* - -This vim plugin provides some convenience functionality for editing LaTeX -documents. The goal has been to create a minimalistic and functional plugin -that is easy to customize and evolve. Most of the functionality provided is -turned on by default, but the user may turn off features that are not desired. -The plugin will hereafter be referred to as |vim-latex|. - - *vim-latex-requirements* -Some of the functionalities of |vim-latex| has certain requirements: - - |vim-latex-latexmk| - Requires that the user has installed both `latexmk` and `pgrep`. If these - are not available, then the functionalities provided by - |vim-latex-latexmk| will not be available. - - If you use Vim under a terminal in Linux or MacOS, then Vim must be - started as a command server with the command line option `--servername`, - e.g. `vim --servername VIM`. For different ways of ensuring this, see: - http://vim.wikia.com/wiki/Enable_servername_capability_in_vim/xterm - - |vim-latex-completion| - The function |latex#complete#bibtex| requires `bibtex` and `kpsewhich` to - parse bib files for bibliography completion. - -============================================================================== -MAIN INTERFACE *vim-latex-main* - -The |vim-latex| interface is based on the |autoload| feature of vim. For each -new latex buffer, the function *latex#init* initializes the variables and -functionalities based on the desired options |vim-latex-options|. The first -run performs some global initialization, which is mainly to define -autocommands. Other functionality is provided by additional autoloaded -scripts, such as |vim-latex-latexmk|. Every additional script should have an -initialization script that sets default mappings, creates autocommands and -performs other necessary initialization. This initialization script is then -called from |latex#init|. - -The main interface provides some basic functionality. |latex#help| lists all -`vim-latex` mappings defined for the current buffer, by default mapped to -'lh'. If the default mappings are used, |latex#help| will -display them. |latex#info| echoes the contents of |g:latex#data| and -|b:latex|. This is useful mainly for debugging. Finally, |latex#reinit| -clears the current data in |g:latex#data| and |b:latex|, stops running -`latexmk` processes |latex#latexmk#stop_all|, and then performs a new -initialization with |latex#init|. - -For each latex project that is opened, a |Dictionary| is created and added to -the list |g:latex#data|. The dictionary is initialized with information tied -to the current project, mainly the different associated file names. In -addition, a dictionary is created for every buffer |b:latex|. This contains -data that is specific to the current buffer, most importantly it contains the -ID of the main latex project. This combination of local and global data -enables |vim-latex| to work properly for multi-file latex projects. It also -allows the editing of different latex projects simultaneously in different -buffers. - - *g:latex#data* -A |List| of |Dictionaries|, each containing data specific to a given latex -project. The ID of a latex project is the index of its dictionary in the list. -An example of a dictionary is given here: > - - { - 'pid': 0, - 'name': 'main', - 'base': 'main.tex', - 'root': '/some/path', - 'tex': '/some/path/main.tex', - 'aux': function('202'), - 'log': function('203'), - 'out': function('204'), - } - -Which entries are present in a given dictionary depends on the current -settings. For example, the entry `pid` is only available if -|vim-latex-latexmk| is enabled |g:latex_latexmk_enabled|. Note that some of -the file entries are functions. The functions are used to find the files when -necessary, in case they do not exist when the latex file is opened. All -defined dictionaries can be printed with the function |latex#info|, by default -mapped to 'li'. - - *b:latex* -For each buffer, |vim-latex| defines a |Dictionary| that contains buffer local -information. An example of such a dictionary is: > - - { - 'id': 0, - 'fold_sections': [], - } - -The most important entry is `id`, which is the index of the corresponding -entry in the list of latex projects |g:latex#data|. Other entries may also be -exist, such as `fold_sections`. The dictionary can be printed with the -function |latex#info|, by default mapped to 'li'. - -Functions: - |latex#info| - |latex#help| - |latex#reinit| - ------------------------------------------------------------------------------- -Support for multi-file projects:~ - *vim-latex-multi-file* - *tex-root* - -|vim-latex| supports multi-file documents in the sense that the plugin -automatically detects the root file of the project. This detection is based -on a recursive search for files that include the current tex file, until -a main file is recognized. A file is assumed to be the main file if it has -the `\begin{document}` line. Files are assumed to live in the same folder or -a parent folder of the current file. This should work in most cases, but it -may fail if for instance the project structure is something like this: > - - path1/main.tex - path2/chapter.tex - -That is, the main file detection will not work for the file `chapter.tex`, -because the main file does not live in the same folder or a parent folder. - -It is also possible to specify the main TeX file with a comment in one of the -first five lines of the current file similar to this: > - - %! TEX root = my-main.tex - -============================================================================== -DEFAULT MAPPINGS *vim-latex-mappings* - -The default mappings for |vim-latex| are given below. See 'map-listing' for -an explanation of the format. The function |latex#help| is provided for -convenience to list all the defined mappings, and it is by default mapped to -'lh'. The default mappings may be disabled with the option -|g:latex_mappings_enabled|, if the user wishes to create his/her own mappings. - -n % *@:call latex#motion#find_matching_pair() -v % *@:call latex#motion#find_matching_pair(1) -o % *@:normal v% - -v a$ *@:call latex#motion#select_inline_math() -v i$ *@:call latex#motion#select_inline_math(1) -o a$ *@:normal va$ -o i$ *@:normal vi$ - -v ae *@:call latex#motion#select_environment() -v ie *@:call latex#motion#select_environment(1) -o ae *@:normal vae -o ie *@:normal vie - -v ad *@:call latex#motion#select_delimiter() -v id *@:call latex#motion#select_delimiter(1) -o ad *@:normal va( -o id *@:normal vi( - -n [[ *@:call latex#motion#next_sec(0,1,0) -n [] *@:call latex#motion#next_sec(1,1,0) -n ][ *@:call latex#motion#next_sec(1,0,0) -n ]] *@:call latex#motion#next_sec(0,0,0) -v [[ *@:call latex#motion#next_sec(0,1,1) -v [] *@:call latex#motion#next_sec(1,1,1) -v ][ *@:call latex#motion#next_sec(1,0,1) -v ]] *@:call latex#motion#next_sec(0,0,1) -o [[ *@:normal v[[ -o [] *@:normal v[] -o ][ *@:normal v][ -o ]] *@:normal v]] - -n li *@:call latex#info() -n lh *@:call latex#help() -n lR *@:call latex#reinit() -n lt *@:call latex#toc#open() -n lT *@:call latex#toc#toggle() -n ll *@:call latex#latexmk#toggle() -n lk *@:call latex#latexmk#stop(1) -n lK *@:call latex#latexmk#stop_all() -n le *@:call latex#latexmk#errors(1) -n lo *@:call latex#latexmk#output() -n lg *@:call latex#latexmk#status() -n lG *@:call latex#latexmk#status(1) -n lc *@:call latex#latexmk#clean() -n lC *@:call latex#latexmk#clean(1) -n lv *@:call latex#view#view() -n lr *@:call latex#view#rsearch() - -n zx *@:call latex#fold#refresh() -n dse *@:call latex#change#env('') -n cse *@:call latex#change#env_prompt() -n dsc @ds}dF\ -n csc *@:call latex#change#command() -n tse *@:call latex#change#toggle_env_star() -n tsd *@:call latex#change#toggle_delim() -n *@:call latex#change#to_command()i -i *@:call latex#change#to_command() -i ]] *@:call latex#change#close_environment() - -============================================================================== -COMMANDS *vim-latex-commands* - -|vim-latex| is mainly based on a function API as described in the section -|vim-latex-functions|. However, commands are also defined for convenience. -Below the commands are listed in alphabetical order. - -*VimLatexClean* call latex#latexmk#clean(0) -*VimLatexClean!* call latex#latexmk#clean(1) -*VimLatexCompile* call latex#latexmk#compile() -*VimLatexCompileSS* call latex#latexmk#compile_singleshot(0) -*VimLatexCompileSS!* call latex#latexmk#compile_singleshot(1) -*VimLatexCompileToggle* call latex#latexmk#toggle() -*VimLatexErrors* call latex#latexmk#errors(1) -*VimLatexErrors!* call latex#latexmk#errors(0) -*VimLatexHelp* call latex#help() -*VimLatexInfo* call latex#info() -*VimLatexLacheck* call latex#latexmk#lacheck() -*VimLatexOutput* call latex#latexmk#output() -*VimLatexRefreshFolds* call latex#fold#refresh() -*VimLatexReinitialize* call latex#reinit() -*VimLatexStatus* call latex#latexmk#status(0) -*VimLatexStatus!* call latex#latexmk#status(1) -*VimLatexStop* call latex#latexmk#stop() -*VimLatexStopAll* call latex#latexmk#stop_all() -*VimLatexTocOpen* call latex#toc#open() -*VimLatexTocToggle* call latex#toc#toggle() -*VimLatexView* call latex#view#view() -*VimLatexRSearch* call latex#view#rsearch() - -============================================================================== -OPTIONS *vim-latex-options* - -This section describes the options for |vim-latex|. The options are first -listed in alphabetical order, before they are described in more detail. The -descriptions also list the default values. - -Overview:~ - - |g:latex_enabled| - |g:latex_complete_close_braces| - |g:latex_complete_enabled| - |g:latex_complete_recursive_bib| - |g:latex_complete_patterns| - |g:latex_fold_enabled| - |g:latex_fold_automatic| - |g:latex_fold_envs| - |g:latex_fold_parts| - |g:latex_fold_preamble| - |g:latex_fold_sections| - |g:latex_indent_enabled| - |g:latex_latexmk_build_dir| - |g:latex_latexmk_callback| - |g:latex_latexmk_enabled| - |g:latex_latexmk_continuous| - |g:latex_latexmk_background| - |g:latex_latexmk_options| - |g:latex_mappings_enabled| - |g:latex_motion_enabled| - |g:latex_motion_matchparen| - |g:latex_quickfix_autojump| - |g:latex_quickfix_ignored_warnings| - |g:latex_quickfix_ignore_all_warnings| - |g:latex_quickfix_mode| - |g:latex_toc_enabled| - |g:latex_toc_fold_levels| - |g:latex_toc_fold| - |g:latex_toc_hide_help| - |g:latex_toc_hide_preamble| - |g:latex_toc_hide_line_numbers| - |g:latex_toc_numbers| - |g:latex_toc_numbers_width| - |g:latex_toc_resize| - |g:latex_toc_secnumdepth| - |g:latex_toc_split_pos| - |g:latex_toc_width| - |g:latex_view_enabled| - |g:latex_view_general_viewer| - |g:latex_view_general_options| - |g:latex_view_method| - |g:latex_view_mupdf_options| - |g:latex_view_okular_options| - |g:latex_view_sumatrapdf_options| - ------------------------------------------------------------------------------- -Detailed descriptions and default values:~ - - *g:latex_enabled* -If this variable exists and is 0, then |vim-latex| is completely disabled. By -default, it is not defined. - - *g:latex_complete_close_braces* -When a label or a cite has been completed, this option controls whether it -will be followed by a closing brace. > - let g:latex_complete_close_braces = 0 -< - *g:latex_complete_enabled* -Use this option to prevent the plugin from setting the 'omnifunc': > - let g:latex_complete_enabled = 1 -< - *g:latex_complete_recursive_bib* -This option toggles recursive searching for bibliography files. Note that this -option may lead to a significant slowdown for large projects if enabled. > - let g:latex_complete_recursive_bib = 0 -< - *g:latex_complete_patterns* -Define patterns that control when the label and citation completion is -triggered. > - let g:latex_complete_patterns = { - \ 'ref' : '\C\\v\?\(eq\|page\|[cC]\)\?ref\*\?\_\s*{[^{}]*', - \ 'bib' : '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*', - \ }) -< - *g:latex_fold_enabled* -Use this option to disable/enable folding. > - let g:latex_fold_enabled = 1 -< - *g:latex_fold_automatic* -Set manual or automatic updating of fold levels. For manual mode, one must -use the |zx| mapping to update the foldlevels when desired. For automatic -mode, the fold levels will be updated automatically. Beware that this may -lead to some minor lags for large files. > - let g:latex_fold_automatic = 1 -< - *g:latex_fold_envs* -Decide whether environments should be folded or not. > - let g:latex_fold_envs = 1 -< - *g:latex_fold_parts* -List of parts that should be folded. > - let g:latex_fold_parts = [ - \ "appendix", - \ "frontmatter", - \ "mainmatter", - \ "backmatter", - \ ] -< - *g:latex_fold_preamble* -Decide whether preamble should be folded or not. > - let g:latex_fold_preamble = 1 -< - *g:latex_fold_sections* -List of section constructs that should be folded. > - let g:latex_fold_sections = [ - \ "part", - \ "chapter", - \ "section", - \ "subsection", - \ "subsubsection", - \ ] -< - *g:latex_indent_enabled* -Use |vim-latex| indentation function. Not as customizable as the official -indentation function, but imho it is better. > - let g:latex_indent_enabled = 1 -< - *g:latex_latexmk_build_dir* -Set this variable in case a dedicated build dir is used with `latexmk`/`latex` -compilations. > - let g:latex_latexmk_build_dir = '.' -< - *g:latex_latexmk_callback* -If enabled, this option tells `latexmk` to run |latex#latexmk#errors| after -compilation is finished. Note that this feature only works if vim is compiled -with the |+clientserver| option. > - let g:latex_latexmk_callback = 1 -< - *g:latex_latexmk_enabled* -Whether to enable the `latexmk` interface or not. Note that even if it is not -enabled, the autoload functions will be available. However, the -necessary variables and autocommands will not be defined, and the mappings -will not be created. > - let g:latex_latexmk_enabled = 1 -< - *g:latex_latexmk_background* -If continuous mode is disabled, then this option may be used to set -whether single compilations should be run in the foreground or the -background. > - let g:latex_latexmk_background = 0 -< - *g:latex_latexmk_continuous* -If enabled, `latexmk` will run in continuous mode. This means that the -document is compiled every time a document file has been changed. Set to 0 to -disable. Note that the callback functions only work if continuous mode is enabled. > - let g:latex_latexmk_continuous = 1 -< - *g:latex_latexmk_options* -Set desired options for `latexmk` compilation. Note that options may also be -specified indirectly through a `.latexmkrc` file. > - let g:latex_latexmk_options = '-pdf' -< - *g:latex_quickfix_autojump* -Whether to automatically jump to the first error whenever the |quickfix| window -is opened. > - let g:latex_latexmk_autojump = 0 -< - *g:latex_quickfix_ignore_all_warnings* -If enabled, all LaTeX warnings are ignored and will not be listed in the -quickfix window. LaTeX errors will of course still be listed. > - let g:latex_quickfix_ignore_all_warnings = 0 -< - *g:latex_quickfix_ignored_warnings* -List of warning messages that should be ignored. By default, the list is -empty, thus no warnings are ignored. The list is a list of strings. Any -LaTeX warning that contains a string in the list will be ignored. To ignore -some common LaTeX warnings, try the following setting: > - let g:latex_quickfix_ignored_warnings = [ - \ 'Underfull', - \ 'Overfull', - \ 'specifier changed to', - \ ] -< - *g:latex_quickfix_mode* -This option controls the behaviour of the quickfix window in case errors -and/or warnings are found. The recognized options are: - - Value Effect ~ - 0 The quickfix window is never opened automatically. - 1 The quickfix window is opened automatically when there are errors, - and it becomes the active window. - 2 The quickfix window is opened automatically when there are errors, - but it does not become the active window. - -The default value is: > - let g:latex_quickfix_mode = 2 -< - *g:latex_quickfix_open_on_warning* -If it is 0, then the quickfix window will only be opened on errors or when -it is forced open. > - let g:latex_quickfix_open_on_warning = 1 -< - *g:latex_mappings_enabled* -Whether to load the default mappings. If this is set to 0, then no mappings -will be defined. Since all of the functionality is available as functions, -this allows the user to define his or her own mappings. > - let g:latex_mappings_enabled= 1 -< - *g:latex_motion_enabled* -Whether to enable the motion interface. If it is disabled, then neither the -default mappings nor the autocommands that enable highlighting of matching -parens will be defined. > - let g:latex_motion_enabled = 1 -< - *g:latex_motion_matchparen* -Enable highlighting of matching parens. This gives better support for LaTeX, -but disables the builtin |matchparen|. > - let g:latex_motion_matchparen = 1 -< - *g:latex_toc_enabled* -Enable interface for TOC. If it is disabled, then mappings for the TOC will -not be created. > - let g:latex_toc_enabled = 1 -< - *g:latex_toc_fold_levels* -If TOC entries are folded, this option controls the number of fold levels that -will be used. > - let g:latex_toc_fold_levels = 0 -< - *g:latex_toc_fold* -Turn on folding of TOC entries. > - let g:latex_toc_fold = 0 -< - *g:latex_toc_hide_help* -Allow the TOC help text to be hidden. > - let g:latex_toc_hide_help = 0 -< - *g:latex_toc_hide_preamble* -If enabled, the start of the preamble is not shown in the TOC. > - let g:latex_toc_hide_preamble = 0 -< - *g:latex_toc_hide_line_numbers* -If enabled, line numbers will be hidden in the TOC window. That is, -|nonumber| and |norelativenumber| will be set locally for the TOC window. > - let g:latex_toc_hide_line_numbers = 1 -< - *g:latex_toc_numbers* -Toggle display of numbers in TOC. The numbers may also be toggled inside the -TOC window with the `s` keybinding. > - let g:latex_toc_numbers = 1 -< - *g:latex_toc_numbers_width* -Set display width of numbers in TOC. If 0, the width is set based on the -section depth. > - let g:latex_toc_numbers_width = 0 -< - *g:latex_toc_resize* -Automatically resize vim when the TOC window is opened. > - let g:latex_toc_resize = 1 -< - *g:latex_toc_secnumdepth* -Define number of section levels to display. Set level corresponding to the -desired latex variable `secnumdepth`. Note that the variable may be updated -directly through the TOC window. For more info on `secnumdepth` see e.g. -http://en.wikibooks.org/w/index.php?title=LaTeX/Document_Structure > - let g:latex_toc_secnumdepth = 3 -< - *g:latex_toc_split_pos* -Define where the TOC window is opened. > - let g:latex_toc_split_pos = 'vert leftabove' -< - *g:latex_toc_width* -Set width of TOC window. > - let g:latex_toc_width = 30 -< - *g:latex_view_enabled* -Enable interface for view functionality. > - let g:latex_view_enabled = 1 -< - *g:latex_view_general_viewer* -Set general viewer. > - let g:latex_view_general_viewer = 'xdg-open' -< - *g:latex_view_method* -Set viewer method. If not set or set to `general`, it uses the general -viewer, see |g:latex_view_general_viewer|. > - let g:latex_view_method = '' - -The currently available choices are: > - general - mupdf - okular - sumatrapdf -< - *g:latex_view_general_options* - *g:latex_view_mupdf_options* - *g:latex_view_okular_options* - *g:latex_view_sumatrapdf_options* -Set custom options for the given viewer. > - let g:latex_view_general_options = '' - let g:latex_view_mupdf_options = '' - let g:latex_view_okular_options = '' - let g:latex_view_sumatrapdf_options = '' -< - *g:latex_view_mupdf_send_keys* -String of keys sent to MuPDF after the PDF file has been opened. The keys are -sent by the function |latex#view#mupdf_poststart|. > - let g:latex_view_mupdf_send_keys = '' -< -============================================================================== -OMNI COMPLETION *vim-latex-completion* - -|vim-latex| provides an 'omnifunc' for omni completion, see |compl-omni| and -|latex#complete#omnifunc|. The function is enabled by default, but may be -disabled with |g:latex_complete_enabled|. Omni completion is accessible with -|i_CTRL-X_CTRL-O|. - -The omni function completes labels and citations. The completion candidates -are gathered with the functions |latex#complete#labels| and -|latex#complete#bibtex|. If |g:latex_complete_close_braces| is set to 1, then -the completion includes closing braces. - -Associated settings: - |g:latex_complete_enabled| - |g:latex_complete_patterns.ref| - |g:latex_complete_patterns.bib| - |g:latex_complete_close_braces| - |g:latex_complete_recursive_bib| - -Functions: - |latex#complete#omnifunc| - |latex#complete#labels| - |latex#complete#bibtex| - ------------------------------------------------------------------------------- -Complete labels~ - -Label completion is triggered by '\ref{' commands as defined with -|g:latex_complete_patterns.ref|. The completion parses every relevant aux -file to gather the completion candidates. This is important to note, because -it means that the completion only works when the latex document has been -compiled. - -As an example: > - - \ref{sec: - -offers a list of all matching labels, with their associated value and page -number. The label completion matches: - - 1. labels: > - \ref{sec: -< 2. numbers: > - \eqref{2 -< 3. labels and numbers together (separated by whitespace): > - \eqref{eq 2 - ------------------------------------------------------------------------------- -Complete citations~ - -Citation completion is triggered by '\cite{' commands as defined with -|g:latex_complete_patterns.bib|. The completion parses included bibliography -files (`*.bib`) and `thebibliography` environments to gather the completion -candidates. - -As an example, assume that a bibliography file is included with the following -entry: > - - @book { knuth1981, - author = "Donald E. Knuth", - title = "Seminumerical Algorithms", - publisher = "Addison-Wesley", - year = "1981" } - -Then the bibliography key `knuth1981` will be completed with e.g.: > - - \cite{Knuth 1981 - \cite{algo - \cite{Don.*Knuth - -In particular, note that regular expressions (or vim patterns) can be used -after '\cite{' to search for candidates. - -============================================================================== -FOLDING *vim-latex-folding* - -|vim-latex| can fold texts according to LaTeX structure (part, chapter, section -and subsection). Folding is turned on by default, but it can be disabled if -desired |g:latex_fold_enabled|. - -When folding is turned on and a latex document is opened, the document is -parsed once in order to define the highest fold level based on which parts -(such as frontmatter, backmatter, and appendix) and section types (chapter, -section, etc.) are present. If the document has been edited and a new fold -level is required (or has become redundant), then |latex#fold#refresh| can be -used to refresh the fold level settings. This function is mapped by default -to 'zx'. - -Associated settings: - |g:latex_fold_enabled| - |g:latex_fold_automatic| - |g:latex_fold_preamble| - |g:latex_fold_parts| - |g:latex_fold_sections| - |g:latex_fold_envs| - -Functions: - |latex#fold#level| - |latex#fold#text| - |latex#fold#refresh| - -============================================================================== -INDENTATION *vim-latex-indent* - -The official indentation function is pretty good and allows for some -customization. However, I am not quite satisfied, so I wrote my own -indentation function that is not customizable at all (at least for now), but -that I think is better. It is enabled by default, but may be disabled if -desired |g:latex_indent_enabled|. - -Associated settings: - |g:latex_indent_enabled| - -============================================================================== -LATEXMK *vim-latex-latexmk* - -|vim-latex| provides a basic interface to `latexmk` for compilation. The -interface may be disabled with |g:latex_latexmk_enabled|. The default -mappings are: > - - nnoremap ll :call latex#latexmk#toggle() - nnoremap lk :call latex#latexmk#stop() - nnoremap lK :call latex#latexmk#stop_all() - nnoremap le :call latex#latexmk#errors(1) - nnoremap lo :call latex#latexmk#output() - nnoremap lg :call latex#latexmk#status(0) - nnoremap lG :call latex#latexmk#status(1) - nnoremap lc :call latex#latexmk#clean(0) - nnoremap lC :call latex#latexmk#clean(1) - -Compilation is started with |latex#latexmk#compile| or may be toggled by -|latex#latexmk#toggle|. The default behaviour uses preview continuous mode of -`latexmk`, which may be disabled with |g:latex_latexmk_continuous|. If it is -disabled, then the option |g:latex_latexmk_background| may be used to decide -if single shot compilation should run in the foreground or the background. - -Single shot compilation may always be issued with the function -|latex#latexmk#compile_singleshot|. This function ignores the -|g:latex_latexmk_background|` setting, though, and will by default hide the -output from the `latexmk` command. The function is available through the -command |VimLatexCompileSS|, and if desired one may create a custom mapping -such as > - - nnoremap ls :VimLatexCompileSS - -A banged version of the command also exists, which will provide a more verbose -output. - -If vim is compiled with the |+clientserver| option and if -|g:latex_latexmk_callback| is enabled, then compilation errors are parsed -automatically. This is done by utilizing the tricks explained in -|vim-latex-latexmk-tricks|. Note however that this only works for continuous -compilation mode. - -To check for and view errors in the quickfix window, use -|latex#latexmk#errors|. To check if background compilation is running, use -|latex#latexmk#status|. - -Associated settings: - |g:latex_latexmk_enabled| - |g:latex_latexmk_callback| - |g:latex_latexmk_autojump| - |g:latex_latexmk_continuous| - |g:latex_latexmk_background| - |g:latex_latexmk_options| - -Functions: - |latex#latexmk#clean| - |latex#latexmk#compile| - |latex#latexmk#compile_singleshot| - |latex#latexmk#errors| - |latex#latexmk#lacheck| - |latex#latexmk#output| - |latex#latexmk#status| - |latex#latexmk#stop| - |latex#latexmk#stop_all| - |latex#latexmk#toggle| - ------------------------------------------------------------------------------- - *vim-latex-latexmk-tricks* -Latexmk tricks~ - -`latexmk` allows to set options through a configuration file -`$HOME/.latexmkrc`. A particular set of options are very convenient for -a good coupling between |vim-latex| and `latexmk`: `$..._cmd`, where `...` -refers to either `compiling`, `success`, or `failure`. These options can be -used to specify commands that are run by `latexmk` before and after -a compilation run. For instance, one may use these options: > - -$compiling_cmd = "xdotool search --name \"%D\" " . - "set_window --name \"%D compiling...\""; -$success_cmd = "xdotool search --name \"%D\" " . - "set_window --name \"%D OK\"; " . - "gvim --remote-expr 'latex#latexmk#callback(1)'"; -$failure_cmd = "xdotool search --name \"%D\" " . - "set_window --name \"%D FAILURE\"; " . - "gvim --remote-expr 'latex#latexmk#callback(0)'"; - -Here `xdotool` (http://www.semicomplete.com/projects/xdotool/) is used to -change the title of the pdf viewer during and after compilation. In addition, -|latex#latexmk#errors| is called through the |clientserver| after each run to -either open the quickfix window when there are errors/warnings, or to close the -quickfix window in case all errors/warnings are gone. - -The latter trick is utilized in |vim-latex| to automatically run the callback -commands if vim has the option |+clientserver|, and if the option -|g:latex_latexmk_callback| is enabled. The command that is used by `latexmk` -is then on the following form: > - - gvim --servername v:servername --remote-expr 'latex#latexmk#callback(0)' - -This command is then appended to the existing `$success_cmd` and -`$failure_cmd`. Note that if the existing commands are not empty, then they -must end with a semicolon in order to allow |vim-latex| to append safely. - ------------------------------------------------------------------------------- - *vim-latex-latexmk-lacheck* -Lacheck~ - -After compilation of a LaTeX document, the log file will contain errors that -are parsed by |vim-latex| as explained above. However, there are a syntax -checkers for LaTeX, and we here provide a simple interface to `lacheck` for -checking your LaTeX manuscript for errors. - -Your manuscript may be checked using `lacheck` with the command `VimLatexLacheck`. - -============================================================================== -VIEW *vim-latex-view* - -|vim-latex| provides functions for viewing the compiled documents. A command -and a mapping is defined for the multipurpose `view` function, which calls the -chosen view method defined by |g:latex_view_method|. - -Associated settings: - |g:latex_view_enabled| - |g:latex_view_general_viewer| - |g:latex_view_general_options| - |g:latex_view_method| - |g:latex_view_mupdf_options| - |g:latex_view_okular_options| - |g:latex_view_sumatrapdf_options| - -Functions: - |latex#view#general| - |latex#view#mupdf| - |latex#view#mupdf_rsearch| - |latex#view#okular| - |latex#view#sumatrapdf| - ------------------------------------------------------------------------------- -SYNCTEX SUPPORT *vim-latex-synctex* - -Synctex is a tool that enables synchronization of the text editor position and -the pdf viewer position. The tool may be used to add mappings in vim to go to -the current position in the compiled pdf document (forward search), and also -to go from a specific position in the pdf file to the corresponding position -in vim (inverse/backward search). - -To make synctex work, one must enable synctex manually by adding the line > - - $pdflatex = 'pdflatex -synctex=1 %O %S'; - -to `~/.latexmkrc`. - -Forward search~ - -|vim-latex| currently supports forward search for a limited set of viewers. -The functionality is enabled by choosing the desired viewer with the -|g:latex_view_method| option. The currently supported viewers are: - * MuPDF - * Okular - * SumatraPDF - * Zathura - -Backward search~ - -Backward or inverse search is typially set up inside the specific viewer -through an option named something like "inverse search command-line". -A standard value for the option is: > - - gvim --remote-silent +%l "%f" - -Backward search is unfortunately not supported by all pdf viewers. The -following is a list of viewers that to my knowledge should support backward -search: - * Okular - * SumatraPDF - * Evince (since version 2.91.3) - * Zathura - -Note: Inverse search relies on the |clientserver| functionality of vim. Each - instance of vim runs its own server. The above mentioned standard value - implies the default server name, which might not be the actual name of - the server for the vim instance you are using. - -Note: For backward search to work on windows, one must ensure that the folder - that contains `gVim.exe` is in your `%PATH%` environment variable. - -MuPDF does not support inverse search. However, by the use of some semi ugly -hacks, we have implemented a command inside vim that simulates the -functionality. The command is |VimLatexRSearch|, and is by default mapped to -`lr` if MuPDF is chosen as the viewer. The command will go to -the line in the tex project that corresponds to the FIRST line on the page -that is open in MuPDF. - -For SumatraPDF one may set the inverse search setting from vim directly by -adding some command line options as shown below. The advantage of doing this -is that one may specify the vim server name explicitly, which means that the -backward search will also work as expected if one has several vim instances -running. To enable this, use the general viewer and: > - - let g:latex_view_general_viewer='SumatraPDF ' - \ . '-reuse-instance -inverse-search ' - \ . '"gvim --servername '.v:servername.' --remote-send \"^^' - \ . ':drop \%f^:\%l^:normal\! zzzv^' - \ . ':execute ''drop ''.fnameescape(''\%f'')^' - \ . ':\%l^:normal\! zzzv^' - \ . ':call remote_foreground('''.v:servername.''')^\""' - -============================================================================== -MOTION *vim-latex-motion* - -|vim-latex| provides some functions that can be used to give improved motions -and text objects. For instance, |vim-latex-motion| enables highlighting of -matching parens or tags (such as begin/end structures). The functionality is -enabled by default, but may be disabled if desired. - -Associated settings: - |g:latex_motion_enabled| - |g:latex_motion_matchparen| - -Functions: - |latex#motion#find_matching_pair| - |latex#motion#next_section| - |latex#motion#sel_delimiter| - |latex#motion#sel_environment| - |latex#motion#sel_inline_math| - -============================================================================== -CHANGE *vim-latex-change* - -|vim-latex| provides mappings that are inspired by `surround.vim` -(https://github.com/tpope/vim-surround) (if it is installed, see -|surround.txt|). These mappings are: - `cse` - change surrounding environment - `dse` - delete surrounding environment - `csc` - change surrounding command - `dsc` - delete surrounding command - Note: This mappings is only available if `surround.vim` is also - available. - `tsd` - toggle delimiters (add/remove `\left` and `\right`) - `tse` - toggle starred environment - -An environment that has been opened but not closed may be closed by the -mapping `]]`. - -In addition, some functionality is provided to wrap the current selection. -This is not mapped to anything by default. - -For additional coupling with `surround.vim`, one may add the following lines -to ones `.vimrc` file to obtain corresonding `yse` and `ysc` mappings. > - - augroup latexSurround - autocmd! - autocmd FileType tex call s:latexSurround() - augroup END - - function! s:latexSurround() - let b:surround_{char2nr("e")} = "\\begin{\1environment: \1}\n\t\r\n\\end{\1\1}" - let b:surround_{char2nr("c")} = "\\\1command: \1{\r}" - endfunction - -Functions: - |latex#change#command| - |latex#change#close_environment| - |latex#change#env| - |latex#change#env_prompt| - |latex#change#to_command| - |latex#change#toggle_delim| - |latex#change#toggle_env_star| - |latex#change#wrap_selection| - |latex#change#wrap_selection_prompt| - -============================================================================== -UTILITY FUNCTIONS *vim-latex-util* - -Several utility functions are available. Many of these are used as building -blocks for other functionalities, but are also available for users to add -additional functionality. - -Functions: - |latex#util#convert_back| - |latex#util#get_delim| - |latex#util#get_env| - |latex#util#has_syntax| - |latex#util#in_comment| - |latex#util#kpsewhich| - |latex#util#tex2tree| - |latex#util#tree2tex| - -============================================================================== -TABLE OF CONTENTS *vim-latex-toc* - -|vim-latex| provides a table of contents (TOC) window that can be opened -|latex#toc#open| or toggled |latex#toc#toggle|. In the TOC, one can use -'' on a selected entry to navigate. - -Associated settings: - |g:latex_toc_enabled| - |g:latex_toc_fold_levels| - |g:latex_toc_fold| - |g:latex_toc_hide_help| - |g:latex_toc_hide_preamble| - |g:latex_toc_hide_line_numbers| - |g:latex_toc_numbers| - |g:latex_toc_numbers_width| - |g:latex_toc_resize| - |g:latex_toc_secnumdepth| - |g:latex_toc_split_pos| - |g:latex_toc_width| - -Functions: - |latex#toc#open| - |latex#toc#toggle| - -============================================================================== -FUNCTION REFERENCE *vim-latex-functions* - -The following is a reference of the available functions, sorted -alphabetically. First a short overview is given, then more detailed -descriptions follow. - -Overview:~ - - |latex#change#command| - |latex#change#close_environment| - |latex#change#env| - |latex#change#env_prompt| - |latex#change#to_command| - |latex#change#toggle_delim| - |latex#change#toggle_env_star| - |latex#change#wrap_selection| - |latex#change#wrap_selection_prompt| - |latex#complete#omnifunc| - |latex#complete#labels| - |latex#complete#bibtex| - |latex#fold#level| - |latex#fold#text| - |latex#fold#refresh| - |latex#help| - |latex#info| - |latex#latexmk#clean| - |latex#latexmk#compile| - |latex#latexmk#compile_singleshot| - |latex#latexmk#errors| - |latex#latexmk#options| - |latex#latexmk#status| - |latex#latexmk#stop| - |latex#latexmk#stop_all| - |latex#latexmk#toggle| - |latex#motion#find_matching_pair| - |latex#motion#next_sec| - |latex#motion#sel_delimiter| - |latex#motion#sel_environment| - |latex#motion#sel_inline_math| - |latex#reinit| - |latex#toc#open| - |latex#toc#toggle| - |latex#util#convert_back| - |latex#util#get_delim| - |latex#util#get_env| - |latex#util#has_syntax| - |latex#util#in_comment| - |latex#util#kpsewhich| - |latex#util#tex2tree| - |latex#util#tree2tex| - |latex#view#general| - |latex#view#mupdf| - |latex#view#mupdf_poststart| - |latex#view#mupdf_rsearch| - |latex#view#okular| - |latex#view#sumatrapdf| - ------------------------------------------------------------------------------- -Detailed descriptions:~ - - *latex#change#command* -Change the current command name to one typed at a prompt. - - *latex#change#close_environment* -Closes current delimiter or environment command. The function is only useful -when used as an insert mode command, since it returns the closing part of the -delimiter or environment. - - *latex#change#env* -Change the current environment name to the one passed as an argument. - - *latex#change#env_prompt* -Change the current environment name to one typed at a prompt. - - *latex#change#to_command* -Turn word under cursor into command. This essentially prepends a backslash -and adds an opening brace. The function may be used both in an insert mode -mapping and in a normal mode mapping. - - *latex#change#toggle_delim* -Toggle delimiters between `(` `)` and `\left(` `\right)` (and similar). - - *latex#change#toggle_env_star* -Toggle star for the current environment. - - *latex#change#wrap_selection* -Wrap the current selection within a supplied command. - - *latex#change#wrap_selection_prompt* -Wrap the current selection within a command given at a prompt. - - *latex#complete#omnifunc* -An 'omnifunc' for label and citation completion, see |vim-latex-completion|. - - *latex#complete#labels* -Parses aux files to gather label candidates for completion. - - *latex#complete#bibtex* -Parses included bibliography files and `thebibliography` environments to -gather candidates for completion. - - *latex#fold#level* -Sets fold level for each line. 'foldexpr' |fold-expr| - - *latex#fold#text* -Sets fold title text. 'foldtext' - - *latex#fold#refresh* -Refreshes fold levels based on which parts and sections used in the current -file buffer. Also issues a |zx| call to update folds. - - *latex#help* -Lists all mappings that are defined specifically for the current buffer. If -the default mappings are used, then |latex#help| will display them. - - *latex#info* -Echoes the contents of |g:latex#data| and |b:latex|. This is useful mainly -for debugging. - - *latex#latexmk#clean* -Clean up temporary files with `latexmk -c`. An optional argument may be -supplied to indicate that the `-C` flag should be used, which also cleans -output files. This will only be run if `latexmk` is not already running. - - *latex#latexmk#compile* -Starts `latexmk -pvc ...` for the given buffer, if it is not already running. - - *latex#latexmk#compile_singleshot* -Starts a single shot compile with `latexmk ...` for the given buffer (if it is -not already running). - - *latex#latexmk#errors* -Parse the log file for errors and warnings. If any errors or warnings are -found, they are displayed in the quickfix window. The exact behaviour is -controlled through the different quickfix specific option: - - |g:latex_quickfix_autojump| - |g:latex_quickfix_ignore_all_warnings| - |g:latex_quickfix_ignored_warnings| - |g:latex_quickfix_mode| - -Note: The function takes one argument, which if nonzero will force open the -quickfix window if any errors are present. This is used in the normal mode -mapping. - - *latex#latexmk#output* -Opens a new buffer that show the output from the `latexmk` command. To close -the buffer, one may simply type `q`. - - *latex#latexmk#status* -Show if `latexmk` has been started for the current buffer. An optional -argument may be supplied, in which case the status for all buffers is shown. - - *latex#latexmk#stop* -Stop the `latexmk` process running for the current buffer. An optional -argument may be given, in which case the function becomes verbose. - - *latex#latexmk#stop_all* -Stops all running `latexmk` processes. - - *latex#latexmk#toggle* -Toggle compilation. Calls |latex#latexmk#compile| if `latexmk` is not running -for the current file. Else it calls |latex#latexmk#stop|. - - *latex#motion#find_matching_pair* -Finds a matching pair of parentheses or begin-end-tags. The functions is used -to find the pair closest to the current cursor position. - - *latex#motion#next_sec* -A motion command function that moves to the next section. Used to redefine -the mappings for ']]', '[[', and similar. - - *latex#motion#sel_delimiter* -A function that is used to create text objects for text contained within a set -of delimiters. - - *latex#motion#sel_environment* -A function that is used to create text objects for environments. - - *latex#motion#sel_inline_math* -A function that is used to create text objects for inline math structures. - - *latex#reinit* -Clears the current global and local data in |g:latex#data| and |b:latex|, -stops running `latexmk` processes |latex#latexmk#stop_all|, and then performs -a new initialization. - - *latex#toc#open* -Open the TOC window. If it is already open, then simply move the cursor to -the TOC window. - - *latex#toc#toggle* -Toggle TOC window: If TOC window is open, then close it. If it is closed, -then open it (but do not move the cursor to the window). - - *latex#util#convert_back* -Convert from stuff like `\IeC{\"u}` to corresponding unicode symbols. - - *latex#util#get_delim* -Get surrounding delimiters (with position). - - *latex#util#get_env* -Get surrounding environment. If optional argument supplied, the function also -returns the position (line and column number) of the begin and end structure. - - *latex#util#has_syntax* -Checks if the given position (or current position) is within the given syntax -structure. - - *latex#util#in_comment* -Checks if the given position (or current position) is within a comment. - - *latex#util#kpsewhich* -Parse file with `kpsewhich`. - - *latex#util#tex2tree* -Turn tex structure to a tree composed of lists. E.g. > - { testing { tex2tree { } } } => [ "testing" , [ "tex2tree", []]] -< - *latex#util#tree2tex* -Turns a tree composed of lists into tex structure. E.g. > - [ "testing" , [ "tex2tree", []]] => { testing { tex2tree { } } } -< - *latex#view#general* -Open the output file with the viewer that is specified with the option -|g:latex_view_general_viewer|. - - *latex#view#mupdf* - *latex#view#okular* - *latex#view#sumatrapdf* -First open the output file if it is not open with MuPDF/Okular/SumatraPDF. -Then perform a forward search. - - *latex#view#mupdf_poststart* -Function that is called after the MuPDF window has been opened. The function -is used to run `xdotool` commands, for instance to return focus to vim and to -possibly send some keys to MuPDF as specified in |g:latex_view_mupdf_send_keys|. - - *latex#view#mupdf_rsearch* -Perform a reverse search by use of `xdotool` and `synctex`. - -============================================================================== -FAQ *vim-latex-faq* - -Q: Vim throws error when jumping to file with |gf|. -A: This might be due to the |isfname| setting, which by default contains `{,}` - on windows. |isfname| is a global option, and can therefore not be set by - `vim-latex`. Suggested solution is to remove `{,}` from |isfname| by: > - - set isfname-={,} - -============================================================================== -CREDITS *vim-latex-credits* - -|vim-latex| is developed by Karl Yngve Lervåg , and is -distributed under the MIT license. The project is available as a Git -repository: https://github.com/lervag/vim-latex. - -|vim-latex| was developed from scratch, but much of the code has been based on -LaTeX-Box: https://github.com/LaTeX-Box-Team/LaTeX-Box. LaTeX-suite was also -an inspiration: http://vim-latex.sourceforge.net/. - -The documentation of |vim-latex| is structured with inspiration from CtrlP -(https://github.com/kien/ctrlp.vim), simply because CtrlP has a very good -documentation. - -============================================================================== -CHANGELOG *vim-latex-changelog* - -The following changelog only logs important changes, such as changes that -break backwards compatibility. See the git log for the detailed changelog. - -2014-12-07: Added more general view functionality~ -Added new module for view functionality. This allows more complex view -functions (and commands), for instance to do forward (and possibly backwards) -searching through `synctex`. In the first version, I added forward search for -mupdf by use of the `synctex` command and `xdotools`. - -The `g:latex_viewer` option has now been deprecated. Instead one should use -|g:latex_view_method| and |g:latex_view_general_viewer|. - -Deprecated option: - *g:latex_viewer* - -2014-06-13: Changed some option names~ -Some |vim-latex| option names were changed in an attempt to make the names -more consistent. These options are listed here for reference: - *g:latex_errorformat_ignore_warnings* - *g:latex_errorformat_show_warnings* - *g:latex_latexmk_autojump* - *g:latex_latexmk_quickfix* -The new names are, respectively: - |g:latex_quickfix_ignored_warnings| - |g:latex_quickfix_ignore_all_warnings| - |g:latex_quickfix_autojump| - |g:latex_quickfix_mode| - -2013-10-05: First public release~ - -============================================================================== - vim:tw=78:ts=8:ft=help:norl: diff --git a/doc/vimtex.txt b/doc/vimtex.txt new file mode 100644 index 0000000..4a0f06d --- /dev/null +++ b/doc/vimtex.txt @@ -0,0 +1,1325 @@ +*vimtex.txt* LaTeX plugin for Vim version 7.3 (and above) +*vimtex* *vimtex* *latex* + +Author: Karl Yngve Lervåg +License: MIT license {{{ + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to + deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + IN THE SOFTWARE. +}}} + +============================================================================== +CONTENTS *vimtex-contents* + + 1. Intro ................................ |vimtex-intro| + 2. Main interface ....................... |vimtex-main| + 3. Default mappings ..................... |vimtex-mappings| + 4. Commands ............................. |vimtex-commands| + 5. Options .............................. |vimtex-options| + 6. Omni completion ...................... |vimtex-completion| + 7. Folding .............................. |vimtex-folding| + 8. Indentation .......................... |vimtex-indent| + 9. Latexmk .............................. |vimtex-latexmk| + Latexmk tricks ....................... |vimtex-latexmk-tricks| + Lacheck .............................. |vimtex-latexmk-lacheck| + 10. View ................................. |vimtex-view| + synctex .............................. |vimtex-synctex| + 11. Motion ............................... |vimtex-motion| + 12. Change ............................... |vimtex-change| + 13. Table of contents .................... |vimtex-toc| + 14. Utility functions .................... |vimtex-util| + 15. Function reference ................... |vimtex-functions| + 16. FAQ .................................. |vimtex-faq| + 17. Credits .............................. |vimtex-credits| + 18. Changelog ............................ |vimtex-changelog| + +============================================================================== +INTRO *vimtex-intro* + +|vimtex| provides functionality for editing LaTeX documents. The goal has +been to create a minimalistic and functional plugin that is easy to customize +and evolve. Most of the functionality provided is turned on by default, but +the user may turn off features that are not desired. + + *vimtex-requirements* +Some of the functionalities of |vimtex| has certain requirements: + + |vimtex-latexmk| + Requires that the user has installed both `latexmk` and `pgrep`. If these + are not available, then the functionalities provided by + |vimtex-latexmk| will not be available. + + If you use Vim under a terminal in Linux or MacOS, then Vim must be + started as a command server with the command line option `--servername`, + e.g. `vim --servername VIM`. For different ways of ensuring this, see: + http://vim.wikia.com/wiki/Enable_servername_capability_in_vim/xterm + + |vimtex-completion| + The function |vimtex#complete#bibtex| requires `bibtex` and `kpsewhich` to + parse bib files for bibliography completion. + +============================================================================== +MAIN INTERFACE *vimtex-main* + +The |vimtex| interface is based on the |autoload| feature of vim. For each +new latex buffer, the function *vimtex#init* initializes the variables and +functionalities based on the desired options |vimtex-options|. The first +run performs some global initialization, which is mainly to define +autocommands. Other functionality is provided by additional autoloaded +scripts, such as |vimtex-latexmk|. Every additional script should have an +initialization script that sets default mappings, creates autocommands and +performs other necessary initialization. This initialization script is then +called from |vimtex#init|. + +The main interface provides some basic functionality. |vimtex#help| lists all +`vimtex` mappings defined for the current buffer, by default mapped to +'lh'. If the default mappings are used, |vimtex#help| will +display them. |vimtex#info| echoes the contents of |g:vimtex#data| and +|b:vimtex|. This is useful mainly for debugging. Finally, |vimtex#reinit| +clears the current data in |g:vimtex#data| and |b:vimtex|, stops running +`latexmk` processes |vimtex#latexmk#stop_all|, and then performs a new +initialization with |vimtex#init|. + +For each latex project that is opened, a |Dictionary| is created and added to +the list |g:vimtex#data|. The dictionary is initialized with information tied +to the current project, mainly the different associated file names. In +addition, a dictionary is created for every buffer |b:vimtex|. This contains +data that is specific to the current buffer, most importantly it contains the +ID of the main latex project. This combination of local and global data +enables |vimtex| to work properly for multi-file latex projects. It also +allows the editing of different latex projects simultaneously in different +buffers. + + *g:vimtex#data* +A |List| of |Dictionaries|, each containing data specific to a given latex +project. The ID of a latex project is the index of its dictionary in the list. +An example of a dictionary is given here: > + + { + 'pid': 0, + 'name': 'main', + 'base': 'main.tex', + 'root': '/some/path', + 'tex': '/some/path/main.tex', + 'aux': function('202'), + 'log': function('203'), + 'out': function('204'), + } + +Which entries are present in a given dictionary depends on the current +settings. For example, the entry `pid` is only available if +|vimtex-latexmk| is enabled |g:vimtex_latexmk_enabled|. Note that some of +the file entries are functions. The functions are used to find the files when +necessary, in case they do not exist when the latex file is opened. All +defined dictionaries can be printed with the function |vimtex#info|, by default +mapped to 'li'. + + *b:vimtex* +For each buffer, |vimtex| defines a |Dictionary| that contains buffer local +information. An example of such a dictionary is: > + + { + 'id': 0, + 'fold_sections': [], + } + +The most important entry is `id`, which is the index of the corresponding +entry in the list of latex projects |g:vimtex#data|. Other entries may also be +exist, such as `fold_sections`. The dictionary can be printed with the +function |vimtex#info|, by default mapped to 'li'. + +Functions: + |vimtex#info| + |vimtex#help| + |vimtex#reinit| + +------------------------------------------------------------------------------ +Support for multi-file projects:~ + *vimtex-multi-file* + *tex-root* + +|vimtex| supports multi-file documents in the sense that the plugin +automatically detects the root file of the project. This detection is based +on a recursive search for files that include the current tex file, until +a main file is recognized. A file is assumed to be the main file if it has +the `\begin{document}` line. Files are assumed to live in the same folder or +a parent folder of the current file. This should work in most cases, but it +may fail if for instance the project structure is something like this: > + + path1/main.tex + path2/chapter.tex + +That is, the main file detection will not work for the file `chapter.tex`, +because the main file does not live in the same folder or a parent folder. + +It is also possible to specify the main TeX file with a comment in one of the +first five lines of the current file similar to this: > + + %! TEX root = my-main.tex + +============================================================================== +DEFAULT MAPPINGS *vimtex-mappings* + +The default mappings for |vimtex| are given below. See 'map-listing' for +an explanation of the format. The function |vimtex#help| is provided for +convenience to list all the defined mappings, and it is by default mapped to +'lh'. The default mappings may be disabled with the option +|g:vimtex_mappings_enabled|, if the user wishes to create his/her own mappings. + +n % *@:call vimtex#motion#find_matching_pair() +v % *@:call vimtex#motion#find_matching_pair(1) +o % *@:normal v% + +v a$ *@:call vimtex#motion#select_inline_math() +v i$ *@:call vimtex#motion#select_inline_math(1) +o a$ *@:normal va$ +o i$ *@:normal vi$ + +v ae *@:call vimtex#motion#select_environment() +v ie *@:call vimtex#motion#select_environment(1) +o ae *@:normal vae +o ie *@:normal vie + +v ad *@:call vimtex#motion#select_delimiter() +v id *@:call vimtex#motion#select_delimiter(1) +o ad *@:normal va( +o id *@:normal vi( + +n [[ *@:call vimtex#motion#next_sec(0,1,0) +n [] *@:call vimtex#motion#next_sec(1,1,0) +n ][ *@:call vimtex#motion#next_sec(1,0,0) +n ]] *@:call vimtex#motion#next_sec(0,0,0) +v [[ *@:call vimtex#motion#next_sec(0,1,1) +v [] *@:call vimtex#motion#next_sec(1,1,1) +v ][ *@:call vimtex#motion#next_sec(1,0,1) +v ]] *@:call vimtex#motion#next_sec(0,0,1) +o [[ *@:normal v[[ +o [] *@:normal v[] +o ][ *@:normal v][ +o ]] *@:normal v]] + +n li *@:call vimtex#info() +n lh *@:call vimtex#help() +n lR *@:call vimtex#reinit() +n lt *@:call vimtex#toc#open() +n lT *@:call vimtex#toc#toggle() +n ll *@:call vimtex#latexmk#toggle() +n lk *@:call vimtex#latexmk#stop(1) +n lK *@:call vimtex#latexmk#stop_all() +n le *@:call vimtex#latexmk#errors(1) +n lo *@:call vimtex#latexmk#output() +n lg *@:call vimtex#latexmk#status() +n lG *@:call vimtex#latexmk#status(1) +n lc *@:call vimtex#latexmk#clean() +n lC *@:call vimtex#latexmk#clean(1) +n lv *@:call vimtex#view#view() +n lr *@:call vimtex#view#rsearch() + +n zx *@:call vimtex#fold#refresh() +n dse *@:call vimtex#change#env('') +n cse *@:call vimtex#change#env_prompt() +n dsc @ds}dF\ +n csc *@:call vimtex#change#command() +n tse *@:call vimtex#change#toggle_env_star() +n tsd *@:call vimtex#change#toggle_delim() +n *@:call vimtex#change#to_command()i +i *@:call vimtex#change#to_command() +i ]] *@:call vimtex#change#close_environment() + +============================================================================== +COMMANDS *vimtex-commands* + +|vimtex| is mainly based on a function API as described in the section +|vimtex-functions|. However, commands are also defined for convenience. +Below the commands are listed in alphabetical order. + +*VimtexClean* call vimtex#latexmk#clean(0) +*VimtexClean!* call vimtex#latexmk#clean(1) +*VimtexCompile* call vimtex#latexmk#compile() +*VimtexCompileSS* call vimtex#latexmk#compile_singleshot(0) +*VimtexCompileSS!* call vimtex#latexmk#compile_singleshot(1) +*VimtexCompileToggle* call vimtex#latexmk#toggle() +*VimtexErrors* call vimtex#latexmk#errors(1) +*VimtexErrors!* call vimtex#latexmk#errors(0) +*VimtexHelp* call vimtex#help() +*VimtexInfo* call vimtex#info() +*VimtexLacheck* call vimtex#latexmk#lacheck() +*VimtexOutput* call vimtex#latexmk#output() +*VimtexRefreshFolds* call vimtex#fold#refresh() +*VimtexReinitialize* call vimtex#reinit() +*VimtexStatus* call vimtex#latexmk#status(0) +*VimtexStatus!* call vimtex#latexmk#status(1) +*VimtexStop* call vimtex#latexmk#stop() +*VimtexStopAll* call vimtex#latexmk#stop_all() +*VimtexTocOpen* call vimtex#toc#open() +*VimtexTocToggle* call vimtex#toc#toggle() +*VimtexView* call vimtex#view#view() +*VimtexRSearch* call vimtex#view#rsearch() + +============================================================================== +OPTIONS *vimtex-options* + +This section describes the options for |vimtex|. The options are first +listed in alphabetical order, before they are described in more detail. The +descriptions also list the default values. + +Overview:~ + + |g:vimtex_enabled| + |g:vimtex_complete_close_braces| + |g:vimtex_complete_enabled| + |g:vimtex_complete_recursive_bib| + |g:vimtex_complete_patterns| + |g:vimtex_fold_enabled| + |g:vimtex_fold_automatic| + |g:vimtex_fold_envs| + |g:vimtex_fold_parts| + |g:vimtex_fold_preamble| + |g:vimtex_fold_sections| + |g:vimtex_indent_enabled| + |g:vimtex_latexmk_build_dir| + |g:vimtex_latexmk_callback| + |g:vimtex_latexmk_enabled| + |g:vimtex_latexmk_continuous| + |g:vimtex_latexmk_background| + |g:vimtex_latexmk_options| + |g:vimtex_mappings_enabled| + |g:vimtex_motion_enabled| + |g:vimtex_motion_matchparen| + |g:vimtex_quickfix_autojump| + |g:vimtex_quickfix_ignored_warnings| + |g:vimtex_quickfix_ignore_all_warnings| + |g:vimtex_quickfix_mode| + |g:vimtex_toc_enabled| + |g:vimtex_toc_fold_levels| + |g:vimtex_toc_fold| + |g:vimtex_toc_hide_help| + |g:vimtex_toc_hide_preamble| + |g:vimtex_toc_hide_line_numbers| + |g:vimtex_toc_numbers| + |g:vimtex_toc_numbers_width| + |g:vimtex_toc_resize| + |g:vimtex_toc_secnumdepth| + |g:vimtex_toc_split_pos| + |g:vimtex_toc_width| + |g:vimtex_view_enabled| + |g:vimtex_view_general_viewer| + |g:vimtex_view_general_options| + |g:vimtex_view_method| + |g:vimtex_view_mupdf_options| + |g:vimtex_view_okular_options| + |g:vimtex_view_sumatrapdf_options| + +------------------------------------------------------------------------------ +Detailed descriptions and default values:~ + + *g:vimtex_enabled* +If this variable exists and is 0, then |vimtex| is completely disabled. By +default, it is not defined. + + *g:vimtex_complete_close_braces* +When a label or a cite has been completed, this option controls whether it +will be followed by a closing brace. > + let g:vimtex_complete_close_braces = 0 +< + *g:vimtex_complete_enabled* +Use this option to prevent the plugin from setting the 'omnifunc': > + let g:vimtex_complete_enabled = 1 +< + *g:vimtex_complete_recursive_bib* +This option toggles recursive searching for bibliography files. Note that this +option may lead to a significant slowdown for large projects if enabled. > + let g:vimtex_complete_recursive_bib = 0 +< + *g:vimtex_complete_patterns* +Define patterns that control when the label and citation completion is +triggered. > + let g:vimtex_complete_patterns = { + \ 'ref' : '\C\\v\?\(eq\|page\|[cC]\)\?ref\*\?\_\s*{[^{}]*', + \ 'bib' : '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*', + \ }) +< + *g:vimtex_fold_enabled* +Use this option to disable/enable folding. > + let g:vimtex_fold_enabled = 1 +< + *g:vimtex_fold_automatic* +Set manual or automatic updating of fold levels. For manual mode, one must +use the |zx| mapping to update the foldlevels when desired. For automatic +mode, the fold levels will be updated automatically. Beware that this may +lead to some minor lags for large files. > + let g:vimtex_fold_automatic = 1 +< + *g:vimtex_fold_envs* +Decide whether environments should be folded or not. > + let g:vimtex_fold_envs = 1 +< + *g:vimtex_fold_parts* +List of parts that should be folded. > + let g:vimtex_fold_parts = [ + \ "appendix", + \ "frontmatter", + \ "mainmatter", + \ "backmatter", + \ ] +< + *g:vimtex_fold_preamble* +Decide whether preamble should be folded or not. > + let g:vimtex_fold_preamble = 1 +< + *g:vimtex_fold_sections* +List of section constructs that should be folded. > + let g:vimtex_fold_sections = [ + \ "part", + \ "chapter", + \ "section", + \ "subsection", + \ "subsubsection", + \ ] +< + *g:vimtex_indent_enabled* +Use |vimtex| indentation function. Not as customizable as the official +indentation function, but imho it is better. > + let g:vimtex_indent_enabled = 1 +< + *g:vimtex_latexmk_build_dir* +Set this variable in case a dedicated build dir is used with `latexmk`/`latex` +compilations. > + let g:vimtex_latexmk_build_dir = '.' +< + *g:vimtex_latexmk_callback* +If enabled, this option tells `latexmk` to run |vimtex#latexmk#errors| after +compilation is finished. Note that this feature only works if vim is compiled +with the |+clientserver| option. > + let g:vimtex_latexmk_callback = 1 +< + *g:vimtex_latexmk_enabled* +Whether to enable the `latexmk` interface or not. Note that even if it is not +enabled, the autoload functions will be available. However, the +necessary variables and autocommands will not be defined, and the mappings +will not be created. > + let g:vimtex_latexmk_enabled = 1 +< + *g:vimtex_latexmk_background* +If continuous mode is disabled, then this option may be used to set +whether single compilations should be run in the foreground or the +background. > + let g:vimtex_latexmk_background = 0 +< + *g:vimtex_latexmk_continuous* +If enabled, `latexmk` will run in continuous mode. This means that the +document is compiled every time a document file has been changed. Set to 0 to +disable. Note that the callback functions only work if continuous mode is enabled. > + let g:vimtex_latexmk_continuous = 1 +< + *g:vimtex_latexmk_options* +Set desired options for `latexmk` compilation. Note that options may also be +specified indirectly through a `.latexmkrc` file. > + let g:vimtex_latexmk_options = '-pdf' +< + *g:vimtex_quickfix_autojump* +Whether to automatically jump to the first error whenever the |quickfix| window +is opened. > + let g:vimtex_latexmk_autojump = 0 +< + *g:vimtex_quickfix_ignore_all_warnings* +If enabled, all LaTeX warnings are ignored and will not be listed in the +quickfix window. LaTeX errors will of course still be listed. > + let g:vimtex_quickfix_ignore_all_warnings = 0 +< + *g:vimtex_quickfix_ignored_warnings* +List of warning messages that should be ignored. By default, the list is +empty, thus no warnings are ignored. The list is a list of strings. Any +LaTeX warning that contains a string in the list will be ignored. To ignore +some common LaTeX warnings, try the following setting: > + let g:vimtex_quickfix_ignored_warnings = [ + \ 'Underfull', + \ 'Overfull', + \ 'specifier changed to', + \ ] +< + *g:vimtex_quickfix_mode* +This option controls the behaviour of the quickfix window in case errors +and/or warnings are found. The recognized options are: + + Value Effect ~ + 0 The quickfix window is never opened automatically. + 1 The quickfix window is opened automatically when there are errors, + and it becomes the active window. + 2 The quickfix window is opened automatically when there are errors, + but it does not become the active window. + +The default value is: > + let g:vimtex_quickfix_mode = 2 +< + *g:vimtex_quickfix_open_on_warning* +If it is 0, then the quickfix window will only be opened on errors or when +it is forced open. > + let g:vimtex_quickfix_open_on_warning = 1 +< + *g:vimtex_mappings_enabled* +Whether to load the default mappings. If this is set to 0, then no mappings +will be defined. Since all of the functionality is available as functions, +this allows the user to define his or her own mappings. > + let g:vimtex_mappings_enabled= 1 +< + *g:vimtex_motion_enabled* +Whether to enable the motion interface. If it is disabled, then neither the +default mappings nor the autocommands that enable highlighting of matching +parens will be defined. > + let g:vimtex_motion_enabled = 1 +< + *g:vimtex_motion_matchparen* +Enable highlighting of matching parens. This gives better support for LaTeX, +but disables the builtin |matchparen|. > + let g:vimtex_motion_matchparen = 1 +< + *g:vimtex_toc_enabled* +Enable interface for TOC. If it is disabled, then mappings for the TOC will +not be created. > + let g:vimtex_toc_enabled = 1 +< + *g:vimtex_toc_fold_levels* +If TOC entries are folded, this option controls the number of fold levels that +will be used. > + let g:vimtex_toc_fold_levels = 0 +< + *g:vimtex_toc_fold* +Turn on folding of TOC entries. > + let g:vimtex_toc_fold = 0 +< + *g:vimtex_toc_hide_help* +Allow the TOC help text to be hidden. > + let g:vimtex_toc_hide_help = 0 +< + *g:vimtex_toc_hide_preamble* +If enabled, the start of the preamble is not shown in the TOC. > + let g:vimtex_toc_hide_preamble = 0 +< + *g:vimtex_toc_hide_line_numbers* +If enabled, line numbers will be hidden in the TOC window. That is, +|nonumber| and |norelativenumber| will be set locally for the TOC window. > + let g:vimtex_toc_hide_line_numbers = 1 +< + *g:vimtex_toc_numbers* +Toggle display of numbers in TOC. The numbers may also be toggled inside the +TOC window with the `s` keybinding. > + let g:vimtex_toc_numbers = 1 +< + *g:vimtex_toc_numbers_width* +Set display width of numbers in TOC. If 0, the width is set based on the +section depth. > + let g:vimtex_toc_numbers_width = 0 +< + *g:vimtex_toc_resize* +Automatically resize vim when the TOC window is opened. > + let g:vimtex_toc_resize = 1 +< + *g:vimtex_toc_secnumdepth* +Define number of section levels to display. Set level corresponding to the +desired latex variable `secnumdepth`. Note that the variable may be updated +directly through the TOC window. For more info on `secnumdepth` see e.g. +http://en.wikibooks.org/w/index.php?title=LaTeX/Document_Structure > + let g:vimtex_toc_secnumdepth = 3 +< + *g:vimtex_toc_split_pos* +Define where the TOC window is opened. > + let g:vimtex_toc_split_pos = 'vert leftabove' +< + *g:vimtex_toc_width* +Set width of TOC window. > + let g:vimtex_toc_width = 30 +< + *g:vimtex_view_enabled* +Enable interface for view functionality. > + let g:vimtex_view_enabled = 1 +< + *g:vimtex_view_general_viewer* +Set general viewer. > + let g:vimtex_view_general_viewer = 'xdg-open' +< + *g:vimtex_view_method* +Set viewer method. If not set or set to `general`, it uses the general +viewer, see |g:vimtex_view_general_viewer|. > + let g:vimtex_view_method = '' + +The currently available choices are: > + general + mupdf + okular + sumatrapdf +< + *g:vimtex_view_general_options* + *g:vimtex_view_mupdf_options* + *g:vimtex_view_okular_options* + *g:vimtex_view_sumatrapdf_options* +Set custom options for the given viewer. > + let g:vimtex_view_general_options = '' + let g:vimtex_view_mupdf_options = '' + let g:vimtex_view_okular_options = '' + let g:vimtex_view_sumatrapdf_options = '' +< + *g:vimtex_view_mupdf_send_keys* +String of keys sent to MuPDF after the PDF file has been opened. The keys are +sent by the function |vimtex#view#mupdf_poststart|. > + let g:vimtex_view_mupdf_send_keys = '' +< +============================================================================== +OMNI COMPLETION *vimtex-completion* + +|vimtex| provides an 'omnifunc' for omni completion, see |compl-omni| and +|vimtex#complete#omnifunc|. The function is enabled by default, but may be +disabled with |g:vimtex_complete_enabled|. Omni completion is accessible with +|i_CTRL-X_CTRL-O|. + +The omni function completes labels and citations. The completion candidates +are gathered with the functions |vimtex#complete#labels| and +|vimtex#complete#bibtex|. If |g:vimtex_complete_close_braces| is set to 1, then +the completion includes closing braces. + +Associated settings: + |g:vimtex_complete_enabled| + |g:vimtex_complete_patterns.ref| + |g:vimtex_complete_patterns.bib| + |g:vimtex_complete_close_braces| + |g:vimtex_complete_recursive_bib| + +Functions: + |vimtex#complete#omnifunc| + |vimtex#complete#labels| + |vimtex#complete#bibtex| + +------------------------------------------------------------------------------ +Complete labels~ + +Label completion is triggered by '\ref{' commands as defined with +|g:vimtex_complete_patterns.ref|. The completion parses every relevant aux +file to gather the completion candidates. This is important to note, because +it means that the completion only works when the LaTeX document has been +compiled. + +As an example: > + + \ref{sec: + +offers a list of all matching labels, with their associated value and page +number. The label completion matches: + + 1. labels: > + \ref{sec: +< 2. numbers: > + \eqref{2 +< 3. labels and numbers together (separated by whitespace): > + \eqref{eq 2 + +------------------------------------------------------------------------------ +Complete citations~ + +Citation completion is triggered by '\cite{' commands as defined with +|g:vimtex_complete_patterns.bib|. The completion parses included bibliography +files (`*.bib`) and `thebibliography` environments to gather the completion +candidates. + +As an example, assume that a bibliography file is included with the following +entry: > + + @book { knuth1981, + author = "Donald E. Knuth", + title = "Seminumerical Algorithms", + publisher = "Addison-Wesley", + year = "1981" } + +Then the bibliography key `knuth1981` will be completed with e.g.: > + + \cite{Knuth 1981 + \cite{algo + \cite{Don.*Knuth + +In particular, note that regular expressions (or vim patterns) can be used +after '\cite{' to search for candidates. + +============================================================================== +FOLDING *vimtex-folding* + +|vimtex| can fold texts according to LaTeX structure (part, chapter, section +and subsection). Folding is turned on by default, but it can be disabled if +desired |g:vimtex_fold_enabled|. + +When folding is turned on and a LaTeX document is opened, the document is +parsed once in order to define the highest fold level based on which parts +(such as frontmatter, backmatter, and appendix) and section types (chapter, +section, etc.) are present. If the document has been edited and a new fold +level is required (or has become redundant), then |vimtex#fold#refresh| can be +used to refresh the fold level settings. This function is mapped by default +to 'zx'. + +Associated settings: + |g:vimtex_fold_enabled| + |g:vimtex_fold_automatic| + |g:vimtex_fold_preamble| + |g:vimtex_fold_parts| + |g:vimtex_fold_sections| + |g:vimtex_fold_envs| + +Functions: + |vimtex#fold#level| + |vimtex#fold#text| + |vimtex#fold#refresh| + +============================================================================== +INDENTATION *vimtex-indent* + +The official indentation function is pretty good and allows for some +customization. However, I am not quite satisfied, so I wrote my own +indentation function that is not customizable at all (at least for now), but +that I think is better. It is enabled by default, but may be disabled if +desired |g:vimtex_indent_enabled|. + +Associated settings: + |g:vimtex_indent_enabled| + +============================================================================== +LATEXMK *vimtex-latexmk* + +|vimtex| provides a basic interface to `latexmk` for compilation. The +interface may be disabled with |g:vimtex_latexmk_enabled|. The default +mappings are: > + + nnoremap ll :call vimtex#latexmk#toggle() + nnoremap lk :call vimtex#latexmk#stop() + nnoremap lK :call vimtex#latexmk#stop_all() + nnoremap le :call vimtex#latexmk#errors(1) + nnoremap lo :call vimtex#latexmk#output() + nnoremap lg :call vimtex#latexmk#status(0) + nnoremap lG :call vimtex#latexmk#status(1) + nnoremap lc :call vimtex#latexmk#clean(0) + nnoremap lC :call vimtex#latexmk#clean(1) + +Compilation is started with |vimtex#latexmk#compile| or may be toggled by +|vimtex#latexmk#toggle|. The default behaviour uses preview continuous mode of +`latexmk`, which may be disabled with |g:vimtex_latexmk_continuous|. If it is +disabled, then the option |g:vimtex_latexmk_background| may be used to decide +if single shot compilation should run in the foreground or the background. + +Single shot compilation may always be issued with the function +|vimtex#latexmk#compile_singleshot|. This function ignores the +|g:vimtex_latexmk_background|` setting, though, and will by default hide the +output from the `latexmk` command. The function is available through the +command |VimtexCompileSS|, and if desired one may create a custom mapping +such as > + + nnoremap ls :VimtexCompileSS + +A banged version of the command also exists, which will provide a more verbose +output. + +If vim is compiled with the |+clientserver| option and if +|g:vimtex_latexmk_callback| is enabled, then compilation errors are parsed +automatically. This is done by utilizing the tricks explained in +|vimtex-latexmk-tricks|. Note however that this only works for continuous +compilation mode. + +To check for and view errors in the quickfix window, use +|vimtex#latexmk#errors|. To check if background compilation is running, use +|vimtex#latexmk#status|. + +Associated settings: + |g:vimtex_latexmk_enabled| + |g:vimtex_latexmk_callback| + |g:vimtex_latexmk_autojump| + |g:vimtex_latexmk_continuous| + |g:vimtex_latexmk_background| + |g:vimtex_latexmk_options| + +Functions: + |vimtex#latexmk#clean| + |vimtex#latexmk#compile| + |vimtex#latexmk#compile_singleshot| + |vimtex#latexmk#errors| + |vimtex#latexmk#lacheck| + |vimtex#latexmk#output| + |vimtex#latexmk#status| + |vimtex#latexmk#stop| + |vimtex#latexmk#stop_all| + |vimtex#latexmk#toggle| + +------------------------------------------------------------------------------ + *vimtex-latexmk-tricks* +Latexmk tricks~ + +`latexmk` allows to set options through a configuration file +`$HOME/.latexmkrc`. A particular set of options are very convenient for +a good coupling between |vimtex| and `latexmk`: `$..._cmd`, where `...` +refers to either `compiling`, `success`, or `failure`. These options can be +used to specify commands that are run by `latexmk` before and after +a compilation run. For instance, one may use these options: > + +$compiling_cmd = "xdotool search --name \"%D\" " . + "set_window --name \"%D compiling...\""; +$success_cmd = "xdotool search --name \"%D\" " . + "set_window --name \"%D OK\"; " . + "gvim --remote-expr 'vimtex#latexmk#callback(1)'"; +$failure_cmd = "xdotool search --name \"%D\" " . + "set_window --name \"%D FAILURE\"; " . + "gvim --remote-expr 'vimtex#latexmk#callback(0)'"; + +Here `xdotool` (http://www.semicomplete.com/projects/xdotool/) is used to +change the title of the pdf viewer during and after compilation. In addition, +|vimtex#latexmk#errors| is called through the |clientserver| after each run to +either open the quickfix window when there are errors/warnings, or to close the +quickfix window in case all errors/warnings are gone. + +The latter trick is utilized in |vimtex| to automatically run the callback +commands if vim has the option |+clientserver|, and if the option +|g:vimtex_latexmk_callback| is enabled. The command that is used by `latexmk` +is then on the following form: > + + gvim --servername v:servername --remote-expr 'vimtex#latexmk#callback(0)' + +This command is then appended to the existing `$success_cmd` and +`$failure_cmd`. Note that if the existing commands are not empty, then they +must end with a semicolon in order to allow |vimtex| to append safely. + +------------------------------------------------------------------------------ + *vimtex-latexmk-lacheck* +Lacheck~ + +After compilation of a LaTeX document, the log file will contain errors that +are parsed by |vimtex| as explained above. However, there are a syntax +checkers for LaTeX, and we here provide a simple interface to `lacheck` for +checking your LaTeX manuscript for errors. + +Your manuscript may be checked using `lacheck` with the command `VimtexLacheck`. + +============================================================================== +VIEW *vimtex-view* + +|vimtex| provides functions for viewing the compiled documents. A command +and a mapping is defined for the multipurpose `view` function, which calls the +chosen view method defined by |g:vimtex_view_method|. + +Associated settings: + |g:vimtex_view_enabled| + |g:vimtex_view_general_viewer| + |g:vimtex_view_general_options| + |g:vimtex_view_method| + |g:vimtex_view_mupdf_options| + |g:vimtex_view_okular_options| + |g:vimtex_view_sumatrapdf_options| + +Functions: + |vimtex#view#general| + |vimtex#view#mupdf| + |vimtex#view#mupdf_rsearch| + |vimtex#view#okular| + |vimtex#view#sumatrapdf| + +------------------------------------------------------------------------------ +SYNCTEX SUPPORT *vimtex-synctex* + +Synctex is a tool that enables synchronization of the text editor position and +the pdf viewer position. The tool may be used to add mappings in vim to go to +the current position in the compiled pdf document (forward search), and also +to go from a specific position in the pdf file to the corresponding position +in vim (inverse/backward search). + +To make synctex work, one must enable synctex manually by adding the line > + + $pdflatex = 'pdflatex -synctex=1 %O %S'; + +to `~/.latexmkrc`. + +Forward search~ + +|vimtex| currently supports forward search for a limited set of viewers. +The functionality is enabled by choosing the desired viewer with the +|g:vimtex_view_method| option. The currently supported viewers are: + * MuPDF + * Okular + * SumatraPDF + * Zathura + +Backward search~ + +Backward or inverse search is typially set up inside the specific viewer +through an option named something like "inverse search command-line". +A standard value for the option is: > + + gvim --remote-silent +%l "%f" + +Backward search is unfortunately not supported by all pdf viewers. The +following is a list of viewers that to my knowledge should support backward +search: + * Okular + * SumatraPDF + * Evince (since version 2.91.3) + * Zathura + +Note: Inverse search relies on the |clientserver| functionality of vim. Each + instance of vim runs its own server. The above mentioned standard value + implies the default server name, which might not be the actual name of + the server for the vim instance you are using. + +Note: For backward search to work on windows, one must ensure that the folder + that contains `gVim.exe` is in your `%PATH%` environment variable. + +MuPDF does not support inverse search. However, by the use of some semi ugly +hacks, we have implemented a command inside vim that simulates the +functionality. The command is |VimtexRSearch|, and is by default mapped to +`lr` if MuPDF is chosen as the viewer. The command will go to the +line in the tex project that corresponds to the FIRST line on the page that is +open in MuPDF. + +For SumatraPDF one may set the inverse search setting from vim directly by +adding some command line options as shown below. The advantage of doing this +is that one may specify the vim server name explicitly, which means that the +backward search will also work as expected if one has several vim instances +running. To enable this, use the general viewer and: > + + let g:vimtex_view_general_viewer='SumatraPDF ' + \ . '-reuse-instance -inverse-search ' + \ . '"gvim --servername '.v:servername.' --remote-send \"^^' + \ . ':drop \%f^:\%l^:normal\! zzzv^' + \ . ':execute ''drop ''.fnameescape(''\%f'')^' + \ . ':\%l^:normal\! zzzv^' + \ . ':call remote_foreground('''.v:servername.''')^\""' + +============================================================================== +MOTION *vimtex-motion* + +|vimtex| provides some functions that can be used to give improved motions +and text objects. For instance, |vimtex-motion| enables highlighting of +matching parens or tags (such as begin/end structures). The functionality is +enabled by default, but may be disabled if desired. + +Associated settings: + |g:vimtex_motion_enabled| + |g:vimtex_motion_matchparen| + +Functions: + |vimtex#motion#find_matching_pair| + |vimtex#motion#next_section| + |vimtex#motion#sel_delimiter| + |vimtex#motion#sel_environment| + |vimtex#motion#sel_inline_math| + +============================================================================== +CHANGE *vimtex-change* + +|vimtex| provides mappings that are inspired by `surround.vim` +(https://github.com/tpope/vim-surround) (if it is installed, see +|surround.txt|). These mappings are: + `cse` - change surrounding environment + `dse` - delete surrounding environment + `csc` - change surrounding command + `dsc` - delete surrounding command + Note: This mappings is only available if `surround.vim` is also + available. + `tsd` - toggle delimiters (add/remove `\left` and `\right`) + `tse` - toggle starred environment + +An environment that has been opened but not closed may be closed by the +mapping `]]`. + +In addition, some functionality is provided to wrap the current selection. +This is not mapped to anything by default. + +For additional coupling with `surround.vim`, one may add the following lines +to ones `.vimrc` file to obtain corresonding `yse` and `ysc` mappings. > + + augroup latexSurround + autocmd! + autocmd FileType tex call s:latexSurround() + augroup END + + function! s:latexSurround() + let b:surround_{char2nr("e")} = "\\begin{\1environment: \1}\n\t\r\n\\end{\1\1}" + let b:surround_{char2nr("c")} = "\\\1command: \1{\r}" + endfunction + +Functions: + |vimtex#change#command| + |vimtex#change#close_environment| + |vimtex#change#env| + |vimtex#change#env_prompt| + |vimtex#change#to_command| + |vimtex#change#toggle_delim| + |vimtex#change#toggle_env_star| + |vimtex#change#wrap_selection| + |vimtex#change#wrap_selection_prompt| + +============================================================================== +UTILITY FUNCTIONS *vimtex-util* + +Several utility functions are available. Many of these are used as building +blocks for other functionalities, but are also available for users to add +additional functionality. + +Functions: + |vimtex#util#convert_back| + |vimtex#util#get_delim| + |vimtex#util#get_env| + |vimtex#util#has_syntax| + |vimtex#util#in_comment| + |vimtex#util#kpsewhich| + |vimtex#util#tex2tree| + |vimtex#util#tree2tex| + +============================================================================== +TABLE OF CONTENTS *vimtex-toc* + +|vimtex| provides a table of contents (TOC) window that can be opened +|vimtex#toc#open| or toggled |vimtex#toc#toggle|. In the TOC, one can use +'' on a selected entry to navigate. + +Associated settings: + |g:vimtex_toc_enabled| + |g:vimtex_toc_fold_levels| + |g:vimtex_toc_fold| + |g:vimtex_toc_hide_help| + |g:vimtex_toc_hide_preamble| + |g:vimtex_toc_hide_line_numbers| + |g:vimtex_toc_numbers| + |g:vimtex_toc_numbers_width| + |g:vimtex_toc_resize| + |g:vimtex_toc_secnumdepth| + |g:vimtex_toc_split_pos| + |g:vimtex_toc_width| + +Functions: + |vimtex#toc#open| + |vimtex#toc#toggle| + +============================================================================== +FUNCTION REFERENCE *vimtex-functions* + +The following is a reference of the available functions, sorted +alphabetically. First a short overview is given, then more detailed +descriptions follow. + +Overview:~ + + |vimtex#change#command| + |vimtex#change#close_environment| + |vimtex#change#env| + |vimtex#change#env_prompt| + |vimtex#change#to_command| + |vimtex#change#toggle_delim| + |vimtex#change#toggle_env_star| + |vimtex#change#wrap_selection| + |vimtex#change#wrap_selection_prompt| + |vimtex#complete#omnifunc| + |vimtex#complete#labels| + |vimtex#complete#bibtex| + |vimtex#fold#level| + |vimtex#fold#text| + |vimtex#fold#refresh| + |vimtex#help| + |vimtex#info| + |vimtex#latexmk#clean| + |vimtex#latexmk#compile| + |vimtex#latexmk#compile_singleshot| + |vimtex#latexmk#errors| + |vimtex#latexmk#options| + |vimtex#latexmk#status| + |vimtex#latexmk#stop| + |vimtex#latexmk#stop_all| + |vimtex#latexmk#toggle| + |vimtex#motion#find_matching_pair| + |vimtex#motion#next_sec| + |vimtex#motion#sel_delimiter| + |vimtex#motion#sel_environment| + |vimtex#motion#sel_inline_math| + |vimtex#reinit| + |vimtex#toc#open| + |vimtex#toc#toggle| + |vimtex#util#convert_back| + |vimtex#util#get_delim| + |vimtex#util#get_env| + |vimtex#util#has_syntax| + |vimtex#util#in_comment| + |vimtex#util#kpsewhich| + |vimtex#util#tex2tree| + |vimtex#util#tree2tex| + |vimtex#view#general| + |vimtex#view#mupdf| + |vimtex#view#mupdf_poststart| + |vimtex#view#mupdf_rsearch| + |vimtex#view#okular| + |vimtex#view#sumatrapdf| + +------------------------------------------------------------------------------ +Detailed descriptions:~ + + *vimtex#change#command* +Change the current command name to one typed at a prompt. + + *vimtex#change#close_environment* +Closes current delimiter or environment command. The function is only useful +when used as an insert mode command, since it returns the closing part of the +delimiter or environment. + + *vimtex#change#env* +Change the current environment name to the one passed as an argument. + + *vimtex#change#env_prompt* +Change the current environment name to one typed at a prompt. + + *vimtex#change#to_command* +Turn word under cursor into command. This essentially prepends a backslash +and adds an opening brace. The function may be used both in an insert mode +mapping and in a normal mode mapping. + + *vimtex#change#toggle_delim* +Toggle delimiters between `(` `)` and `\left(` `\right)` (and similar). + + *vimtex#change#toggle_env_star* +Toggle star for the current environment. + + *vimtex#change#wrap_selection* +Wrap the current selection within a supplied command. + + *vimtex#change#wrap_selection_prompt* +Wrap the current selection within a command given at a prompt. + + *vimtex#complete#omnifunc* +An 'omnifunc' for label and citation completion, see |vimtex-completion|. + + *vimtex#complete#labels* +Parses aux files to gather label candidates for completion. + + *vimtex#complete#bibtex* +Parses included bibliography files and `thebibliography` environments to +gather candidates for completion. + + *vimtex#fold#level* +Sets fold level for each line. 'foldexpr' |fold-expr| + + *vimtex#fold#text* +Sets fold title text. 'foldtext' + + *vimtex#fold#refresh* +Refreshes fold levels based on which parts and sections used in the current +file buffer. Also issues a |zx| call to update folds. + + *vimtex#help* +Lists all mappings that are defined specifically for the current buffer. If +the default mappings are used, then |vimtex#help| will display them. + + *vimtex#info* +Echoes the contents of |g:vimtex#data| and |b:vimtex|. This is useful mainly +for debugging. + + *vimtex#latexmk#clean* +Clean up temporary files with `latexmk -c`. An optional argument may be +supplied to indicate that the `-C` flag should be used, which also cleans +output files. This will only be run if `latexmk` is not already running. + + *vimtex#latexmk#compile* +Starts `latexmk -pvc ...` for the given buffer, if it is not already running. + + *vimtex#latexmk#compile_singleshot* +Starts a single shot compile with `latexmk ...` for the given buffer (if it is +not already running). + + *vimtex#latexmk#errors* +Parse the log file for errors and warnings. If any errors or warnings are +found, they are displayed in the quickfix window. The exact behaviour is +controlled through the different quickfix specific option: + + |g:vimtex_quickfix_autojump| + |g:vimtex_quickfix_ignore_all_warnings| + |g:vimtex_quickfix_ignored_warnings| + |g:vimtex_quickfix_mode| + +Note: The function takes one argument, which if nonzero will force open the +quickfix window if any errors are present. This is used in the normal mode +mapping. + + *vimtex#latexmk#output* +Opens a new buffer that show the output from the `latexmk` command. To close +the buffer, one may simply type `q`. + + *vimtex#latexmk#status* +Show if `latexmk` has been started for the current buffer. An optional +argument may be supplied, in which case the status for all buffers is shown. + + *vimtex#latexmk#stop* +Stop the `latexmk` process running for the current buffer. An optional +argument may be given, in which case the function becomes verbose. + + *vimtex#latexmk#stop_all* +Stops all running `latexmk` processes. + + *vimtex#latexmk#toggle* +Toggle compilation. Calls |vimtex#latexmk#compile| if `latexmk` is not running +for the current file. Else it calls |vimtex#latexmk#stop|. + + *vimtex#motion#find_matching_pair* +Finds a matching pair of parentheses or begin-end-tags. The functions is used +to find the pair closest to the current cursor position. + + *vimtex#motion#next_sec* +A motion command function that moves to the next section. Used to redefine +the mappings for ']]', '[[', and similar. + + *vimtex#motion#sel_delimiter* +A function that is used to create text objects for text contained within a set +of delimiters. + + *vimtex#motion#sel_environment* +A function that is used to create text objects for environments. + + *vimtex#motion#sel_inline_math* +A function that is used to create text objects for inline math structures. + + *vimtex#reinit* +Clears the current global and local data in |g:vimtex#data| and |b:vimtex|, +stops running `latexmk` processes |vimtex#latexmk#stop_all|, and then performs +a new initialization. + + *vimtex#toc#open* +Open the TOC window. If it is already open, then simply move the cursor to +the TOC window. + + *vimtex#toc#toggle* +Toggle TOC window: If TOC window is open, then close it. If it is closed, +then open it (but do not move the cursor to the window). + + *vimtex#util#convert_back* +Convert from stuff like `\IeC{\"u}` to corresponding unicode symbols. + + *vimtex#util#get_delim* +Get surrounding delimiters (with position). + + *vimtex#util#get_env* +Get surrounding environment. If optional argument supplied, the function also +returns the position (line and column number) of the begin and end structure. + + *vimtex#util#has_syntax* +Checks if the given position (or current position) is within the given syntax +structure. + + *vimtex#util#in_comment* +Checks if the given position (or current position) is within a comment. + + *vimtex#util#kpsewhich* +Parse file with `kpsewhich`. + + *vimtex#util#tex2tree* +Turn tex structure to a tree composed of lists. E.g. > + { testing { tex2tree { } } } => [ "testing" , [ "tex2tree", []]] +< + *vimtex#util#tree2tex* +Turns a tree composed of lists into tex structure. E.g. > + [ "testing" , [ "tex2tree", []]] => { testing { tex2tree { } } } +< + *vimtex#view#general* +Open the output file with the viewer that is specified with the option +|g:vimtex_view_general_viewer|. + + *vimtex#view#mupdf* + *vimtex#view#okular* + *vimtex#view#sumatrapdf* +First open the output file if it is not open with MuPDF/Okular/SumatraPDF. +Then perform a forward search. + + *vimtex#view#mupdf_poststart* +Function that is called after the MuPDF window has been opened. The function +is used to run `xdotool` commands, for instance to return focus to vim and to +possibly send some keys to MuPDF as specified in |g:vimtex_view_mupdf_send_keys|. + + *vimtex#view#mupdf_rsearch* +Perform a reverse search by use of `xdotool` and `synctex`. + +============================================================================== +FAQ *vimtex-faq* + +Q: Vim throws error when jumping to file with |gf|. +A: This might be due to the |isfname| setting, which by default contains `{,}` + on windows. |isfname| is a global option, and can therefore not be set by + `vimtex`. Suggested solution is to remove `{,}` from |isfname| by: > + + set isfname-={,} + +============================================================================== +CREDITS *vimtex-credits* + +|vimtex| is developed by Karl Yngve Lervåg , and is +distributed under the MIT license. The project is available as a Git +repository: https://github.com/lervag/vimtex. + +|vimtex| was developed from scratch, but much of the code has been based on +LaTeX-Box: https://github.com/LaTeX-Box-Team/LaTeX-Box. LaTeX-suite was also +an inspiration: http://vim-latex.sourceforge.net/. + +The documentation of |vimtex| is structured with inspiration from CtrlP +(https://github.com/kien/ctrlp.vim), simply because CtrlP has a very good +documentation. + +============================================================================== +CHANGELOG *vimtex-changelog* + +The following changelog only logs important changes, such as changes that +break backwards compatibility. See the git log for the detailed changelog. + + *vim-latex-namechange* +2015-03-08: Changed the name to |vimtex|~ +The old name `vim-latex` was already used by LaTeX-Suite. I was not aware of +the name clash in the beginning. Due to the rising popularity of this plugin, +it has become clear that such a name clash is very inconvenient. The present +change is therefore very much needed. + +The name change is reflected throughout the plugin in the names of commands, +mappings, functions, and options. People should update their `vimrc` settings +accordingly. For instance, every option name should be changed from > + + g:latex_... = ... + +to > + + g:vimtex_... = ... + +2014-12-07: Added more general view functionality~ +Added new module for view functionality. This allows more complex view +functions (and commands), for instance to do forward (and possibly backwards) +searching through `synctex`. In the first version, I added forward search for +mupdf by use of the `synctex` command and `xdotools`. + +The `g:latex_viewer` option has now been deprecated. Instead one should use +|g:vimtex_view_method| and |g:vimtex_view_general_viewer|. + +Deprecated option: + *g:latex_viewer* + +2014-06-13: Changed some option names~ +Some |vimtex| option names were changed in an attempt to make the names +more consistent. These options are listed here for reference: + *g:latex_errorformat_ignore_warnings* + *g:latex_errorformat_show_warnings* + *g:latex_latexmk_autojump* + *g:latex_latexmk_quickfix* +The new names are, respectively: + |g:vimtex_quickfix_ignored_warnings| + |g:vimtex_quickfix_ignore_all_warnings| + |g:vimtex_quickfix_autojump| + |g:vimtex_quickfix_mode| + +2013-10-05: First public release~ + +============================================================================== + vim:tw=78:ts=8:ft=help:norl: diff --git a/ftplugin/tex.vim b/ftplugin/tex.vim index 4add7f6..844c878 100644 --- a/ftplugin/tex.vim +++ b/ftplugin/tex.vim @@ -1,10 +1,10 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com " -if exists('g:latex_enabled') && !g:latex_enabled +if exists('g:vimtex_enabled') && !g:vimtex_enabled finish endif if exists('b:did_ftplugin') @@ -12,6 +12,14 @@ if exists('b:did_ftplugin') endif let b:did_ftplugin = 1 -call latex#init() +if exists('g:latex_enabled') + echohl Error + echom "vim-latex has been renamed to vimtex!" + echom "Please see docs for more information (:h vim-latex-namechange)." + echohl None + finish +endif + +call vimtex#init() " vim: fdm=marker sw=2 diff --git a/ftplugin/latextoc.vim b/ftplugin/vimtex_toc.vim similarity index 83% rename from ftplugin/latextoc.vim rename to ftplugin/vimtex_toc.vim index 5f3dbbf..dc3d41b 100644 --- a/ftplugin/latextoc.vim +++ b/ftplugin/vimtex_toc.vim @@ -1,4 +1,4 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com @@ -16,7 +16,7 @@ setlocal listchars= setlocal nobuflisted setlocal noswapfile setlocal nowrap -if g:latex_toc_hide_line_numbers +if g:vimtex_toc_hide_line_numbers setlocal nonumber setlocal norelativenumber endif @@ -26,14 +26,14 @@ setlocal cursorline setlocal tabstop=8 setlocal cole=0 setlocal cocu=nvic -if g:latex_toc_fold +if g:vimtex_toc_fold setlocal foldmethod=expr - setlocal foldexpr=latextoc#fold_level(v:lnum) - setlocal foldtext=latextoc#fold_text() + setlocal foldexpr=vimtex_toc#fold_level(v:lnum) + setlocal foldtext=vimtex_toc#fold_text() endif " Refresh/Initialize TOC content -call latextoc#init() +call vimtex_toc#init() " Define mappings nnoremap G G4k @@ -77,8 +77,8 @@ function! s:toc_activate(close) "{{{1 " Keep or close TOC window (based on options) if a:close - if g:latex_toc_resize - silent exe "set columns-=" . g:latex_toc_width + if g:vimtex_toc_resize + silent exe "set columns-=" . g:vimtex_toc_width endif execute 'bwipeout ' . toc_bnr else @@ -87,8 +87,8 @@ function! s:toc_activate(close) "{{{1 endfunction function! s:toc_close() "{{{1 - if g:latex_toc_resize - silent exe "set columns-=" . g:latex_toc_width + if g:vimtex_toc_resize + silent exe "set columns-=" . g:vimtex_toc_width endif bwipeout endfunction @@ -129,25 +129,25 @@ function! s:toc_open_entry(entry) "{{{1 endfunction function! s:toc_toggle_numbers() "{{{1 - if g:latex_toc_numbers - let g:latex_toc_numbers = 0 + if g:vimtex_toc_numbers + let g:vimtex_toc_numbers = 0 else - let g:latex_toc_numbers = 1 + let g:vimtex_toc_numbers = 1 endif - call latextoc#refresh() + call vimtex_toc#refresh() endfunction function! s:toc_inc_secnumdepth() "{{{1 let b:toc_secnumdepth = min([b:toc_secnumdepth + 1, 5]) - let g:latex_toc_secnumdepth = b:toc_secnumdepth - call latextoc#refresh() + let g:vimtex_toc_secnumdepth = b:toc_secnumdepth + call vimtex_toc#refresh() endfunction function! s:toc_dec_secnumdepth() "{{{1 let b:toc_secnumdepth = max([b:toc_secnumdepth - 1, -2]) - let g:latex_toc_secnumdepth = b:toc_secnumdepth - call latextoc#refresh() + let g:vimtex_toc_secnumdepth = b:toc_secnumdepth + call vimtex_toc#refresh() endfunction " }}}1 diff --git a/indent/tex.vim b/indent/tex.vim index e88046e..90185de 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -1,4 +1,4 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com @@ -9,56 +9,18 @@ if exists("b:did_indent") endif let b:did_indent = 1 -call latex#util#set_default('g:latex_indent_enabled', 1) -if !g:latex_indent_enabled | finish | endif +call vimtex#util#set_default('g:vimtex_indent_enabled', 1) +if !g:vimtex_indent_enabled | finish | endif let s:cpo_save = &cpo set cpo&vim -" {{{1 Options and common patterns setlocal autoindent -setlocal indentexpr=LatexIndent() +setlocal indentexpr=s:vimtex_indent() setlocal indentkeys& setlocal indentkeys+=[,(,{,),},],\&,=\\item -let s:tikz_indented = 0 - -" Define some common patterns -let s:envs_lists = 'itemize\|description\|enumerate\|thebibliography' -let s:envs_noindent = 'document\|verbatim\|lstlisting' -let s:delimiters_open = '\(' . join([ - \ '{', - \ '(', - \ '\[', - \ '\\{', - \ '\\(', - \ '\\\[', - \ '\\\Cbegin\s*{.\{-}}', - \ '\\\Cleft\s*\%([^\\]\|\\.\|\\\a*\)', - \ '\\\cbigg\?\((\|\[\|\\{\)', - \ ], '\|') . '\)' -let s:delimiters_close = '\(' . join([ - \ '}', - \ ')', - \ '\]', - \ '\\}', - \ '\\)', - \ '\\\]', - \ '\\\Cend\s*{.\{-}}', - \ '\\\Cright\s*\%([^\\]\|\\.\|\\\a*\)', - \ '\\\cbigg\?\()\|\]\|\\}\)', - \ ], '\|') . '\)' -let s:tikz_commands = '\\\(' . join([ - \ 'draw', - \ 'fill', - \ 'path', - \ 'node', - \ 'add\(legendentry\|plot\)', - \ ], '\|') . '\)' -" }}}1 - -" {{{1 LatexIndent -function! LatexIndent() +function! s:vimtex_indent() " {{{1 " Find a non-blank non-comment line above the current line let lnum = prevnonblank(v:lnum - 1) while lnum != 0 && getline(lnum) =~ '^\s*%' @@ -154,9 +116,7 @@ function! LatexIndent() return ind endfunction "}}} - -" {{{1 s:count_delimiters -function! s:count_delimiters(line, pattern) +function! s:count_delimiters(line, pattern) " {{{1 let sum = 0 let indx = match(a:line, a:pattern) while indx >= 0 @@ -167,6 +127,45 @@ function! s:count_delimiters(line, pattern) endwhile return sum endfunction + +" }}}1 + +" {{{1 Script variables +let s:tikz_indented = 0 + +" Define some common patterns +let s:envs_lists = 'itemize\|description\|enumerate\|thebibliography' +let s:envs_noindent = 'document\|verbatim\|lstlisting' +let s:delimiters_open = '\(' . join([ + \ '{', + \ '(', + \ '\[', + \ '\\{', + \ '\\(', + \ '\\\[', + \ '\\\Cbegin\s*{.\{-}}', + \ '\\\Cleft\s*\%([^\\]\|\\.\|\\\a*\)', + \ '\\\cbigg\?\((\|\[\|\\{\)', + \ ], '\|') . '\)' +let s:delimiters_close = '\(' . join([ + \ '}', + \ ')', + \ '\]', + \ '\\}', + \ '\\)', + \ '\\\]', + \ '\\\Cend\s*{.\{-}}', + \ '\\\Cright\s*\%([^\\]\|\\.\|\\\a*\)', + \ '\\\cbigg\?\()\|\]\|\\}\)', + \ ], '\|') . '\)' +let s:tikz_commands = '\\\(' . join([ + \ 'draw', + \ 'fill', + \ 'path', + \ 'node', + \ 'add\(legendentry\|plot\)', + \ ], '\|') . '\)' + " }}}1 let &cpo = s:cpo_save diff --git a/syntax/latextoc.vim b/syntax/latextoc.vim index 79e55d8..275b3ec 100644 --- a/syntax/latextoc.vim +++ b/syntax/latextoc.vim @@ -1,4 +1,4 @@ -" LaTeX plugin for Vim +" vimtex - LaTeX plugin for Vim " " Maintainer: Karl Yngve Lervåg " Email: karl.yngve@gmail.com