Open owiecc opened 2 weeks ago
I have considered this feature again and again, but I have a few unsure things on it:
<TAB>
repeatedly, I would like to have some mechanism to automatically expand them. but this is not great on entering symbol variants.bar.v
to bar
or bar.v.double
easily if we have already expanded it.#let gradient = math.nabla
Therefore, insteadly I'm considering some other inline previewing that won't insert many such unicodes in text documents, such as inlay hints on equations, like the following screenshot:
What's your opinion about it?
I think starting with manual expansion with a <TAB>
and testing the possibility of automating it is the easiest way to implement it. Manual expansion has none of the drawback that you mentioned and people can choose when to use it. Nothing changes for current users, they will not even notice the change. Once implemented the auto-expansion can be implemented on top of it.
From my experience with Julia, the <TAB>
is not that problematic. Adding one keystroke is not a lot when most symbol names in Typst have few to dozen characters. Remember that not all symbols need to be expanded. Maybe it is beneficial to expand only a few characters in key places to increase readability of an equation.
Maybe it is beneficial to expand only a few characters in key places to increase readability of an equation.
this might be a good idea. we may firstly adopt symbol list from typst-math extension
I am not sure what are u really looking for? Is it more like an input method for unicode or an immediate renderer for a subset of math mode? If the first solution, as an ime, is what u need, it is a common pattern to implement this mode with an extra trigger. I believe in Julia or Lean or Agda extension, start with \
triggers such an ime, and we can begin with general symbols in typst.
BTW, I also made a nvim-cmp source for this purpose: https://github.com/Eric-Song-Nop/cmp-typst-symbols
Motivation
It would be nice to be able to use the typst symbol input and be able to expand it to the corresponding glyph. This way equations like this:
$ nabla dot.c E = rho / epsilon_0 $
can be converted to a simpler notation:$ ∇·E = ρ / ε_0 $
. Both produce the same output but the latter is far more readable.Description
Typing
dot.c<TAB>
converts thedot.c
to·
in the source document.Examples/Questions
This is a similar idea to the way one can input symbols in Julia with completion.
I have proposed this feature to the, now deprecated, typst-lsp: https://github.com/nvarner/typst-lsp/issues/49 previously.
Relevant discussion on Julia discourse: https://discourse.julialang.org/t/unicode-autocomplete-howto/96752/2
Relevant typst extension: https://github.com/supersurviveur/typst-math
I am willing to set up a bounty for this feature.