lervag / vimtex

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

lots of errors despite a successful install #2917

Closed brotherJ4mes closed 6 months ago

brotherJ4mes commented 6 months ago

Description

I think I've done all the sanity checks. I'm running vim 8.0.1763, Latexmk 4.80 and I've read the help page on requirements.

I installed via vim-plug and when I run :PlugInstall I get a successful message. (To isolate issues/conflcits I've remove all other packages) I've also removed everything from my ~/.vimrc except:

call plug#begin()
Plug 'lervag/vimtex'
call plug#end()

let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'mupdf-x11'
let g:vimtex_compiler_latexmk= {'options' : ['-pdf', '-shell-escape', '-verbose', '-file-line-error', '-synctex=1', '-interaction=nonstopmode',],}
let g:vimtex_fold_enabled = 1

filetype plugin indent on
syntax enable

When I first open a .tex file with vim, I get a bunch of invalid expression and undefined errors:

"main.tex" [New File]
Error detected while processing /home/j4mes/.vim/plugged/vimtex/autoload/vimtex/syntax/core.vim:
line 1404:
E15: Invalid expression: . join([     'beta', 'gamma', 'rho', 'phi', 'chi' ], '\|') . '\)\>'
E15: Invalid expression: '[-+=()0-9aehijklmnoprstuvx]\|\\\%(' .. join([     'beta', 'gamma', 'rho', 'phi', 'chi' ], '\|') . '\)\>'
line 1409:
E15: Invalid expression: . join([     'beta', 'gamma', 'delta', 'epsilon', 'theta', 'iota', 'phi', 'chi' ], '\|') . '\)\>'
E15: Invalid expression: '[-+=()<>:;0-9a-qr-zA-FG-QRTUVW]\|\\\%(' .. join([     'beta', 'gamma', 'delta', 'epsilon', 'theta', 'iota', 'phi', 'chi' ], 
'\|') . '\)\>'
Error detected while processing function vimtex#syntax#core#init_rules[624]..<SNR>98_match_math_sub_super:
line   10:
E121: Undefined variable: s:re_super
E15: Invalid expression: '"\^\%(' . s:re_super . '\)"' 'conceal contained contains=texMathSuper'
Error detected while processing function vimtex#syntax#core#init_post[12]..vimtex#syntax#packages#init[14]..vimtex#syntax#p#amsmath#load:
line   10:
E121: Undefined variable: #
E116: Invalid arguments for function vimtex#syntax#core#new_env

If I continue past the errors I can use vim regularly and I've found that some features of vim-tex actaully do work (like syntax folding, which I've enabled) or view quick fix errors.

However, most features appear broke (examples below). I'm guessing I'm just doing something dumb/obvious but can't figure it out after a week or two of trying. This seems like such a great tool (and way more sophisticated than my current approach of a bash script, entr and and pkill -HUP mupdf) and I'd love to be able to use it.

Many thanks for any ideas or suggestions to resolve this.


Here's what I get If it try to compile with \ll

Error detected while processing function vimtex#compiler#compile[6]..vimtex#compiler#start:
line   17:
E117: Unknown function: expandcmd
E116: Invalid arguments for function 38

and here's when I try to view table of contents with \lt I get:

Error detected while processing /home/j4mes/.vim/plugged/vimtex/autoload/vimtex/parser/toc/labels.vim:
line   19:
E15: Invalid expression: . '\\label\{\zs.{-}\ze\}', 'format': '%s%s',}
E15: Invalid expression: { 'label_dict': {}, 'prefilter_cmds': ['label'], 'priority': 1, 're': g:vimtex#re#not_comment .. '\\label\{\zs.{-}\ze\}', 'format': '%s%s',}
line   20:
E121: Undefined variable: s:matcher
line   21:
E461: Illegal variable name: l:labels
line   23:
E121: Undefined variable: self
line   24:
E121: Undefined variable: l:labels
E15: Invalid expression: l:labels
line   28:
E461: Illegal variable name: l:wininfo
line   29:
E121: Undefined variable: l:wininfo
E15: Invalid expression: l:wininfo.width - l:wininfo.textoff - 2
line   31:
E461: Illegal variable name: l:width
line   33:
E121: Undefined variable: l:width
line   34:
E121: Undefined variable: l:width
E15: Invalid expression: l:width/2
line   35:
E121: Undefined variable: l:width
E15: Invalid expression: l:width - l:w1
line   36:
E15: Invalid expression: . l:w1 .. 's%' .. l:w2 .. 's'
E15: Invalid expression: '%-' .. l:w1 .. 's%' .. l:w2 .. 's'
line   37:
E193: :endfunction not inside a function
line   40:
E121: Undefined variable: s:matcher
line   41:
E121: Undefined variable: a:context
E116: Invalid arguments for function matchstr(a:context.line, self.re)
E15: Invalid expression: matchstr(a:context.line, self.re)
line   42:
E121: Undefined variable: self
E116: Invalid arguments for function get(self.label_dict, l:key, '')
E15: Invalid expression: get(self.label_dict, l:key, '')
line   52:
E133: :return not inside a function
line   53:
E193: :endfunction not inside a function
Error detected while processing function 72[12]..77[5]..vimtex#parser#toc[13]..vimtex#parser#toc#parse[3]..vimtex#parser#toc#get_matchers[10]..vimtex#parser#toc#labels#new:
line    1:
E121: Undefined variable: s:matcher
E15: Invalid expression: s:matcher
Error detected while processing function 72[12]..77[5]..vimtex#parser#toc[13]..vimtex#parser#toc#parse[3]..vimtex#parser#toc#get_matchers:
line   10:
E712: Argument of extend() must be a List or Dictionary

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Linux 4.18.0-513.18.1.el8_9.x86_64
  Vim version: VIM 8.0 (1-1763)
  Has clientserver: false

VimTeX project: test
  base: test.tex
  root: /home/j4mes
  tex: /home/j4mes/test.tex
  main parser: fallback current file
  document class: 
  compiler: latexmk
    engine: -pdf
    options:
      -pdf
      -shell-escape
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  qf method: LaTeX logfile
lervag commented 6 months ago

I think I've done all the sanity checks. I'm running vim 8.0.1763, Latexmk 4.80 and I've read the help page on requirements.

Seems like a good start! Notice, though, that Vim 8.0.1763 is really quite old! Although it should work, I do plan to bump requirements by quite a lot in not too far future. So I advice that you update your Vim version!

I also notice from the :VimtexInfo output that you are running Linux 4.18 - I'm curious, which distro are you using? If you really are on kernel version 4.18, you should seriously consider to update your system! See here - this kernel version is even outside its LTS support window.

call plug#begin()
Plug 'lervag/vimtex'
call plug#end()

let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'mupdf-x11'
let g:vimtex_compiler_latexmk= {'options' : ['-pdf', '-shell-escape', '-verbose', '-file-line-error', '-synctex=1', '-interaction=nonstopmode',],}
let g:vimtex_fold_enabled = 1

filetype plugin indent on
syntax enable

I'm curious, why do you have let g:tex_flavor = 'latex' - I mean, where did you find the suggestion to include it? You can safely remove it and it has not been relevant for ~5 years now.

'mupdf-x11' is not a valid view method. You probably want to use let g:vimtex_view_method = 'mupdf'. Further, -pdf should not be added to the compiler options. Finally, with vim-plug, you don't need the last two lines. Thus, you can simplify your listed config to this:

call plug#begin()
Plug 'lervag/vimtex'
call plug#end()

let g:vimtex_view_method = 'mupdf'
let g:vimtex_compiler_latexmk = {
      \ 'options': [
      \   '-shell-escape',
      \   '-verbose',
      \   '-file-line-error',
      \   '-synctex=1',
      \   '-interaction=nonstopmode',
      \ ]
      \}
let g:vimtex_fold_enabled = 1

When I first open a .tex file with vim, I get a bunch of invalid expression and undefined errors: …

Hah, I think this is because I use the .. variant for string concatenation. I was not aware this is not backwards compatible. It seems this syntax was only available from Vim version 8.1.114.

As mentioned, I plan to bump the version requirements, and instead of reverting things for backwards compatibility, I would kindly ask you to install a more recent Vim version. I hope that will work for you.

Error detected while processing function vimtex#compiler#compile[6]..vimtex#compiler#start:
line   17:
E117: Unknown function: expandcmd
E116: Invalid arguments for function 38

Hah, one more feature I've used that will need for bumped requirements. This one requires version 8.1.1510.

and here's when I try to view table of contents with \lt I get: …

This is another problem due to the .. syntax.

brotherJ4mes commented 6 months ago

Wow okay thanks much for the quick reply for all the detailed tips!

It does appear that I'm using that very old kernel (at least that's what uname -r reveals) and I'm running Rocky8.

I had tried upgrading vim via package manager but saw that I already had the latest in the repos (which I understand now is also quite old.) I just built vim 9 from source and vimtex is working great! (Thanks for developing this awesome tool!)

The mupdf-x11 was just b/c that was the name of the mupdf binary and it seemed like vimtex couldn't find my mupdf by that name. I just changed the view method back to simply "mupdf" and then created a symlink: /usr/local/bin/mupdf -> /usr/local/bin/mupdf-x11 (seems to be working fine now but not sure if there are more elegant suggestions)

The one thing I still can't figure out is that now I'm getting weird characters floating around in vim when editing tex files. Screenshot attached. They seem to go away if I remove vimtex (though I do still seem to get them when I close vi at the beginning of my terminal prompt....I also eliminate all other lines in my ~/.vimrc again just to make sure)

I read some places that it may be related to my encoding variable in my .viminfo but I'm not smart enough to know how to change that.

screen

Any thoughts?

lervag commented 6 months ago

Wow okay thanks much for the quick reply for all the detailed tips!

No problem.

It does appear that I'm using that very old kernel (at least that's what uname -r reveals) and I'm running Rocky8.

I see; Wikipedia has a nice list of the version history. It seems Rocky 8.9 is still maintained, but I would strongly enourage you to update your distro! And if you do, you should consider to use a distro with more recent kernels.

I had tried upgrading vim via package manager but saw that I already had the latest in the repos (which I understand now is also quite old.) I just built vim 9 from source and vimtex is working great! (Thanks for developing this awesome tool!)

Great, glad to hear it!

The mupdf-x11 was just b/c that was the name of the mupdf binary and it seemed like vimtex couldn't find my mupdf by that name. I just changed the view method back to simply "mupdf" and then created a symlink: /usr/local/bin/mupdf -> /usr/local/bin/mupdf-x11 (seems to be working fine now but not sure if there are more elegant suggestions)

I think symlinking is a very valid way to fix this.

The one thing I still can't figure out is that now I'm getting weird characters floating around in vim when editing tex files. Screenshot attached. They seem to go away if I remove vimtex (though I do still seem to get them when I close vi at the beginning of my terminal prompt....I also eliminate all other lines in my ~/.vimrc again just to make sure)

I believe this is due to the conceal feature. VimTeX uses it to replace e.g. \alpha with α. If your terminal font doesn't support these symbols, then it will not work well.

You can disable the conceal feature entirely with let g:vimtex_syntax_conceal_disable = 1. That should also help you to check if this is indeed the problem.

brotherJ4mes commented 6 months ago

My goofy chars ended up being related to vim v9 and had nothing to do with vimtex.

issue #11728 on the vim github page

A lot of suggestions there but if anyone else runs into this, what worked for me was adding the following to my .vimrc:

set keyprotocol=
let &term=&term

Thanks again for all the support.

lervag commented 6 months ago

Glad to hear you figured it out!