From fc7d5b5101f2bd6f014a047f49f32fea4ef31437 Mon Sep 17 00:00:00 2001 From: arne314 <73391160+arne314@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:31:00 +0100 Subject: [PATCH] perf(snip): don't rely on luasnip wordtrig --- lua/typstar/autosnippets.lua | 4 ++-- lua/typstar/snippets/math.lua | 26 +++++++++++++------------- lua/typstar/snippets/visual.lua | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lua/typstar/autosnippets.lua b/lua/typstar/autosnippets.lua index 45d5230..c8a2ccb 100644 --- a/lua/typstar/autosnippets.lua +++ b/lua/typstar/autosnippets.lua @@ -44,14 +44,14 @@ function M.ri(insert_node_id) return luasnip.function_node(function(args) return args[1][1] end, insert_node_id) end -function M.snip(trigger, expand, insert, condition, priority, wordTrig) +function M.snip(trigger, expand, insert, condition, priority) priority = priority or 1000 return luasnip.snippet( { trig = trigger, trigEngine = M.engine, trigEngineOpts = { condition = condition }, - wordTrig = wordTrig, + wordTrig = false, priority = priority, snippetType = 'autosnippet', }, diff --git a/lua/typstar/snippets/math.lua b/lua/typstar/snippets/math.lua index 9470950..2232aea 100644 --- a/lua/typstar/snippets/math.lua +++ b/lua/typstar/snippets/math.lua @@ -34,28 +34,28 @@ return { snip('ge', '>>= ', {}, math), -- operators - snip('ak([^k ])', '+ <>', { cap(1) }, math, 100, false), - snip('sk([^k ])', '- <>', { cap(1) }, math, 100, false), - snip('oak', 'plus.circle ', {}, math, 1100), - snip('bak', 'plus.square ', {}, math, 1100), - snip('mak', 'plus.minus ', {}, math, 1100), - snip('xx', 'times ', {}, math), + snip('ak([^k ])', '+ <>', { cap(1) }, math, 100), + snip('sk([^k ])', '- <>', { cap(1) }, math, 100), + snip('oak', 'plus.circle ', {}, math), + snip('bak', 'plus.square ', {}, math), + snip('mak', 'plus.minus ', {}, math), + snip('xx', 'times ', {}, math, 900), snip('oxx', 'times.circle ', {}, math), snip('bxx', 'times.square ', {}, math), -- sets -- 'st' to '{<>} in ./visual.lua snip('set', '{<> | <>}', { i(1), i(2) }, math), - snip('es', 'emptyset ', {}, math), + snip('es', 'emptyset ', {}, math, 900), snip('ses', '{emptyset} ', {}, math), snip('sp', 'supset ', {}, math), snip('sb', 'subset ', {}, math), snip('sep', 'supset.eq ', {}, math), snip('seb', 'subset.eq ', {}, math), - snip('nn', 'sect ', {}, math), - snip('uu', 'union ', {}, math), - snip('bnn', 'sect.big ', {}, math, 1100), - snip('buu', 'union.big ', {}, math, 1100), + snip('nn', 'sect ', {}, math, 900), + snip('uu', 'union ', {}, math, 900), + snip('bnn', 'sect.big ', {}, math), + snip('buu', 'union.big ', {}, math), snip('swo', 'without ', {}, math), -- misc @@ -73,12 +73,12 @@ return { snip('(.*)kk', '<>^(<>)', { cap(1), i(1, 'n') }, math), snip('ddx', '(d <>)(d <>)', { i(1, 'f'), i(2, 'x') }, math), - snip('it', 'integral', {}, math), snip('int', 'integral_(<>)^(<>)', { i(1, 'a'), i(2, 'b') }, math), snip('oit', 'integral_Omega', {}, math), snip('dit', 'integral_(<>)', { i(1, 'Omega') }, math), + snip('it', 'integral ', {}, math, 900), - snip('sm', 'sum ', {}, math), + snip('sm', 'sum ', {}, math, 900), snip('sum', 'sum_(<>)^(<>)', { i(1, 'i=0'), i(2, 'oo') }, math), snip('osm', 'sum_Omega', {}, math), snip('dsm', 'sum_(<>)', { i(1, 'I') }, math), diff --git a/lua/typstar/snippets/visual.lua b/lua/typstar/snippets/visual.lua index 74b2f5d..0d7fefc 100644 --- a/lua/typstar/snippets/visual.lua +++ b/lua/typstar/snippets/visual.lua @@ -81,7 +81,7 @@ local smart_wrap = function(args, parent, old_state, expand) end for _, val in pairs(operations) do - table.insert(snippets, snip(val[1], '<>', { d(1, smart_wrap, {}, { user_args = { val } }) }, math, 1000, false)) + table.insert(snippets, snip(val[1], '<>', { d(1, smart_wrap, {}, { user_args = { val } }) }, math)) end return {