mirror of
https://github.com/Ascyii/typstar.git
synced 2026-01-01 05:24:24 -05:00
feat(snip): otn for generic number series
This commit is contained in:
@@ -31,7 +31,7 @@ Markup snippets:
|
|||||||
|
|
||||||
Math snippets:
|
Math snippets:
|
||||||
- [Many shorthands](./lua/typstar/snippets/math.lua) for mathematical expressions
|
- [Many shorthands](./lua/typstar/snippets/math.lua) for mathematical expressions
|
||||||
- Series of numbered letters: `<letter> ot<optional last index> ` → `<letter>_1, <letter>_2, ... ` (e.g. `a ot ` → `a_1, a_2, ... `, `a ot4 ` → `a_1, a_2, a_3, a_4 `, `alpha otk ` → `alpha_1, alpha_2, ..., alpha_k `)
|
- Series of numbered letters: `<letter> ot<optional last index> ` → `<letter>_1, <letter>_2, ... ` (e.g. `a ot ` → `a_1, a_2, ... `, `a ot4 ` → `a_1, a_2, a_3, a_4 `, `alpha otk ` → `alpha_1, alpha_2, ..., alpha_k `, `oti ` → `1, 2, ..., i `)
|
||||||
- Wrapping of any mathematical expression (see [operations](./lua/typstar/snippets/visual.lua), works nested, multiline and in visual mode via the [selection key](#installation)): `<expression><operation>` → `<operation>(<expression>)` (e.g. `(a^2+b^2)rt` → `sqrt(a^2+b^2)`, `lambdatd` → `tilde(lambda)`, `(1+1)sQ` → `[1+1]`, `(1+1)sq` → `[(1+1)]`)
|
- Wrapping of any mathematical expression (see [operations](./lua/typstar/snippets/visual.lua), works nested, multiline and in visual mode via the [selection key](#installation)): `<expression><operation>` → `<operation>(<expression>)` (e.g. `(a^2+b^2)rt` → `sqrt(a^2+b^2)`, `lambdatd` → `tilde(lambda)`, `(1+1)sQ` → `[1+1]`, `(1+1)sq` → `[(1+1)]`)
|
||||||
- Simple functions: `fo<value> ` → `f(<value>) ` (e.g. `fox ` → `f(x) `, `ao5 ` → `a(5) `)
|
- Simple functions: `fo<value> ` → `f(<value>) ` (e.g. `fox ` → `f(x) `, `ao5 ` → `a(5) `)
|
||||||
- Matrices: `<size>ma` and `<size>lma` (e.g. `23ma` → 2x3 matrix)
|
- Matrices: `<size>ma` and `<size>lma` (e.g. `23ma` → 2x3 matrix)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ function M.engine(trigger, opts)
|
|||||||
|
|
||||||
-- custom word trig
|
-- custom word trig
|
||||||
local from = #line - #whole + 1
|
local from = #line - #whole + 1
|
||||||
if opts.wordTrig and from ~= 1 and string.match(string.sub(line, from - 1, from - 1), '[%w.]') ~= nil then
|
if opts.wordTrig and from ~= 1 and string.match(line:sub(from - 1, from - 1), '[%w._]') ~= nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ return {
|
|||||||
),
|
),
|
||||||
|
|
||||||
-- series of numbered letters
|
-- 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 ', '<>_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, 1000, { maxTrigLength = 13 }), -- a_1, a_2, ... a_j or a_1, a_2, a_2, a_3, a_4, a_5
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user