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 +++++++++++++++++++++++++++++++++----------- .config/vim/vimrc | 22 ++++++------- 2 files changed, 66 insertions(+), 29 deletions(-) (limited to '.config/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 diff --git a/.config/vim/vimrc b/.config/vim/vimrc index 6c6ad49..e7134db 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -26,6 +26,7 @@ set formatoptions+=tcroqn2bmj set number set nowrap set splitright +set conceallevel=2 " Fix shift-tab exe 'set t_kB=' . nr2char(27) . '[Z' @@ -57,15 +58,11 @@ syntax enable set background=dark set colorcolumn=81 - -"let &t_8f = "\[38:2:%lu:%lu:%lum" -"let &t_8b = "\[48:2:%lu:%lu:%lum" - " Colorscheme overrides, for transparency -let g:moonflyTransparent = 1 -let g:moonflyCursorColor = 1 +let g:moonflyTransparent = 1 +let g:moonflyCursorColor = 1 let g:moonflyTerminalColors = 1 -let g:moonflyUndercurls = 1 +let g:moonflyUndercurls = 1 let g:jellybeans_overrides = { 'background': { \ 'guibg': 'none', @@ -117,7 +114,6 @@ let g:syntastic_disabled_filetypes=['asm', 's', 'latex', 'tex', 'javac', 'java'] let g:tex_flavor='latex' let g:vimtex_view_method='zathura' let g:vimtex_quickfix_mode=0 -set conceallevel=2 let g:tex_conceal='abdmg' let g:vimtex_compiler_method = 'latexrun' let g:vimtex_compiler_latexrun = { @@ -168,6 +164,10 @@ map imap A imap I +" Fuzzy Wuzzy bindings +noremap :Files +noremap :Buffers + "autocmd VimEnter * silent !echo -ne "\e[1 q" "autocmd VimResume * silent !echo -ne "\e[1 q" @@ -195,8 +195,8 @@ autocmd VimLeave * silent execute "!echo -e '\e[6 q'" autocmd InsertEnter * silent execute "!echo -ne '\e[6 q'" autocmd InsertLeave * silent execute "!echo -ne '\e[2 q'" -" Undercurls +" Undercurls/spelling let &t_Cs = "\e[4:3m" let &t_Ce = "\e[4:0m" -hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=red -hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=yellow +highlight SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=red +highlight SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=yellow -- cgit v1.3