diff --git a/lua/typstar/autosnippets.lua b/lua/typstar/autosnippets.lua index 8bf494e..3111cdd 100644 --- a/lua/typstar/autosnippets.lua +++ b/lua/typstar/autosnippets.lua @@ -32,7 +32,14 @@ end function M.snip(trigger, expand, insert, condition, priority) priority = priority or 1000 return luasnip.snippet( - { trig = trigger, regTrig = true, wordtrig = false, priority = priority, snippetType = 'autosnippet' }, + { + trig = trigger, + trigEngine = 'ecma', + regTrig = true, + wordtrig = false, + priority = priority, + snippetType = 'autosnippet' + }, fmta(expand, { unpack(insert) }), { condition = function() @@ -46,7 +53,7 @@ function M.snip(trigger, expand, insert, condition, priority) end function M.start_snip(trigger, expand, insert, condition, priority) - return M.snip('^%s*' .. trigger, expand, insert, condition, priority) + return M.snip('^\\s*' .. trigger, expand, insert, condition, priority) end function M.toggle_autosnippets() diff --git a/lua/typstar/snippets/letters.lua b/lua/typstar/snippets/letters.lua index 50b661c..4230039 100644 --- a/lua/typstar/snippets/letters.lua +++ b/lua/typstar/snippets/letters.lua @@ -29,7 +29,7 @@ local greek_letters = { { 'z', 'zeta' }, { 'Z', 'Zeta' }, } local latin_letters = { 'f', 'u', 'v', 'w', 'y' } -- remaining ones are added dynamically -local common_indices = { '%d+', 'i', 'j', 'k', 'n' } +local common_indices = { '\\d+', 'i', 'j', 'k', 'n' } for _, letter in ipairs({ unpack(latin_letters) }) do table.insert(latin_letters, letter:upper()) @@ -40,7 +40,7 @@ local generate_index_snippets = function(letter) table.insert(letter_snippets, snip(letter .. '(' .. index .. ') ', letter .. '_(<>) ', { cap(1) }, math, 200)) table.insert(letter_snippets, - snip('$' .. letter .. '$(' .. index .. ') ', '$' .. letter .. '_(<>)$ ', { cap(1) }, markup, 200)) + snip('\\$' .. letter .. '\\$(' .. index .. ') ', '$' .. letter .. '_(<>)$ ', { cap(1) }, markup, 200)) end end diff --git a/lua/typstar/snippets/math.lua b/lua/typstar/snippets/math.lua index 691faf5..7a0ee5c 100644 --- a/lua/typstar/snippets/math.lua +++ b/lua/typstar/snippets/math.lua @@ -75,8 +75,6 @@ return { snip('lm', 'lim <>', { i(1, 'a_n') }, math), snip('lim', 'lim_(<> ->> <>) <>', { i(1, 'n'), i(2, 'oo'), i(3, 'a_n') }, math), - snip('lim sup', 'limsup <>', { i(1, 'a_n') }, math), - snip('lim(_.*%-.*) sup', 'limsup<> <>', { cap(1), i(1, 'a_n') }, math), - snip('lim inf', 'liminf <>', { i(1, 'a_n') }, math), - snip('lim(_.*%-.*) inf', 'liminf<> <>', { cap(1), i(1, 'a_n') }, math), + snip('lim (sup|inf)', 'lim<> <>', { cap(1), i(1, 'a_n') }, math), + snip('lim(_.*-.*) (sup|inf)', 'lim<><> <>', { cap(2), cap(1), i(1, 'a_n') }, math), } diff --git a/lua/typstar/snippets/matrix.lua b/lua/typstar/snippets/matrix.lua index bb077da..8c76aac 100644 --- a/lua/typstar/snippets/matrix.lua +++ b/lua/typstar/snippets/matrix.lua @@ -78,6 +78,6 @@ local lmat = function(_, sp) end return { - snip('(%d)(%d)ma', 'mat(\n\t<>\n)', { d(1, mat) }, math), - snip('(%d)(%d)lma', 'mat(\n\t<>\n)', { d(1, lmat) }, math), + snip('(\\d)(\\d)ma', 'mat(\n\t<>\n)', { d(1, mat) }, math), + snip('(\\d)(\\d)lma', 'mat(\n\t<>\n)', { d(1, lmat) }, math), } diff --git a/lua/typstar/snippets/visual.lua b/lua/typstar/snippets/visual.lua index 6bf869d..693bf8c 100644 --- a/lua/typstar/snippets/visual.lua +++ b/lua/typstar/snippets/visual.lua @@ -61,12 +61,12 @@ end for _, val in pairs(operations) do table.insert(snippets, snip(val[1], val[2] .. '<>' .. val[3], { d(1, get_visual) }, math)) - table.insert(snippets, snip('[%s$]' .. val[1], val[2] .. '<>' .. val[3], { i(1, '1') }, math)) + table.insert(snippets, snip('[\\s$]' .. val[1], val[2] .. '<>' .. val[3], { i(1, '1') }, math)) table.insert(snippets, - snip('([%w]+)' + snip('([\\w]+)' .. val[1], val[2] .. '<>' .. val[3], { cap(1) }, math, 900)) table.insert(snippets, - snip('(.*[%)|%]|%}])' .. val[1], '<>', { f(wrap_brackets, {}, { user_args = { val } }), nil }, math, 1100)) + snip('(.*[\\)|\\]|\\}])' .. val[1], '<>', { f(wrap_brackets, {}, { user_args = { val } }), nil }, math, 1100)) end return {