Changed plugin name to vimtex
This commit is contained in:
parent
d9be80a86e
commit
a14cc5997d
20
README.md
20
README.md
@ -1,4 +1,4 @@
|
|||||||
# vim-latex
|
# vimtex
|
||||||
|
|
||||||
## Introduction
|
## 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)
|
[vimscript#2945](http://www.vim.org/scripts/script.php?script_id=2945)
|
||||||
- [LaTeX-Box](https://github.com/LaTeX-Box-Team/LaTeX-Box):
|
- [LaTeX-Box](https://github.com/LaTeX-Box-Team/LaTeX-Box):
|
||||||
[vimscript#3109](http://www.vim.org/scripts/script.php?script_id=3109)
|
[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
|
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
|
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
|
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.
|
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
|
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
|
recommend [UltiSnips](https://github.com/SirVer/ultisnips) for snippets and
|
||||||
[neocomplete](https://github.com/Shougo/neocomplete.vim) for completion.
|
[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.
|
Read the documentation for a more thorough introduction.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -33,23 +31,23 @@ Read the documentation for a more thorough introduction.
|
|||||||
### With gmarik vundle
|
### With gmarik vundle
|
||||||
_https://github.com/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.
|
`:PluginInstall` in a vim buffer. Add `!` to the command to update.
|
||||||
|
|
||||||
### With neobundle
|
### With neobundle
|
||||||
_https://github.com/Shougo/neobundle.vim_
|
_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.
|
`:NeoBundleInstall` in a vim buffer. Add `!` to the command to update.
|
||||||
|
|
||||||
### With pathogen
|
### With pathogen
|
||||||
_https://github.com/tpope/vim-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:
|
clone`. This will typically be enough:
|
||||||
|
|
||||||
cd ~/.vim/bundle
|
cd ~/.vim/bundle
|
||||||
git clone git://github.com/lervag/vim-latex
|
git clone git://github.com/lervag/vimtex
|
||||||
|
|
||||||
### Without a plugin manager
|
### Without a plugin manager
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
|
@ -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 <silent><buffer> <localleader>li <plug>(vl-info)
|
|
||||||
nmap <silent><buffer> <localleader>lh <plug>(vl-help)
|
|
||||||
nmap <silent><buffer> <localleader>lR <plug>(vl-reinit)
|
|
||||||
|
|
||||||
nmap <silent><buffer> dse <plug>(vl-delete-env)
|
|
||||||
nmap <silent><buffer> dsc <plug>(vl-delete-cmd)
|
|
||||||
nmap <silent><buffer> cse <plug>(vl-change-env)
|
|
||||||
nmap <silent><buffer> csc <plug>(vl-change-cmd)
|
|
||||||
nmap <silent><buffer> tse <plug>(vl-toggle-star)
|
|
||||||
nmap <silent><buffer> tsd <plug>(vl-toggle-delim)
|
|
||||||
nmap <silent><buffer> <F7> <plug>(vl-create-cmd)
|
|
||||||
imap <silent><buffer> <F7> <plug>(vl-create-cmd)
|
|
||||||
imap <silent><buffer> ]] <plug>(vl-close-env)
|
|
||||||
|
|
||||||
if g:latex_latexmk_enabled
|
|
||||||
nmap <silent><buffer> <localleader>ll <plug>(vl-compile-toggle)
|
|
||||||
nmap <silent><buffer> <localleader>lo <plug>(vl-compile-output)
|
|
||||||
nmap <silent><buffer> <localleader>lk <plug>(vl-stop)
|
|
||||||
nmap <silent><buffer> <localleader>lK <plug>(vl-stop-all)
|
|
||||||
nmap <silent><buffer> <localleader>le <plug>(vl-errors)
|
|
||||||
nmap <silent><buffer> <localleader>lc <plug>(vl-clean)
|
|
||||||
nmap <silent><buffer> <localleader>lC <plug>(vl-clean-full)
|
|
||||||
nmap <silent><buffer> <localleader>lg <plug>(vl-status)
|
|
||||||
nmap <silent><buffer> <localleader>lG <plug>(vl-status-all)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:latex_motion_enabled
|
|
||||||
nmap <silent><buffer> % <plug>(vl-%)
|
|
||||||
xmap <silent><buffer> % <plug>(vl-%)
|
|
||||||
omap <silent><buffer> % <plug>(vl-%)
|
|
||||||
nmap <silent><buffer> ]] <plug>(vl-]])
|
|
||||||
nmap <silent><buffer> ][ <plug>(vl-][)
|
|
||||||
nmap <silent><buffer> [] <plug>(vl-[])
|
|
||||||
nmap <silent><buffer> [[ <plug>(vl-[[)
|
|
||||||
xmap <silent><buffer> ]] <plug>(vl-]])
|
|
||||||
xmap <silent><buffer> ][ <plug>(vl-][)
|
|
||||||
xmap <silent><buffer> [] <plug>(vl-[])
|
|
||||||
xmap <silent><buffer> [[ <plug>(vl-[[)
|
|
||||||
omap <silent><buffer> ]] <plug>(vl-]])
|
|
||||||
omap <silent><buffer> ][ <plug>(vl-][)
|
|
||||||
omap <silent><buffer> [] <plug>(vl-[])
|
|
||||||
omap <silent><buffer> [[ <plug>(vl-[[)
|
|
||||||
xmap <silent><buffer> ie <plug>(vl-ie)
|
|
||||||
xmap <silent><buffer> ae <plug>(vl-ae)
|
|
||||||
omap <silent><buffer> ie <plug>(vl-ie)
|
|
||||||
omap <silent><buffer> ae <plug>(vl-ae)
|
|
||||||
xmap <silent><buffer> i$ <plug>(vl-i$)
|
|
||||||
xmap <silent><buffer> a$ <plug>(vl-a$)
|
|
||||||
omap <silent><buffer> i$ <plug>(vl-i$)
|
|
||||||
omap <silent><buffer> a$ <plug>(vl-a$)
|
|
||||||
xmap <silent><buffer> id <plug>(vl-id)
|
|
||||||
xmap <silent><buffer> ad <plug>(vl-ad)
|
|
||||||
omap <silent><buffer> id <plug>(vl-id)
|
|
||||||
omap <silent><buffer> ad <plug>(vl-ad)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:latex_toc_enabled
|
|
||||||
nmap <silent><buffer> <localleader>lt <plug>(vl-toc-open)
|
|
||||||
nmap <silent><buffer> <localleader>lT <plug>(vl-toc-toggle)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:latex_view_enabled
|
|
||||||
nmap <silent><buffer> <localleader>lv <plug>(vl-view)
|
|
||||||
if has_key(g:latex#data[b:latex.id], 'rsearch')
|
|
||||||
nmap <silent><buffer> <localleader>lr <plug>(vl-reverse-search)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" vim: fdm=marker sw=2
|
|
@ -1,25 +1,25 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" 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
|
let s:initialized = 0
|
||||||
|
|
||||||
function! latex#init() " {{{1
|
function! vimtex#init() " {{{1
|
||||||
call s:init_options()
|
call s:init_options()
|
||||||
call s:init_environment()
|
call s:init_environment()
|
||||||
|
|
||||||
call latex#toc#init(s:initialized)
|
call vimtex#toc#init(s:initialized)
|
||||||
call latex#fold#init(s:initialized)
|
call vimtex#fold#init(s:initialized)
|
||||||
call latex#view#init(s:initialized)
|
call vimtex#view#init(s:initialized)
|
||||||
call latex#motion#init(s:initialized)
|
call vimtex#motion#init(s:initialized)
|
||||||
call latex#labels#init(s:initialized)
|
call vimtex#labels#init(s:initialized)
|
||||||
call latex#change#init(s:initialized)
|
call vimtex#change#init(s:initialized)
|
||||||
call latex#latexmk#init(s:initialized)
|
call vimtex#latexmk#init(s:initialized)
|
||||||
call latex#complete#init(s:initialized)
|
call vimtex#complete#init(s:initialized)
|
||||||
call latex#mappings#init(s:initialized)
|
call vimtex#mappings#init(s:initialized)
|
||||||
|
|
||||||
"
|
"
|
||||||
" This variable is used to allow a distinction between global and buffer
|
" This variable is used to allow a distinction between global and buffer
|
||||||
@ -28,19 +28,19 @@ function! latex#init() " {{{1
|
|||||||
let s:initialized = 1
|
let s:initialized = 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#info() " {{{1
|
function! vimtex#info() " {{{1
|
||||||
if !s:initialized
|
if !s:initialized
|
||||||
echoerr "Error: vim-latex has not been initialized!"
|
echoerr "Error: vimtex has not been initialized!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Print buffer data
|
" Print buffer data
|
||||||
echo "b:latex"
|
echo "b:vimtex"
|
||||||
call s:print_dict(b:latex)
|
call s:print_dict(b:vimtex)
|
||||||
|
|
||||||
" Print global data
|
" Print global data
|
||||||
let n = 0
|
let n = 0
|
||||||
for data in g:latex#data
|
for data in g:vimtex#data
|
||||||
" Prepare for printing
|
" Prepare for printing
|
||||||
let d = deepcopy(data)
|
let d = deepcopy(data)
|
||||||
for f in ['aux', 'out', 'log']
|
for f in ['aux', 'out', 'log']
|
||||||
@ -49,14 +49,14 @@ function! latex#info() " {{{1
|
|||||||
|
|
||||||
" Print data blob title line
|
" Print data blob title line
|
||||||
echo "\n"
|
echo "\n"
|
||||||
echo "g:latex#data[" . n . "] : " . remove(d, 'name')
|
echo "g:vimtex#data[" . n . "] : " . remove(d, 'name')
|
||||||
call s:print_dict(d)
|
call s:print_dict(d)
|
||||||
let n += 1
|
let n += 1
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#help() " {{{1
|
function! vimtex#help() " {{{1
|
||||||
if g:latex_mappings_enabled
|
if g:vimtex_mappings_enabled
|
||||||
nmap <buffer>
|
nmap <buffer>
|
||||||
xmap <buffer>
|
xmap <buffer>
|
||||||
omap <buffer>
|
omap <buffer>
|
||||||
@ -65,25 +65,25 @@ function! latex#help() " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#reinit() " {{{1
|
function! vimtex#reinit() " {{{1
|
||||||
"
|
"
|
||||||
" Stop latexmk processes (if running)
|
" Stop latexmk processes (if running)
|
||||||
"
|
"
|
||||||
call latex#latexmk#stop_all()
|
call vimtex#latexmk#stop_all()
|
||||||
|
|
||||||
"
|
"
|
||||||
" Reset global variables
|
" Reset global variables
|
||||||
"
|
"
|
||||||
let s:initialized = 0
|
let s:initialized = 0
|
||||||
unlet g:latex#data
|
unlet g:vimtex#data
|
||||||
|
|
||||||
"
|
"
|
||||||
" Reset and reinitialize buffers
|
" Reset and reinitialize buffers
|
||||||
"
|
"
|
||||||
let n = bufnr('%')
|
let n = bufnr('%')
|
||||||
bufdo if getbufvar('%', '&filetype') == 'tex' |
|
bufdo if getbufvar('%', '&filetype') == 'tex' |
|
||||||
\ unlet b:latex |
|
\ unlet b:vimtex |
|
||||||
\ call latex#init() |
|
\ call vimtex#init() |
|
||||||
\ endif
|
\ endif
|
||||||
silent execute 'buffer ' . n
|
silent execute 'buffer ' . n
|
||||||
endfunction
|
endfunction
|
||||||
@ -91,8 +91,8 @@ endfunction
|
|||||||
|
|
||||||
function! s:init_environment() " {{{1
|
function! s:init_environment() " {{{1
|
||||||
" Initialize global and local data blobs
|
" Initialize global and local data blobs
|
||||||
call latex#util#set_default('g:latex#data', [])
|
call vimtex#util#set_default('g:vimtex#data', [])
|
||||||
call latex#util#set_default('b:latex', {})
|
call vimtex#util#set_default('b:vimtex', {})
|
||||||
|
|
||||||
" Set some file type specific vim options
|
" Set some file type specific vim options
|
||||||
setlocal suffixesadd+=.tex
|
setlocal suffixesadd+=.tex
|
||||||
@ -102,7 +102,7 @@ function! s:init_environment() " {{{1
|
|||||||
let main = s:get_main()
|
let main = s:get_main()
|
||||||
let id = s:get_id(main)
|
let id = s:get_id(main)
|
||||||
if id >= 0
|
if id >= 0
|
||||||
let b:latex.id = id
|
let b:vimtex.id = id
|
||||||
else
|
else
|
||||||
let data = {}
|
let data = {}
|
||||||
let data.tex = main
|
let data.tex = main
|
||||||
@ -119,35 +119,35 @@ function! s:init_environment() " {{{1
|
|||||||
return s:get_main_out(self)
|
return s:get_main_out(self)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call add(g:latex#data, data)
|
call add(g:vimtex#data, data)
|
||||||
let b:latex.id = len(g:latex#data) - 1
|
let b:vimtex.id = len(g:vimtex#data) - 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Define commands
|
" Define commands
|
||||||
command! -buffer VimLatexInfo call latex#info()
|
command! -buffer VimtexInfo call Vimtex#info()
|
||||||
command! -buffer VimLatexHelp call latex#help()
|
command! -buffer VimtexHelp call vimtex#help()
|
||||||
command! -buffer VimLatexReinitialize call latex#reinit()
|
command! -buffer VimtexReinitialize call vimtex#reinit()
|
||||||
|
|
||||||
" Define mappings
|
" Define mappings
|
||||||
nnoremap <buffer> <plug>(vl-info) :call latex#info()<cr>
|
nnoremap <buffer> <plug>(vimtex-info) :call vimtex#info()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-help) :call latex#help()<cr>
|
nnoremap <buffer> <plug>(vimtex-help) :call vimtex#help()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-reinit) :call latex#reinit()<cr>
|
nnoremap <buffer> <plug>(vimtex-reinit) :call vimtex#reinit()<cr>
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:init_options() " {{{1
|
function! s:init_options() " {{{1
|
||||||
call latex#util#set_default('g:latex_quickfix_ignore_all_warnings', 0)
|
call vimtex#util#set_default('g:vimtex_quickfix_ignore_all_warnings', 0)
|
||||||
call latex#util#set_default('g:latex_quickfix_ignored_warnings', [])
|
call vimtex#util#set_default('g:vimtex_quickfix_ignored_warnings', [])
|
||||||
|
|
||||||
call latex#util#error_deprecated('g:latex_errorformat_ignore_warnings')
|
call vimtex#util#error_deprecated('g:vimtex_errorformat_ignore_warnings')
|
||||||
call latex#util#error_deprecated('g:latex_errorformat_show_warnings')
|
call vimtex#util#error_deprecated('g:vimtex_errorformat_show_warnings')
|
||||||
endfunction
|
endfunction
|
||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
function! s:get_id(main) " {{{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
|
let id = 0
|
||||||
while id < len(g:latex#data)
|
while id < len(g:vimtex#data)
|
||||||
if g:latex#data[id].tex == a:main
|
if g:vimtex#data[id].tex == a:main
|
||||||
return id
|
return id
|
||||||
endif
|
endif
|
||||||
let id += 1
|
let id += 1
|
||||||
@ -236,7 +236,7 @@ function! s:get_main_ext(texdata, ext) " {{{1
|
|||||||
" Create set of candidates
|
" Create set of candidates
|
||||||
let candidates = [
|
let candidates = [
|
||||||
\ a:texdata.name,
|
\ a:texdata.name,
|
||||||
\ g:latex_latexmk_build_dir . '/' . a:texdata.name,
|
\ g:vimtex_latexmk_build_dir . '/' . a:texdata.name,
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" Search through the candidates
|
" Search through the candidates
|
||||||
@ -255,7 +255,7 @@ function! s:get_main_out(texdata) " {{{1
|
|||||||
" Create set of candidates
|
" Create set of candidates
|
||||||
let candidates = [
|
let candidates = [
|
||||||
\ a:texdata.name,
|
\ a:texdata.name,
|
||||||
\ g:latex_latexmk_build_dir . '/' . a:texdata.name,
|
\ g:vimtex_latexmk_build_dir . '/' . a:texdata.name,
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" Check for pdf files
|
" Check for pdf files
|
@ -1,32 +1,32 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#change#init(initialized) " {{{1
|
function! vimtex#change#init(initialized) " {{{1
|
||||||
" Define mappings
|
" Define mappings
|
||||||
nnoremap <silent><buffer> <plug>(vl-delete-env)
|
nnoremap <silent><buffer> <plug>(vimtex-delete-env)
|
||||||
\ :call latex#change#env('')<cr>
|
\ :call vimtex#change#env('')<cr>
|
||||||
nnoremap <silent><buffer> <plug>(vl-delete-cmd) vaBom`o<esc>xg``xdF\
|
nnoremap <silent><buffer> <plug>(vimtex-delete-cmd) vaBom`o<esc>xg``xdF\
|
||||||
\:silent! call repeat#set("\<plug>(vl-delete-cmd)", v:count)<cr>
|
\:silent! call repeat#set("\<plug>(vimtex-delete-cmd)", v:count)<cr>
|
||||||
nnoremap <silent><buffer> <plug>(vl-change-env)
|
nnoremap <silent><buffer> <plug>(vimtex-change-env)
|
||||||
\ :call latex#change#env_prompt()<cr>
|
\ :call vimtex#change#env_prompt()<cr>
|
||||||
nnoremap <silent><buffer> <plug>(vl-change-cmd)
|
nnoremap <silent><buffer> <plug>(vimtex-change-cmd)
|
||||||
\ :call latex#change#command()<cr>
|
\ :call vimtex#change#command()<cr>
|
||||||
nnoremap <silent><buffer> <plug>(vl-toggle-star)
|
nnoremap <silent><buffer> <plug>(vimtex-toggle-star)
|
||||||
\ :call latex#change#toggle_env_star()<cr>
|
\ :call vimtex#change#toggle_env_star()<cr>
|
||||||
nnoremap <silent><buffer> <plug>(vl-toggle-delim)
|
nnoremap <silent><buffer> <plug>(vimtex-toggle-delim)
|
||||||
\ :call latex#change#toggle_delim()<cr>
|
\ :call vimtex#change#toggle_delim()<cr>
|
||||||
nnoremap <silent><buffer> <plug>(vl-create-cmd)
|
nnoremap <silent><buffer> <plug>(vimtex-create-cmd)
|
||||||
\ :call latex#change#to_command()<cr>i
|
\ :call vimtex#change#to_command()<cr>i
|
||||||
inoremap <silent><buffer> <plug>(vl-create-cmd)
|
inoremap <silent><buffer> <plug>(vimtex-create-cmd)
|
||||||
\ <c-r>=latex#change#to_command()<cr>
|
\ <c-r>=vimtex#change#to_command()<cr>
|
||||||
inoremap <silent><buffer> <plug>(vl-close-env)
|
inoremap <silent><buffer> <plug>(vimtex-close-env)
|
||||||
\ <c-r>=latex#change#close_environment()<cr>
|
\ <c-r>=vimtex#change#close_environment()<cr>
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#command() " {{{1
|
function! vimtex#change#command() " {{{1
|
||||||
let pos_save = getpos('.')
|
let pos_save = getpos('.')
|
||||||
let savereg = @a
|
let savereg = @a
|
||||||
|
|
||||||
@ -49,13 +49,13 @@ function! latex#change#command() " {{{1
|
|||||||
let @a = savereg
|
let @a = savereg
|
||||||
call setpos('.', pos_save)
|
call setpos('.', pos_save)
|
||||||
|
|
||||||
silent! call repeat#set("\<plug>(vl-change-cmd)" . new . '
', v:count)
|
silent! call repeat#set("\<plug>(vimtex-change-cmd)" . new . '
', v:count)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#close_environment() " {{{1
|
function! vimtex#change#close_environment() " {{{1
|
||||||
" Close delimiters
|
" Close delimiters
|
||||||
let [lnum, cnum] = searchpairpos('\C\\left\>', '', '\C\\right\>', 'bnW',
|
let [lnum, cnum] = searchpairpos('\C\\left\>', '', '\C\\right\>', 'bnW',
|
||||||
\ 'latex#util#in_comment()')
|
\ 'vimtex#util#in_comment()')
|
||||||
if lnum > 0
|
if lnum > 0
|
||||||
let line = strpart(getline(lnum), cnum - 1)
|
let line = strpart(getline(lnum), cnum - 1)
|
||||||
let bracket = matchstr(line, '^\\left\zs\((\|\[\|\\{\||\|\.\)\ze')
|
let bracket = matchstr(line, '^\\left\zs\((\|\[\|\\{\||\|\.\)\ze')
|
||||||
@ -72,7 +72,7 @@ function! latex#change#close_environment() " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Close environment
|
" Close environment
|
||||||
let env = latex#util#get_env()
|
let env = vimtex#util#get_env()
|
||||||
if env == '\['
|
if env == '\['
|
||||||
return '\]'
|
return '\]'
|
||||||
elseif env == '\('
|
elseif env == '\('
|
||||||
@ -82,8 +82,8 @@ function! latex#change#close_environment() " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#delim(open, close) " {{{1
|
function! vimtex#change#delim(open, close) " {{{1
|
||||||
let [d1, l1, c1, d2, l2, c2] = latex#util#get_delim()
|
let [d1, l1, c1, d2, l2, c2] = vimtex#util#get_delim()
|
||||||
|
|
||||||
let line = getline(l1)
|
let line = getline(l1)
|
||||||
let line = strpart(line,0,c1 - 1) . a:open . strpart(line, c1 + len(d1) - 1)
|
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)
|
call setline(l2, line)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#env(new) " {{{1
|
function! vimtex#change#env(new) " {{{1
|
||||||
let [env, l1, c1, l2, c2] = latex#util#get_env(1)
|
let [env, l1, c1, l2, c2] = vimtex#util#get_env(1)
|
||||||
|
|
||||||
if a:new == ''
|
if a:new == ''
|
||||||
let beg = ''
|
let beg = ''
|
||||||
@ -134,23 +134,23 @@ function! latex#change#env(new) " {{{1
|
|||||||
call setline(l2, line)
|
call setline(l2, line)
|
||||||
|
|
||||||
if a:new == ''
|
if a:new == ''
|
||||||
silent! call repeat#set("\<plug>(vl-delete-env)", v:count)
|
silent! call repeat#set("\<plug>(vimtex-delete-env)", v:count)
|
||||||
else
|
else
|
||||||
silent! call repeat#set("\<plug>(vl-change-env)" . a:new . "
", v:count)
|
silent! call repeat#set("\<plug>(vimtex-change-env)" . a:new . "
", v:count)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#env_prompt() " {{{1
|
function! vimtex#change#env_prompt() " {{{1
|
||||||
let new_env = input('Change ' . latex#util#get_env() . ' for: ', '',
|
let new_env = input('Change ' . vimtex#util#get_env() . ' for: ', '',
|
||||||
\ 'customlist,' . s:sidwrap('input_complete'))
|
\ 'customlist,' . s:sidwrap('input_complete'))
|
||||||
if empty(new_env)
|
if empty(new_env)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
call latex#change#env(new_env)
|
call vimtex#change#env(new_env)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#to_command() " {{{1
|
function! vimtex#change#to_command() " {{{1
|
||||||
" Get current line
|
" Get current line
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
|
|
||||||
@ -190,11 +190,11 @@ function! latex#change#to_command() " {{{1
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#toggle_delim() " {{{1
|
function! vimtex#change#toggle_delim() " {{{1
|
||||||
"
|
"
|
||||||
" Toggle \left and \right variants of delimiters
|
" 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 == ''
|
if d1 == ''
|
||||||
return 0
|
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)
|
let line = strpart(line, 0, c2 - 1) . newd2 . strpart(line, c2 + len(d2) - 1)
|
||||||
call setline(l2, line)
|
call setline(l2, line)
|
||||||
|
|
||||||
silent! call repeat#set("\<plug>(vl-toggle-delim)", v:count)
|
silent! call repeat#set("\<plug>(vimtex-toggle-delim)", v:count)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#toggle_env_star() " {{{1
|
function! vimtex#change#toggle_env_star() " {{{1
|
||||||
let env = latex#util#get_env()
|
let env = vimtex#util#get_env()
|
||||||
|
|
||||||
if env == '\('
|
if env == '\('
|
||||||
return
|
return
|
||||||
@ -240,18 +240,18 @@ function! latex#change#toggle_env_star() " {{{1
|
|||||||
let new_env = env . '*'
|
let new_env = env . '*'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call latex#change#env(new_env)
|
call vimtex#change#env(new_env)
|
||||||
|
|
||||||
silent! call repeat#set("\<plug>(vl-toggle-star)", v:count)
|
silent! call repeat#set("\<plug>(vimtex-toggle-star)", v:count)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! latex#change#wrap_selection(wrapper) " {{{1
|
function! vimtex#change#wrap_selection(wrapper) " {{{1
|
||||||
keepjumps normal! `>a}
|
keepjumps normal! `>a}
|
||||||
execute 'keepjumps normal! `<i\' . a:wrapper . '{'
|
execute 'keepjumps normal! `<i\' . a:wrapper . '{'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#change#wrap_selection_prompt(...) " {{{1
|
function! vimtex#change#wrap_selection_prompt(...) " {{{1
|
||||||
let env = input('Environment: ', '',
|
let env = input('Environment: ', '',
|
||||||
\ 'customlist,' . s:sidwrap('input_complete'))
|
\ 'customlist,' . s:sidwrap('input_complete'))
|
||||||
if empty(env)
|
if empty(env)
|
||||||
@ -287,7 +287,7 @@ let s:SID = matchstr(expand('<sfile>'), '\zs<SNR>\d\+_\ze.*$')
|
|||||||
|
|
||||||
function! s:input_complete(lead, cmdline, pos) " {{{1
|
function! s:input_complete(lead, cmdline, pos) " {{{1
|
||||||
let suggestions = []
|
let suggestions = []
|
||||||
for entry in g:latex_complete_environments
|
for entry in g:vimtex_complete_environments
|
||||||
let env = entry.word
|
let env = entry.word
|
||||||
if env =~ '^' . a:lead
|
if env =~ '^' . a:lead
|
||||||
call add(suggestions, env)
|
call add(suggestions, env)
|
||||||
@ -310,7 +310,7 @@ function! s:search_and_skip_comments(pat, ...) " {{{1
|
|||||||
let flags = substitute(flags, 'c', '', 'g')
|
let flags = substitute(flags, 'c', '', 'g')
|
||||||
|
|
||||||
" keep searching while in comment
|
" keep searching while in comment
|
||||||
while latex#util#in_comment()
|
while vimtex#util#in_comment()
|
||||||
let ret = search(a:pat, flags, stopline)
|
let ret = search(a:pat, flags, stopline)
|
||||||
if !ret
|
if !ret
|
||||||
break
|
break
|
@ -1,17 +1,17 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#complete#init(initialized) " {{{1
|
function! vimtex#complete#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_complete_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_complete_enabled', 1)
|
||||||
if !g:latex_complete_enabled | return | endif
|
if !g:vimtex_complete_enabled | return | endif
|
||||||
|
|
||||||
" Set default options
|
" Set default options
|
||||||
call latex#util#set_default('g:latex_complete_close_braces', 0)
|
call vimtex#util#set_default('g:vimtex_complete_close_braces', 0)
|
||||||
call latex#util#set_default('g:latex_complete_recursive_bib', 0)
|
call vimtex#util#set_default('g:vimtex_complete_recursive_bib', 0)
|
||||||
call latex#util#set_default('g:latex_complete_patterns',
|
call vimtex#util#set_default('g:vimtex_complete_patterns',
|
||||||
\ {
|
\ {
|
||||||
\ 'ref' : '\C\\v\?\(eq\|page\|[cC]\|labelc\)\?ref\*\?\_\s*{[^{}]*',
|
\ 'ref' : '\C\\v\?\(eq\|page\|[cC]\|labelc\)\?ref\*\?\_\s*{[^{}]*',
|
||||||
\ 'bib' : '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*',
|
\ 'bib' : '\C\\\a*cite\a*\*\?\(\[[^\]]*\]\)*\_\s*{[^{}]*',
|
||||||
@ -25,29 +25,29 @@ function! latex#complete#init(initialized) " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Check if kpsewhich is required and available
|
" 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 "Warning: bibtex completion not available"
|
||||||
echom " Missing executable: kpsewhich"
|
echom " Missing executable: kpsewhich"
|
||||||
echom " You could try to turn off recursive bib functionality"
|
echom " You could try to turn off recursive bib functionality"
|
||||||
let s:bibtex = 0
|
let s:bibtex = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
setlocal omnifunc=latex#complete#omnifunc
|
setlocal omnifunc=vimtex#complete#omnifunc
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#complete#omnifunc(findstart, base) " {{{1
|
function! vimtex#complete#omnifunc(findstart, base) " {{{1
|
||||||
if a:findstart
|
if a:findstart
|
||||||
"
|
"
|
||||||
" First call: Find start of text to be completed
|
" 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
|
" types of completion and the values are the patterns that must match for
|
||||||
" the given type. Currently, it completes labels (e.g. \ref{...), bibtex
|
" the given type. Currently, it completes labels (e.g. \ref{...), bibtex
|
||||||
" entries (e.g. \cite{...) and commands (e.g. \...).
|
" entries (e.g. \cite{...) and commands (e.g. \...).
|
||||||
"
|
"
|
||||||
let pos = col('.') - 1
|
let pos = col('.') - 1
|
||||||
let line = getline('.')[:pos-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 . '$'
|
if line =~ pattern . '$'
|
||||||
let s:completion_type = type
|
let s:completion_type = type
|
||||||
while pos > 0
|
while pos > 0
|
||||||
@ -65,9 +65,9 @@ function! latex#complete#omnifunc(findstart, base) " {{{1
|
|||||||
" Second call: Find list of matches
|
" Second call: Find list of matches
|
||||||
"
|
"
|
||||||
if s:completion_type == 'ref'
|
if s:completion_type == 'ref'
|
||||||
return latex#complete#labels(a:base)
|
return vimtex#complete#labels(a:base)
|
||||||
elseif s:completion_type == 'bib' && s:bibtex
|
elseif s:completion_type == 'bib' && s:bibtex
|
||||||
return latex#complete#bibtex(a:base)
|
return vimtex#complete#bibtex(a:base)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -76,8 +76,8 @@ endfunction
|
|||||||
let s:bibtex = 1
|
let s:bibtex = 1
|
||||||
let s:completion_type = ''
|
let s:completion_type = ''
|
||||||
|
|
||||||
function! latex#complete#labels(regex) " {{{1
|
function! vimtex#complete#labels(regex) " {{{1
|
||||||
let labels = s:labels_get(g:latex#data[b:latex.id].aux())
|
let labels = s:labels_get(g:vimtex#data[b:vimtex.id].aux())
|
||||||
let matches = filter(copy(labels), 'v:val[0] =~ ''' . a:regex . '''')
|
let matches = filter(copy(labels), 'v:val[0] =~ ''' . a:regex . '''')
|
||||||
|
|
||||||
" Try to match label and number
|
" Try to match label and number
|
||||||
@ -103,7 +103,7 @@ function! latex#complete#labels(regex) " {{{1
|
|||||||
\ 'word': m[0],
|
\ 'word': m[0],
|
||||||
\ 'menu': printf("%7s [p. %s]", '('.m[1].')', m[2])
|
\ '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 = copy(entry)
|
||||||
let entry.abbr = entry.word
|
let entry.abbr = entry.word
|
||||||
let entry.word = entry.word . '}'
|
let entry.word = entry.word . '}'
|
||||||
@ -114,7 +114,7 @@ function! latex#complete#labels(regex) " {{{1
|
|||||||
return suggestions
|
return suggestions
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#complete#bibtex(regexp) " {{{1
|
function! vimtex#complete#bibtex(regexp) " {{{1
|
||||||
let res = []
|
let res = []
|
||||||
|
|
||||||
let s:type_length = 4
|
let s:type_length = 4
|
||||||
@ -135,7 +135,7 @@ function! latex#complete#bibtex(regexp) " {{{1
|
|||||||
\ }
|
\ }
|
||||||
|
|
||||||
" Close braces if desired
|
" 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 . '}'
|
let w.word = w.word . '}'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ function! s:bibtex_search(regexp) " {{{2
|
|||||||
|
|
||||||
" The bibtex completion seems to require that we are in the project root
|
" The bibtex completion seems to require that we are in the project root
|
||||||
let l:save_pwd = getcwd()
|
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
|
" Find data from external bib files
|
||||||
let bibfiles = join(s:bibtex_find_bibs(), ',')
|
let bibfiles = join(s:bibtex_find_bibs(), ',')
|
||||||
@ -189,7 +189,7 @@ function! s:bibtex_search(regexp) " {{{2
|
|||||||
let exe = {}
|
let exe = {}
|
||||||
let exe.cmd = 'bibtex -terse ' . tmp.aux
|
let exe.cmd = 'bibtex -terse ' . tmp.aux
|
||||||
let exe.bg = 0
|
let exe.bg = 0
|
||||||
call latex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
|
|
||||||
" Parse temporary bbl file
|
" Parse temporary bbl file
|
||||||
let lines = split(substitute(join(readfile(tmp.bbl), "\n"),
|
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)
|
execute 'lcd ' . fnameescape(l:save_pwd)
|
||||||
|
|
||||||
" Find data from 'thebibliography' environments
|
" 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
|
if match(lines, '\C\\begin{thebibliography}') >= 0
|
||||||
for line in filter(filter(lines, 'v:val =~ ''\C\\bibitem'''),
|
for line in filter(filter(lines, 'v:val =~ ''\C\\bibitem'''),
|
||||||
\ 'v:val =~ a:regexp')
|
\ 'v:val =~ a:regexp')
|
||||||
@ -242,7 +242,7 @@ function! s:bibtex_find_bibs(...) " {{{2
|
|||||||
if a:0
|
if a:0
|
||||||
let file = a:1
|
let file = a:1
|
||||||
else
|
else
|
||||||
let file = g:latex#data[b:latex.id].tex
|
let file = g:vimtex#data[b:vimtex.id].tex
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !filereadable(file)
|
if !filereadable(file)
|
||||||
@ -265,11 +265,11 @@ function! s:bibtex_find_bibs(...) " {{{2
|
|||||||
"
|
"
|
||||||
" Recursively search included files
|
" Recursively search included files
|
||||||
"
|
"
|
||||||
if g:latex_complete_recursive_bib
|
if g:vimtex_complete_recursive_bib
|
||||||
for entry in map(filter(lines,
|
for entry in map(filter(lines,
|
||||||
\ 'v:val =~ ' . s:re_incsearch),
|
\ 'v:val =~ ' . s:re_incsearch),
|
||||||
\ 'matchstr(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
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -336,14 +336,14 @@ function! s:labels_extract(file) " {{{2
|
|||||||
let lines = readfile(a:file)
|
let lines = readfile(a:file)
|
||||||
let lines = filter(lines, 'v:val =~# ''\\newlabel{''')
|
let lines = filter(lines, 'v:val =~# ''\\newlabel{''')
|
||||||
let lines = filter(lines, 'v:val !~# ''@cref''')
|
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
|
for line in lines
|
||||||
let tree = latex#util#tex2tree(line)
|
let tree = vimtex#util#tex2tree(line)
|
||||||
if !empty(tree[2][0])
|
if !empty(tree[2][0])
|
||||||
call add(matches, [
|
call add(matches, [
|
||||||
\ latex#util#tree2tex(tree[1][0]),
|
\ vimtex#util#tree2tex(tree[1][0]),
|
||||||
\ latex#util#tree2tex(tree[2][0][0]),
|
\ vimtex#util#tree2tex(tree[2][0][0]),
|
||||||
\ latex#util#tree2tex(tree[2][1][0]),
|
\ vimtex#util#tree2tex(tree[2][1][0]),
|
||||||
\ ])
|
\ ])
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
@ -1,18 +1,18 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#fold#init(initialized) " {{{1
|
function! vimtex#fold#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_fold_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_fold_enabled', 1)
|
||||||
if !g:latex_fold_enabled | return | endif
|
if !g:vimtex_fold_enabled | return | endif
|
||||||
|
|
||||||
" Set default options
|
" Set default options
|
||||||
call latex#util#set_default('g:latex_fold_automatic', 1)
|
call vimtex#util#set_default('g:vimtex_fold_automatic', 1)
|
||||||
call latex#util#set_default('g:latex_fold_preamble', 1)
|
call vimtex#util#set_default('g:vimtex_fold_preamble', 1)
|
||||||
call latex#util#set_default('g:latex_fold_envs', 1)
|
call vimtex#util#set_default('g:vimtex_fold_envs', 1)
|
||||||
call latex#util#set_default('g:latex_fold_parts',
|
call vimtex#util#set_default('g:vimtex_fold_parts',
|
||||||
\ [
|
\ [
|
||||||
\ "part",
|
\ "part",
|
||||||
\ "appendix",
|
\ "appendix",
|
||||||
@ -20,7 +20,7 @@ function! latex#fold#init(initialized) " {{{1
|
|||||||
\ "mainmatter",
|
\ "mainmatter",
|
||||||
\ "backmatter",
|
\ "backmatter",
|
||||||
\ ])
|
\ ])
|
||||||
call latex#util#set_default('g:latex_fold_sections',
|
call vimtex#util#set_default('g:vimtex_fold_sections',
|
||||||
\ [
|
\ [
|
||||||
\ "chapter",
|
\ "chapter",
|
||||||
\ "section",
|
\ "section",
|
||||||
@ -29,26 +29,26 @@ function! latex#fold#init(initialized) " {{{1
|
|||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
" Define some script variables
|
" Define some script variables
|
||||||
let s:parts = '\v^\s*(\\|\% Fake)(' . join(g:latex_fold_parts, '|') . ')>'
|
let s:parts = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_parts, '|') . ')>'
|
||||||
let s:secs = '\v^\s*(\\|\% Fake)(' . join(g:latex_fold_sections, '|') . ')>'
|
let s:secs = '\v^\s*(\\|\% Fake)(' . join(g:vimtex_fold_sections, '|') . ')>'
|
||||||
|
|
||||||
" Set fold options
|
" Set fold options
|
||||||
setl foldmethod=expr
|
setl foldmethod=expr
|
||||||
setl foldexpr=latex#fold#level(v:lnum)
|
setl foldexpr=vimtex#fold#level(v:lnum)
|
||||||
setl foldtext=latex#fold#text()
|
setl foldtext=vimtex#fold#text()
|
||||||
|
|
||||||
" Initalize folds
|
" Initalize folds
|
||||||
call latex#fold#refresh('zX')
|
call vimtex#fold#refresh('zX')
|
||||||
|
|
||||||
" Remap zx to refresh fold levels
|
" Remap zx to refresh fold levels
|
||||||
nnoremap <silent><buffer> zx :call latex#fold#refresh('zx')<cr>
|
nnoremap <silent><buffer> zx :call vimtex#fold#refresh('zx')<cr>
|
||||||
nnoremap <silent><buffer> zX :call latex#fold#refresh('zX')<cr>
|
nnoremap <silent><buffer> zX :call vimtex#fold#refresh('zX')<cr>
|
||||||
|
|
||||||
" Define commands
|
" Define commands
|
||||||
command! -buffer VimLatexRefreshFolds call latex#fold#refresh('zx')
|
command! -buffer VimtexRefreshFolds call vimtex#fold#refresh('zx')
|
||||||
|
|
||||||
" Set options for automatic/manual mode
|
" 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)
|
" For some reason, foldmethod=expr makes undo slow (at least in some cases)
|
||||||
nnoremap <silent><buffer> u :call FdmSave()<cr>u:call FdmRestore()<cr>
|
nnoremap <silent><buffer> u :call FdmSave()<cr>u:call FdmRestore()<cr>
|
||||||
|
|
||||||
@ -68,12 +68,12 @@ function! latex#fold#init(initialized) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#fold#refresh(map) " {{{1
|
function! vimtex#fold#refresh(map) " {{{1
|
||||||
" Parse tex file to dynamically set the sectioning fold levels
|
" 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
|
" Refresh folds
|
||||||
if g:latex_fold_automatic
|
if g:vimtex_fold_automatic
|
||||||
execute 'normal! ' . a:map
|
execute 'normal! ' . a:map
|
||||||
else
|
else
|
||||||
setl foldmethod=expr
|
setl foldmethod=expr
|
||||||
@ -82,7 +82,7 @@ function! latex#fold#refresh(map) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#fold#level(lnum) " {{{1
|
function! vimtex#fold#level(lnum) " {{{1
|
||||||
" Check for normal lines first (optimization)
|
" Check for normal lines first (optimization)
|
||||||
let line = getline(a:lnum)
|
let line = getline(a:lnum)
|
||||||
if line !~ '\(% Fake\|\\\(document\|begin\|end\|'
|
if line !~ '\(% Fake\|\\\(document\|begin\|end\|'
|
||||||
@ -91,7 +91,7 @@ function! latex#fold#level(lnum) " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Fold preamble
|
" Fold preamble
|
||||||
if g:latex_fold_preamble
|
if g:vimtex_fold_preamble
|
||||||
if line =~# '^\s*\\documentclass'
|
if line =~# '^\s*\\documentclass'
|
||||||
return ">1"
|
return ">1"
|
||||||
elseif line =~# '^\s*\\begin\s*{\s*document\s*}'
|
elseif line =~# '^\s*\\begin\s*{\s*document\s*}'
|
||||||
@ -100,7 +100,7 @@ function! latex#fold#level(lnum) " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Fold chapters and sections
|
" Fold chapters and sections
|
||||||
for [part, level] in b:latex.fold_parts
|
for [part, level] in b:vimtex.fold_parts
|
||||||
if line =~# part
|
if line =~# part
|
||||||
return ">" . level
|
return ">" . level
|
||||||
endif
|
endif
|
||||||
@ -112,7 +112,7 @@ function! latex#fold#level(lnum) " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Fold environments
|
" Fold environments
|
||||||
if g:latex_fold_envs
|
if g:vimtex_fold_envs
|
||||||
if line =~# s:notcomment . s:notbslash . '\\begin\s*{.\{-}}'
|
if line =~# s:notcomment . s:notbslash . '\\begin\s*{.\{-}}'
|
||||||
if line !~# '\\end'
|
if line !~# '\\end'
|
||||||
return "a1"
|
return "a1"
|
||||||
@ -128,7 +128,7 @@ function! latex#fold#level(lnum) " {{{1
|
|||||||
return "="
|
return "="
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#fold#text() " {{{1
|
function! vimtex#fold#text() " {{{1
|
||||||
" Initialize
|
" Initialize
|
||||||
let line = getline(v:foldstart)
|
let line = getline(v:foldstart)
|
||||||
let level = v:foldlevel > 1 ? repeat('-', v:foldlevel-2) . '*' : ''
|
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)
|
" Parse part commands (frontmatter, appendix, part, etc)
|
||||||
let lines = filter(copy(buffer), 'v:val =~ ''' . s:parts . '''')
|
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 . '\>'
|
let partpattern = '^\s*\(\\\|% Fake\)' . part . '\>'
|
||||||
for line in lines
|
for line in lines
|
||||||
if line =~# partpattern
|
if line =~# partpattern
|
||||||
@ -256,7 +256,7 @@ function! s:parse_folded() " {{{1
|
|||||||
|
|
||||||
" Parse section commands (chapter, [sub...]section)
|
" Parse section commands (chapter, [sub...]section)
|
||||||
let lines = filter(copy(buffer), 'v:val =~ ''' . s:secs . '''')
|
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 . '\>'
|
let partpattern = '^\s*\(\\\|% Fake\)' . part . '\>'
|
||||||
for line in lines
|
for line in lines
|
||||||
if line =~# partpattern
|
if line =~# partpattern
|
@ -1,14 +1,14 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#labels#init(initialized) " {{{1
|
function! vimtex#labels#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_labels_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_labels_enabled', 1)
|
||||||
if !g:latex_labels_enabled | return | endif
|
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
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
@ -1,68 +1,68 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#latexmk#init(initialized) " {{{1
|
function! vimtex#latexmk#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_latexmk_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_latexmk_enabled', 1)
|
||||||
if !g:latex_latexmk_enabled | return | endif
|
if !g:vimtex_latexmk_enabled | return | endif
|
||||||
if s:system_incompatible() | return | endif
|
if s:system_incompatible() | return | endif
|
||||||
|
|
||||||
" Set default options
|
" Set default options
|
||||||
call latex#util#set_default('g:latex_latexmk_background', 0)
|
call vimtex#util#set_default('g:vimtex_latexmk_background', 0)
|
||||||
call latex#util#set_default('g:latex_latexmk_build_dir', '.')
|
call vimtex#util#set_default('g:vimtex_latexmk_build_dir', '.')
|
||||||
call latex#util#set_default('g:latex_latexmk_callback', 1)
|
call vimtex#util#set_default('g:vimtex_latexmk_callback', 1)
|
||||||
call latex#util#set_default('g:latex_latexmk_continuous', 1)
|
call vimtex#util#set_default('g:vimtex_latexmk_continuous', 1)
|
||||||
call latex#util#set_default('g:latex_latexmk_options', '-pdf')
|
call vimtex#util#set_default('g:vimtex_latexmk_options', '-pdf')
|
||||||
call latex#util#set_default('g:latex_quickfix_autojump', '0')
|
call vimtex#util#set_default('g:vimtex_quickfix_autojump', '0')
|
||||||
call latex#util#set_default('g:latex_quickfix_mode', '2')
|
call vimtex#util#set_default('g:vimtex_quickfix_mode', '2')
|
||||||
call latex#util#set_default('g:latex_quickfix_open_on_warning', '1')
|
call vimtex#util#set_default('g:vimtex_quickfix_open_on_warning', '1')
|
||||||
call latex#util#error_deprecated('g:latex_build_dir')
|
call vimtex#util#error_deprecated('g:vimtex_build_dir')
|
||||||
call latex#util#error_deprecated('g:latex_latexmk_autojump')
|
call vimtex#util#error_deprecated('g:vimtex_latexmk_autojump')
|
||||||
call latex#util#error_deprecated('g:latex_latexmk_output')
|
call vimtex#util#error_deprecated('g:vimtex_latexmk_output')
|
||||||
call latex#util#error_deprecated('g:latex_latexmk_quickfix')
|
call vimtex#util#error_deprecated('g:vimtex_latexmk_quickfix')
|
||||||
|
|
||||||
" Set compiler (this defines the errorformat)
|
" Set compiler (this defines the errorformat)
|
||||||
compiler latexmk
|
compiler latexmk
|
||||||
|
|
||||||
let g:latex#data[b:latex.id].pid = 0
|
let g:vimtex#data[b:vimtex.id].pid = 0
|
||||||
|
|
||||||
" Define commands
|
" Define commands
|
||||||
command! -buffer VimLatexCompile call latex#latexmk#compile()
|
command! -buffer VimtexCompile call vimtex#latexmk#compile()
|
||||||
command! -buffer -bang VimLatexCompileSS call latex#latexmk#compile_ss(<q-bang> == "!")
|
command! -buffer -bang VimtexCompileSS call vimtex#latexmk#compile_ss(<q-bang> == "!")
|
||||||
command! -buffer VimLatexCompileToggle call latex#latexmk#toggle()
|
command! -buffer VimtexCompileToggle call vimtex#latexmk#toggle()
|
||||||
command! -buffer VimLatexCompileOutput call latex#latexmk#output()
|
command! -buffer VimtexCompileOutput call vimtex#latexmk#output()
|
||||||
command! -buffer VimLatexStop call latex#latexmk#stop()
|
command! -buffer VimtexStop call vimtex#latexmk#stop()
|
||||||
command! -buffer VimLatexStopAll call latex#latexmk#stop_all()
|
command! -buffer VimtexStopAll call vimtex#latexmk#stop_all()
|
||||||
command! -buffer -bang VimLatexErrors call latex#latexmk#errors(<q-bang> == "!")
|
command! -buffer -bang VimtexErrors call vimtex#latexmk#errors(<q-bang> == "!")
|
||||||
command! -buffer -bang VimLatexClean call latex#latexmk#clean(<q-bang> == "!")
|
command! -buffer -bang VimtexClean call vimtex#latexmk#clean(<q-bang> == "!")
|
||||||
command! -buffer -bang VimLatexStatus call latex#latexmk#status(<q-bang> == "!")
|
command! -buffer -bang VimtexStatus call vimtex#latexmk#status(<q-bang> == "!")
|
||||||
command! -buffer VimLatexLacheck call latex#latexmk#lacheck()
|
command! -buffer VimtexLacheck call vimtex#latexmk#lacheck()
|
||||||
|
|
||||||
" Define mappings
|
" Define mappings
|
||||||
nnoremap <buffer> <plug>(vl-compile) :call latex#latexmk#compile()<cr>
|
nnoremap <buffer> <plug>(vimtex-compile) :call vimtex#latexmk#compile()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-compile-ss) :call latex#latexmk#compile_ss(0)<cr>
|
nnoremap <buffer> <plug>(vimtex-compile-ss) :call vimtex#latexmk#compile_ss(0)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-compile-toggle) :call latex#latexmk#toggle()<cr>
|
nnoremap <buffer> <plug>(vimtex-compile-toggle) :call vimtex#latexmk#toggle()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-compile-output) :call latex#latexmk#output()<cr>
|
nnoremap <buffer> <plug>(vimtex-compile-output) :call vimtex#latexmk#output()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-stop) :call latex#latexmk#stop()<cr>
|
nnoremap <buffer> <plug>(vimtex-stop) :call vimtex#latexmk#stop()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-stop-all) :call latex#latexmk#stop_all()<cr>
|
nnoremap <buffer> <plug>(vimtex-stop-all) :call vimtex#latexmk#stop_all()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-errors) :call latex#latexmk#errors(1)<cr>
|
nnoremap <buffer> <plug>(vimtex-errors) :call vimtex#latexmk#errors(1)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-clean) :call latex#latexmk#clean(0)<cr>
|
nnoremap <buffer> <plug>(vimtex-clean) :call vimtex#latexmk#clean(0)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-clean-full) :call latex#latexmk#clean(1)<cr>
|
nnoremap <buffer> <plug>(vimtex-clean-full) :call vimtex#latexmk#clean(1)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-status) :call latex#latexmk#status(0)<cr>
|
nnoremap <buffer> <plug>(vimtex-status) :call vimtex#latexmk#status(0)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-status-all) :call latex#latexmk#status(1)<cr>
|
nnoremap <buffer> <plug>(vimtex-status-all) :call vimtex#latexmk#status(1)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-lacheck) :call latex#latexmk#lacheck()<cr>
|
nnoremap <buffer> <plug>(vimtex-lacheck) :call vimtex#latexmk#lacheck()<cr>
|
||||||
|
|
||||||
" The remaining part is only relevant for continuous mode
|
" 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
|
" Ensure that all latexmk processes are stopped when vim exits
|
||||||
" Note: Only need to define this once, globally.
|
" Note: Only need to define this once, globally.
|
||||||
if !a:initialized
|
if !a:initialized
|
||||||
augroup latex_latexmk
|
augroup latex_latexmk
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd VimLeave * call latex#latexmk#stop_all()
|
autocmd VimLeave * call vimtex#latexmk#stop_all()
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ function! latex#latexmk#init(initialized) " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#callback(status) " {{{1
|
function! vimtex#latexmk#callback(status) " {{{1
|
||||||
call latex#latexmk#errors(0)
|
call vimtex#latexmk#errors(0)
|
||||||
redraw!
|
redraw!
|
||||||
|
|
||||||
echohl ModeMsg
|
echohl ModeMsg
|
||||||
@ -90,16 +90,16 @@ function! latex#latexmk#callback(status) " {{{1
|
|||||||
endif
|
endif
|
||||||
echohl None
|
echohl None
|
||||||
|
|
||||||
if has_key(g:latex#data[b:latex.id].viewer, 'latexmk_callback')
|
if has_key(g:vimtex#data[b:vimtex.id].viewer, 'latexmk_callback')
|
||||||
call g:latex#data[b:latex.id].viewer.latexmk_callback()
|
call g:vimtex#data[b:vimtex.id].viewer.latexmk_callback()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#clean(full) " {{{1
|
function! vimtex#latexmk#clean(full) " {{{1
|
||||||
let data = g:latex#data[b:latex.id]
|
let data = g:vimtex#data[b:vimtex.id]
|
||||||
if data.pid
|
if data.pid
|
||||||
echomsg "latexmk is already running"
|
echomsg "latexmk is already running"
|
||||||
return
|
return
|
||||||
@ -113,15 +113,15 @@ function! latex#latexmk#clean(full) " {{{1
|
|||||||
else
|
else
|
||||||
let cmd = 'cd ' . shellescape(data.root) . '; '
|
let cmd = 'cd ' . shellescape(data.root) . '; '
|
||||||
endif
|
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 .= a:full ? ' -C ' : ' -c'
|
||||||
let cmd .= latex#util#fnameescape(data.base)
|
let cmd .= vimtex#util#fnameescape(data.base)
|
||||||
let exe = {
|
let exe = {
|
||||||
\ 'cmd' : cmd,
|
\ 'cmd' : cmd,
|
||||||
\ 'bg' : 0,
|
\ 'bg' : 0,
|
||||||
\ }
|
\ }
|
||||||
call latex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
let g:latex#data[b:latex.id].cmd_latexmk_clean = cmd
|
let g:vimtex#data[b:vimtex.id].cmd_latexmk_clean = cmd
|
||||||
|
|
||||||
if a:full
|
if a:full
|
||||||
echomsg "latexmk full clean finished"
|
echomsg "latexmk full clean finished"
|
||||||
@ -131,7 +131,7 @@ function! latex#latexmk#clean(full) " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#lacheck() " {{{1
|
function! vimtex#latexmk#lacheck() " {{{1
|
||||||
compiler lacheck
|
compiler lacheck
|
||||||
|
|
||||||
silent lmake %
|
silent lmake %
|
||||||
@ -143,19 +143,19 @@ function! latex#latexmk#lacheck() " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#toggle() " {{{1
|
function! vimtex#latexmk#toggle() " {{{1
|
||||||
let data = g:latex#data[b:latex.id]
|
let data = g:vimtex#data[b:vimtex.id]
|
||||||
|
|
||||||
if data.pid
|
if data.pid
|
||||||
call latex#latexmk#stop()
|
call vimtex#latexmk#stop()
|
||||||
else
|
else
|
||||||
call latex#latexmk#compile()
|
call vimtex#latexmk#compile()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#compile() " {{{1
|
function! vimtex#latexmk#compile() " {{{1
|
||||||
let data = g:latex#data[b:latex.id]
|
let data = g:vimtex#data[b:vimtex.id]
|
||||||
if data.pid
|
if data.pid
|
||||||
echomsg "latexmk is already running for `" . data.base . "'"
|
echomsg "latexmk is already running for `" . data.base . "'"
|
||||||
return
|
return
|
||||||
@ -163,13 +163,13 @@ function! latex#latexmk#compile() " {{{1
|
|||||||
|
|
||||||
" Build command line and start latexmk
|
" Build command line and start latexmk
|
||||||
let exe = s:latexmk_build_cmd(data)
|
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.bg = 0
|
||||||
let exe.silent = 0
|
let exe.silent = 0
|
||||||
endif
|
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)
|
call s:latexmk_set_pid(data)
|
||||||
|
|
||||||
echomsg 'latexmk started in continuous mode ...'
|
echomsg 'latexmk started in continuous mode ...'
|
||||||
@ -179,29 +179,29 @@ function! latex#latexmk#compile() " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#compile_ss(verbose) " {{{1
|
function! vimtex#latexmk#compile_ss(verbose) " {{{1
|
||||||
let data = g:latex#data[b:latex.id]
|
let data = g:vimtex#data[b:vimtex.id]
|
||||||
if data.pid
|
if data.pid
|
||||||
echomsg "latexmk is already running for `" . data.base . "'"
|
echomsg "latexmk is already running for `" . data.base . "'"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:latex_latexmk_continuous = g:latex_latexmk_continuous
|
let l:vimtex_latexmk_continuous = g:vimtex_latexmk_continuous
|
||||||
let g:latex_latexmk_continuous = 0
|
let g:vimtex_latexmk_continuous = 0
|
||||||
let exe = s:latexmk_build_cmd(data)
|
let exe = s:latexmk_build_cmd(data)
|
||||||
if a:verbose
|
if a:verbose
|
||||||
let exe.bg = 0
|
let exe.bg = 0
|
||||||
let exe.silent = 0
|
let exe.silent = 0
|
||||||
endif
|
endif
|
||||||
call latex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
let g:latex_latexmk_continuous = l:latex_latexmk_continuous
|
let g:vimtex_latexmk_continuous = l:vimtex_latexmk_continuous
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#errors(force) " {{{1
|
function! vimtex#latexmk#errors(force) " {{{1
|
||||||
cclose
|
cclose
|
||||||
|
|
||||||
let log = g:latex#data[b:latex.id].log()
|
let log = g:vimtex#data[b:vimtex.id].log()
|
||||||
if empty(log)
|
if empty(log)
|
||||||
if a:force
|
if a:force
|
||||||
echo "No log file found!"
|
echo "No log file found!"
|
||||||
@ -209,7 +209,7 @@ function! latex#latexmk#errors(force) " {{{1
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:latex_quickfix_autojump
|
if g:vimtex_quickfix_autojump
|
||||||
execute 'cfile ' . fnameescape(log)
|
execute 'cfile ' . fnameescape(log)
|
||||||
else
|
else
|
||||||
execute 'cgetfile ' . fnameescape(log)
|
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.
|
" normal mode mapping). Else the behaviour is based on the settings.
|
||||||
"
|
"
|
||||||
let open_quickfix_window = a:force
|
let open_quickfix_window = a:force
|
||||||
\ || (g:latex_quickfix_mode > 0
|
\ || (g:vimtex_quickfix_mode > 0
|
||||||
\ && (g:latex_quickfix_open_on_warning
|
\ && (g:vimtex_quickfix_open_on_warning
|
||||||
\ || s:log_contains_error(log)))
|
\ || s:log_contains_error(log)))
|
||||||
|
|
||||||
if open_quickfix_window
|
if open_quickfix_window
|
||||||
botright cwindow
|
botright cwindow
|
||||||
if g:latex_quickfix_mode == 2
|
if g:vimtex_quickfix_mode == 2
|
||||||
wincmd p
|
wincmd p
|
||||||
endif
|
endif
|
||||||
redraw!
|
redraw!
|
||||||
@ -236,11 +236,11 @@ function! latex#latexmk#errors(force) " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#output() " {{{1
|
function! vimtex#latexmk#output() " {{{1
|
||||||
if has_key(g:latex#data[b:latex.id], 'tmp')
|
if has_key(g:vimtex#data[b:vimtex.id], 'tmp')
|
||||||
let tmp = g:latex#data[b:latex.id].tmp
|
let tmp = g:vimtex#data[b:vimtex.id].tmp
|
||||||
else
|
else
|
||||||
echo "vim-latex: No output exists"
|
echo "vimtex: No output exists"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -270,10 +270,10 @@ function! latex#latexmk#output() " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#status(detailed) " {{{1
|
function! vimtex#latexmk#status(detailed) " {{{1
|
||||||
if a:detailed
|
if a:detailed
|
||||||
let running = 0
|
let running = 0
|
||||||
for data in g:latex#data
|
for data in g:vimtex#data
|
||||||
if data.pid
|
if data.pid
|
||||||
if !running
|
if !running
|
||||||
echo "latexmk is running"
|
echo "latexmk is running"
|
||||||
@ -293,7 +293,7 @@ function! latex#latexmk#status(detailed) " {{{1
|
|||||||
echo "latexmk is not running"
|
echo "latexmk is not running"
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if g:latex#data[b:latex.id].pid
|
if g:vimtex#data[b:vimtex.id].pid
|
||||||
echo "latexmk is running"
|
echo "latexmk is running"
|
||||||
else
|
else
|
||||||
echo "latexmk is not running"
|
echo "latexmk is not running"
|
||||||
@ -302,12 +302,12 @@ function! latex#latexmk#status(detailed) " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#stop() " {{{1
|
function! vimtex#latexmk#stop() " {{{1
|
||||||
let pid = g:latex#data[b:latex.id].pid
|
let pid = g:vimtex#data[b:vimtex.id].pid
|
||||||
let base = g:latex#data[b:latex.id].base
|
let base = g:vimtex#data[b:vimtex.id].base
|
||||||
if pid
|
if pid
|
||||||
call s:latexmk_kill_pid(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 . "'"
|
echo "latexmk stopped for `" . base . "'"
|
||||||
else
|
else
|
||||||
echo "latexmk is not running for `" . base . "'"
|
echo "latexmk is not running for `" . base . "'"
|
||||||
@ -315,8 +315,8 @@ function! latex#latexmk#stop() " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#stop_all() " {{{1
|
function! vimtex#latexmk#stop_all() " {{{1
|
||||||
for data in g:latex#data
|
for data in g:vimtex#data
|
||||||
if data.pid
|
if data.pid
|
||||||
call s:latexmk_kill_pid(data.pid)
|
call s:latexmk_kill_pid(data.pid)
|
||||||
let data.pid = 0
|
let data.pid = 0
|
||||||
@ -327,7 +327,7 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
" Helper function(s) for building the latexmk command
|
" 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')
|
if has('win32')
|
||||||
return ' -e "$' . a:name . ' = ''' . a:value . '''"'
|
return ' -e "$' . a:name . ' = ''' . a:value . '''"'
|
||||||
else
|
else
|
||||||
@ -354,33 +354,33 @@ function! s:latexmk_build_cmd(data) " {{{1
|
|||||||
let cmd .= ' && max_print_line=2000 latexmk'
|
let cmd .= ' && max_print_line=2000 latexmk'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let cmd .= ' ' . g:latex_latexmk_options
|
let cmd .= ' ' . g:vimtex_latexmk_options
|
||||||
let cmd .= ' -e ' . shellescape('$pdflatex =~ s/ / -file-line-error /')
|
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'
|
let cmd .= ' -pvc'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:latex_latexmk_callback && has('clientserver')
|
if g:vimtex_latexmk_callback && has('clientserver')
|
||||||
let success = v:progname
|
let success = v:progname
|
||||||
let success .= ' --servername ' . v:servername
|
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 = v:progname
|
||||||
let failed .= ' --servername ' . v:servername
|
let failed .= ' --servername ' . v:servername
|
||||||
let failed .= ' --remote-expr \"latex\#latexmk\#callback(0)\"'
|
let failed .= ' --remote-expr \"vimtex\#latexmk\#callback(0)\"'
|
||||||
let cmd .= latex#latexmk#add_option('success_cmd', success)
|
let cmd .= vimtex#latexmk#add_option('success_cmd', success)
|
||||||
let cmd .= latex#latexmk#add_option('failure_cmd', failed)
|
let cmd .= vimtex#latexmk#add_option('failure_cmd', failed)
|
||||||
let s:first_callback = 1
|
let s:first_callback = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_key(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:latex#data[b:latex.id].viewer.latexmk_append_argument()
|
let cmd .= g:vimtex#data[b:vimtex.id].viewer.latexmk_append_argument()
|
||||||
endif
|
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')
|
if has('win32')
|
||||||
let cmd .= ' >' . tmp
|
let cmd .= ' >' . tmp
|
||||||
let cmd = 'cmd /s /c "' . cmd . '"'
|
let cmd = 'cmd /s /c "' . cmd . '"'
|
||||||
@ -418,7 +418,7 @@ function! s:latexmk_kill_pid(pid) " {{{1
|
|||||||
let exe.cmd = 'kill ' . a:pid
|
let exe.cmd = 'kill ' . a:pid
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call latex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
@ -436,9 +436,9 @@ function! s:stop_buffer() " {{{1
|
|||||||
"
|
"
|
||||||
" Only run if latex variables are set
|
" Only run if latex variables are set
|
||||||
"
|
"
|
||||||
if !exists('b:latex') | return | endif
|
if !exists('b:vimtex') | return | endif
|
||||||
let id = b:latex.id
|
let id = b:vimtex.id
|
||||||
let pid = g:latex#data[id].pid
|
let pid = g:vimtex#data[id].pid
|
||||||
|
|
||||||
"
|
"
|
||||||
" Only stop if latexmk is running
|
" Only stop if latexmk is running
|
||||||
@ -449,7 +449,7 @@ function! s:stop_buffer() " {{{1
|
|||||||
"
|
"
|
||||||
let n = 0
|
let n = 0
|
||||||
for b in filter(range(1, bufnr("$")), 'buflisted(v:val)')
|
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
|
let n += 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -458,7 +458,7 @@ function! s:stop_buffer() " {{{1
|
|||||||
" Only stop if current buffer is the last for current latex blob
|
" Only stop if current buffer is the last for current latex blob
|
||||||
"
|
"
|
||||||
if n == 1
|
if n == 1
|
||||||
silent call latex#latexmk#stop()
|
silent call vimtex#latexmk#stop()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -475,7 +475,7 @@ function! s:system_incompatible() " {{{1
|
|||||||
"
|
"
|
||||||
for cmd in required
|
for cmd in required
|
||||||
if !executable(cmd)
|
if !executable(cmd)
|
||||||
echom "Warning: Could not initialize latex#latexmk"
|
echom "Warning: Could not initialize vimtex#latexmk"
|
||||||
echom " Missing executable: " . cmd
|
echom " Missing executable: " . cmd
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
80
autoload/vimtex/mappings.vim
Normal file
80
autoload/vimtex/mappings.vim
Normal file
@ -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 <silent><buffer> <localleader>li <plug>(vimtex-info)
|
||||||
|
nmap <silent><buffer> <localleader>lh <plug>(vimtex-help)
|
||||||
|
nmap <silent><buffer> <localleader>lR <plug>(vimtex-reinit)
|
||||||
|
|
||||||
|
nmap <silent><buffer> dse <plug>(vimtex-delete-env)
|
||||||
|
nmap <silent><buffer> dsc <plug>(vimtex-delete-cmd)
|
||||||
|
nmap <silent><buffer> cse <plug>(vimtex-change-env)
|
||||||
|
nmap <silent><buffer> csc <plug>(vimtex-change-cmd)
|
||||||
|
nmap <silent><buffer> tse <plug>(vimtex-toggle-star)
|
||||||
|
nmap <silent><buffer> tsd <plug>(vimtex-toggle-delim)
|
||||||
|
nmap <silent><buffer> <F7> <plug>(vimtex-create-cmd)
|
||||||
|
imap <silent><buffer> <F7> <plug>(vimtex-create-cmd)
|
||||||
|
imap <silent><buffer> ]] <plug>(vimtex-close-env)
|
||||||
|
|
||||||
|
if g:vimtex_latexmk_enabled
|
||||||
|
nmap <silent><buffer> <localleader>ll <plug>(vimtex-compile-toggle)
|
||||||
|
nmap <silent><buffer> <localleader>lo <plug>(vimtex-compile-output)
|
||||||
|
nmap <silent><buffer> <localleader>lk <plug>(vimtex-stop)
|
||||||
|
nmap <silent><buffer> <localleader>lK <plug>(vimtex-stop-all)
|
||||||
|
nmap <silent><buffer> <localleader>le <plug>(vimtex-errors)
|
||||||
|
nmap <silent><buffer> <localleader>lc <plug>(vimtex-clean)
|
||||||
|
nmap <silent><buffer> <localleader>lC <plug>(vimtex-clean-full)
|
||||||
|
nmap <silent><buffer> <localleader>lg <plug>(vimtex-status)
|
||||||
|
nmap <silent><buffer> <localleader>lG <plug>(vimtex-status-all)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if g:vimtex_motion_enabled
|
||||||
|
nmap <silent><buffer> % <plug>(vimtex-%)
|
||||||
|
xmap <silent><buffer> % <plug>(vimtex-%)
|
||||||
|
omap <silent><buffer> % <plug>(vimtex-%)
|
||||||
|
nmap <silent><buffer> ]] <plug>(vimtex-]])
|
||||||
|
nmap <silent><buffer> ][ <plug>(vimtex-][)
|
||||||
|
nmap <silent><buffer> [] <plug>(vimtex-[])
|
||||||
|
nmap <silent><buffer> [[ <plug>(vimtex-[[)
|
||||||
|
xmap <silent><buffer> ]] <plug>(vimtex-]])
|
||||||
|
xmap <silent><buffer> ][ <plug>(vimtex-][)
|
||||||
|
xmap <silent><buffer> [] <plug>(vimtex-[])
|
||||||
|
xmap <silent><buffer> [[ <plug>(vimtex-[[)
|
||||||
|
omap <silent><buffer> ]] <plug>(vimtex-]])
|
||||||
|
omap <silent><buffer> ][ <plug>(vimtex-][)
|
||||||
|
omap <silent><buffer> [] <plug>(vimtex-[])
|
||||||
|
omap <silent><buffer> [[ <plug>(vimtex-[[)
|
||||||
|
xmap <silent><buffer> ie <plug>(vimtex-ie)
|
||||||
|
xmap <silent><buffer> ae <plug>(vimtex-ae)
|
||||||
|
omap <silent><buffer> ie <plug>(vimtex-ie)
|
||||||
|
omap <silent><buffer> ae <plug>(vimtex-ae)
|
||||||
|
xmap <silent><buffer> i$ <plug>(vimtex-i$)
|
||||||
|
xmap <silent><buffer> a$ <plug>(vimtex-a$)
|
||||||
|
omap <silent><buffer> i$ <plug>(vimtex-i$)
|
||||||
|
omap <silent><buffer> a$ <plug>(vimtex-a$)
|
||||||
|
xmap <silent><buffer> id <plug>(vimtex-id)
|
||||||
|
xmap <silent><buffer> ad <plug>(vimtex-ad)
|
||||||
|
omap <silent><buffer> id <plug>(vimtex-id)
|
||||||
|
omap <silent><buffer> ad <plug>(vimtex-ad)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if g:vimtex_toc_enabled
|
||||||
|
nmap <silent><buffer> <localleader>lt <plug>(vimtex-toc-open)
|
||||||
|
nmap <silent><buffer> <localleader>lT <plug>(vimtex-toc-toggle)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if g:vimtex_view_enabled
|
||||||
|
nmap <silent><buffer> <localleader>lv <plug>(vimtex-view)
|
||||||
|
if has_key(g:vimtex#data[b:vimtex.id], 'rsearch')
|
||||||
|
nmap <silent><buffer> <localleader>lr <plug>(vimtex-reverse-search)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" vim: fdm=marker sw=2
|
@ -1,47 +1,47 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#motion#init(initialized) " {{{1
|
function! vimtex#motion#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_motion_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_motion_enabled', 1)
|
||||||
if !g:latex_motion_enabled | return | endif
|
if !g:vimtex_motion_enabled | return | endif
|
||||||
|
|
||||||
" Set default options
|
" 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
|
" Define mappings
|
||||||
nnoremap <buffer> <plug>(vl-%) :call latex#motion#find_matching_pair()<cr>
|
nnoremap <buffer> <plug>(vimtex-%) :call vimtex#motion#find_matching_pair()<cr>
|
||||||
xnoremap <buffer> <plug>(vl-%) :<c-u>call latex#motion#find_matching_pair(1)<cr>
|
xnoremap <buffer> <plug>(vimtex-%) :<c-u>call vimtex#motion#find_matching_pair(1)<cr>
|
||||||
onoremap <buffer> <plug>(vl-%) :normal v%<cr>
|
onoremap <buffer> <plug>(vimtex-%) :normal v%<cr>
|
||||||
nnoremap <buffer> <plug>(vl-]]) :call latex#motion#next_section(0,0,0)<cr>
|
nnoremap <buffer> <plug>(vimtex-]]) :call vimtex#motion#next_section(0,0,0)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-][) :call latex#motion#next_section(1,0,0)<cr>
|
nnoremap <buffer> <plug>(vimtex-][) :call vimtex#motion#next_section(1,0,0)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-[]) :call latex#motion#next_section(1,1,0)<cr>
|
nnoremap <buffer> <plug>(vimtex-[]) :call vimtex#motion#next_section(1,1,0)<cr>
|
||||||
nnoremap <buffer> <plug>(vl-[[) :call latex#motion#next_section(0,1,0)<cr>
|
nnoremap <buffer> <plug>(vimtex-[[) :call vimtex#motion#next_section(0,1,0)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-]]) :<c-u>call latex#motion#next_section(0,0,1)<cr>
|
xnoremap <buffer> <plug>(vimtex-]]) :<c-u>call vimtex#motion#next_section(0,0,1)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-][) :<c-u>call latex#motion#next_section(1,0,1)<cr>
|
xnoremap <buffer> <plug>(vimtex-][) :<c-u>call vimtex#motion#next_section(1,0,1)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-[]) :<c-u>call latex#motion#next_section(1,1,1)<cr>
|
xnoremap <buffer> <plug>(vimtex-[]) :<c-u>call vimtex#motion#next_section(1,1,1)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-[[) :<c-u>call latex#motion#next_section(0,1,1)<cr>
|
xnoremap <buffer> <plug>(vimtex-[[) :<c-u>call vimtex#motion#next_section(0,1,1)<cr>
|
||||||
onoremap <buffer> <plug>(vl-]]) :normal v]]<cr>
|
onoremap <buffer> <plug>(vimtex-]]) :normal v]]<cr>
|
||||||
onoremap <buffer> <plug>(vl-][) :normal v][<cr>
|
onoremap <buffer> <plug>(vimtex-][) :normal v][<cr>
|
||||||
onoremap <buffer> <plug>(vl-[]) :normal v[]<cr>
|
onoremap <buffer> <plug>(vimtex-[]) :normal v[]<cr>
|
||||||
onoremap <buffer> <plug>(vl-[[) :normal v[[<cr>
|
onoremap <buffer> <plug>(vimtex-[[) :normal v[[<cr>
|
||||||
xnoremap <buffer> <plug>(vl-ie) :<c-u>call latex#motion#sel_environment(1)<cr>
|
xnoremap <buffer> <plug>(vimtex-ie) :<c-u>call vimtex#motion#sel_environment(1)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-ae) :<c-u>call latex#motion#sel_environment()<cr>
|
xnoremap <buffer> <plug>(vimtex-ae) :<c-u>call vimtex#motion#sel_environment()<cr>
|
||||||
onoremap <buffer> <plug>(vl-ie) :normal vie<cr>
|
onoremap <buffer> <plug>(vimtex-ie) :normal vie<cr>
|
||||||
onoremap <buffer> <plug>(vl-ae) :normal vae<cr>
|
onoremap <buffer> <plug>(vimtex-ae) :normal vae<cr>
|
||||||
xnoremap <buffer> <plug>(vl-i$) :<c-u>call latex#motion#sel_inline_math(1)<cr>
|
xnoremap <buffer> <plug>(vimtex-i$) :<c-u>call vimtex#motion#sel_inline_math(1)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-a$) :<c-u>call latex#motion#sel_inline_math()<cr>
|
xnoremap <buffer> <plug>(vimtex-a$) :<c-u>call vimtex#motion#sel_inline_math()<cr>
|
||||||
onoremap <buffer> <plug>(vl-i$) :normal vi$<cr>
|
onoremap <buffer> <plug>(vimtex-i$) :normal vi$<cr>
|
||||||
onoremap <buffer> <plug>(vl-a$) :normal va$<cr>
|
onoremap <buffer> <plug>(vimtex-a$) :normal va$<cr>
|
||||||
xnoremap <buffer> <plug>(vl-id) :<c-u>call latex#motion#sel_delimiter(1)<cr>
|
xnoremap <buffer> <plug>(vimtex-id) :<c-u>call vimtex#motion#sel_delimiter(1)<cr>
|
||||||
xnoremap <buffer> <plug>(vl-ad) :<c-u>call latex#motion#sel_delimiter()<cr>
|
xnoremap <buffer> <plug>(vimtex-ad) :<c-u>call vimtex#motion#sel_delimiter()<cr>
|
||||||
onoremap <buffer> <plug>(vl-id) :normal vi(<cr>
|
onoremap <buffer> <plug>(vimtex-id) :normal vi(<cr>
|
||||||
onoremap <buffer> <plug>(vl-ad) :normal va(<cr>
|
onoremap <buffer> <plug>(vimtex-ad) :normal va(<cr>
|
||||||
|
|
||||||
" Highlight matching parens ($, (), ...)
|
" Highlight matching parens ($, (), ...)
|
||||||
if !a:initialized && g:latex_motion_matchparen
|
if !a:initialized && g:vimtex_motion_matchparen
|
||||||
augroup latex_motion
|
augroup latex_motion
|
||||||
autocmd!
|
autocmd!
|
||||||
" Disable matchparen autocommands
|
" Disable matchparen autocommands
|
||||||
@ -59,12 +59,12 @@ function! latex#motion#init(initialized) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#motion#find_matching_pair(...) " {{{1
|
function! vimtex#motion#find_matching_pair(...) " {{{1
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
normal! gv
|
normal! gv
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if latex#util#in_comment() | return | endif
|
if vimtex#util#in_comment() | return | endif
|
||||||
|
|
||||||
" Save position
|
" Save position
|
||||||
let nl = line('.')
|
let nl = line('.')
|
||||||
@ -90,7 +90,7 @@ function! latex#motion#find_matching_pair(...) " {{{1
|
|||||||
if delim =~ '^\$'
|
if delim =~ '^\$'
|
||||||
let inline = s:notcomment . s:notbslash . '\$'
|
let inline = s:notcomment . s:notbslash . '\$'
|
||||||
let [lnum0, cnum0] = searchpos('.', 'nW')
|
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)
|
let [lnum2, cnum2] = searchpos(inline, 'nW', 0, 200)
|
||||||
else
|
else
|
||||||
let [lnum2, cnum2] = searchpos(not_cursor . inline, 'bnW', 0, 200)
|
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
|
if delim =~# '^' . open_pat
|
||||||
call searchpairpos(open_pat, '', close_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')
|
call search(close_pat, 'ce')
|
||||||
return
|
return
|
||||||
elseif delim =~# '^' . close_pat
|
elseif delim =~# '^' . close_pat
|
||||||
call searchpairpos(open_pat, '', not_cursor . 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
|
return
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#motion#next_section(type, backwards, visual) " {{{1
|
function! vimtex#motion#next_section(type, backwards, visual) " {{{1
|
||||||
" Restore visual mode if desired
|
" Restore visual mode if desired
|
||||||
if a:visual
|
if a:visual
|
||||||
normal! gv
|
normal! gv
|
||||||
@ -150,10 +150,10 @@ function! latex#motion#next_section(type, backwards, visual) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#motion#sel_delimiter(...) " {{{1
|
function! vimtex#motion#sel_delimiter(...) " {{{1
|
||||||
let inner = a:0 > 0
|
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
|
if inner
|
||||||
let c1 += len(d1)
|
let c1 += len(d1)
|
||||||
@ -184,10 +184,10 @@ function! latex#motion#sel_delimiter(...) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#motion#sel_environment(...) " {{{1
|
function! vimtex#motion#sel_environment(...) " {{{1
|
||||||
let inner = a:0 > 0
|
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)
|
call cursor(lnum, cnum)
|
||||||
if inner
|
if inner
|
||||||
if env =~ '^\'
|
if env =~ '^\'
|
||||||
@ -213,12 +213,12 @@ function! latex#motion#sel_environment(...) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#motion#sel_inline_math(...) " {{{1
|
function! vimtex#motion#sel_inline_math(...) " {{{1
|
||||||
let inner = a:0 > 0
|
let inner = a:0 > 0
|
||||||
|
|
||||||
let dollar_pat = '\\\@<!\$'
|
let dollar_pat = '\\\@<!\$'
|
||||||
|
|
||||||
if latex#util#has_syntax('texMathZoneX')
|
if vimtex#util#has_syntax('texMathZoneX')
|
||||||
call s:search_and_skip_comments(dollar_pat, 'cbW')
|
call s:search_and_skip_comments(dollar_pat, 'cbW')
|
||||||
elseif getline('.')[col('.') - 1] == '$'
|
elseif getline('.')[col('.') - 1] == '$'
|
||||||
call s:search_and_skip_comments(dollar_pat, 'bW')
|
call s:search_and_skip_comments(dollar_pat, 'bW')
|
||||||
@ -283,7 +283,7 @@ let s:section.= '>'
|
|||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
function! s:highlight_matching_pair(...) " {{{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
|
let hmode = a:0 > 0 ? 1 : 0
|
||||||
|
|
||||||
2match none
|
2match none
|
||||||
@ -307,7 +307,7 @@ function! s:highlight_matching_pair(...) " {{{1
|
|||||||
" Match inline math
|
" Match inline math
|
||||||
"
|
"
|
||||||
let [lnum0, cnum0] = searchpos('.', 'nW')
|
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 . '\$',
|
let [lnum2, cnum2] = searchpos(s:notcomment . s:notbslash . '\$',
|
||||||
\ 'nW', line('w$'), 200)
|
\ 'nW', line('w$'), 200)
|
||||||
else
|
else
|
||||||
@ -328,7 +328,7 @@ function! s:highlight_matching_pair(...) " {{{1
|
|||||||
|
|
||||||
if delim =~# '^' . open_pat
|
if delim =~# '^' . open_pat
|
||||||
let [lnum2, cnum2] = searchpairpos(open_pat, '', close_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
|
execute '2match MatchParen /\%(\%' . nl . 'l\%' . cnum
|
||||||
\ . 'c' . s:delimiters_open[i] . '\|\%'
|
\ . 'c' . s:delimiters_open[i] . '\|\%'
|
||||||
\ . lnum2 . 'l\%' . cnum2 . 'c'
|
\ . lnum2 . 'l\%' . cnum2 . 'c'
|
||||||
@ -337,7 +337,7 @@ function! s:highlight_matching_pair(...) " {{{1
|
|||||||
elseif delim =~# '^' . close_pat
|
elseif delim =~# '^' . close_pat
|
||||||
let [lnum2, cnum2] = searchpairpos(open_pat, '',
|
let [lnum2, cnum2] = searchpairpos(open_pat, '',
|
||||||
\ '\C\%(\%'. nl . 'l\%' . cnum . 'c\)\@!' . close_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
|
execute '2match MatchParen /\%(\%' . lnum2 . 'l\%' . cnum2
|
||||||
\ . 'c' . s:delimiters_open[i] . '\|\%'
|
\ . 'c' . s:delimiters_open[i] . '\|\%'
|
||||||
\ . nl . 'l\%' . cnum . 'c'
|
\ . nl . 'l\%' . cnum . 'c'
|
||||||
@ -362,7 +362,7 @@ function! s:search_and_skip_comments(pat, ...) " {{{1
|
|||||||
let flags = substitute(flags, 'c', '', 'g')
|
let flags = substitute(flags, 'c', '', 'g')
|
||||||
|
|
||||||
" keep searching while in comment
|
" keep searching while in comment
|
||||||
while latex#util#in_comment()
|
while vimtex#util#in_comment()
|
||||||
let ret = search(a:pat, flags, stopline)
|
let ret = search(a:pat, flags, stopline)
|
||||||
if !ret
|
if !ret
|
||||||
break
|
break
|
@ -1,37 +1,37 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#toc#init(initialized) " {{{1
|
function! vimtex#toc#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_toc_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_toc_enabled', 1)
|
||||||
if !g:latex_toc_enabled | return | endif
|
if !g:vimtex_toc_enabled | return | endif
|
||||||
|
|
||||||
" Set default options
|
" Set default options
|
||||||
call latex#util#set_default('g:latex_toc_fold', 0)
|
call vimtex#util#set_default('g:vimtex_toc_fold', 0)
|
||||||
call latex#util#set_default('g:latex_toc_fold_levels', 10)
|
call vimtex#util#set_default('g:vimtex_toc_fold_levels', 10)
|
||||||
call latex#util#set_default('g:latex_toc_hide_help', 0)
|
call vimtex#util#set_default('g:vimtex_toc_hide_help', 0)
|
||||||
call latex#util#set_default('g:latex_toc_hide_line_numbers', 1)
|
call vimtex#util#set_default('g:vimtex_toc_hide_line_numbers', 1)
|
||||||
call latex#util#set_default('g:latex_toc_hide_preamble', 0)
|
call vimtex#util#set_default('g:vimtex_toc_hide_preamble', 0)
|
||||||
call latex#util#set_default('g:latex_toc_numbers', 1)
|
call vimtex#util#set_default('g:vimtex_toc_numbers', 1)
|
||||||
call latex#util#set_default('g:latex_toc_numbers_width', 0)
|
call vimtex#util#set_default('g:vimtex_toc_numbers_width', 0)
|
||||||
call latex#util#set_default('g:latex_toc_resize', 1)
|
call vimtex#util#set_default('g:vimtex_toc_resize', 1)
|
||||||
call latex#util#set_default('g:latex_toc_secnumdepth', 3)
|
call vimtex#util#set_default('g:vimtex_toc_secnumdepth', 3)
|
||||||
call latex#util#set_default('g:latex_toc_split_pos', 'vert leftabove')
|
call vimtex#util#set_default('g:vimtex_toc_split_pos', 'vert leftabove')
|
||||||
call latex#util#set_default('g:latex_toc_width', 30)
|
call vimtex#util#set_default('g:vimtex_toc_width', 30)
|
||||||
call latex#util#error_deprecated('g:latex_toc_split_side')
|
call vimtex#util#error_deprecated('g:vimtex_toc_split_side')
|
||||||
|
|
||||||
" Define commands
|
" Define commands
|
||||||
command! -buffer VimLatexTocOpen call latex#toc#open()
|
command! -buffer VimtexTocOpen call vimtex#toc#open()
|
||||||
command! -buffer VimLatexTocToggle call latex#toc#toggle()
|
command! -buffer VimtexTocToggle call vimtex#toc#toggle()
|
||||||
|
|
||||||
" Define mappings
|
" Define mappings
|
||||||
nnoremap <buffer> <plug>(vl-toc-open) :call latex#toc#open()<cr>
|
nnoremap <buffer> <plug>(vimtex-toc-open) :call vimtex#toc#open()<cr>
|
||||||
nnoremap <buffer> <plug>(vl-toc-toggle) :call latex#toc#toggle()<cr>
|
nnoremap <buffer> <plug>(vimtex-toc-toggle) :call vimtex#toc#toggle()<cr>
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#toc#open() " {{{1
|
function! vimtex#toc#open() " {{{1
|
||||||
" Go to TOC if it already exists
|
" Go to TOC if it already exists
|
||||||
let winnr = bufwinnr(bufnr('LaTeX TOC'))
|
let winnr = bufwinnr(bufnr('LaTeX TOC'))
|
||||||
if winnr >= 0
|
if winnr >= 0
|
||||||
@ -46,17 +46,17 @@ function! latex#toc#open() " {{{1
|
|||||||
let toc = s:parse_toc()
|
let toc = s:parse_toc()
|
||||||
|
|
||||||
" Resize vim session if wanted, then create TOC window
|
" Resize vim session if wanted, then create TOC window
|
||||||
if g:latex_toc_resize
|
if g:vimtex_toc_resize
|
||||||
silent exe "set columns+=" . g:latex_toc_width
|
silent exe "set columns+=" . g:vimtex_toc_width
|
||||||
endif
|
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
|
" Set buffer local variables
|
||||||
let b:toc = toc
|
let b:toc = toc
|
||||||
let b:toc_numbers = 1
|
let b:toc_numbers = 1
|
||||||
let b:toc_max_level = s:max_level
|
let b:toc_max_level = s:max_level
|
||||||
let b:toc_topmatters = s:count_matters
|
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_winnr = bufwinnr(calling_buf)
|
||||||
let b:calling_file = calling_file
|
let b:calling_file = calling_file
|
||||||
let b:calling_line = calling_line
|
let b:calling_line = calling_line
|
||||||
@ -64,14 +64,14 @@ function! latex#toc#open() " {{{1
|
|||||||
setlocal filetype=latextoc
|
setlocal filetype=latextoc
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#toc#toggle() " {{{1
|
function! vimtex#toc#toggle() " {{{1
|
||||||
if bufwinnr(bufnr('LaTeX TOC')) >= 0
|
if bufwinnr(bufnr('LaTeX TOC')) >= 0
|
||||||
if g:latex_toc_resize
|
if g:vimtex_toc_resize
|
||||||
silent exe "set columns-=" . g:latex_toc_width
|
silent exe "set columns-=" . g:vimtex_toc_width
|
||||||
endif
|
endif
|
||||||
silent execute 'bwipeout' . bufnr('LaTeX TOC')
|
silent execute 'bwipeout' . bufnr('LaTeX TOC')
|
||||||
else
|
else
|
||||||
call latex#toc#open()
|
call vimtex#toc#open()
|
||||||
silent execute 'wincmd w'
|
silent execute 'wincmd w'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -140,7 +140,7 @@ let s:re_other = {
|
|||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
function! s:parse_toc() " {{{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
|
" Reset TOC numbering
|
||||||
call s:number_reset('preamble')
|
call s:number_reset('preamble')
|
||||||
@ -157,7 +157,7 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
function! s:parse_limits(file) " {{{1
|
function! s:parse_limits(file) " {{{1
|
||||||
if !filereadable(a:file)
|
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
|
echoerr "File not readable: " . a:file
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
@ -191,7 +191,7 @@ function! s:parse_file(file) " {{{1
|
|||||||
if a:file == ''
|
if a:file == ''
|
||||||
return []
|
return []
|
||||||
elseif !filereadable(a:file)
|
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
|
echoerr "File not readable: " . a:file
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
@ -210,7 +210,7 @@ function! s:parse_file(file) " {{{1
|
|||||||
|
|
||||||
" 2. Parse preamble
|
" 2. Parse preamble
|
||||||
if s:number.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, {
|
call add(toc, {
|
||||||
\ 'title' : 'Preamble',
|
\ 'title' : 'Preamble',
|
||||||
\ 'number' : '',
|
\ 'number' : '',
|
@ -1,12 +1,10 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" 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
|
" Substitute stuff like '\IeC{\"u}' to corresponding unicode symbols
|
||||||
"
|
"
|
||||||
@ -82,15 +80,15 @@ let s:convert_back_list = map([
|
|||||||
\ ['\\\~n}' , 'ñ'],
|
\ ['\\\~n}' , 'ñ'],
|
||||||
\], '[''\C\(\\IeC\s*{\)\?'' . v:val[0], v:val[1]]')
|
\], '[''\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)
|
if exists(a:variable)
|
||||||
echoerr "Deprecation error: " . a:variable
|
echoerr "Deprecation error: " . a:variable
|
||||||
echoerr "Please read docs for more info!"
|
echoerr "Please read docs for more info!"
|
||||||
echoerr ":h vim-latex-changelog"
|
echoerr ":h vimtex-changelog"
|
||||||
endif
|
endif
|
||||||
endfunction
|
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
|
" Execute the given command on the current system. Wrapper function to make
|
||||||
" it easier to run on both windows and unix.
|
" it easier to run on both windows and unix.
|
||||||
"
|
"
|
||||||
@ -108,7 +106,7 @@ function! latex#util#execute(exe) " {{{1
|
|||||||
|
|
||||||
" Check and parse arguments
|
" Check and parse arguments
|
||||||
if !has_key(a:exe, 'cmd')
|
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!"
|
echoerr "Argument error, exe.cmd does not exist!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -171,19 +169,19 @@ function! latex#util#execute(exe) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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
|
" 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
|
" double quotes. shellscape() on Windows with "shellslash" set will produce
|
||||||
" a path enclosed by single quotes, which "cmd" does not recognize and
|
" 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.
|
" processed through this function.
|
||||||
"
|
"
|
||||||
return has('win32') ? '"' . a:path . '"' : shellescape(a:path)
|
return has('win32') ? '"' . a:path . '"' : shellescape(a:path)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#get_env(...) " {{{1
|
function! vimtex#util#get_env(...) " {{{1
|
||||||
" latex#util#get_env([with_pos])
|
" vimtex#util#get_env([with_pos])
|
||||||
" Returns:
|
" Returns:
|
||||||
" - environment
|
" - environment
|
||||||
" if with_pos is not given
|
" if with_pos is not given
|
||||||
@ -209,7 +207,7 @@ function! latex#util#get_env(...) " {{{1
|
|||||||
let flags .= 'c'
|
let flags .= 'c'
|
||||||
endif
|
endif
|
||||||
let [lnum1, cnum1] = searchpairpos(begin_pat, '', end_pat, flags,
|
let [lnum1, cnum1] = searchpairpos(begin_pat, '', end_pat, flags,
|
||||||
\ 'latex#util#in_comment()')
|
\ 'vimtex#util#in_comment()')
|
||||||
|
|
||||||
let env = ''
|
let env = ''
|
||||||
|
|
||||||
@ -234,7 +232,7 @@ function! latex#util#get_env(...) " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let [lnum2, cnum2] = searchpairpos(begin_pat, '', end_pat, flags,
|
let [lnum2, cnum2] = searchpairpos(begin_pat, '', end_pat, flags,
|
||||||
\ 'latex#util#in_comment()')
|
\ 'vimtex#util#in_comment()')
|
||||||
|
|
||||||
call setpos('.', saved_pos)
|
call setpos('.', saved_pos)
|
||||||
return [env, lnum1, cnum1, lnum2, cnum2]
|
return [env, lnum1, cnum1, lnum2, cnum2]
|
||||||
@ -244,7 +242,7 @@ function! latex#util#get_env(...) " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#get_delim() " {{{1
|
function! vimtex#util#get_delim() " {{{1
|
||||||
" Save position in order to restore before finishing
|
" Save position in order to restore before finishing
|
||||||
let pos_original = getpos('.')
|
let pos_original = getpos('.')
|
||||||
|
|
||||||
@ -283,7 +281,7 @@ function! latex#util#get_delim() " {{{1
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Search for closing delimiter
|
" 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
|
" Check if the current is pair is the closest pair
|
||||||
if pos[0] && pos[0]*1000 + pos[1] < l2*1000 + c2
|
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 c2=pos[1]
|
||||||
let d2=matchstr(strpart(getline(l2), c2 - 1), close)
|
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 l1=pos[0]
|
||||||
let c1=pos[1]
|
let c1=pos[1]
|
||||||
let d1=matchstr(strpart(getline(l1), c1 - 1), open)
|
let d1=matchstr(strpart(getline(l1), c1 - 1), open)
|
||||||
@ -318,7 +316,7 @@ let s:delimiters_close = [
|
|||||||
\ '\\\cbigg\?\()\|\]\|\\}\)',
|
\ '\\\cbigg\?\()\|\]\|\\}\)',
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
function! latex#util#get_os() " {{{1
|
function! vimtex#util#get_os() " {{{1
|
||||||
if has("win32")
|
if has("win32")
|
||||||
return "win"
|
return "win"
|
||||||
elseif has("unix")
|
elseif has("unix")
|
||||||
@ -330,19 +328,19 @@ function! latex#util#get_os() " {{{1
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#has_syntax(name, ...) " {{{1
|
function! vimtex#util#has_syntax(name, ...) " {{{1
|
||||||
" Usage: latex#util#has_syntax(name, [line], [col])
|
" Usage: vimtex#util#has_syntax(name, [line], [col])
|
||||||
let line = a:0 >= 1 ? a:1 : line('.')
|
let line = a:0 >= 1 ? a:1 : line('.')
|
||||||
let col = a:0 >= 2 ? a:2 : col('.')
|
let col = a:0 >= 2 ? a:2 : col('.')
|
||||||
return 0 <= index(map(synstack(line, col),
|
return 0 <= index(map(synstack(line, col),
|
||||||
\ 'synIDattr(v:val, "name") == "' . a:name . '"'), 1)
|
\ 'synIDattr(v:val, "name") == "' . a:name . '"'), 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#in_comment(...) " {{{1
|
function! vimtex#util#in_comment(...) " {{{1
|
||||||
return synIDattr(synID(line('.'), col('.'), 0), "name") =~# '^texComment'
|
return synIDattr(synID(line('.'), col('.'), 0), "name") =~# '^texComment'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#kpsewhich(file, ...) " {{{1
|
function! vimtex#util#kpsewhich(file, ...) " {{{1
|
||||||
let cmd = 'kpsewhich '
|
let cmd = 'kpsewhich '
|
||||||
let cmd .= a:0 > 0 ? a:1 : ''
|
let cmd .= a:0 > 0 ? a:1 : ''
|
||||||
let cmd .= ' "' . a:file . '"'
|
let cmd .= ' "' . a:file . '"'
|
||||||
@ -358,19 +356,19 @@ function! latex#util#kpsewhich(file, ...) " {{{1
|
|||||||
return out
|
return out
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#set_default(variable, default) " {{{1
|
function! vimtex#util#set_default(variable, default) " {{{1
|
||||||
if !exists(a:variable)
|
if !exists(a:variable)
|
||||||
let {a:variable} = a:default
|
let {a:variable} = a:default
|
||||||
endif
|
endif
|
||||||
endfunction
|
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)
|
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
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#tex2tree(str) " {{{1
|
function! vimtex#util#tex2tree(str) " {{{1
|
||||||
let tree = []
|
let tree = []
|
||||||
let i1 = 0
|
let i1 = 0
|
||||||
let i2 = -1
|
let i2 = -1
|
||||||
@ -393,7 +391,7 @@ function! latex#util#tex2tree(str) " {{{1
|
|||||||
else
|
else
|
||||||
let depth -= 1
|
let depth -= 1
|
||||||
if depth == 0
|
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
|
let i1 = i2 + 1
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -401,11 +399,11 @@ function! latex#util#tex2tree(str) " {{{1
|
|||||||
return tree
|
return tree
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latex#util#tree2tex(tree) " {{{1
|
function! vimtex#util#tree2tex(tree) " {{{1
|
||||||
if type(a:tree) == type('')
|
if type(a:tree) == type('')
|
||||||
return a:tree
|
return a:tree
|
||||||
else
|
else
|
||||||
return '{' . join(map(a:tree, 'latex#util#tree2tex(v:val)'), '') . '}'
|
return '{' . join(map(a:tree, 'vimtex#util#tree2tex(v:val)'), '') . '}'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
@ -1,34 +1,34 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
function! latex#view#init(initialized) " {{{1
|
function! vimtex#view#init(initialized) " {{{1
|
||||||
call latex#util#set_default('g:latex_view_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_view_enabled', 1)
|
||||||
if !g:latex_view_enabled | return | endif
|
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
|
" Initialize viewer options
|
||||||
for viewer in s:viewers
|
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
|
endfor
|
||||||
|
|
||||||
" Initialize other options
|
" 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',
|
\ 'linux' : 'xdg-open',
|
||||||
\ 'mac' : 'open',
|
\ 'mac' : 'open',
|
||||||
\ })
|
\ })
|
||||||
call latex#util#set_default('g:latex_view_method', 'general')
|
call vimtex#util#set_default('g:vimtex_view_method', 'general')
|
||||||
call latex#util#set_default('g:latex_view_mupdf_send_keys', '')
|
call vimtex#util#set_default('g:vimtex_view_mupdf_send_keys', '')
|
||||||
call latex#util#error_deprecated('g:latex_viewer')
|
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)
|
if !exists(viewer)
|
||||||
echoerr "Viewer does not exist!"
|
echoerr "Viewer does not exist!"
|
||||||
echoerr "Viewer: " . g:latex_view_method
|
echoerr "Viewer: " . g:vimtex_view_method
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -36,18 +36,18 @@ function! latex#view#init(initialized) " {{{1
|
|||||||
call data.viewer.init()
|
call data.viewer.init()
|
||||||
|
|
||||||
" Define commands
|
" 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')
|
if has_key(data.viewer, 'reverse_search')
|
||||||
command! -buffer -nargs=* VimLatexRSearch
|
command! -buffer -nargs=* VimtexRSearch
|
||||||
\ call g:latex#data[b:latex.id].viewer.reverse_search()
|
\ call g:vimtex#data[b:vimtex.id].viewer.reverse_search()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Define mappings
|
" Define mappings
|
||||||
nnoremap <buffer> <plug>(vl-view)
|
nnoremap <buffer> <plug>(vimtex-view)
|
||||||
\ :call g:latex#data[b:latex.id].viewer.view()<cr>
|
\ :call g:vimtex#data[b:vimtex.id].viewer.view()<cr>
|
||||||
if has_key(data.viewer, 'reverse_search')
|
if has_key(data.viewer, 'reverse_search')
|
||||||
nnoremap <buffer> <plug>(vl-reverse-search)
|
nnoremap <buffer> <plug>(vimtex-reverse-search)
|
||||||
\ :call g:latex#data[b:latex.id].viewer.reverse_search()<cr>
|
\ :call g:vimtex#data[b:vimtex.id].viewer.reverse_search()<cr>
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -67,27 +67,27 @@ endfor
|
|||||||
|
|
||||||
" {{{1 General
|
" {{{1 General
|
||||||
function! s:general.init() dict " {{{2
|
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 "General viewer is not available!"
|
||||||
echoerr "g:latex_view_general_viewer = "
|
echoerr "g:vimtex_view_general_viewer = "
|
||||||
\ . g:latex_view_general_viewer
|
\ . g:vimtex_view_general_viewer
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:general.view() dict " {{{2
|
function! s:general.view() dict " {{{2
|
||||||
let exe = {}
|
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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let exe.cmd .= ' ' . g:latex_view_general_options
|
let exe.cmd .= ' ' . g:vimtex_view_general_options
|
||||||
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
|
let self.cmd_view = exe.cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -123,21 +123,21 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:mupdf.start() dict " {{{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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let exe = {}
|
let exe = {}
|
||||||
let exe.cmd = 'mupdf ' . g:latex_view_mupdf_options
|
let exe.cmd = 'mupdf ' . g:vimtex_view_mupdf_options
|
||||||
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_start = exe.cmd
|
let self.cmd_start = exe.cmd
|
||||||
|
|
||||||
call self.xwin_get_id()
|
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.forward_search()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ function! s:mupdf.forward_search() dict " {{{2
|
|||||||
if !executable('xdotool') | return | endif
|
if !executable('xdotool') | return | endif
|
||||||
if !executable('synctex') | 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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
@ -155,8 +155,8 @@ function! s:mupdf.forward_search() dict " {{{2
|
|||||||
let self.cmd_synctex_view = "synctex view -i "
|
let self.cmd_synctex_view = "synctex view -i "
|
||||||
\ . (line(".") + 1) . ":"
|
\ . (line(".") + 1) . ":"
|
||||||
\ . (col(".") + 1) . ":"
|
\ . (col(".") + 1) . ":"
|
||||||
\ . latex#util#fnameescape(expand("%:p"))
|
\ . vimtex#util#fnameescape(expand("%:p"))
|
||||||
\ . " -o " . latex#util#fnameescape(outfile)
|
\ . " -o " . vimtex#util#fnameescape(outfile)
|
||||||
\ . " | grep -m1 'Page:' | sed 's/Page://' | tr -d '\n'"
|
\ . " | grep -m1 'Page:' | sed 's/Page://' | tr -d '\n'"
|
||||||
let self.page = system(self.cmd_synctex_view)
|
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 = 'xdotool'
|
||||||
let exe.cmd .= ' type --window ' . self.xwin_id
|
let exe.cmd .= ' type --window ' . self.xwin_id
|
||||||
let exe.cmd .= ' "' . self.page . 'g"'
|
let exe.cmd .= ' "' . self.page . 'g"'
|
||||||
call latex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
let self.cmd_forward_search = exe.cmd
|
let self.cmd_forward_search = exe.cmd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ function! s:mupdf.reverse_search() dict " {{{2
|
|||||||
if !executable('xdotool') | return | endif
|
if !executable('xdotool') | return | endif
|
||||||
if !executable('synctex') | 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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
@ -222,18 +222,18 @@ endfunction
|
|||||||
" }}}2
|
" }}}2
|
||||||
function! s:mupdf.latexmk_callback() dict " {{{2
|
function! s:mupdf.latexmk_callback() dict " {{{2
|
||||||
call self.xwin_get_id()
|
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.forward_search()
|
||||||
call self.focus_vim()
|
call self.focus_vim()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:mupdf.latexmk_append_argument() dict " {{{2
|
function! s:mupdf.latexmk_append_argument() dict " {{{2
|
||||||
let cmd = latex#latexmk#add_option('new_viewer_always', '0')
|
let cmd = vimtex#latexmk#add_option('new_viewer_always', '0')
|
||||||
let cmd .= latex#latexmk#add_option('pdf_update_method', '2')
|
let cmd .= vimtex#latexmk#add_option('pdf_update_method', '2')
|
||||||
let cmd .= latex#latexmk#add_option('pdf_update_signal', 'SIGHUP')
|
let cmd .= vimtex#latexmk#add_option('pdf_update_signal', 'SIGHUP')
|
||||||
let cmd .= latex#latexmk#add_option('pdf_previewer',
|
let cmd .= vimtex#latexmk#add_option('pdf_previewer',
|
||||||
\ 'start mupdf ' . g:latex_view_mupdf_options)
|
\ 'start mupdf ' . g:vimtex_view_mupdf_options)
|
||||||
return cmd
|
return cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -248,18 +248,18 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:okular.view() dict " {{{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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let exe = {}
|
let exe = {}
|
||||||
let exe.cmd = 'okular ' . g:latex_view_okular_options
|
let exe.cmd = 'okular ' . g:vimtex_view_okular_options
|
||||||
let exe.cmd .= ' --unique ' . latex#util#fnameescape(outfile)
|
let exe.cmd .= ' --unique ' . vimtex#util#fnameescape(outfile)
|
||||||
let exe.cmd .= '\#src:' . line('.') . latex#util#fnameescape(expand('%:p'))
|
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
|
let self.cmd_view = exe.cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -274,20 +274,20 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:qpdfview.view() dict " {{{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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let exe = {}
|
let exe = {}
|
||||||
let exe.cmd = 'qpdfview ' . g:latex_view_qpdfview_options
|
let exe.cmd = 'qpdfview ' . g:vimtex_view_qpdfview_options
|
||||||
let exe.cmd .= ' --unique ' . latex#util#fnameescape(outfile)
|
let exe.cmd .= ' --unique ' . vimtex#util#fnameescape(outfile)
|
||||||
let exe.cmd .= '\#src:' . latex#util#fnameescape(expand('%:p'))
|
let exe.cmd .= '\#src:' . vimtex#util#fnameescape(expand('%:p'))
|
||||||
let exe.cmd .= ':' . line('.')
|
let exe.cmd .= ':' . line('.')
|
||||||
let exe.cmd .= ':' . col('.')
|
let exe.cmd .= ':' . col('.')
|
||||||
|
|
||||||
call latex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
let self.cmd_view = exe.cmd
|
let self.cmd_view = exe.cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -302,19 +302,19 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:sumatrapdf.view() dict " {{{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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let exe = {}
|
let exe = {}
|
||||||
let exe.cmd = 'SumatraPDF ' . g:latex_view_sumatrapdf_options
|
let exe.cmd = 'SumatraPDF ' . g:vimtex_view_sumatrapdf_options
|
||||||
let exe.cmd .= ' -forward-search ' . latex#util#fnameescape(expand('%:p'))
|
let exe.cmd .= ' -forward-search ' . vimtex#util#fnameescape(expand('%:p'))
|
||||||
let exe.cmd .= ' ' . line('.')
|
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
|
let self.cmd_view = exe.cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -348,19 +348,19 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:zathura.start() dict " {{{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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let exe = {}
|
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)
|
let exe.cmd .= ' -x "' . exepath(v:progname)
|
||||||
\ . ' --servername ' . v:servername
|
\ . ' --servername ' . v:servername
|
||||||
\ . ' --remote +\%{line} \%{input}"'
|
\ . ' --remote +\%{line} \%{input}"'
|
||||||
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_start = exe.cmd
|
let self.cmd_start = exe.cmd
|
||||||
|
|
||||||
@ -370,7 +370,7 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:zathura.forward_search() dict " {{{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)
|
if !filereadable(outfile)
|
||||||
echomsg "Can't view: Output file is not readable!"
|
echomsg "Can't view: Output file is not readable!"
|
||||||
return
|
return
|
||||||
@ -380,9 +380,9 @@ function! s:zathura.forward_search() dict " {{{2
|
|||||||
let exe.cmd = 'zathura --synctex-forward '
|
let exe.cmd = 'zathura --synctex-forward '
|
||||||
let exe.cmd .= line(".")
|
let exe.cmd .= line(".")
|
||||||
let exe.cmd .= ':' . col('.')
|
let exe.cmd .= ':' . col('.')
|
||||||
let exe.cmd .= ':' . latex#util#fnameescape(expand('%:p'))
|
let exe.cmd .= ':' . vimtex#util#fnameescape(expand('%:p'))
|
||||||
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_forward_search = exe.cmd
|
let self.cmd_forward_search = exe.cmd
|
||||||
endfunction
|
endfunction
|
||||||
@ -396,9 +396,9 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:zathura.latexmk_append_argument() dict " {{{2
|
function! s:zathura.latexmk_append_argument() dict " {{{2
|
||||||
let cmd = latex#latexmk#add_option('new_viewer_always', '0')
|
let cmd = vimtex#latexmk#add_option('new_viewer_always', '0')
|
||||||
let cmd .= latex#latexmk#add_option('pdf_previewer',
|
let cmd .= vimtex#latexmk#add_option('pdf_previewer',
|
||||||
\ 'start zathura ' . g:latex_view_zathura_options
|
\ 'start zathura ' . g:vimtex_view_zathura_options
|
||||||
\ . ' -x \"' . exepath(v:progname)
|
\ . ' -x \"' . exepath(v:progname)
|
||||||
\ . ' --servername ' . v:servername
|
\ . ' --servername ' . v:servername
|
||||||
\ . ' --remote +\%{line} \%{input}\" \%S')
|
\ . ' --remote +\%{line} \%{input}\" \%S')
|
@ -1,4 +1,4 @@
|
|||||||
% LaTeX plugin for Vim
|
% vimtex - LaTeX plugin for Vim
|
||||||
%
|
%
|
||||||
% Maintainer: Karl Yngve Lervåg
|
% Maintainer: Karl Yngve Lervåg
|
||||||
% Email: karl.yngve@gmail.com
|
% Email: karl.yngve@gmail.com
|
@ -1,10 +1,24 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" 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 pline = getline(a:lnum - 1)
|
||||||
let cline = getline(a:lnum)
|
let cline = getline(a:lnum)
|
||||||
let nline = getline(a:lnum + 1)
|
let nline = getline(a:lnum + 1)
|
||||||
@ -17,36 +31,24 @@ function! latextoc#fold_level(lnum) " {{{1
|
|||||||
return 0
|
return 0
|
||||||
endif
|
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
|
return '>' . l:nn
|
||||||
endif
|
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
|
return l:cn
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return '='
|
return '='
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! latextoc#fold_text() " {{{1
|
" }}}1
|
||||||
|
function! vimtextoc#fold_text() " {{{1
|
||||||
return getline(v:foldstart)
|
return getline(v:foldstart)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
function! vimtextoc#refresh() " {{{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
|
|
||||||
if !exists('b:toc') | return | endif
|
if !exists('b:toc') | return | endif
|
||||||
|
|
||||||
" Fill TOC entries
|
" Fill TOC entries
|
||||||
@ -58,6 +60,7 @@ function! latextoc#refresh() " {{{1
|
|||||||
" Restore old position
|
" Restore old position
|
||||||
call setpos('.', b:toc_pos_saved)
|
call setpos('.', b:toc_pos_saved)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
function! s:add_start() " {{{1
|
function! s:add_start() " {{{1
|
||||||
@ -69,8 +72,8 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
function! s:add_entries() " {{{1
|
function! s:add_entries() " {{{1
|
||||||
let closest_index = 0
|
let closest_index = 0
|
||||||
if g:latex_toc_numbers_width
|
if g:vimtex_toc_numbers_width
|
||||||
let s:width = g:latex_toc_numbers_width
|
let s:width = g:vimtex_toc_numbers_width
|
||||||
else
|
else
|
||||||
let s:width = 2*(b:toc_secnumdepth+2)
|
let s:width = 2*(b:toc_secnumdepth+2)
|
||||||
endi
|
endi
|
||||||
@ -90,7 +93,7 @@ function! s:add_entries() " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}1
|
" }}}1
|
||||||
function! s:add_help() " {{{1
|
function! s:add_help() " {{{1
|
||||||
if !g:latex_toc_hide_help
|
if !g:vimtex_toc_hide_help
|
||||||
call append('$', "")
|
call append('$', "")
|
||||||
call append('$', "<Esc>/q: close")
|
call append('$', "<Esc>/q: close")
|
||||||
call append('$', "<Space>: jump")
|
call append('$', "<Space>: jump")
|
||||||
@ -113,7 +116,7 @@ function! s:print_entry(entry) " {{{1
|
|||||||
|
|
||||||
" Create entry string
|
" Create entry string
|
||||||
let entry = ''
|
let entry = ''
|
||||||
if g:latex_toc_numbers
|
if g:vimtex_toc_numbers
|
||||||
let entry .= printf(s:num_format, level >= b:toc_secnumdepth + 2
|
let entry .= printf(s:num_format, level >= b:toc_secnumdepth + 2
|
||||||
\ ? '' : strpart(s:print_number(a:entry.number), 0, s:width))
|
\ ? '' : strpart(s:print_number(a:entry.number), 0, s:width))
|
||||||
endif
|
endif
|
@ -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
|
if exists("current_compiler") | finish | endif
|
||||||
let current_compiler = "lacheck"
|
let current_compiler = "lacheck"
|
||||||
|
|
||||||
|
@ -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
|
if exists("current_compiler") | finish | endif
|
||||||
let current_compiler = "latexmk"
|
let current_compiler = "latexmk"
|
||||||
|
|
||||||
@ -24,11 +30,11 @@ CompilerSet errorformat+=%Z<argument>\ %m
|
|||||||
CompilerSet errorformat+=%Cl.%l\ %m
|
CompilerSet errorformat+=%Cl.%l\ %m
|
||||||
|
|
||||||
" Show warnings
|
" Show warnings
|
||||||
if exists("g:latex_quickfix_ignore_all_warnings")
|
if exists("g:vimtex_quickfix_ignore_all_warnings")
|
||||||
\ && exists("g:latex_quickfix_ignored_warnings")
|
\ && exists("g:vimtex_quickfix_ignored_warnings")
|
||||||
\ && !g:latex_quickfix_ignore_all_warnings
|
\ && !g:vimtex_quickfix_ignore_all_warnings
|
||||||
" Ignore some 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'), ' ')
|
let warning = escape(substitute(w, '[\,]', '%\\\\&', 'g'), ' ')
|
||||||
exe 'CompilerSet errorformat+=%-G%.%#'. warning .'%.%#'
|
exe 'CompilerSet errorformat+=%-G%.%#'. warning .'%.%#'
|
||||||
endfor
|
endfor
|
||||||
|
1309
doc/latex.txt
1309
doc/latex.txt
File diff suppressed because it is too large
Load Diff
1325
doc/vimtex.txt
Normal file
1325
doc/vimtex.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,10 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
"
|
"
|
||||||
|
|
||||||
if exists('g:latex_enabled') && !g:latex_enabled
|
if exists('g:vimtex_enabled') && !g:vimtex_enabled
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
if exists('b:did_ftplugin')
|
if exists('b:did_ftplugin')
|
||||||
@ -12,6 +12,14 @@ if exists('b:did_ftplugin')
|
|||||||
endif
|
endif
|
||||||
let b:did_ftplugin = 1
|
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
|
" vim: fdm=marker sw=2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
@ -16,7 +16,7 @@ setlocal listchars=
|
|||||||
setlocal nobuflisted
|
setlocal nobuflisted
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
setlocal nowrap
|
setlocal nowrap
|
||||||
if g:latex_toc_hide_line_numbers
|
if g:vimtex_toc_hide_line_numbers
|
||||||
setlocal nonumber
|
setlocal nonumber
|
||||||
setlocal norelativenumber
|
setlocal norelativenumber
|
||||||
endif
|
endif
|
||||||
@ -26,14 +26,14 @@ setlocal cursorline
|
|||||||
setlocal tabstop=8
|
setlocal tabstop=8
|
||||||
setlocal cole=0
|
setlocal cole=0
|
||||||
setlocal cocu=nvic
|
setlocal cocu=nvic
|
||||||
if g:latex_toc_fold
|
if g:vimtex_toc_fold
|
||||||
setlocal foldmethod=expr
|
setlocal foldmethod=expr
|
||||||
setlocal foldexpr=latextoc#fold_level(v:lnum)
|
setlocal foldexpr=vimtex_toc#fold_level(v:lnum)
|
||||||
setlocal foldtext=latextoc#fold_text()
|
setlocal foldtext=vimtex_toc#fold_text()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Refresh/Initialize TOC content
|
" Refresh/Initialize TOC content
|
||||||
call latextoc#init()
|
call vimtex_toc#init()
|
||||||
|
|
||||||
" Define mappings
|
" Define mappings
|
||||||
nnoremap <buffer> <silent> G G4k
|
nnoremap <buffer> <silent> G G4k
|
||||||
@ -77,8 +77,8 @@ function! s:toc_activate(close) "{{{1
|
|||||||
|
|
||||||
" Keep or close TOC window (based on options)
|
" Keep or close TOC window (based on options)
|
||||||
if a:close
|
if a:close
|
||||||
if g:latex_toc_resize
|
if g:vimtex_toc_resize
|
||||||
silent exe "set columns-=" . g:latex_toc_width
|
silent exe "set columns-=" . g:vimtex_toc_width
|
||||||
endif
|
endif
|
||||||
execute 'bwipeout ' . toc_bnr
|
execute 'bwipeout ' . toc_bnr
|
||||||
else
|
else
|
||||||
@ -87,8 +87,8 @@ function! s:toc_activate(close) "{{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:toc_close() "{{{1
|
function! s:toc_close() "{{{1
|
||||||
if g:latex_toc_resize
|
if g:vimtex_toc_resize
|
||||||
silent exe "set columns-=" . g:latex_toc_width
|
silent exe "set columns-=" . g:vimtex_toc_width
|
||||||
endif
|
endif
|
||||||
bwipeout
|
bwipeout
|
||||||
endfunction
|
endfunction
|
||||||
@ -129,25 +129,25 @@ function! s:toc_open_entry(entry) "{{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:toc_toggle_numbers() "{{{1
|
function! s:toc_toggle_numbers() "{{{1
|
||||||
if g:latex_toc_numbers
|
if g:vimtex_toc_numbers
|
||||||
let g:latex_toc_numbers = 0
|
let g:vimtex_toc_numbers = 0
|
||||||
else
|
else
|
||||||
let g:latex_toc_numbers = 1
|
let g:vimtex_toc_numbers = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call latextoc#refresh()
|
call vimtex_toc#refresh()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:toc_inc_secnumdepth() "{{{1
|
function! s:toc_inc_secnumdepth() "{{{1
|
||||||
let b:toc_secnumdepth = min([b:toc_secnumdepth + 1, 5])
|
let b:toc_secnumdepth = min([b:toc_secnumdepth + 1, 5])
|
||||||
let g:latex_toc_secnumdepth = b:toc_secnumdepth
|
let g:vimtex_toc_secnumdepth = b:toc_secnumdepth
|
||||||
call latextoc#refresh()
|
call vimtex_toc#refresh()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:toc_dec_secnumdepth() "{{{1
|
function! s:toc_dec_secnumdepth() "{{{1
|
||||||
let b:toc_secnumdepth = max([b:toc_secnumdepth - 1, -2])
|
let b:toc_secnumdepth = max([b:toc_secnumdepth - 1, -2])
|
||||||
let g:latex_toc_secnumdepth = b:toc_secnumdepth
|
let g:vimtex_toc_secnumdepth = b:toc_secnumdepth
|
||||||
call latextoc#refresh()
|
call vimtex_toc#refresh()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
@ -1,4 +1,4 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
@ -9,56 +9,18 @@ if exists("b:did_indent")
|
|||||||
endif
|
endif
|
||||||
let b:did_indent = 1
|
let b:did_indent = 1
|
||||||
|
|
||||||
call latex#util#set_default('g:latex_indent_enabled', 1)
|
call vimtex#util#set_default('g:vimtex_indent_enabled', 1)
|
||||||
if !g:latex_indent_enabled | finish | endif
|
if !g:vimtex_indent_enabled | finish | endif
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
" {{{1 Options and common patterns
|
|
||||||
setlocal autoindent
|
setlocal autoindent
|
||||||
setlocal indentexpr=LatexIndent()
|
setlocal indentexpr=s:vimtex_indent()
|
||||||
setlocal indentkeys&
|
setlocal indentkeys&
|
||||||
setlocal indentkeys+=[,(,{,),},],\&,=\\item
|
setlocal indentkeys+=[,(,{,),},],\&,=\\item
|
||||||
|
|
||||||
let s:tikz_indented = 0
|
function! s:vimtex_indent() " {{{1
|
||||||
|
|
||||||
" 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()
|
|
||||||
" Find a non-blank non-comment line above the current line
|
" Find a non-blank non-comment line above the current line
|
||||||
let lnum = prevnonblank(v:lnum - 1)
|
let lnum = prevnonblank(v:lnum - 1)
|
||||||
while lnum != 0 && getline(lnum) =~ '^\s*%'
|
while lnum != 0 && getline(lnum) =~ '^\s*%'
|
||||||
@ -154,9 +116,7 @@ function! LatexIndent()
|
|||||||
return ind
|
return ind
|
||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
function! s:count_delimiters(line, pattern) " {{{1
|
||||||
" {{{1 s:count_delimiters
|
|
||||||
function! s:count_delimiters(line, pattern)
|
|
||||||
let sum = 0
|
let sum = 0
|
||||||
let indx = match(a:line, a:pattern)
|
let indx = match(a:line, a:pattern)
|
||||||
while indx >= 0
|
while indx >= 0
|
||||||
@ -167,6 +127,45 @@ function! s:count_delimiters(line, pattern)
|
|||||||
endwhile
|
endwhile
|
||||||
return sum
|
return sum
|
||||||
endfunction
|
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
|
" }}}1
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
" LaTeX plugin for Vim
|
" vimtex - LaTeX plugin for Vim
|
||||||
"
|
"
|
||||||
" Maintainer: Karl Yngve Lervåg
|
" Maintainer: Karl Yngve Lervåg
|
||||||
" Email: karl.yngve@gmail.com
|
" Email: karl.yngve@gmail.com
|
||||||
|
Loading…
Reference in New Issue
Block a user