-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
toggle autostnippets #1281
Comments
This seems like a nice addition, and, while I have not yet considered changing settings of a running session (how it interacts with already-expanded snippets, for example), en/disabling autosnippets should not cause any issues as that only means re/unregistering an autocommand :) I'll look into what other settings can be sensibly changed during a running session, until then (and it may be a while because I don't have much time to spend on luasnip at the moment) you can also assing |
Thanks for the advice and your work on this! Good call to use an empty function, I just have a question: how would you go about creating a single command to toggle with this approach? It seems like it would require some kind of state (which maybe is more of a neovim question), or some kind of luasnip status query function. |
Oh, for your config, I'd recommend something like local enable_autosnippets = true
ls.setup({
enable_autosnippets = enable_autosnippets
})
local expand_autosnippets_orig = ls.expand_auto
local nop = function() end
vim.keymap.set({ "i", "s" }, "<C-c>", function()
enable_autosnippets = not enable_autosnippets
if enable_autosnippets then
ls.expand_auto = expand_autosnippets_orig
else
ls.expand_auto = nop
end
end, { silent = false }) So, store the original function in a variable and then assign it or a function that does nothing based on |
I'm sure this is possible in the with some kind of scripting via the setup function, but it would be nice to have a dedicated method (unless I'm missing it from the docs). I have a bunch of snippets that are single letters that auto trigger, I would like to be able to enable and disable this functionality with a command. I came up with this to disable them:
Which is most of what I want, but toggling them with the same shortcut would be nice. Maybe there is some way to do that in nvim like a state variable, or maybe some kind of query for the status of enable_autostnippets
The text was updated successfully, but these errors were encountered: