lervag / vimtex

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

Hide preamble in TOC not working #2787

Closed petobens closed 1 year ago

petobens commented 1 year ago

Description

vim.g.vimtex_toc_show_preamble doesn't seem to work

Steps to reproduce

  1. Open nvim with the following minimal init.lua:

    local root = '/tmp/nvim-minimal'
    
    -- Set stdpaths to use root dir
    for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
        vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
    end
    
    -- Bootstrap lazy
    local lazypath = root .. '/plugins/lazy.nvim'
    if not vim.loop.fs_stat(lazypath) then
        vim.fn.system({
            'git',
            'clone',
            '--filter=blob:none',
            '--single-branch',
            'https://github.com/folke/lazy.nvim.git',
            lazypath,
        })
    end
    vim.opt.runtimepath:prepend(lazypath)
    
    -- Install and configure plugins
    local plugins = {
        {
            'lervag/vimtex',
            config = function()
                vim.g.vimtex_toc_show_preamble = 0
            end,
            ft = { 'tex', 'bib' },
        },
    }
    require('lazy').setup(plugins, {
        root = root .. '/plugins',
    })
  2. Edit a tex file containing

    \documentclass{article}
    \begin{document}
    
    \section{Foo}
    
    \end{document}
  3. Run VimtexTocOpen

Expected behavior

After 3. above I would expect the preamble not to be seen in the TOC.

Actual behavior

There is a preamble entry in the TOC.

image

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Arch Linux
  Vim version: NVIM v0.10.0-dev-1045+g131a1ee82d
  Has clientserver: true
  Servername: /run/user/1000/nvim.2623593.0

VimTeX project: foo
  base: foo.tex
  root: /home/pedro/Desktop
  tex: /home/pedro/Desktop/foo.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: General
  qf method: LaTeX logfile
lervag commented 1 year ago

First, sorry for taking so very long to answer. I've been quite busy lately with work and I've also enjoyed perhaps too many hours of playing Baldurs Gate. 😊

I've merged the PR from @julio-b which seems to resolve your issue. Thanks @julio-b, that is very much appreciated!

petobens commented 1 year ago

Thanks!