-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension seems to be getting clobbered by other Telescope extensions #22
Comments
I've the same problem and no solution. |
Not sure why M.opts is nil in luasnip_fn, even though it's set at the top-level of the module, but anyway, here are the changes I made to workaround it... luasnip.lua @ line 68: M.opts = {
preview = {
check_mime_type = true,
},
} To: local _opts = {
preview = {
check_mime_type = true,
},
}
M.opts = _opts luasnip.lua @ line 74: opts = vim.tbl_extend('keep', opts or {}, M.opts) To: local opts = vim.tbl_extend('keep', opts or {}, M.opts or _opts) luasnip.lua @ line 177: M.opts = vim.tbl_extend('keep', optsExt, opts) To: M.opts = vim.tbl_extend('keep', optsExt or {}, opts or {}, M.opts or _opts) |
Hi; sorry I'm late to the party. I've been flat out with real life. I'm not a plugin expert myself, I'm afraid. This was originally meant as a straightforward port of the Ultisnips Telescope extension to LuaSnip to scratch a personal itch, and has sprouted a few legs since. Issues may have crept in as we've found and fixed edge cases. I looked OP's stack trace, and then noticed independently that I myself had thought that the proper way to define modules was to declare I tried out simply declaring M as local in that module, and it seemed to work fine for me.
EDIT: Spoke too soon! It broke snippet loading for me, and I have a report due. I'll test @xorander00 's solution now. |
I put @xorander00's changes into a branch - Thanks again, @prurph and @xorander00 ! |
This is what I do too and is a very common pattern in Lua. You've got it right, IMO.
I completely missed that M wasn't local lol. That could have something to do with opts being nil in luasnip_fn, though I don't remember lifetime/scoping rules in Lua off the top of my head. My workaround is pretty lame and just defensively falling back to empty tables + the locally declared _opts table. It would be better to figure out why M.opts is nil in luasnip_fn. |
Agreed -- I think this needs a bit more investigation. I'll try and get to this shortly, as I've just gotten past crunch time, but if you've got time to dig in a little further, I won't stop you ;-) |
I reset my changes back to the latest commit and took a look again really quick. I changed M to be local and merged the M.opts {} assignment into the M initialization line. Seems to be working for me, but I've only used it for a couple of minutes and I have a bunch of stuff left on to todo-list for today. If anyone else wants to try it and see how it goes for them, the patch is below. If a PR is needed, let me know. diff --git a/lua/telescope/_extensions/luasnip.lua b/lua/telescope/_extensions/luasnip.lua
index 7eee771..05beaff 100644
--- a/lua/telescope/_extensions/luasnip.lua
+++ b/lua/telescope/_extensions/luasnip.lua
@@ -14,7 +14,11 @@ local conf = require("telescope.config").values
local ext_conf = require("telescope._extensions")
-- stylua: ignore end
-M = {}
+local M = {
+ preview = {
+ check_mime_type = true,
+ },
+}
local filter_null = function(str, default)
return str and str or (default and default or '')
@@ -65,11 +69,6 @@ local default_search_text = function(entry)
.. filter_description(entry.context.name, entry.context.description)
end
-M.opts = {
- preview = {
- check_mime_type = true,
- },
-}
M.luasnip_fn = function(opts)
opts = vim.tbl_extend('keep', opts or {}, M.opts) |
Late to the party here, but I think the reason is that if any other extension also sets M as a global, and loads after this extension, it wipes out the global created here. I ran into this yesterday and tracked it down to orgmode addressed this quickly once I reported it, and their fix was also to just do a local M. |
This should be addressed now. I've applied a pair of small fixes, and tested it. Nothing seems to have regressed so far. Please shout if you see anything! |
Fix applied. |
I'm trying to use
telescope-luasnip.nvim
with LazyVim, which bundles a few other telescope extensions. The issue I'm having is that:Telescope luasnip
works exactly once, then subsequent invocations give the following error:My config is:
where
on_load
is used for other telescope etensions in LazyVim that work correctly. I've also tried a lot of different orders to ensure the extension isn't being loaded until after Telescope is setup, as well as not adding any explicit config at all and just letting the extension autoload but no dice. The fact it works properly once makes me think that's not an issue with it loading the first time, rather something corrupting/clobbering/overwriting it.it seems like this extension sets a global and my guess is that somehow gets clobbered when other extensions are invoked. This is supported by the fact that
:Telescope luasnip
will give that error on the first invocation if I call any other Telescope picker first.I'm certainly far from an nvim plugin or Lua expert, but I'm confused why M appears to be global here. That said, I tried renaming it and the issue persisted, so it doesn't seem to be a name collision. I haven't tried disabling other extensions yet because this one is less critical to my workflow and all of the others seem to work alongside along side each other without any issues. Any thoughts on how I might debug this? Thanks!
The text was updated successfully, but these errors were encountered: