Allow toggling snippet auto expand or not.
parent
413cd02ae6
commit
f64e3f1f55
|
@ -151,6 +151,10 @@ return {
|
|||
{ trig = [[\lr]], wordTrig = false },
|
||||
t('↔')
|
||||
),
|
||||
s(
|
||||
{ trig = [[←r]], wordTrig = false },
|
||||
t('↔')
|
||||
),
|
||||
s(
|
||||
{ trig = [[\r]], wordTrig = false },
|
||||
t('→')
|
||||
|
@ -192,13 +196,17 @@ return {
|
|||
|
||||
-- Other operators
|
||||
s(
|
||||
{ trig = [[\neg]], wordTrig = false },
|
||||
{ trig = [[\not]], wordTrig = false },
|
||||
t('¬')
|
||||
),
|
||||
s(
|
||||
{ trig = [[\and]], wordTrig = false },
|
||||
t('∧')
|
||||
),
|
||||
s(
|
||||
{ trig = [[αnd]], wordTrig = false },
|
||||
t('∧')
|
||||
),
|
||||
s(
|
||||
{ trig = [[\or]], wordTrig = false },
|
||||
t('∨')
|
||||
|
@ -223,10 +231,18 @@ return {
|
|||
{ trig = [[\leq]], wordTrig = false },
|
||||
t('≤')
|
||||
),
|
||||
s(
|
||||
{ trig = [[←eq]], wordTrig = false },
|
||||
t('≤')
|
||||
),
|
||||
s(
|
||||
{ trig = [[\geq]], wordTrig = false },
|
||||
t('≥')
|
||||
),
|
||||
s(
|
||||
{ trig = [[γeq]], wordTrig = false },
|
||||
t('≥')
|
||||
),
|
||||
s(
|
||||
{ trig = [[\in]], wordTrig = false },
|
||||
t('∈')
|
||||
|
@ -235,5 +251,8 @@ return {
|
|||
{ trig = [[\notin]], wordTrig = false },
|
||||
t('∉')
|
||||
),
|
||||
|
||||
s(
|
||||
{ trig = [[¬in]], wordTrig = false },
|
||||
t('∉')
|
||||
),
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ function M.setup()
|
|||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'luasnip', option = { show_autosnippets = true } },
|
||||
{ name = 'nvim_lsp' },
|
||||
{
|
||||
name = 'buffer',
|
||||
|
|
|
@ -75,11 +75,24 @@ function M.setup()
|
|||
end, { silent = true, expr = true, remap = true })
|
||||
|
||||
-- Allow aborting the active snippet at any point in time.
|
||||
vim.keymap.set(
|
||||
{ 'n', 'i', 's' },
|
||||
'<c-l>',
|
||||
'<cmd>LuaSnipUnlinkCurrent<cr>'
|
||||
)
|
||||
vim.keymap.set({ 'n', 'i', 's' }, '<c-l>', '<cmd>LuaSnipUnlinkCurrent<cr>')
|
||||
|
||||
-- Allow toggling autoexpansion on and off. This is more or less the intended
|
||||
-- approach: https://github.com/L3MON4D3/LuaSnip/issues/832#issuecomment-1474993417
|
||||
luasnip.expand_auto_on = true
|
||||
|
||||
local expand_auto = luasnip.expand_auto
|
||||
local toggle_expand_auto = function()
|
||||
if luasnip.expand_auto_on then
|
||||
luasnip.expand_auto = function() end
|
||||
else
|
||||
luasnip.expand_auto = expand_auto
|
||||
end
|
||||
luasnip.expand_auto_on = not luasnip.expand_auto_on
|
||||
end
|
||||
|
||||
toggle_expand_auto()
|
||||
vim.keymap.set({ 'n', 'i', 's' }, '', toggle_expand_auto)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -24,4 +24,12 @@ function M.get_dap_status()
|
|||
end
|
||||
end
|
||||
|
||||
function M.get_autoexpand_status()
|
||||
if require('luasnip').expand_auto_on then
|
||||
return "🟢 auto"
|
||||
else
|
||||
return "🔴 auto"
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -20,6 +20,7 @@ let
|
|||
lualine_y = {
|
||||
require('utils.statusline').get_active_lsp,
|
||||
require('utils.statusline').get_dap_status,
|
||||
require('utils.statusline').get_autoexpand_status,
|
||||
},
|
||||
lualine_z = {'%c:%l:%%%p'},
|
||||
},
|
||||
|
@ -31,7 +32,9 @@ let
|
|||
plugin = pkgs.vimPlugins.luasnip;
|
||||
config = ''
|
||||
require('utils.luasnip').setup()
|
||||
require('luasnip').add_snippets('all', require('utf8.snippets'))
|
||||
require('luasnip').add_snippets('all', require('utf8.snippets'), {
|
||||
type = "autosnippets",
|
||||
})
|
||||
${config.programs.neovim.nvim-snippets}
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue