feat(snip)!: update latin greek map with reasons

This commit is contained in:
arne314
2025-08-03 12:00:15 +02:00
parent fcd3edbad2
commit 517d60b72a
2 changed files with 18 additions and 12 deletions

View File

@@ -14,6 +14,14 @@ To efficiently navigate insert nodes and avoid overlapping ones,
use `:TypstarSmartJump` and `:TypstarSmartJumpBack`.
Available snippets can mostly be intuitively derived from [here](././lua/typstar/snippets), they include:
Universal snippets:
- Alphanumeric characters: `:<char>` &#8594; `$<char>$ ` in markup (e.g. `:X` &#8594; `$X$ `, `:5` &#8594; `$5$ `)
- Greek letters: `;<latin>` &#8594; `<greek>` in math and `$<greek>$ ` in markup (e.g. `;a` &#8594; `alpha`/`$alpha$ `)
- Common indices (numbers and letters `i-n`): `<letter><index> ` &#8594; `<letter>_<index> ` in math and `$<letter>$<index> ` &#8594; `$<letter>_<index>$ ` in markup (e.g `A314 ` &#8594; `A_314 `, `$alpha$n ` &#8594; `$alpha_n$ `)
You can find a complete map of latin to greek letters including reasons for the less intuitive ones [here](./lua/typstar/snippets/letters.lua).
Note that some greek letters have multiple latin ones mapped to them.
Markup snippets:
- Begin inline math with `ll` and multiline math with `dm`
- [Markup shorthands](./lua/typstar/snippets/markup.lua) (e.g. `HIG` &#8594; `#highlight[<cursor>]`, `IMP` &#8594; `$==>$ `)
@@ -23,9 +31,6 @@ Markup snippets:
Math snippets:
- [Many shorthands](./lua/typstar/snippets/math.lua) for mathematical expressions
- Alphanumeric characters: `:<char>` &#8594; `$<char>$ ` in markup (e.g. `:X` &#8594; `$X$ `, `:5` &#8594; `$5$ `)
- Greek letters: `;<latin>` &#8594; `<greek>` in math and `$<greek>$ ` in markup (e.g. `;a` &#8594; `alpha`/`$alpha$ `)
- Common indices (numbers and letters `i-n`): `<letter><index> ` &#8594; `<letter>_<index> ` in math and `$<letter>$<index> ` &#8594; `$<letter>_<index>$ ` in markup (e.g `A314 ` &#8594; `A_314 `, `$alpha$n ` &#8594; `$alpha_n$ `)
- Series of numbered letters: `<letter> ot<optional last index> ` &#8594; `<letter>_1, <letter>_2, ... ` (e.g. `a ot ` &#8594; `a_1, a_2, ... `, `a ot4 ` &#8594; `a_1, a_2, a_3, a_4 `, `alpha otk ` &#8594; `alpha_1, alpha_2, ..., alpha_k `)
- 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>` &#8594; `<operation>(<expression>)` (e.g. `(a^2+b^2)rt` &#8594; `sqrt(a^2+b^2)`, `lambdatd` &#8594; `tilde(lambda)`, `(1+1)sQ` &#8594; `[1+1]`, `(1+1)sq` &#8594; `[(1+1)]`)
- Matrices: `<size>ma` and `<size>lma` (e.g. `23ma` &#8594; 2x3 matrix)

View File

@@ -16,31 +16,32 @@ local greek_letters_map = {
['c'] = 'chi',
['d'] = 'delta',
['e'] = 'epsilon',
['f'] = 'phi',
['f'] = 'phi', -- sound
['g'] = 'gamma',
['h'] = 'eta',
['h'] = 'eta', -- look
['i'] = 'iota',
['j'] = 'theta',
['k'] = 'kappa',
['l'] = 'lambda',
['m'] = 'mu',
['n'] = 'nu',
['o'] = 'omega',
['o'] = 'omikron',
['p'] = 'psi',
['q'] = 'eta',
['q'] = 'theta', -- look?
['r'] = 'rho',
['s'] = 'sigma',
['t'] = 'tau',
['v'] = 'nu',
['w'] = 'omega',
['u'] = 'upsilon',
['v'] = 'nu', -- look
['w'] = 'omega', -- look
['x'] = 'xi',
['y'] = 'upsilon',
['y'] = 'upsilon', -- look
['z'] = 'zeta',
}
local greek_keys = {}
local greek_letters_set = {}
local common_indices = { '\\d+', '[i-n]' }
-- buitins and caligraphic letters from github.com/lentilus/readable-typst
-- builtins and calligraphic letters from github.com/lentilus/typst-scribe
local index_conflicts = { 'Im', 'in', 'ln', 'Pi', 'pi', 'Xi', 'xi', 'Ii', 'Jj', 'Kk', 'Ll', 'Mm', 'Nn' }
local index_conflicts_set = {}
local punctuation_prepend_space = { ',', ';' }