Coder Social home page Coder Social logo

Comments (8)

L3MON4D3 avatar L3MON4D3 commented on June 12, 2024

Have you tried doing doautocmd User LuasnipSnippetsAdded after adding your snippets? It should happen automatically for snippets loaded via "luasnip.loaders.from_{vscode,snipmate}".load, but adding snippets to the table manually doesn't trigger the event.

from cmp_luasnip.

smjonas avatar smjonas commented on June 12, 2024

Thanks for the suggestion, I tried that but then require("luasnip.session").latest_load_ft seems to be nil and causes this error:

Error detected while processing User Autocommands for "LuasnipSnippetsAdded":
E5108: Error executing lua ...ite/pack/packer/opt/cmp_luasnip/lua/cmp_luasnip/init.lua:29: table index is
nil
stack traceback:
        ...ite/pack/packer/opt/cmp_luasnip/lua/cmp_luasnip/init.lua:29: in function 'refresh'
        [string ":lua"]:1: in main chunk

from cmp_luasnip.

L3MON4D3 avatar L3MON4D3 commented on June 12, 2024

Ahh right, forgot about that. I added a function, "luasnip".refresh_notify(filetype) to trigger that autocmd correctly.

from cmp_luasnip.

smjonas avatar smjonas commented on June 12, 2024

Thanks for your fast response! Unfortunately, I still get the same error even after upgrading Luasnip when running :doautocmd User LuasnipSnippetsAdded.

from cmp_luasnip.

L3MON4D3 avatar L3MON4D3 commented on June 12, 2024

Are you calling doautocmd or the refresh_notify? :D

from cmp_luasnip.

smjonas avatar smjonas commented on June 12, 2024

Ohh at first I was using doautocmd but :lua require("luasnip").refresh_notify("lua") does nothing. Are you sure it is possible with that command since I don't think Lua will automagically reload my module with the snippet definitions :D? My snippets are in a plugins/luasnip.lua module so I tried :lua package.loadedp["plugins.loaded"] = nil, then reloading it with packer but this also didn't work.

from cmp_luasnip.

L3MON4D3 avatar L3MON4D3 commented on June 12, 2024

Ohh, no, that we can't do. The refresh_notify only tells cmp_luasnip (or other plugins) that snippets were added.
You could register an autocommand that :luafiles plugins/luasnip.lua to reload your snippets, but that working also depends on what you do in there (won't work if you also load() snippets).
I recommend checking out this, it's a pretty nice setup that also has reload-capability.

from cmp_luasnip.

smjonas avatar smjonas commented on June 12, 2024

Alright, thanks for these tips, I will check out the link! I guess, I was just used to it from UltiSnips, but there it's easier to reload snippets on file save since a special filetype is used.

from cmp_luasnip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.