Closed lee-shun closed 1 year ago
Every time vimtex finishes compiling, if at that moment I am navigating using "h", there will be a weird movement that takes me to the next line.
For example, in the following gif, …
It looks like this is related to nvim-notify.
NOTE: I tried without noice and notify, the bug disappears.
Then it seems this is a bug with either noice or notify. Can you make a minimal example? E.g. something like this:
% test.tex
\documentclass{minimal}
\begin{document}
Hello world
\end{document}
" test.vim
set runtimepath^=~/path/to/vimtex
set runtimepath^=~/path/to/noice.nvim
set runtimepath^=~/path/to/nui.nvim
set runtimepath^=~/path/to/nvim-notify
set runtimepath+=~/path/to/vimtex/after
filetype plugin indent on
syntax enable
lua <<EOF
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_quickfix_mode = 0
vim.g.vimtex_mappings_enabled = 0
vim.g.vimtex_imaps_enabled = 0
vim.g.vimtex_text_obj_enabled = 0
vim.g.vimtex_fold_enabled = 0
vim.g.vimtex_syntax_conceal_disable = 1
vim.g.vimtex_format_enabled = 0
vim.g.vimtex_syntax_enabled = 0
-- options for noice.nvim, etc, goes here
EOF
Now run nvim --clean -u test.vim test.tex
in some test folder and try and reproduce the error.
By the way, regarding your configuration:
ft = "tex"
when loading VimTeX! VimTeX is already properly lazy by use of autoloaded functions and ftplugin/tex.vim
.g:tex_conceal
is irrelevant and you can safely remove it.It is probably related to both nvim-notify and noice. If you can make a minimal example like I've tried to help you start with, then it will be much easier to debug it. So I suggest you start there.
Thank you for your reply! Yes, because when I disable the noice and notify, this bug disappers. I will make a minimal example soon.
Hmmmm, interestingly I use the minimal "test.tex" with my current vim config, but this bug seems to have disappeared...
like this:
Hello! After hundreds of tries, I found that the "callback" option matters. After I put the following setting in my config, this bug disappeared.
let g:vimtex_compiler_latexmk = {
\ 'build_dir' : '',
\ 'callback' : 0, " just disable this one
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'hooks' : [],
\ 'options' : [
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
But would you be so kind to explain to me what exactly the callback does? And why it will generate this weird movement with noice.nvim? @lervag
Yes: the callback option (which you should probably keep enabled!) allows the latexmk
process that VimTeX starts that is responsible for compiling your project to communicate the status ("success", "failed", "new compilation triggered") to VimTeX. This in turn allows for the notifications you see, e.g. "VimTeX: compilation completed" or "VimTeX: compilation failed".
I don't believe there is an error or bug here, and I'm quite convinced that the problem is related to the combination of noice and notify. For debugging this, I would do this:
.vimrc
, init.vim
or init.lua
file with which you can reproduce the problem (similar to how I explained earlier).If you are able to provide both a minimal LaTeX file, a minimal configuration, and a simple set of instructions with which I or anyone else can use to reproduce this problem, then the chance of it being fixed is MUCH higher!
@lervag Thank you for your answer. I just got time to reproduce the issue with the following minimal config:
set termguicolors
call plug#begin('~/.config/nvim/plugged')
Plug 'folke/noice.nvim'
Plug 'MunifTanjim/nui.nvim'
Plug 'rcarriga/nvim-notify'
Plug 'Pocco81/auto-save.nvim'
Plug 'lervag/vimtex'
call plug#end()
lua << EOF
-- notice and notify
require("notify").setup(
{
timeout = 3000,
max_height = function()
return math.floor(vim.o.lines * 0.75)
end,
max_width = function()
return math.floor(vim.o.columns * 0.75)
end,
})
require("noice").setup({
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = false, -- use a classic bottom cmdline for search
command_palette = false, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
})
require("auto-save").setup {}
-- for vimtex
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_quickfix_mode = 0
vim.g.vimtex_mappings_enabled = 0
vim.g.vimtex_imaps_enabled = 0
vim.g.vimtex_text_obj_enabled = 0
vim.g.vimtex_fold_enabled = 0
vim.g.tex_conceal = "abdmg"
vim.g.vimtex_syntax_conceal_disable = 1
vim.g.vimtex_format_enabled = 0
vim.g.vimtex_syntax_enabled = 0
EOF
Compile the following template with the "VimtexCompile" command, and at the same time, move your cursor left or right continuously; after the notify message, you will find your cursor jumping to the next line! Concordia University Thesis Template_debug.zip
I can reproduce this with a much more minimal setup. The steps:
Prepare:
mkdir test
cd test
git clone --depth=1 https://github.com/lervag/vimtex
git clone --depth=1 https://github.com/folke/noice.nvim
git clone --depth=1 https://github.com/MunifTanjim/nui.nvim
Create minimal init.vim
with following contents:
" init.vim
set runtimepath^=vimtex
set runtimepath^=nui.nvim
set runtimepath^=noice.nvim
filetype plugin on
let g:vimtex_quickfix_mode = 0
lua require("noice").setup {}
silent edit test.tex
silent! VimtexClean
normal! 8G
sleep 250m
VimtexCompile
Create minimal test.tex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
Hello \xxx world
\end{document}
Now do nvim --clean -u init.vim
When the file has loaded, press and hold h
Observe that the cursor moves to the next line when the VimTeX callback is finished.
The line of code in VimTeX that is called when this thing happens is here:
The stack trace:
FILE LINE FUNCTION CALL
vimtex/autoload/vimtex/qf/u.vim 15
vimtex/autoload/vimtex/qf/latexlog.vim call vimtex#qf#u#caddfile(self, fnameescape(a:log))
vimtex/autoload/vimtex/qf.vim 127 call b:vimtex.qf.addqflist(l:tex, l:log)
vimtex/autoload/vimtex/qf.vim 46 call vimtex#qf#setqflist()
vimtex/autoload/vimtex/compiler.vim 95 call vimtex#qf#open(0)
vimtex/autoload/vimtex/compiler/_template.vim 500 call vimtex#compiler#callback(l:status)
vimtex/autoload/vimtex/compiler/_template.vim 439 call s:check_callback()
Brief description of this stack trace: The call stack starts from a callback from a jobstart
that is started here:
This callback is used to check for the status of latexmk
and to act accordingly. An error is reported, so VimTeX starts to parse the log file to build the quickfix entries.
As far as I can understand, there is no bug on the VimTeX side. I have no idea why noautocmd caddfile ...
would cause any such problems. I'm hoping that the minimal example can be helpful for others that may be able to help. I strongly believe that, if there is a bug, it is either 1) with noice.nvim or nui.nvim or 2) with neovim itself.
I tried to simplify this entire business further to avoid VimTeX as a dependency at all, but that was hard.
Notice, though, that this only happens when there is an error in the latex log. Also, notice that it only happens "sometimes"; if I try to reproduce three times, it may only be reproduced two of the three times.
Perhaps @folke would be able to help here with his expertice on both lua and noice.nvim?
I also have no idea what could cause. This is the only issue that reports this kind of behavior. Since I'm not a vimtex user, and the issue is not really breaking, I'm not planning to spend time investigating this further.
If someone would figure it out and it turns out to be a noice issue, then feel free to create a PR
I also have no idea what could cause. This is the only issue that reports this kind of behavior. Since I'm not a vimtex user, and the issue is not really breaking, I'm not planning to spend time investigating this further.
That's fair. And it's the same for me; I've tried to figure it out, but I failed.
If someone would figure it out and it turns out to be a noice issue, then feel free to create a PR
Same for me; if someone should understand something I don't that explains why this is a VimTeX issue, then I would be happy to hear it and/or see a PR.
I'm closing this with "won't fix", as I don't plan to spend more time on it.
Thank you!
Sorry that I couldn't be of more help. :\
Sorry that I couldn't be of more help. :\
No worry! Thank you and @folke for creating these great plugins! Nothing is perfect, Cheers! :+1:
Thanks! :) <3
@lee-shun Did you ever find a workaround for this problem?
Description
Hello!
Every time vimtex finishes compiling, if at that moment I am navigating using "h", there will be a weird movement that takes me to the next line.
NOTE: I tried without noice and notify, the bug disappears.
For example, in the following gif, I am pressing "h" only, but once the "message vimtex compile failed!" there will be a movement takes me to the next line...
Steps to reproduce
I use lazy.nvim.
noice.nvim
notify.nvim
Expected behavior
No response
Actual behavior
weird movement
Do you use a latexmkrc file?
NO
VimtexInfo