lervag / vimtex

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

i am facing the error while opening latex fiels in vimtex #2763

Closed Aneeqasif closed 1 year ago

Aneeqasif commented 1 year ago

Description

image

Steps to reproduce

-- Disable imaps (using Ultisnips)
-- vim.g.vimtex_imaps_enabled = 0
-- Do not open pdfviwer on compile
-- vim.g.vimtex_view_automatic = 0
-- Disable conceal
vim.g.vimtex_syntax_conceal = {
    accents = 1,
    cites = 1,
    fancy = 1,
    greek = 1,
    math_bounds = 1,
    math_delimiters = 1,
    math_fracs = 1,
    math_super_sub = 1,
    math_symbols = 1,
    sections = 1,
    styles = 1,
}
vim.api.nvim_command('set conceallevel=2')

-- PDF viewer settings
-- for zathura
-- vim.g.vimtex_view_general_viewer = "zathura"
-- vim.g.vimtex_view_method = "zathura"
-- vim.g['vimtex_context_pdf_viewer'] = 'zathura'

--  for okular

vim.g['vimtex_context_pdf_viewer'] = 'okular'
vim.g.vimtex_view_general_viewer = "okular"
vim.cmd([[

    let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
    " let g:vimtex_view_general_options_latexmk = '--unique' 
]])

vim.g.tex_conceal= "abdmg"

vim.cmd([[
let g:vimtex_mappings_prefix = '<localleader>v'
let g:vimtex_imaps_leader = "`"

" let g:vimtex_grammar_textidote = {
"       \ 'jar': '/usr/share/java/textidote.jar',
"       \ 'args': '',
"       \}

set spelllang=en_gb

" let g:vimtex_grammar_vlty = {
"       \ 'lt_directory': '/usr/bin/',
"       \ 'lt_command': 'languagetool',
"       \ 'lt_disable': 'WHITESPACE_RULE',
"       \ 'lt_enable': '',
"       \ 'lt_disablecategories': '',
"       \ 'lt_enablecategories': '',
"       \ 'server': 'my',
"       \ 'shell_options': '',
"       \ 'show_suggestions': 1,
"       \ 'encoding': 'auto',
"       \}

" let g:livepreview_engine = 'latexmk' . ' ["-shell-escape"]' 
let g:vimtex_complete_enabled = 1
" let g:vimtex_compiler_progname = 'nvr'
" let g:vimtex_compiler_latexmk.options += ['-shell-escape']
" Silent all messages
" let g:vimtex_compiler_silent=1

let g:vimtex_toc_config = {
    \'split_width':  30,
    \'show_help':  0,
    \'layer_status' : { 
        \'content': 1,
        \'label': 0,
        \'todo': 1,
        \'include': 0 
    \ }
    \}

let g:vimtex_log_ignore = [
      \ 'Underfull \\hbox',
      \ 'Overfull \\hbox',
      \ 'LaTeX Warning: .\+ float specifier changed to',
      \ 'LaTeX hooks Warning',
      \ 'Package siunitx Warning: Detected the "physics" package:',
      \ 'Package hyperref Warning: Token not allowed in a PDF string',
      \ 'Compilation completed',
      \]

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

" let vim.g.vimtex_compile_latexmk_engines = {
"   ['_'] = '-xelatex',
" }
]])

-- Disable quickfix auto open
vim.g.vimtex_quickfix_ignore_mode = 0

-- vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf"
-- Do not auto open quickfix on compile erros
vim.g.vimtex_quickfix_mode = 0

vim.g.vimtex_fold_enabled = 1
vim.g.vimtex_fold_manual = 1

Expected behavior

No response

Actual behavior

Whenever it try to open a file it just through error. the plugin keybindings and commandly only work if the file is main.tex. otherwise it throues some autocmd error.

Do you use a latexmkrc file?

# $pdflatex = 'pdflatex -synctex=1 %O %S';

$latex = 'latex -synctex=1 %O  --shell-escape %S';
$pdflatex = 'pdflatex -synctex=1 -interaction=nonstopmode %O  --shell-escape %S';

VimtexInfo

System info:
  OS: ArcoLinux
  Vim version: NVIM v0.9.1
  Has clientserver: true
  Servername: /run/user/1000/lvim.253396.0

VimTeX project: main
  base: main.tex
  root: /home/aneeq/Documents/FYP/latex/thesis-bs
  tex: /home/aneeq/Documents/FYP/latex/thesis-bs/main.tex
  main parser: current file verified
  document class: report
  packages: amsbsy amsfonts amsgen amsmath amsopn amssymb amstext babel blindtext caption caption3 cite color epsfig etoolbox fancyhdr float geometry graphics graphicx hyperref inputenc keyval lmodern mathdots pdftexcmds setspace siunitx subcaption translations trig url wrapfig xcolor
  source files:
    main.tex
    TP1.tex
    blankpage.tex
    submission approval.tex
    TP2.tex
    dedications.tex
    Abstract.tex
    Chapter 1.tex
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: General
  qf method: LaTeX logfile
lervag commented 1 year ago

Thanks, I think my last commit may have fixed your problem. Can you update and test?


Your configuration is quite "messy". The following is a reduced version of your configuration where I've:

  1. removed (IMHO) unnecessary comments,
  2. removed unnecessary settings (e.g. where you set things that are already default), and
  3. converted to pure Lua.
-- Notice that these options are window and buffer local options
vim.wo.conceallevel = 2
vim.bo.spelllang = "en_gb"

vim.g.vimtex_syntax_conceal = {
    sections = 1,
}

vim.g.vimtex_context_pdf_viewer = "okular"
vim.g.vimtex_view_general_viewer = "okular"
vim.g.vimtex_view_general_options = "--unique file:@pdf\\#src:@line@tex"

vim.g.vimtex_mappings_prefix = "<localleader>v"

vim.g.vimtex_toc_config = {
    show_help = 0,
    layer_status = {
        content = 1,
        label = 0,
        todo = 1,
        include = 0
    }
}

vim.g.vimtex_log_ignore = {
    "Underfull \\\\hbox",
    "Overfull \\\\hbox",
    "LaTeX Warning: .\\+ float specifier changed to",
    "LaTeX hooks Warning",
    'Package siunitx Warning: Detected the "physics" package:',
    "Package hyperref Warning: Token not allowed in a PDF string",
    "Compilation completed",
}

vim.g.vimtex_quickfix_mode = 0

vim.g.vimtex_fold_enabled = 1
vim.g.vimtex_fold_manual = 1
Aneeqasif commented 1 year ago

the issue got fixed. thank you so much for that :heart: . i have a lil problem with inverse search through zathura like by shift+r-click to get to the code in latex (which does work in okular) can u give me some pointer how to do that or what can be issue for this. :)

zathura --version (from arch official extra repo)
zathura 0.5.2
girara 0.3.9 (runtime: 0.4.0)
(plugin) djvu (0.2.9) (/usr/lib/zathura/libdjvu.so)
(plugin) pdf-mupdf (0.4.0) (/usr/lib/zathura/libpdf-mupdf.so)

and how can i do add this in lua i need to do it when working with using minted package -- " let g:vimtex_compiler_latexmk.options += ['-shell-escape']

lervag commented 1 year ago

the issue got fixed. thank you so much for that

Glad to hear it!

i have a lil problem with inverse search through zathura like by shift+r-click to get to the code in latex (which does work in okular) can u give me some pointer how to do that or what can be issue for this. :)

Inverse search in Zathura is activated with ctrl + right-click. Perhaps that's your problem?

and how can i do add this in lua i need to do it when working with using minted package -- " let g:vimtex_compiler_latexmk.options += ['-shell-escape']

vim.g.vimtex_compiler_latexmk = {
    options = {
      "-verbose",
      "-file-line-error",
      "-synctex=1",
      "-interaction=nonstopmode",
      "-shell-escape",
    }
}
Aneeqasif commented 1 year ago

Inverse search in Zathura is activated with ctrl + right-click

yeah i have tried this many times and it donot work :(

lervag commented 1 year ago

Strange. It works for me. I'm also on Arch Linux.

What's the output of these commands?

ldd /usr/bin/zathura|grep sync
zathura --help|grep -- -x

Also, can you provide a proper minimal example for this? Preferable with a minimal vimrc file, e.g. test.vim with this content:

set nocompatible
set runtimepath^=~/.local/plugged/vimtex
set runtimepath+=~/.local/plugged/vimtex/after
filetype plugin indent on
syntax enable

let g:vimtex_view_method = 'zathura'

Change ~/.local/plugged/vimtex to the path to VimTeX on your computer.

Also, create a corresponding minimal LaTeX file, e.g. test.tex:

\documentclass{minimal}
\begin{document}
Hello World!
\newpage
Hello Moon!
\end{document}

Then, from a terminal, do: nvim --clean -u test.vim test.tex and check if things work with the minimal config and example.

Aneeqasif commented 1 year ago

i can not make it work with the test.vim as vimtex commands were not available. with following settings test.vim

set nocompatible
set runtimepath^=~/.local/share/nvim/lazy/vimtex
set runtimepath+=~/.local/share/nvim/lazy/vimtex/after/ftplugin
filetype plugin indent on
syntax enable

let g:vimtex_view_method = 'zathura'

the tree is

/home/aneeq/.local/share/nvim/lazy/vimtex
├── after
│   └── ftplugin
├── assets
│   └── json
├── autoload
│   ├── health
│   ├── unite
│   ├── vimtex
│   └── vimtex.vim
├── cliff.toml
├── compiler
│   ├── bibertool.vim
│   ├── chktex.vim
│   ├── lacheck.vim
│   ├── style-check.vim
│   ├── textidote.vim
│   └── vlty.vim
├── CONTRIBUTING.md
├── doc
│   ├── tags
│   ├── targets-textobj-cheatsheet.md
│   └── vimtex.txt
├── docker
│   └── Dockerfile
├── DOCUMENTATION.md
├── ftdetect
│   ├── cls.vim
│   ├── tex.vim
│   └── tikz.vim
├── ftplugin
│   ├── bib.vim
│   └── tex.vim
├── .github
│   ├── ISSUE_TEMPLATE
│   └── workflows
├── .gitignore
├── indent
│   ├── bib.vim
│   └── tex.vim
├── LICENSE.md
├── plugin
│   └── vimtex.vim
├── README.md
├── rplugin
│   └── python3
├── syntax
│   └── tex.vim
├── test
│   ├── common
│   ├── example-book
│   ├── example-book-multifile
│   ├── example-minimal
│   ├── example-performance
│   ├── example-quickfix
│   ├── example-quick-start
│   ├── example-startup-timing
│   ├── Makefile
│   ├── test-bibfiles
│   ├── test-cache
│   ├── test-commands
│   ├── test-compiler
│   ├── test-compiler-generic
│   ├── test-compiler-method-dynamic
│   ├── test-compiler-pdfmode
│   ├── test-compiler-selected
│   ├── test-completion-bibstyle
│   ├── test-completion-bibtex
│   ├── test-completion-bibtex-speed
│   ├── test-completion-commands
│   ├── test-completion-documentclass
│   ├── test-completion-environments
│   ├── test-completion-filenames
│   ├── test-completion-glossary
│   ├── test-completion-glossary-texinputs
│   ├── test-completion-labels
│   ├── test-completion-packages
│   ├── test-context-cite
│   ├── test-delim
│   ├── test-doc
│   ├── test-env
│   ├── test-folding
│   ├── test-folding-bib
│   ├── test-formatting
│   ├── test-getfile
│   ├── test-get-main
│   ├── test-imaps
│   ├── test-include
│   ├── test-indentation
│   ├── test-indentation-timing
│   ├── test-jobs
│   ├── test-matchparen-speed
│   ├── test-metadata
│   ├── test-motions
│   ├── test-motions-virtual
│   ├── test-parser-bib
│   ├── test-parser-cmds
│   ├── test-parser-tex
│   ├── test-parser-toc
│   ├── test-paths
│   ├── test-quickfix
│   ├── test-quickfix-fix-path
│   ├── test-state
│   ├── test-subfiles
│   ├── test-syntax
│   ├── test-texflavor
│   ├── test-textobj
│   ├── test-textobj-targets
│   ├── test-toc
│   ├── test-toc-speed
│   ├── test-utils
│   ├── test-view
│   └── test-wordcount
├── .vintrc.yaml
└── VISUALS.md

86 directories, 29 files

output for required commands are

ldd /usr/bin/zathura|grep sync
        libsynctex.so.2 => /usr/lib/libsynctex.so.2 (0x00007f5d194b7000)

#####

zathura --help|grep -- -x
  -x, --synctex-editor-command=cmd     Synctex editor (forwarded to the synctex command)
lervag commented 1 year ago

i can not make it work with the test.vim as vimtex commands were not available.

Well, then we need to figure out why.

Ok, do this:

cd $HOME
mkdir test
cd test
touch test.vim
touch test.tex
# add content to the above files, then
nvim --clean -u test.vim test.tex

The content of test.tex is the same as mentioned in my previous post. The content of test.vim is this (almost the same as what you just posted):

set nocompatible

set runtimepath^=/home/aneeq/.local/share/nvim/lazy/vimtex
set runtimepath+=/home/aneeq/.local/share/nvim/lazy/vimtex/after
filetype plugin indent on
syntax enable

let g:vimtex_view_method = 'zathura'

After doing nvim --clean -u test.vim test.tex, you should be able to do :VimtexCompile to start compilation. Can you confirm that?

output for required commands are …

Good, this indicates that we should be able to make everything work.


Also: I notice you are using lazy.nvim; please confirm that you do not lazy load VimTeX.

Aneeqasif commented 1 year ago

yes i am able to compile and :VimtexView to the specific line in zathura but i cant do ctrl+right click to go back to neovim latex line of interest through zathura . the cursos just stays at its position. i was using xbindkey that had a similiar shortcut for a bash script but even after killing it the zathura synctex is not working. :(

lervag commented 1 year ago

Ah, sorry, I've been thinking about this the wrong way. I did ask an important question that you never answered:

Also: I notice you are using lazy.nvim; please confirm that you do not lazy load VimTeX.

Can you show me your current actual configuration, i.e. not the minimal one? If you have it on github, e.g.?

lervag commented 1 year ago

To be clear: I believe you are lazy loading VimTeX, which will essentially break this exact feature.

Aneeqasif commented 1 year ago

To be clear: I believe you are lazy loading VimTeX, which will essentially break this exact feature.

mmmm this is my lazy config

  {"lervag/vimtex",
    lazy=false,
    ft = {"tex","bib"},
    config = function()
      require("custom.configs.vimtex")
    end,
  },

but by defualt lazy is configured to lazy load all plugins . i also have vim can i install vimtex and test it from a short init.vim file.

lervag commented 1 year ago

mmmm this is my lazy config …

Yes: The ft = ... implies that you are lazy loading VimTeX. Please remove that line. I believe things will work as expected afterwards.

but by defualt lazy is configured to lazy load all plugins .

I assume this means you are using LazyVim? lazy.nvim (the plugin manager) does not lazy load by default, but it can be configured to do so.

i also have vim can i install vimtex and test it from a short init.vim file.

That will not be necessary.