iurimateus / luasnip-latex-snippets.nvim

A port of Gilles Castel's UltiSnip snippets for LuaSnip.
Apache License 2.0
131 stars 50 forks source link

"no parser for 'latex' language" error even though I don't use treesitter #25

Open JetpackJackson opened 7 months ago

JetpackJackson commented 7 months ago

Got this error recently, setting use on markdown to false stops it (I don't get this error in tex files.)


Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:99: no parser for 'latex' language, see :help treesitter-parsers
stack traceback:
    [C]: in function 'error'
    /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:99: in function 'add'
    /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:109: in function 'new'
    /usr/share/nvim/runtime/lua/vim/treesitter.lua:64: in function '_create_parser'
    /usr/share/nvim/runtime/lua/vim/treesitter.lua:130: in function 'get_parser'
    ...ippets.nvim/lua/luasnip-latex-snippets/util/ts_utils.lua:20: in function 'get_node_at_cursor'
    ...ippets.nvim/lua/luasnip-latex-snippets/util/ts_utils.lua:56: in function 'fn'
    ...-snippets.nvim/lua/luasnip-latex-snippets/util/utils.lua:19: in function 'condition'
    ...al/share/nvim/lazy/luasnip/lua/luasnip/nodes/snippet.lua:27: in function 'resolveExpandParams'
    ...al/share/nvim/lazy/luasnip/lua/luasnip/nodes/snippet.lua:769: in function 'matches'
    .../luasnip/lua/luasnip/session/snippet_collection/init.lua:176: in function 'match_snippet'
    .../jet/.local/share/nvim/lazy/luasnip/lua/luasnip/init.lua:352: in function 'expand_auto'
    ...et/.local/share/nvim/lazy/luasnip/lua/luasnip/config.lua:279: in function <...et/.local/share/nvim/lazy/luasnip/lua/luasnip/config.lua:277>```
iurimateus commented 7 months ago

I don't think we should error there, but markdown is only supported with treesitter (which use_markdown implies).

v0ry commented 4 months ago

Had the same problem, had to config the Treesitter,

-- Userd For Syntax Highlighting
-- https://linovox.com/nvim-treesitter-syntax-highlighting-in-neovim/
local M = {
  "nvim-treesitter/nvim-treesitter",
  event = { "BufReadPost", "BufNewFile" },
  build = ":TSUpdate",
}

function M.config()
  require("nvim-treesitter.configs").setup {
    ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python", "c", "cpp", "css", "html", "javascript" },
    ignore_install = { "latex"}, -- Don't install parsers with filetypes in this list
    highlight = { enable = true, disable = { "latex" } }, -- Don't enable synxtax highlighting for latex
    auto_install = true,
    sync_install = false, -- install synchronously
    indent = { enable = true },
    rainbow = {
      enable = true,
      extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
      max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int
    },
    incremental_selection = {
      enable = true,
      keymaps = {
        init_selection = "gnn",
        node_incremental = "grn",
        scope_incremental = "grc",
        node_decremental = "grm",
      },
    },
  }
end

return M

Now your the parser won't load, and you disabled syntax hightlighting. Which you want VimTex to do. You can check out my config, it works. using neovim.lazy on macos nvim

JetpackJackson commented 4 months ago

Thanks for the code. I haven't had this error in a while, but I've also changed a lot of my plugins and parts of my config since then so I'm thinking it could have been some sort of conflict with something else I had installed. Should I close the issue?

iurimateus commented 4 months ago

Should I close the issue?

I haven't looked into it yet... Leave it open so I can track it.

keiwanjamaly commented 3 months ago

I had the same error recently and to my understanding, luasnip-latex-snippets.nvim uses treesitter for example

https://github.com/iurimateus/luasnip-latex-snippets.nvim/blob/064f2abb6d08ebdd17b4a2baa181ffa7c4011f39/lua/luasnip-latex-snippets/util/ts_utils.lua#L20

So I basically installed the treesitter latex parser and disabled syntax highlighting for latex in treesitter (if you prefer the vimtex highlighter).

iurimateus commented 3 months ago

This should only be called if use_treesitter is set to true though...