Replies: 2 comments 5 replies
-
Use |
Beta Was this translation helpful? Give feedback.
1 reply
-
Write this in e.g. lua/snippets_common.lua local M = {}
local expand_auto_allowed = true
vim.keymap.set({'i', 'n'}, '<A-a>', function() expand_auto_allowed = not expand_auto_allowed end)
local function condition_for_expand_auto()
return expand_auto_allowed
end
M.expand_auto_condition = require("luasnip.extras.conditions").make_condition(condition_for_expand_auto)
return M And then in your snippet files: local eac = require('snippets_common').expand_auto_condition
-- ...
s('if ', fmt('if {} then\n\t{}\nend', { i(1), i(0) }), {condition = eac}) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe there is a simple DIY solution like to assign an empty function to
expand_auto
, or to reconfigure luasnip on the fly (is it possible?).But I feel you could provide us a function which receives boolean and accordingly enables or disables
expand_auto
. What do you think?The bigger problem is that when you add autosnippets like
if
orwhile
you believe that they shouldn't expand in some environments like@string
or@comment
. Using treesitter api seems hard for that - I haven't found any tutorial for that (have you?).Beta Was this translation helpful? Give feedback.
All reactions