iurimateus / luasnip-latex-snippets.nvim

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

Some Snippets dont expand #27

Closed JonaGTHB closed 5 months ago

JonaGTHB commented 10 months ago

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 })
iurimateus commented 9 months ago

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.

maxdulay commented 8 months ago

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 `

iurimateus commented 8 months ago

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.

v0ry commented 7 months ago

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 commented 7 months ago
      "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,