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

feat: add LaTeX parser #100

Closed
wants to merge 9 commits into from
Closed

feat: add LaTeX parser #100

wants to merge 9 commits into from

Conversation

grantlemons
Copy link
Collaborator

No description provided.

@grantlemons grantlemons changed the title feat: add latex parser feat: add LaTeX parser Aug 5, 2024
@lervag
Copy link

lervag commented Aug 12, 2024

Just a random thought, if anyone would find it of interest: I've already written a little bit about things like grammar checkers and LSPs in the VimTeX docs. If and when this PR is finished and merged, I think it could be of interest to the community that I also mention Harper as a possible tool for spell and grammar checking (for the English language). I think it should be mentioned under :help vimtex-af-lsp and :help vimtex-grammar. I would be happy to consider a PR, but also to write something myself. The latter would be easier if someone could help me with providing some good relevant links to how a Vim/Neovim user could "get started" with Harper.

@grantlemons
Copy link
Collaborator Author

Update: This is mostly functional, but does not treat macros in paragraphs correctly.
Additionally, it lints package import configuration, which is non-optional.

@grantlemons
Copy link
Collaborator Author

To anyone waiting on this, sorry for the lack of progress, LaTeX is such a weird language, and nvim-treesitter itself sometimes has trouble.

The biggest issue is considering the inputs to macros as separate sentences, and giving lints about capitalization.

@lervag
Copy link

lervag commented Oct 4, 2024

No worries, take your time. It's no surprise, really! 😅

@grantlemons grantlemons closed this by deleting the head repository Oct 5, 2024
@grantlemons
Copy link
Collaborator Author

Note, this isn't actually closed, but I moved it to a branch of the main repository instead of my fork. Not sure I can edit the PR to reflect that though.

@pinpox
Copy link

pinpox commented Oct 17, 2024

Note, this isn't actually closed, but I moved it to a branch of the main repository instead of my fork

I'm trying to use harper with typst and would consider contributing support for it. Could your work for latex (which has a similiar use-case) be expanded to that? If not, please link the new PR/branch, maybe I can figure out how to build it from there.

@lervag
Copy link

lervag commented Oct 17, 2024

@pinpox The typst syntax is very different than latex syntax, though, isn't it?

@pinpox
Copy link

pinpox commented Oct 17, 2024

@pinpox The typst syntax is very different than latex syntax, though, isn't it?

Yes, it is more similar to markdown. typst has treesitter and LSP support though, which if I understand correctly are used for Latex support implementation.

I suppose it would be a matter of just interfacing with a different treesitter grammar to extract text parts, but I might be wrong.

@grantlemons grantlemons mentioned this pull request Nov 29, 2024
@grantlemons
Copy link
Collaborator Author

@pinpox The typst syntax is very different than latex syntax, though, isn't it?

Yes, it is more similar to markdown. typst has treesitter and LSP support though, which if I understand correctly are used for Latex support implementation.

I suppose it would be a matter of just interfacing with a different treesitter grammar to extract text parts, but I might be wrong.

Thankfully, Typst is written in Rust, so the folks over there have already done the work of creating a parsing crate that we can interface with, which is a lot simpler than using the treesitter implementation.

LaTeX in particular is tough because of macros, which are expanded at compile-time, so we can't know how a piece of text is expanded just through grabbing every text node from treesitter.

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

Successfully merging this pull request may close these issues.

3 participants