Closed yangwenbo99 closed 11 months ago
This is great, thank you! I appreciate your input about symbol concealing. I will make sure to look into it once I find some time. And, if you happen to make something work sooner I'd be happy to merge it!
Thank you for the great project. When you have time, take a look at the symbol concealing file I generated using this script. It is partially working, except that I haven't written the part for superscripts and subscripts.
@kaarmu Now, the syntax concealing generated by this script is rather usable (see below), with some modifications to the syntax file required:
syntax match typstMathNumber
\ /\(\<\|_\)\@<=\d\+\>/
\ contained
syntax cluster typstMath
\ contains=@typstCommon
\ ,@typstHashtag
\ ,typstMathFunction
\ ,typstMathNumber
\ ,typstMathSymbol
\ ,typstMathBold
\ ,typstMathScripts
highlight default link typstMathScripts Number
However, the generated syntax script for math concealing is rather long (1150 lines currently, and will increase in the future), direct copy-and-paste it into your project might not be the best idea. Perhaps just put in README.md
and let user generate the syntax file by themselves? I am currently using
python syntax.py > ~/.config/nvim/after/syntax/typst.vim
This is really cool, @yangwenbo99. I think ~1000 lines is not a problem especially considering that other vim plugins can be really big, e.g. vimtex. Though you make a valid point that it will have to be updated over time.
All in all, my opinion is that it will be more useful for most people (even if not complete) to include one big syntax file for all the symbols. Then perhaps there will exist some edge-cases but my general approach is 80/20 rule. We can of course also add instructions in the README pointing to your script to generate new syntax files as well.
So, if you want to then I'd love to merge this. In that case I think it's best if you create a new PR with the symbols syntax file for this version of typst (I had some problem running your script, missing an html file) and write the instructions in the README (you know best on this one).
Great work!
@kaarmu The two html files are typst's reference pages:
wget https://typst.app/docs/reference/symbols/ -O symbols_0.html
wget https://typst.app/docs/reference/symbols/sym/ -O symbols.html
python syntax.py > typst.vim
The newer version supports the standard bold(x)
bold font and concealing of scripts. (See the note)
Alright, of course! It is updated!
I added some basic math mode syntax highlights. I think symbol concealing should be automatically generated using a script instead. A generated conceal syntax file is here.