From d85607e1430431124c53c195e04648935b61d035 Mon Sep 17 00:00:00 2001 From: druckdev <63563978+druckdev@users.noreply.github.com> Date: Mon, 23 Nov 2020 01:49:19 +0100 Subject: [PATCH] vim,zathura: Setup LaTeX file development LaTeX files can now be automatically compiled in vim and jumping into the relevant lines from PDF to code or the other way around is possible too. Add the LaTeX coc-language server as well. Thanks to @AurelWeinhold --- .config/vim/pack/plugins/opt/vimtex | 1 + .config/vim/vimrc | 7 ++++++- .config/vim/vimtex.vim | 24 ++++++++++++++++++++++++ .config/zathura/zathurarc | 4 ++++ .gitmodules | 3 +++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 160000 .config/vim/pack/plugins/opt/vimtex create mode 100644 .config/vim/vimtex.vim diff --git a/.config/vim/pack/plugins/opt/vimtex b/.config/vim/pack/plugins/opt/vimtex new file mode 160000 index 0000000..7c886a0 --- /dev/null +++ b/.config/vim/pack/plugins/opt/vimtex @@ -0,0 +1 @@ +Subproject commit 7c886a0731f1aa283899575615b75192ec3632b7 diff --git a/.config/vim/vimrc b/.config/vim/vimrc index 32b8f78..7cc554a 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -1,11 +1,13 @@ " Set leader key let mapleader = "\" +let maplocalleader = mapleader " Plugins ###################################################################### " Auto completion " needs vim >= 8.1.1719 to support features like popup and text property. if (has('patch-8.1.1719') || has('nvim')) - let g:coc_global_extensions = ['coc-clangd', 'coc-sh', 'coc-python'] + let g:coc_global_extensions = + \ ['coc-clangd', 'coc-sh', 'coc-python', 'coc-vimtex'] packadd! coc.nvim source $XDG_CONFIG_HOME/vim/coc.nvim.vim endif @@ -17,6 +19,9 @@ packadd! fzf.vim nmap f :Files " Theme packadd! onedark.vim +" LaTeX +packadd! vimtex +source $XDG_CONFIG_HOME/vim/vimtex.vim " Git information packadd! vim-gitgutter " Surround text with parentheses, brackets, quotes, tags, etc. diff --git a/.config/vim/vimtex.vim b/.config/vim/vimtex.vim new file mode 100644 index 0000000..41de01a --- /dev/null +++ b/.config/vim/vimtex.vim @@ -0,0 +1,24 @@ +let g:tex_flavor = "latex" +let g:vimtex_compiler_progname = 'nvr' + +" Setup latexmk and make callback possible with synctex +" (Click into PDF to land in code) +let g:vimtex_compiler_latexmk = { +\ 'build_dir' : 'build', +\ 'callback' : 1, +\ 'continuous' : 1, +\ 'executable' : 'latexmk', +\ 'hooks' : [], +\ 'options' : [ +\ '-verbose', +\ '-file-line-error', +\ '-synctex=1', +\ '-interaction=nonstopmode', +\ '-shell-escape', +\ ], +\} + +" synctex needs to be activated in zathurarc as well +let g:vimtex_context_pdf_viewer='zathura' +let g:vimtex_view_general_viewer = 'zathura' +let g:vimtex_view_method='zathura' diff --git a/.config/zathura/zathurarc b/.config/zathura/zathurarc index c76fc34..a3ed8d3 100644 --- a/.config/zathura/zathurarc +++ b/.config/zathura/zathurarc @@ -16,3 +16,7 @@ set recolor-reverse-video true # Search while typing set incremental-search true + +# vimtex +set synctex true +set synctex-editor-command "nvr --remote +%{line} %{input}" diff --git a/.gitmodules b/.gitmodules index 4dd676d..96a7404 100644 --- a/.gitmodules +++ b/.gitmodules @@ -58,3 +58,6 @@ [submodule ".local/bin/fzf-repo"] path = .local/bin/fzf-repo url = https://github.com/junegunn/fzf +[submodule ".config/vim/pack/plugins/opt/vimtex"] + path = .config/vim/pack/plugins/opt/vimtex + url = https://github.com/lervag/vimtex