-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(languages): Lean experimental tree-sitter-lean #1422
Conversation
Cool :) Let me know how it goes. There are lots of issues (and in neovim it's super painful perf wise at the minute because the queries are large), but it does work. |
BTW is the parser the C output of the compiled Lean parser? And would it make sense to rather use the Lean source for compiling this? I've been making several Lean <-> C <-> Rust bindings. |
It's what
The grammar was mostly hand-ported (first not-very-directly, now somewhat directly) from the Lean source. It did (does) occur to me that it may be possible to transpile it but I haven't experimented with doing so. |
Currently the syntax highlight only works when there is an error. The LSP works fine, but it needs to have some display of the '$/lean/fileProgress' notification (which I'm guessing is the goal view). |
|
I think this should be improved with tree-sitter v0.20.2 (see tree-sitter/tree-sitter#1510), but I'm not sure if dependabot has ugraded that dependency yet in helix |
Yes! Indeed that change fixed the perf issue on the neovim side. |
Co-authored-by: Ivan Tham <pickfire@riseup.net>
0.20.2 is in master, but I've accidentally excluded it from the 0.6 release. I'll push a patch release later this week to include some bug fixes so it'll be included in a stable release then as well. |
So do you want to merge this? It works for me although more features could be added like a lean info view. |
I'll do a thorough review later today, but as mentioned on Matrix, the highlights need to be modified to match https://docs.helix-editor.com/themes.html#syntax-highlighting There's no Similarly the injections.scm definitions are different |
@archseer Are we okay for merging? I'll probably add an Lean info view in a later PR. |
runtime/queries/lean/highlights.scm
Outdated
; Variables | ||
(identifier) @variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll want to move this stanza down to the bottom of the file. The higher in the file, the higher the precedence with helix (it's reversed in neovim), so this stanza will match all identifiers and so the rules on L38-L67 will never match.
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
I notice that there are still several bugs in the highlightning, but this is probably an error in the lean-tree-sitter parser and not here. |
Yes, there are still plenty of parsing bugs. Issues or patches are of course welcome. |
Co-authored-by: Michael Davis <michael.davis@nfiindustries.com>
@the-mikedavis So let's merge? |
Sorry for the delay, I'll merge after the CI run 👍🏻 |
Probably not the best place to raise this, but @Julian any idea why the compiled Lean grammar is so big? It's 16MB, compared to haskell's 3.2MB or rust's 1.1MB. |
It's a big/complicated grammar -- IIRC Agda's is similarly large and ran into some of the same tree-sitter issues I ran into. There's some improvements possible but right now improving it has been somewhat low priority for me in favor of other Lean editor things (and other obligations entirely). PRs certainly welcome. |
Trying out the experimental tree-sitter-lean from @Julian