Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support typst as a document format #24

Open
lukasjuhrich opened this issue Apr 26, 2024 · 1 comment
Open

Support typst as a document format #24

lukasjuhrich opened this issue Apr 26, 2024 · 1 comment

Comments

@lukasjuhrich
Copy link

lukasjuhrich commented Apr 26, 2024

Hi,

I want to make textlsp work with typst (gh).
It has a working tree-sitter-implementation (this is what helix currently uses).

I have never worked with tree-sitter and would like to take this as an opportunity to learn the topic, so please treat me as completely ignorant.

What do I have to do to implement this? I assume something similar as in documents/latex, but where is the upstream grammar specified?

@hangyav
Copy link
Owner

hangyav commented May 1, 2024

Hi,

Thanks for your interest in the project. I'd be happy for a PR adding support for typst.

AFAIK there is no grammar specified for how exactly to extract text from the TS parse. So far I looked at the parse of a few files to figure out the relevant content/nodes. To do this I used a TS playground tool (neovim in my case, helix might have an equivalent or simply this).

The documentation on how to add new parsers is a bit weak at this point, but yes latex.py:_iterate_text_nodes which is the main function to implement is a good place to start. The main idea is to sequentially return TextNode objects representing words and whitespaces to build the cleaned content of a given file (textual content to be analysed by the tools). Important building blocks are paragraphs (text block separated from others by an empty line), which you can think of as atomic units for the analysers. So you might need to add empty lines even though there isn't one in the source, e.g., after a section title even if the next paragraph is not separated with and empty line. Also, take a look at the tests to see some examples.

Hope this helps to get started. Let me know if there's anything that's not clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants