lervag / vimtex

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

Cant open "filename" for writing: name too long #3001

Open Felipe-9 opened 1 day ago

Felipe-9 commented 1 day ago

Description

When opening a new file i get the following error:

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...rew/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: Error executing lua: ...rew/Cellar/
neovim/0.10.1/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autocommands for "tex": Vim(append):
Error executing lua callback: BufReadPost Autocommands for "*"..FileType Autocommands for "tex"..function vimtex#bib#files[37]..<
SNR>94_files_manual[57]..20, line 8: Vim(call):E482: Can't open file /Users/felipepinto/.cache/vimtex/bibfiles%Users%"...long_file_name...".json for writing: name too
 long
stack traceback:
        [C]: in function 'vimtex#bib#files'
        ...cal/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/source.lua:152: in function 'start_parser'
        ...local/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/init.lua:15: in function <...local/share/nvim/lazy/cmp-vimtex/lua/cmp_
vimtex/init.lua:15>
        [C]: in function 'nvim_cmd'
        ...rew/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:36: in function <...rew/Cellar/neovim/0.10.1/share/nvim/runti
me/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        ...rew/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.10.1/share/nvim/runti
me/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        ...rew/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:36: in function <...rew/Cellar/neovim/0.10.1/share/nvim/runti
me/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        ...rew/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.10.1/share/nvim/runti
me/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        ...rew/Cellar/neovim/0.10.1/share/nvim/runtime/filetype.lua:35: in function <...rew/Cellar/neovim/0.10.1/share/nvim/runti
me/filetype.lua:10>

I should note

Steps to reproduce

Have my configuration and try to compile a file with a long path i guess?

vimtex.lua

return {
  "lervag/vimtex",
  lazy = false,     -- we don't want to lazy load VimTeX
  -- tag = "v2.15", -- uncomment to pin to a specific release
  init = function()
    -- VimTeX configuration goes here, e.g.
    local g = vim.g
    g.vimtex_view_method = "zathura_simple"
    g.vimtex_compiler_engine = "lualatex"
    g.tex_flavor = "lualatex"
    g.vimtex_compiler_latexmk = {
      aux_dir = ".build",
      out_dir = "",
      -- options = [[
      --   
      -- ]]
    }
    g.vimtex_quickfix_mode=0
    g.vimtex_mappings_enable=0
    g.vimtex_syntax_conceal = {
      accents = 1,             
      ligatures = 1,
      cites = 1,
      fancy = 1,
      spacing = 1,
      greek = 1,
      math_bounds = 1,
      math_delimiters = 1,
      math_fracs = 1,
      math_super_sub = 1,
      math_symbols = 1,
      sections = 0,
      styles = 1,
    }
    g.vimtex_log_ignore = ({
      "Underfull",
      "Overfull",
      "specifier changed to",
      "Token not allowed in PDF string",
    })

    -- ---@diagnostic disable-next-line: missing-fields
    -- require 'nvim-treesitter.configs'.setup {
    --   ignore_install = { "latex" },
    -- }
  end
}

Expected behavior

Open the file normally with normal capabilities

Actual behavior

opening file as a text file, no highlights or completions

Do you use a latexmkrc file?

no

VimtexInfo

System info:
  OS: macOS 14.6.1 (23G93)
  Vim version: NVIM v0.10.1
  Has clientserver: true
  Servername: /var/folders/5f/hn34hzl13y907124_kr68p380000gn/T/nvim.felipepinto/lcLxVB/nvim.9938.0

VimTeX project: AM3C-Class_Annotations.1
  base: AM3C-Class_Annotations.1.tex
  root: /Users/felipepinto/Documents/.../dir
  tex: /Users/felipepinto/Documents/.../file.tex
  main parser: texroot specifier
  document class: subfiles
  packages: calc expl3 fontenc fontsize fontspec ifluatex iftex import luacode mypallete preview shellesc xcolor xfp xkeyval xparse
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    aux_dir: .build
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
  qf method: LaTeX logfile
lervag commented 1 day ago

Before answering your question, let me help you with the config. I've cleaned it up, removed a lot of unnecessary stuff. E.g., you don't need to set things if you don't change from the default. Also, g:tex_flavor is not relevant, and there was a couple of minor errors.

I also removed the comments, but feel free to add them back of course!

return {
  "lervag/vimtex",
  lazy = false,
  init = function()
    vim.g.vimtex_view_method = "zathura_simple"
    vim.g.vimtex_compiler_latexmk_engines = { ['_'] = '-lualatex' }
    vim.g.vimtex_compiler_latexmk = { aux_dir = ".build" }
    vim.g.vimtex_quickfix_mode = 0
    vim.g.vimtex_mappings_enable = 0
    vim.g.vimtex_log_ignore = {
      "Underfull",
      "Overfull",
      "specifier changed to",
      "Token not allowed in PDF string",
    }
  end
}
lervag commented 1 day ago

When opening a new file i get the following error: …

Well, ok; can you please create a minimal example that will reproduce this problem? It's very hard to parse the error message to figure out what is wrong here. If this is just about the path name, then it should be simple for you to create such an example with very small tex files.

Felipe-9 commented 1 day ago

on creating the mwe i noticed that the original file simply, as the error described, has a filename that was too long apparently 23 char is the limit for file size and since the file had 24 chars i got the error, no idea why tho, is this a bug? Just renaming the file with one letter less and it opens and compiles no problem

lervag commented 1 day ago

I've never heard of or experienced this myself and it does not feel like this should be a bug. So if you are able to make an mwe I could see if I can reproduce.

Felipe-9 commented 19 hours ago

OK here it goes the MWA, i added it to the nvim config file inside a directory with a very long name, its important as the long path is a problem.

I must note that i added your config suggestions, thank you very much for that i also added shell-escape as i normally use it when compiling my latex files

vimtex.lua

...
    vim.g.vimtex_compiler_latexmk = {
      aux_dir = ".build",
      options = {
        "-shell-escape",
        "-verbose",
        "-file-line-error",
        "-synctex=1",
        "-interaction=nonstopmode",
      }
    }
...

the tree

~/.config/nvim/MWE-Pathwhitaverylongasspathnameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
├── MWE-withaverylongassnameeeeeeeeeeeee.1.tex
└── MWE.tex

MWE.tex

% \documentclass{article}
\documentclass[
    class=article,
    multi={minipage},
    border={3mm},
]{standalone}
\usepackage{luacode}
\usepackage{xparse} % xparse - multiple optional arguments
\usepackage{calc}
\setlength\textwidth{160mm}
\usepackage[fontsize=12pt]{fontsize}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{subfiles}

\begin{document}

\section{main}
main file

\end{document}

MWE-withaverylongassnameeeeeeeeeeeee.1.tex

% !TEX root = ./MWE-withaverylongassnameeeeeeeeeeeee.1.tex
\documentclass["./MWE.tex"]{subfiles}

\usepackage{sections}

\begin{document}

\section{}
test

\end{document}