lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.51k stars 389 forks source link

init error when opening a .sty file #682

Closed verga closed 7 years ago

verga commented 7 years ago

Hi! I get the error message

"min.sty" 3L, 62C
Error detected while processing function vimtex#init[39]..<SNR>57_init_mappings:

line   94:
E716: Key not present in Dictionary: viewer, 'reverse_search')
E116: Invalid arguments for function has_key(b:vimtex.viewer, 'reverse_search')
E15: Invalid expression: has_key(b:vimtex.viewer, 'reverse_search')

when trying to open a .sty file.

Minimal example:

min.sty:

\NeedsTeXFormat{LaTeX2e}                                                   
\ProvidesPackage{varticle}                                                 
\endimput 

.vimrc

set nocompatible

" Load Vimtex
let &rtp  = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'

" Load other plugins, if necessary
" let &rtp = '~/path/to/other/plugin,' . &rtp

filetype plugin indent on
syntax enable

The command vim min.sty gives the error.

lervag commented 7 years ago

Strange. I can't reproduce. I did vim -u minivimrc min.sty, where minivimrc is the name I used for the minimal vimrc file.

Are you using the latest version of vimtex? Which version of Vim are you using?

clason commented 7 years ago

I can reproduce this with vim8 (8.0.311) and neovim (0.1.7), if the minivimrc has the additional line au BufNewFile,BufRead *.cls,*.sty set ft=tex

and if I open the style file in a new window from a standard tex file:

  1. vim -u minivimrc $ANY_TEX_FILE
  2. <ctrl-w,n>
  3. :e min.sty
verga commented 7 years ago

I'am using the latest versions (from homebrew):

macvim: stable 8.0-126 (bottled), HEAD
GUI for vim, made for macOS
https://github.com/macvim-dev/macvim
/usr/local/Cellar/macvim/8.0-126 (2,115 files, 33.7M) *
  Built from source on 2017-02-07 at 16:02:11 with: --with-lua --with-luajit --with-override-system-vim --with-python3 --without-python

compiled with python 3 (without python2) I also often update the vimtex plugin (last time, today).

For reference vim --version gives:

vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb  7 2017 16:01:56)
MacOS X (unix) version
Included patches: 1-297
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +find_in_path    -mouse_sysmouse  -tag_any_white
+arabic          +float           +mouse_urxvt     +tcl
+autocmd         +folding         +mouse_xterm     +termguicolors
+balloon_eval    -footer          +multi_byte      +terminfo
+browse          +fork()          +multi_lang      +termresponse
++builtin_terms  +fullscreen      -mzscheme        +textobjects
+byte_offset     -gettext         +netbeans_intg   +timers
+channel         -hangul_input    +num64           +title
+cindent         +iconv           +odbeditor       +toolbar
+clientserver    +insert_expand   +packages        +transparency
+clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        +perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con_gui  +lua             +rightleft       +writebackup
+diff            +menu            +ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
+dnd             +modify_fname    +signs           +xim
-ebcdic          +mouse           +smartindent     -xpm
+emacs_tags      +mouseshape      +startuptime     -xsmp
+eval            +mouse_dec       +statusline      -xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          
+farsi           +mouse_netterm   +tag_binary      
+file_in_path    +mouse_sgr       +tag_old_static  
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -L/usr/local/lib -L. -L/usr/local/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework Cocoa  -pagezero_size 10000 -image_base 100000000 -L/usr/local/opt/luajit/lib -lluajit-5.1 -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl  -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework Ruby    
verga commented 7 years ago

Try using the option

" Vimtex options go here
"
let g:vimtex_view_enabled = 1

added at the end of the minimal vimrc, and then the command vi -u .vimrc min.sty

lervag commented 7 years ago

g:vimtex_view_enabled is already set to 1 by default, so that option changes nothing. I still can not reproduce based on your input, @verga.

lervag commented 7 years ago

However, I can reproduce when following @clason's steps. Looking into it now.

lervag commented 7 years ago

Sorry, @verga, my fault. Setting the option really does make the error appear. I've understood the problem now, should be able to fix it pretty fast.

clason commented 7 years ago

That fixes the error on opening for me; but now I get an error on closing (which I think was already there before the fix; I just always focused on the first one). Same steps as above, followed by

  1. <ctrl+w,q> (or )

yields

Error detected while processing function <SNR>66_clean_on_quit:
line    2:
E716: Key not present in Dictionary: pid > 0