Issue
I'm trying to define custom mappings for the <plug>(vimtex-compile-toggle) and <plug>(vimtex-view) commands which by default are <localleader>ll and <localleader>lv respectively. I wish to change the mapping for <plug>(vimtex-compile-toggle) to <localleader>c and <plug>(vimtex-view) to <localleader>v.
I defined these mappings in my init.vim as follows:
augroup vimrc_tex
au!
au FileType tex nmap <buffer><silent> <localleader>c <plug>(vimtex-compile-toggle)
au FileType tex nmap <buffer><silent> <localleader>v <plug>(vimtex-view)
augroup END
The mapping for <plug>(vimtex-view) works just fine when I run <localleader>v but <plug>(vimtex-compile-toggle) doesn't work. Running <localleader>c does nothing.
The default mapping however (<localleader>ll) works just fine.
Commands/Input
When I run nvim -u minimal.vim minimal.tex, I get the following error:
Error detected while processing /home/ashish/.config/nvim/plugged/vimtex/after/ftplugin/tex.vim:
line 18:
E117: Unknown function: vimtex#util#command
E15: Invalid expression: vimtex#util#command('scriptnames')
line 20:
E121: Undefined variable: s:scriptnames
E116: Invalid arguments for function copy
E116: Invalid arguments for function filter
E116: Invalid arguments for function empty
E15: Invalid expression: !empty(filter(copy(s:scriptnames), "v:val =~# 'latex-box'"))
line 21:
E121: Undefined variable: s:latexbox
E15: Invalid expression: s:latexbox
Error detected while processing /home/ashish/.config/nvim/plugged/vimtex/after/syntax/tex.vim:
line 7:
E117: Unknown function: vimtex#syntax#init
Press ENTER or type command to continue
Observed Behaviour
Running <localleader>c yields nothing. However, removing this mapping and running <localleader>ll works just fine.
Expected Behaviour
Running <localleader>c is expected to compile the document and output vimtex: Compilation completed.
Output from VimtexInfo
System info
OS: Linux 5.4.66-1-lts
Vim version: NVIM v0.4.4
Has clientserver: true
Servername: /tmp/nvimbPy86O/0
vimtex project: minimal
base: minimal.tex
root: /home/ashish/misc
tex: /home/ashish/misc/minimal.tex
out:
log:
aux:
fls:
main parser: current file verified
compiler: latexmk
configuration:
continuous: 1
callback: 1
latexmk options:
-verbose
-file-line-error
-synctex=1
-interaction=nonstopmode
latexmk engine: -pdf
viewer: Zathura
xwin id: 0
qf: LaTeX logfile
addqflist: 61
fix_paths: 62
set_errorformat: 60
document class: minimal
When I run nvim -u minimal.vim minimal.tex, I get the following error:
Ok, this looks strange. What is the content of your minimal.vim?
Ok, this looks strange. What is the content of your
minimal.vim?
set nocompatible
let &rtp = '~/.config/nvim/plugged/vimtex' . &rtp
let &rtp .= ',~/.config/nvim/plugged/vimtex/after'
let mapleader=","
let maplocalleader=","
let g:tex_flavor = "latex"
let g:vimtex_view_method = "zathura"
The original issue is about the mappings. The reason it does not work is because there is no such thing as <plug>(vimtex-compile-toggle). It is called <plug>(vimtex-compile). If you make this change, then things should work.
Regarding the second issue (please, in the future, open a _single_ issue for each problem/question/task!): Do you have this problem normally? Or does it only show when you use the minimal vimrc file?
The original issue is about the mappings. The reason it does not work is because there is no such thing as
<plug>(vimtex-compile-toggle). It is called<plug>(vimtex-compile). If you make this change, then things should work.
Thanks a lot! It does work. I had taken <plug>(vimtex-compile-toggle) from the wiki instead of the in-built documentation. The wiki has to be updated accordingly.
Regarding the second issue (please, in the future, open a _single_ issue for each problem/question/task!): Do you have this problem normally? Or does it only show when you use the minimal vimrc file?
I had originally never planned to post this error message since it does not hinder my workflow. It only appeared during my testing with minimal.vim and does not appear with my init.vim. I thought it might pertain to my main issue, which is why I posted it. Apologies for that.
Great, happy to hear it works. Feel free to open a new issue if you should have more problems like the error message in your OP.
@lervag Thanks a lot as always! :)