lervag / vimtex

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

ToC split width doesn't change width #2780

Closed Nora-n closed 1 year ago

Nora-n commented 1 year ago

Description

I want the table of content to be smaller than its default value. :help vimtex_toc indicates I should change the parameter g.vimtex_split_width. Thus in my vimtex.lua file I have

return {
  {
    "lervag/vimtex",
    ft = "tex", -- without ft, it's not working too
    lazy = false,
    config = function()
      vim.g.vimtex_quickfix_enabled = 1
      vim.g.vimtex_syntax_enabled = 1
      vim.g.vimtex_quickfix_mode = 0
      vim.g.tex_flavor = "latex"
      vim.g.tex_conceal = "abdmg"
      vim.g.vimtex_compiler_method = "latexmk"
      vim.g.vimtex_view_method = "zathura"
      vim.g.latex_view_general_viewer = "zathura"
      vim.g.vimtex_split_width = 20
      vim.cmd("call vimtex#init()")
    end,
  },
}

However, ToC size is the same.

Steps to reproduce

  1. nvim minimal.tex
  2. :VimtexTocToggle
  3. :q
  4. nvim $HOME/.config/nvim/lua/plugins/vimtex.lua
  5. Change split_width to 20
  6. Reopen minimal
  7. Toggle ToC

Expected behavior

I expect the ToC to change width.

Actual behavior

It doesn't.

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Arch Linux
  Vim version: NVIM v0.9.1
  Has clientserver: true
  Servername: /run/user/1000/nvim.711051.0

VimTeX project: minimal
  base: minimal.tex
  root: /home/nora/Documents/Enseignement/Prepa/figures_generales
  tex: /home/nora/Documents/Enseignement/Prepa/figures_generales/minimal.tex
  main parser: current file verified
  document class: article
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    xwin id: 0
  qf method: LaTeX logfile
julio-b commented 1 year ago

This works for me

{
        "lervag/vimtex",
        lazy = false,
        ft = { "tex" },
        config = function()
            vim.g.vimtex_view_method = "zathura"
            vim.g.vimtex_compiler_method = "latexmk"
            vim.g.vimtex_toc_config = {
                split_width = 20
            }
        end,
}

:h g:vimtex_toc_config

lervag commented 1 year ago

First, thanks for giving a very nice and detailed issue description!

Thus in my vimtex.lua file I have: …

There are a few things that I would change here:

I've compiled those tips and a few other minor improvements (e.g. remove options that you do not change form default values, and remove unnecessary g.tex_* options) in the following suggested config:

return {
  {
    "lervag/vimtex",
    lazy = false,
    init = function()
      vim.g.vimtex_quickfix_mode = 0
      vim.g.vimtex_view_method = "zathura"
      vim.g.vimtex_toc_config = {
        split_width = 20
      }
    end,
  },
}

I would think that things should work if you use the above suggested config. If not, then please open a new issue. Preferably try and create a reproducible example.

@julio-b Please also note that you should NOT have ft = "tex" in your config!

Nora-n commented 1 year ago

Thank you! Works like a charm, as always.

lervag commented 1 year ago

Glad to hear it :)