lervag / vimtex

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

How to disable adding figure caption after \ref{} #3009

Open JulioHC00 opened 1 month ago

JulioHC00 commented 1 month ago

Description

I'm sorry if this isn't something that VimTex does, but I can't think of any other plugin that may be doing this. Whenever I write \ref{fig:blahblah} I immediately get the caption added after it as a kind of ghost text. It's just there to be seen, but won't appear in the document. Just like below.

image

This is being quite buggy for me, and I'd like to disable it. I've tried disabling concealing, but it remains there, and I can't find anything in the docs to help me.

Steps to reproduce

% Minimal latex document
% Run 
\documentclass{article}

% Package for figures
\usepackage{graphicx}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{missing.png}
    \caption{Some figure here}
    \label{fig:figure}
\end{figure}

Here we refer to the figure \ref{fig:figure}. %Here you get the text "Figure 1: Some figure here" in a lighter colour.

\end{document}

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Ubuntu 22.04.5 LTS
  Vim version: NVIM v0.10.2
  Has clientserver: true
  Servername: /run/user/1000/nvim.26660.0

VimTeX project: minimal
  base: minimal.tex
  root: /home/julio/Downloads/latex_test
  tex: /home/julio/Downloads/latex_test/minimal.tex
  main parser: fallback current file
  document class: 
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 7
      output: /tmp/nvim.julio/4PKYWa/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -view=none -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'minimal.tex'
      pid: 26854
  viewer: General
    job: 
      pid: -
      cmd: okular --unique file:'/home/julio/Downloads/latex_test/minimal.pdf'#src:5'/home/julio/Downloads/latex_test/minimal.tex'
  qf method: LaTeX logfile
lervag commented 1 month ago

I'm sorry if this isn't something that VimTex does, but I can't think of any other plugin that may be doing this. Whenever I write \ref{fig:blahblah} I immediately get the caption added after it as a kind of ghost text. It's just there to be seen, but won't appear in the document. Just like below.

I'm pretty sure, but not entirely, this is something caused by texlab. So I'm also quite sure you are using texlab as an LSP. But it's hard to know, because I don't know anything about your config...

Steps to reproduce

Your "steps to reproduce" do not contain a minimal init.lua file. An example of such a file is this:

-- NOTE: Use the correct path to VimTeX in the following two lines!
vim.opt.runtimepath:prepend "~/.local/plugged/vimtex"
vim.opt.runtimepath:append "~/.local/plugged/vimtex/after"
vim.cmd [[filetype plugin indent on]]

vim.g.vimtex_cache_root = "."
vim.g.vimtex_cache_persistent = false
user202729 commented 1 month ago

Try running :scriptname, it will give a reasonable description of what plugins you have. Then you can disable them one by one.

To copy to clipboard use

:let @+=execute('scriptname')
BRS5672023 commented 4 weeks ago

I'd guess this comes from nvim-lspconfig, you may disable the inlay hints like this https://github.com/LazyVim/LazyVim/discussions/3191#discussioncomment-9467691

thunderbird-1990 commented 3 days ago

I figured it out.

This is indeed TexLab related.

The related settings are texlab.inlayHints.labelDefinitions and texlab.inlayHints.labelReferences, see https://github.com/latex-lsp/texlab/wiki/Configuration.