From bccfee6e989bdd150b2d2a3174dbf5cb3ae81c8d Mon Sep 17 00:00:00 2001 From: 0scar Date: Sat, 11 Jun 2022 21:03:29 +0200 Subject: Update vimconfig Add bindings for fuzzy finder --- .config/vim/ftplugin/tex.vim | 73 +++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) (limited to '.config/vim/ftplugin/tex.vim') diff --git a/.config/vim/ftplugin/tex.vim b/.config/vim/ftplugin/tex.vim index 33c0116..c283e69 100644 --- a/.config/vim/ftplugin/tex.vim +++ b/.config/vim/ftplugin/tex.vim @@ -1,26 +1,63 @@ -imap FTT \texttt{}i -imap FBF \textbf{}i -imap FIT \textit{}i -imap MTT \mathtt{}i -imap MBF \mathbf{}i -imap MIT \mathit{}i +function! GetMainDoc() + let l:maindoc = search('\\begin{document}', "cnw") + if l:maindoc > 0 + return '%' + else + " Find the main document file + " Must be in the same folder of the current file + let l:maindocs = split(system("grep -lE '\\\\begin{document}' " . expand('%:h') . "/*.tex"), '\n') + if len(l:maindocs) > 0 + " Use the first document containing `begin{document}` + return l:maindocs[0] + else + return "" + endif + endif +endfunction -imap MCC \mathcal{}<++>T{i +function! CompileMainDoc() + let l:latexcmd ='autocmd BufWritePost ! + \ latexrun --latex-args="-synctex=1 -interaction=nonstopmode" ' -inoremap /<++>cf> -noremap /<++>cf> + execute(l:latexcmd . GetMainDoc()) +endfunction -vnoremap `IT `>a}` -vnoremap `BF `>a}` -vnoremap `TT `>a}` -vnoremap `MI `>a}` -vnoremap `MB `>a}` -vnoremap `MT `>a}` +function! Synctex() + " remove 'silent' for debugging + let l:doc = GetMainDoc() + execute "silent !mv -u latex.out/" . substitute(l:doc, '\.tex', '') . ".synctex.gz ." + execute "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . bufname('%') . " " . expand('%:t:r') . ".pdf" + redraw! +endfunction + +imap FTT \texttt{}i +imap FBF \textbf{}i +imap FIT \textit{}i +imap FSC \textsc{}i +imap MTT \mathtt{}i +imap MBF \mathbf{}i +imap MIT \mathit{}i +imap MSC \mathsc{}i + +imap MCC \mathcal{}<++>T{i + +inoremap /<++>cf> +noremap /<++>cf> + +vnoremap `it `>a}` +vnoremap `bf `>a}` +vnoremap `tt `>a}` +vnoremap `mi `>a}` +vnoremap `mb `>a}` +vnoremap `mt `>a}` " put \begin{} \end{} tags tags around the current word -autocmd BufRead *.tex map YpkI\begin{A}jI\end{A}kA -autocmd BufRead *.tex map! YpkI\begin{A}jI\end{A}kA -autocmd BufRead *.tex map :call Synctex() +vnoremap YpkI\begin{A}jI\end{A}kA +nmap :call Synctex() + +"setlocal spell spelllang=en_US + +call CompileMainDoc() " autocmd BufRead *.tex imap /\ \land " autocmd BufRead *.tex imap \/ \lor -- cgit v1.3