Merge branch 'main' into dev

This commit is contained in:
2025-10-30 09:41:08 +01:00
7 changed files with 458 additions and 354 deletions

View File

@@ -106,25 +106,25 @@ function M.engine(trigger, opts)
if not M.snippets_toggle or not condition() then return nil end
local first_idx = 1
if max_length ~= nil then
first_idx = #line_full - max_length -- include additional char for wordtrig
if first_idx < 0 then
if is_fixed_length then
-- include additional char for wordtrig
first_idx = #line_full - max_length
if first_idx < 1 then
if is_fixed_length and first_idx < 0 then
return nil
else
first_idx = 1
end
end
if first_idx > 0 then
if string.byte(line_full, first_idx) > 127 then return nil end
end
end
if line_full:byte(first_idx) > 127 then first_idx = 1 end -- avoid splitting bytes within unicode characters
local line = line_full:sub(first_idx)
local whole, captures = base_engine(line, trig)
if whole == nil then return nil end
-- custom word trig
local from = #line - #whole + 1
if opts.wordTrig and from ~= 1 and string.match(string.sub(line, from - 1, from - 1), '[%w.]') ~= nil then
local first_letter = line:sub(from - 1, from - 1)
if opts.wordTrig and from ~= 1 and (first_letter:byte(1) > 127 or first_letter:match('[%w._]') ~= nil) then
return nil
end

View File

@@ -24,7 +24,7 @@ local greek_letters_map = {
['l'] = 'lambda',
['m'] = 'mu',
['n'] = 'nu',
['o'] = 'omikron',
['o'] = 'omicron',
['p'] = 'psi',
['q'] = 'theta', -- look?
['r'] = 'rho',
@@ -129,8 +129,9 @@ return {
),
-- series of numbered letters
snip('ot(\\w) ', '1, 2, ..., <> ', { cap(1) }, math, 800), -- 1, 2, ..., n
snip('(' .. trigger_index_pre .. ') ot ', '<>_1, <>_2, ... ', { cap(1), cap(1) }, math), -- a_1, a_2, ...
snip('(' .. trigger_index_pre .. ') ot(\\w+) ', '<> ', { d(1, get_series) }, math, 1000, { maxTrigLength = 13 }), -- a_1, a_2, ... a_j or a_1, a_2, a_2, a_3, a_4, a_5
snip('(' .. trigger_index_pre .. ') ot(\\w+) ', '<> ', { d(1, get_series) }, math, nil, { maxTrigLength = 13 }), -- a_1, a_2, ... a_j or a_1, a_2, a_2, a_3, a_4, a_5
-- misc
snip('(' .. trigger_index_pre .. ')bl', 'B_<> (<>) ', { cap(1), i(1, 'x_0') }, math, 100),

View File

@@ -39,7 +39,7 @@ return {
snip('oak', 'plus.circle ', {}, math),
snip('bak', 'plus.square ', {}, math),
snip('mak', 'plus.minus ', {}, math),
snip('xx', 'times ', {}, math, 900),
snip('xx', 'times ', {}, math),
snip('oxx', 'times.circle ', {}, math),
snip('bxx', 'times.square ', {}, math),
snip('ff', '(<>) / (<>) <>', { i(1, 'a'), i(2, 'b'), i(3) }, math),
@@ -47,6 +47,7 @@ return {
-- exponents
snip('iv', '^(-1) ', {}, math, 500, { wordTrig = false, blacklist = { 'equiv' } }),
snip('tp', '^top ', {}, math, 500, { wordTrig = false }),
snip('sr', '^2 ', {}, math, 500, { wordTrig = false }),
snip('cb', '^3 ', {}, math, 500, { wordTrig = false }),
snip('jj', '_(<>) ', { i(1, 'n') }, math, 500, { wordTrig = false }),
@@ -55,15 +56,15 @@ return {
-- sets
-- 'st' to '{<>} in ./visual.lua
snip('set', '{<> | <>}', { i(1), i(2) }, math),
snip('es', 'emptyset ', {}, math, 900),
snip('set', '{<> mid(|) <>}', { i(1), i(2) }, math),
snip('es', 'emptyset ', {}, math),
snip('ses', '{emptyset} ', {}, math),
snip('sp', 'supset ', {}, math),
snip('sb', 'subset ', {}, math),
snip('sep', 'supset.eq ', {}, math),
snip('seb', 'subset.eq ', {}, math),
snip('nn', 'inter ', {}, math, 900),
snip('uu', 'union ', {}, math, 900),
snip('nn', 'inter ', {}, math),
snip('uu', 'union ', {}, math),
snip('bnn', 'inter.big ', {}, math),
snip('buu', 'union.big ', {}, math),
snip('swo', 'without ', {}, math),
@@ -76,25 +77,27 @@ return {
snip('cc', 'cases(\n\t<>\n)\\', { i(1, '1') }, math),
snip('([A-Za-z])o([A-Za-z0-9]) ', '<>(<>) ', { cap(1), cap(2) }, math, 100, {
maxTrigLength = 4,
blacklist = { 'bot ', 'cos ', 'cot ', 'dot ', 'log ', 'mod ', 'top ', 'won ', 'xor ' },
blacklist = { 'bot ', 'cos ', 'cot ', 'dot ', 'log ', 'mod ', 'top ', 'won ', 'xor ' },
}),
snip('(K|M|N|Q|R|S|Z)([\\dn]) ', '<><>^<> ', { cap(1), cap(1), cap(2) }, math),
snip('dx', 'dif / (dif <>) ', { i(1, 'x') }, math, 900),
snip('dx', 'dif / (dif <>) ', { i(1, 'x') }, math),
snip('ddx', '(dif <>) / (dif <>) ', { i(1, 'f'), i(2, 'x') }, math),
snip('DX', 'diff / (diff <>) ', { i(1, 'x') }, math, 900),
snip('DX', 'diff / (diff <>) ', { i(1, 'x') }, math),
snip('DDX', '(diff <>) / (diff <>) ', { i(1, 'f'), i(2, 'x') }, math),
snip('part', 'partial ', {}, math, 1600),
snip('it', 'integral ', {}, math, 900),
snip('iot', 'integral.vol ', {}, math, 900),
snip('it', 'integral ', {}, math),
snip('iot', 'integral.vol ', {}, math),
snip('int', 'integral_(<>)^(<>) ', { i(1, 'a'), i(2, 'b') }, math),
snip('oit', 'integral_Omega ', {}, math),
snip('oit', 'integral.cont_(<>) ', { i(1, 'C') }, math),
snip('dit', 'integral_(<>) ', { i(1, 'Omega') }, 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),
snip('sm', 'sum ', {}, math),
snip('sum', 'sum_(<>)^(<>) ', { i(1, 'k=1'), i(2, 'oo') }, math),
snip('dsm', 'sum_(<>) ', { i(1, 'Omega') }, math),
snip('prd', 'product ', {}, math),
snip('prod', 'product_(<>)^(<>) ', { i(1, 'k=1'), i(2, 'n') }, math),
snip('lm', 'lim ', {}, math),
snip('lim', 'lim_(<> ->> <>) ', { i(1, 'n'), i(2, 'oo') }, math),
@@ -104,7 +107,7 @@ return {
'lim<><> ',
{ cap(2), cap(1) },
math,
1000,
nil,
{ maxTrigLength = 25 }
),
}