luasnip-latex-snippets.nvim icon indicating copy to clipboard operation
luasnip-latex-snippets.nvim copied to clipboard

Some Snippets dont expand

Open JonaGTHB opened this issue 1 year ago • 5 comments

Hi, first of i want to say thanks for making this plugin.

The issue I'm facing is the following: Some snippets don't expand while some others do. I've written down some examples:

a1 correctly expands to a_{1} 32/3 correctly expands to \frac{32}{3} fun correctly expands to f \colon \R \to \R \colon Other snippets on the other hand don't seem to expand, examples include: sum which should expand to \sum_{n = 1}^{\infty} lim which should expand to \lim_{n \to \infty}

Funnily enough i can see these snippets in LuaSnip when executing :LuaSnipListAvailable which for example shows

    }, {
      description = { "sum" },
      name = "sum",
      regTrig = false,
      trigger = "sum",
      wordTrig = false
    }, {

I'd really appreciate some help in fixing this or a heads-up if this is unsupported functionality.

Thanks

P.s I've attached relevant lua code for configuration.

(in plugins for lazy.nvim)

{'iurimateus/luasnip-latex-snippets.nvim', dependencies = {'L3MON4D3/LuaSnip'}},

(in nvim/after/plugins/luasnip-latex.lua)

require('luasnip-latex-snippets').setup({
    use_treesitter = true,
})

(in nvim/after/plugins/luasnip.lua)

require('luasnip').config.setup(
    { enable_autosnippets = true })

JonaGTHB avatar Dec 05 '23 20:12 JonaGTHB

I think those aren't set to automatically expand, since they might be too disruptive. They should show on completion though, if using e.g. cmp-luasnip.

iurimateus avatar Dec 08 '23 11:12 iurimateus

Hi, I'm having the same issue but :LuaSnipListAvailable does not show any of the snippets that do not automatically expand. For some reason they aren't being added? Edit: I fixed it by adding local math_i = require("luasnip-latex-snippets/math_i").retrieve(is_math) and ls.add_snippets("markdown", math_i, { default_priority = 0 })under M.setup_markdown in init.lua `

maxdulay avatar Jan 18 '24 06:01 maxdulay

Hi, I'm having the same issue but :LuaSnipListAvailable does not show any of the snippets that do not automatically expand. For some reason they aren't being added? Edit: I fixed it by adding local math_i = require("luasnip-latex-snippets/math_i").retrieve(is_math) and ls.add_snippets("markdown", math_i, { default_priority = 0 })under M.setup_markdown in init.lua `

Thanks! I've pushed a fix, although I don't think it's the same issue.

iurimateus avatar Jan 24 '24 13:01 iurimateus

Figured It Out, Here is what I did, what solved it for me!

Check if the plugin did load.

LuaSnipListAvailable

Check if it manually expands

:lua require'luasnip'.expand() :message -- in Lua messages are silenced (often) display error messages

If you use nvim.lazy

{ "iurimateus/luasnip-latex-snippets.nvim", -- vimtex isn't required if using treesitter branch = "fix/lazy-loading", -- change the branch dependencies = { "L3MON4D3/LuaSnip", "lervag/vimtex" }, ft = {"tex", "markdown" }, config = function() require'luasnip-latex-snippets'.setup({ use_treesitter = true }) -- or setup({ use_treesitter = true }) end, },

v0ry avatar Feb 09 '24 02:02 v0ry

      "iurimateus/luasnip-latex-snippets.nvim",
      -- vimtex isn't required if using treesitter
      branch = "fix/lazy-loading",
      dependencies = { "L3MON4D3/LuaSnip", "lervag/vimtex" },
      ft = {"tex", "markdown" },
      config = function()
        require'luasnip-latex-snippets'.setup({ use_treesitter = true })
        -- or setup({ use_treesitter = true })
      end,

v0ry avatar Feb 09 '24 02:02 v0ry