latex-lsp / tree-sitter-latex

LaTeX grammar for tree-sitter
MIT License
87 stars 21 forks source link

LaTeX language broken #131

Closed niceiq closed 3 weeks ago

niceiq commented 3 weeks ago

The Error

At first, I had a similar error as issue #6543. I followed the instructions in issue 3092, and then this started to happen whenever I open a LaTeX file with Neovim.

E5108: Error executing lua: vim/_editor.lua:0: BufReadPost Autocommands for "*": Vim(append):Error executing lua callback: /usr/local/share/nvim/runtime/filetype.lua:21: Err
or executing lua: /usr/local/share/nvim/runtime/filetype.lua:22: BufReadPost Autocommands for "*"..FileType Autocommands for "*": Vim(append):tree-sitter CLI not found: `tre
e-sitter` is not executable!
stack traceback:
        [C]: in function 'nvim_cmd'
        /usr/local/share/nvim/runtime/filetype.lua:22: in function </usr/local/share/nvim/runtime/filetype.lua:21>
        [C]: in function 'nvim_buf_call'
        /usr/local/share/nvim/runtime/filetype.lua:21: in function </usr/local/share/nvim/runtime/filetype.lua:10>
        [C]: at 0x62483577a2bc
        [C]: in function 'pcall'
        ...t/nvim-tree.lua/lua/nvim-tree/actions/node/open-file.lua:334: in function 'open_in_new_window'
        ...t/nvim-tree.lua/lua/nvim-tree/actions/node/open-file.lua:383: in function 'fn'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:177: in function 'edit'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:189: in function 'fn'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:65: in function <...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:62>
stack traceback:
        [C]: in function 'nvim_buf_call'
        /usr/local/share/nvim/runtime/filetype.lua:21: in function </usr/local/share/nvim/runtime/filetype.lua:10>
        [C]: at 0x62483577a2bc
        [C]: in function 'pcall'
        ...t/nvim-tree.lua/lua/nvim-tree/actions/node/open-file.lua:334: in function 'open_in_new_window'
        ...t/nvim-tree.lua/lua/nvim-tree/actions/node/open-file.lua:383: in function 'fn'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:177: in function 'edit'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:189: in function 'fn'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:65: in function <...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:62>
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...e/pack/packer/start/nvim-tree.lua/lua/nvim-tree/view.lua:354: in function 'resize'
        ...t/nvim-tree.lua/lua/nvim-tree/actions/node/open-file.lua:390: in function 'fn'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:177: in function 'edit'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:189: in function 'fn'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:65: in function <...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/api.lua:62>

It has been a while since I've worked with LaTeX (few months), so I don't know when it broke precisely.

Other file types are working as expected (C & Lua I've tested).

Checkhealth

Output of :checkhealth nvim-treesitter:


==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v18.17.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (GCC) 14.1.1 20240522
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.6.32-1-lts",
  sysname = "Linux",
  version = "#1 SMP PREEMPT_DYNAMIC Sun, 26 May 2024 07:42:17 +0000"
} ~

Parser/Features         H L F I J
  - ada                 ✓ ✓ ✓ . ✓
  - agda                ✓ . ✓ . ✓
  - angular             ✓ ✓ ✓ ✓ ✓
  - apex                ✓ ✓ ✓ . ✓
  - arduino             ✓ ✓ ✓ ✓ ✓
  - asm                 ✓ . . . ✓
  - astro               ✓ ✓ ✓ ✓ ✓
  - authzed             ✓ . . . ✓
  - awk                 ✓ . . . ✓
  - bash                ✓ ✓ ✓ . ✓
  - bass                ✓ ✓ ✓ ✓ ✓
  - beancount           ✓ . ✓ . ✓
  - bibtex              ✓ . ✓ ✓ ✓
  - bicep               ✓ ✓ ✓ ✓ ✓
  - bitbake             ✓ ✓ ✓ ✓ ✓
  - blueprint           ✓ . . . ✓
  - bp                  ✓ ✓ ✓ ✓ ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - c_sharp             ✓ ✓ ✓ . ✓
  - cairo               ✓ ✓ ✓ ✓ ✓
  - capnp               ✓ ✓ ✓ ✓ ✓
  - chatito             ✓ ✓ ✓ ✓ ✓
  - clojure             ✓ ✓ ✓ . ✓
  - cmake               ✓ . ✓ ✓ ✓
  - comment             ✓ . . . .
  - commonlisp          ✓ ✓ ✓ . ✓
  - cooklang            ✓ . . . ✓
  - corn                ✓ ✓ ✓ ✓ ✓
  - cpon                ✓ ✓ ✓ ✓ ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - csv                 ✓ . . . .
  - cuda                ✓ ✓ ✓ ✓ ✓
  - cue                 ✓ ✓ ✓ ✓ ✓
  - d                   ✓ ✓ ✓ ✓ ✓
  - dart                ✓ ✓ ✓ ✓ ✓
  - devicetree          ✓ ✓ ✓ ✓ ✓
  - dhall               ✓ . ✓ . ✓
  - diff                ✓ . . . .
  - disassembly         ✓ . . . ✓
  - djot                ✓ ✓ ✓ ✓ ✓
  - dockerfile          ✓ . . . ✓
  - dot                 ✓ . . ✓ ✓
  - doxygen             ✓ . . ✓ ✓
  - dtd                 ✓ ✓ ✓ . ✓
  - earthfile           ✓ . . . ✓
  - ebnf                ✓ . . . ✓
  - eds                 ✓ . ✓ . .
  - eex                 ✓ . . . ✓
  - elixir              ✓ ✓ ✓ ✓ ✓
  - elm                 ✓ . . . ✓
  - elsa                ✓ ✓ ✓ ✓ ✓
  - elvish              ✓ . . . ✓
  - embedded_template   ✓ . . . ✓
  - erlang              ✓ . ✓ . ✓
  - facility            ✓ . ✓ ✓ ✓
  - faust               ✓ . . . ✓
  - fennel              ✓ ✓ ✓ . ✓
  - fidl                ✓ . ✓ . ✓
  - firrtl              ✓ ✓ ✓ ✓ ✓
  - fish                ✓ ✓ ✓ ✓ ✓
  - foam                ✓ ✓ ✓ ✓ ✓
  - forth               ✓ ✓ ✓ ✓ ✓
  - fortran             ✓ . ✓ ✓ ✓
  - fsh                 ✓ . . . ✓
  - func                ✓ . . . ✓
  - fusion              ✓ ✓ ✓ ✓ ✓
  - gdscript            ✓ ✓ ✓ ✓ ✓
  - gdshader            ✓ . . . ✓
  - git_config          ✓ . ✓ . ✓
  - git_rebase          ✓ . . . ✓
  - gitattributes       ✓ ✓ . . ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . ✓
  - gleam               ✓ ✓ ✓ ✓ ✓
  - glimmer             ✓ ✓ ✓ ✓ ✓
  - glsl                ✓ ✓ ✓ ✓ ✓
  - gn                  ✓ ✓ ✓ ✓ ✓
  - gnuplot             ✓ . . . ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - godot_resource      ✓ ✓ ✓ . ✓
  - gomod               ✓ . . . ✓
  - gosum               ✓ . . . .
  - gotmpl              ✓ . . . ✓
  - gowork              ✓ . . . ✓
  - gpg                 ✓ . . . ✓
  - graphql             ✓ . . ✓ ✓
  - groovy              ✓ ✓ ✓ ✓ ✓
  - gstlaunch           ✓ . . . .
  - hack                ✓ . . . ✓
  - hare                ✓ ✓ ✓ ✓ ✓
  - haskell             ✓ ✓ ✓ . ✓
  - haskell_persistent  ✓ . ✓ . .
  - hcl                 ✓ . ✓ ✓ ✓
  - heex                ✓ ✓ ✓ ✓ ✓
  - helm                ✓ . . . ✓
  - hjson               ✓ ✓ ✓ ✓ ✓
  - hlsl                ✓ ✓ ✓ ✓ ✓
  - hlsplaylist         ✓ . . . ✓
  - hocon               ✓ . ✓ . ✓
  - hoon                ✓ ✓ ✓ . ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - htmldjango          ✓ . ✓ ✓ ✓
  - http                ✓ . . . ✓
  - hurl                ✓ . ✓ ✓ ✓
  - hyprlang            ✓ . ✓ ✓ ✓
  - idl                 ✓ . . . ✓
  - ini                 ✓ . ✓ . ✓
  - inko                ✓ ✓ ✓ ✓ ✓
  - ispc                ✓ ✓ ✓ ✓ ✓
  - janet_simple        ✓ ✓ ✓ . ✓
  - java                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - jq                  ✓ ✓ . . ✓
  - jsdoc               ✓ . . . .
  - json                ✓ ✓ ✓ ✓ .
  - json5               ✓ . . . ✓
  - jsonc               ✓ ✓ ✓ ✓ ✓
  - jsonnet             ✓ ✓ ✓ . ✓
  - julia               ✓ ✓ ✓ ✓ ✓
  - just                ✓ ✓ ✓ ✓ ✓
  - kconfig             ✓ ✓ ✓ ✓ ✓
  - kdl                 ✓ ✓ ✓ ✓ ✓
  - kotlin              ✓ ✓ ✓ . ✓
  - koto                ✓ ✓ ✓ . ✓
  - kusto               ✓ . . . ✓
  - lalrpop             ✓ ✓ ✓ . ✓
  - ledger              ✓ . ✓ ✓ ✓
  - leo                 ✓ . . ✓ ✓
  - linkerscript        ✓ ✓ ✓ ✓ ✓
  - liquid              ✓ . . . ✓
  - liquidsoap          ✓ ✓ ✓ ✓ ✓
  - llvm                ✓ . . . ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - luadoc              ✓ . . . .
  - luap                ✓ . . . .
  - luau                ✓ ✓ ✓ ✓ ✓
  - m68k                ✓ ✓ ✓ . ✓
  - make                ✓ . ✓ . ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - matlab              ✓ ✓ ✓ ✓ ✓
  - menhir              ✓ . . . ✓
  - mermaid             ✓ . . . ✓
  - meson               ✓ . ✓ ✓ ✓
  - muttrc              ✓ . . . ✓
  - nasm                ✓ . . . ✓
  - nickel              ✓ . . ✓ ✓
  - nim                 ✓ ✓ ✓ . ✓
  - nim_format_string   ✓ . . . ✓
  - ninja               ✓ . ✓ ✓ ✓
  - nix                 ✓ ✓ ✓ . ✓
  - norg                . . . . .
  - nqc                 ✓ ✓ ✓ ✓ ✓
  - objc                ✓ ✓ ✓ ✓ ✓
  - objdump             ✓ . . . ✓
  - ocaml               ✓ ✓ ✓ ✓ ✓
  - ocaml_interface     ✓ ✓ ✓ ✓ ✓
  - odin                ✓ ✓ ✓ ✓ ✓
  - org                 . . . . .
  - pascal              ✓ ✓ ✓ ✓ ✓
  - passwd              ✓ . . . .
  - pem                 ✓ . ✓ . ✓
  - perl                ✓ . ✓ . ✓
  - php                 ✓ ✓ ✓ ✓ ✓
  - php_only            ✓ ✓ ✓ ✓ ✓
  - phpdoc              ✓ . . . .
  - pioasm              ✓ . . . ✓
  - po                  ✓ . ✓ . ✓
  - pod                 ✓ . . . .
  - poe_filter          ✓ . ✓ ✓ ✓
  - pony                ✓ ✓ ✓ ✓ ✓
  - printf              ✓ . . . .
  - prisma              ✓ . ✓ . ✓
  - promql              ✓ . . . ✓
  - properties          ✓ ✓ . . ✓
  - proto               ✓ . ✓ . ✓
  - prql                ✓ . . . ✓
  - psv                 ✓ . . . .
  - pug                 ✓ . . . ✓
  - puppet              ✓ ✓ ✓ ✓ ✓
  - purescript          ✓ ✓ . . ✓
  - pymanifest          ✓ . . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - ql                  ✓ ✓ ✓ ✓ ✓
  - qmldir              ✓ . . . ✓
  - qmljs               ✓ . ✓ . ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - r                   ✓ ✓ . ✓ ✓
  - racket              ✓ . ✓ . ✓
  - ralph               ✓ . . . ✓
  - rasi                ✓ ✓ ✓ ✓ ✓
  - rbs                 ✓ . ✓ ✓ ✓
  - re2c                ✓ ✓ ✓ ✓ ✓
  - readline            ✓ . ✓ ✓ ✓
  - regex               ✓ . . . .
  - rego                ✓ . . . ✓
  - requirements        ✓ . . . ✓
  - rnoweb              ✓ . ✓ . ✓
  - robot               ✓ . ✓ ✓ ✓
  - roc                 ✓ ✓ . . ✓
  - ron                 ✓ ✓ ✓ ✓ ✓
  - rst                 ✓ ✓ . . ✓
  - ruby                ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - scala               ✓ ✓ ✓ . ✓
  - scheme              ✓ . ✓ . ✓
  - scss                ✓ . ✓ ✓ ✓
  - slang               ✓ ✓ ✓ ✓ ✓
  - slint               ✓ ✓ ✓ ✓ ✓
  - smali               ✓ ✓ ✓ ✓ ✓
  - smithy              ✓ . . . ✓
  - snakemake           ✓ ✓ ✓ ✓ ✓
  - solidity            ✓ . ✓ . ✓
  - soql                ✓ . . . .
  - sosl                ✓ . . . .
  - sourcepawn          ✓ ✓ . . ✓
  - sparql              ✓ ✓ ✓ ✓ ✓
  - sql                 ✓ . . ✓ ✓
  - squirrel            ✓ ✓ ✓ ✓ ✓
  - ssh_config          ✓ ✓ ✓ ✓ ✓
  - starlark            ✓ ✓ ✓ ✓ ✓
  - strace              ✓ . . . ✓
  - styled              ✓ . ✓ ✓ ✓
  - supercollider       ✓ ✓ ✓ ✓ ✓
  - surface             ✓ . ✓ ✓ ✓
  - svelte              ✓ ✓ ✓ ✓ ✓
  - sxhkdrc             ✓ . ✓ . ✓
  - systemtap           ✓ ✓ ✓ . ✓
  - t32                 ✓ ✓ ✓ ✓ ✓
  - tablegen            ✓ ✓ ✓ ✓ ✓
  - tact                ✓ ✓ ✓ ✓ ✓
  - tcl                 ✓ . ✓ ✓ ✓
  - templ               ✓ . . . ✓
  - terraform           ✓ . ✓ ✓ ✓
  - textproto           ✓ . ✓ ✓ ✓
  - thrift              ✓ ✓ ✓ ✓ ✓
  - tiger               ✓ ✓ ✓ ✓ ✓
  - tlaplus             ✓ ✓ ✓ . ✓
  - tmux                ✓ . . . ✓
  - todotxt             ✓ . . . .
  - toml                ✓ ✓ ✓ ✓ ✓
  - tsv                 ✓ . . . .
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - turtle              ✓ ✓ ✓ ✓ ✓
  - twig                ✓ . . . ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - typespec            ✓ . . ✓ ✓
  - typoscript          ✓ . ✓ ✓ ✓
  - typst               ✓ . ✓ ✓ ✓
  - udev                ✓ ✓ . . ✓
  - ungrammar           ✓ ✓ ✓ ✓ ✓
  - usd                 ✓ ✓ ✓ ✓ ✓
  - uxntal              ✓ ✓ ✓ ✓ ✓
  - v                   ✓ ✓ ✓ ✓ ✓
  - vala                ✓ . ✓ . ✓
  - vento               ✓ . . . ✓
  - verilog             ✓ ✓ ✓ . ✓
  - vhs                 ✓ . . . ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - vue                 ✓ . ✓ ✓ ✓
  - wgsl                ✓ . ✓ ✓ ✓
  - wgsl_bevy           ✓ . ✓ ✓ .
  - wing                ✓ ✓ ✓ . ✓
  - wit                 ✓ . . . ✓
  - xcompose            ✓ ✓ . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓
  - yang                ✓ . ✓ ✓ ✓
  - yuck                ✓ ✓ ✓ ✓ ✓
  - zathurarc           ✓ . . . ✓
  - zig                 ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

Is it normal that latex is not listed in the language list?

Config File

Here is my Treesitter Config File:

local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
    return
end

require("nvim-treesitter.configs").setup({
    -- A list of parser names, or "all" (the five listed parsers should always be installed)
    ensure_installed = "all",

    -- Install parsers synchronously (only applied to `ensure_installed`)
    sync_install = false,

    -- Automatically install missing parsers when entering buffer
    -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
    auto_install = true,

    -- List of parsers to ignore installing (for "all")
    ignore_install = { "" },

    ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
    -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!

    highlight = {
        enable = true,
        -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
        -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
        -- the name of the parser)
        -- list of language that will be disabled
        disable = { "" },
        -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files

        -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
        -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
        -- Using this option may slow down your editor, and you may see some duplicate highlights.
        -- Instead of true it can also be a list of languages
        additional_vim_regex_highlighting = false,
    },
    autopairs = {
        enable = true,
    },
    -- ts-context-commentstring plugin logic
    context_commentstring = {
        enable = true,
        enable_autocmd = false,
    },
})
clason commented 3 weeks ago

This is not an issue with this parser; you need to install tree-sitter to be able to use nvim-treesitter.

niceiq commented 3 weeks ago

This is not an issue with this parser; you need to install tree-sitter to be able to use nvim-treesitter.

I have it installed already.

image

clason commented 3 weeks ago

Then make sure neovim can find it (tree-sitter must be in $PATH).

niceiq commented 3 weeks ago

Installing the tree-sitter-clipackage solved it.

It was an odd behavior though because every other language was working fine except LaTeX, so I just assume it couldn't fine a parser for LaTeX.

image

P.S.: For reference: I'm using Artix Linux.

clason commented 3 weeks ago

It was an odd behavior though because every other language was working fine except LaTeX

That was pure coincidence; this would have happened for any parser that -- like this one since a while back -- does not commit the generated parser to the repository. There's a handful of these tracked in nvim-treesitter, and it will become much more common in the future.