From ce6f423e7ab53eb23dff8bd0a80afbabca14c40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sun, 15 Nov 2015 23:01:02 +0100 Subject: [PATCH] Added VimtexReload - easier vimtex development --- autoload/vimtex.vim | 33 +++++++++++++++++++++++++++++++-- autoload/vimtex/fold.vim | 8 +++++--- doc/vimtex.txt | 6 ++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/autoload/vimtex.vim b/autoload/vimtex.vim index 8c0cf2f..655f33d 100644 --- a/autoload/vimtex.vim +++ b/autoload/vimtex.vim @@ -146,6 +146,32 @@ function! vimtex#wordcount(detailed) " {{{1 highlight link TexcountValue Constant endfunction +" }}}1 +" {{{1 function! vimtex#reload() +let s:file = expand('') + +if !exists('s:reloading_script') + function! vimtex#reload() + let s:reloading_script = 1 + + let l:scripts = [s:file] + \ + map(copy(s:modules), + \ 'fnamemodify(s:file, '':h'') . ''/vimtex/'' . v:val . ''.vim''') + + for l:file in l:scripts + execute 'source' l:file + endfor + + let s:initialized = 0 + call vimtex#init() + + call vimtex#echo#formatted([ + \ 'vimtex: ', ['VimtexWarning', 'reloaded']]) + + unlet s:reloading_script + endfunction +endif + " }}}1 @@ -255,10 +281,12 @@ function! s:init_buffer() " {{{1 " Define commands command! -buffer -bang VimtexInfo call vimtex#info( == "!") command! -buffer -bang VimtexWordCount call vimtex#wordcount( == "!") + command! -buffer VimtexReload call vimtex#reload() " Define mappings - nnoremap (vimtex-info) :call vimtex#info(0) - nnoremap (vimtex-info-full) :call vimtex#info(1) + nnoremap (vimtex-info) :VimtexInfo + nnoremap (vimtex-info-full) :VimtexInfo! + nnoremap (vimtex-reload) :VimtexReload " " Attach autocommands @@ -285,6 +313,7 @@ function! s:init_mappings() " {{{1 call s:map('n', 'li', '(vimtex-info)') call s:map('n', 'lI', '(vimtex-info-full)') + call s:map('n', 'lx', '(vimtex-reload)') call s:map('n', 'dse', '(vimtex-delete-env)') call s:map('n', 'dsc', '(vimtex-delete-cmd)') diff --git a/autoload/vimtex/fold.vim b/autoload/vimtex/fold.vim index b72e354..2cacd1a 100644 --- a/autoload/vimtex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -82,9 +82,11 @@ function! vimtex#fold#init_buffer() " {{{1 function! s:fold_manual_refresh() call vimtex#fold#refresh('zx') - execute 'autocmd!' b:fold_manual_augroup - execute 'augroup!' b:fold_manual_augroup - unlet b:fold_manual_augroup + if exists('b:fold_manual_augroup') + execute 'autocmd!' b:fold_manual_augroup + execute 'augroup!' b:fold_manual_augroup + unlet b:fold_manual_augroup + endif endfunction endif endfunction diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 246f827..02a91db 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -290,6 +290,7 @@ This feature is explained in more detail later, see |vimtex-imaps|. lG |(vimtex-status-all)| `n` lc |(vimtex-clean)| `n` lC |(vimtex-clean-full)| `n` + lx |(vimtex-reload)| `n` dse |(vimtex-delete-env)| `n` dsc |(vimtex-delete-cmd)| `n` cse |(vimtex-change-env)| `n` @@ -995,6 +996,11 @@ Commands~ *(vimtex-reverse-search)* :VimtexRSearch Do reverse search (only available for MuPDF viewer). + *VimtexReload* + *(vimtex-reload)* +:VimtexReload Reload |vimtex| scripts. This is primarely useful + when developing and debugging |vimtex| itself. + *VimtexWordCount* :VimtexWordCount Shows the number of words in the current project. The count is created with `texcount` through a call