-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
40c28ec
Add experimental tree-sitter-lean
Anderssorby 6bc6d78
Run docgen
Anderssorby 35b56e3
Copy over the queries from lean.nvim
Anderssorby 6d7ea9f
Update .gitmodules
Anderssorby a3c4408
Update lean highlights and run docgen
Anderssorby 9655ba3
Merge remote-tracking branch 'upstream/master' into acs/add-lean
Anderssorby a4e96bd
Update runtime/queries/lean/injections.scm
Anderssorby 6890c08
Lean: Move variable matcher to bottom
Anderssorby 47af837
Update runtime/queries/lean/locals.scm
Anderssorby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule tree-sitter-lean
added at
d98426
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
(namespace) | ||
(section) | ||
|
||
(instance) | ||
(def) | ||
(theorem) | ||
(example) | ||
|
||
(product) | ||
(array) | ||
(list) | ||
|
||
(string) | ||
] @fold |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
(open | ||
namespace: (identifier) @namespace) | ||
(namespace | ||
name: (identifier) @namespace) | ||
(section | ||
name: (identifier) @namespace) | ||
|
||
; Variables | ||
(identifier) @variable | ||
|
||
;; Identifier naming conventions | ||
((identifier) @type | ||
(#match? @type "^[A-Z]")) | ||
|
||
(arrow) @type | ||
(product) @type | ||
|
||
;; Declarations | ||
|
||
[ | ||
"abbrev" | ||
"def" | ||
"theorem" | ||
"constant" | ||
"instance" | ||
"axiom" | ||
"example" | ||
"inductive" | ||
"structure" | ||
"class" | ||
|
||
"deriving" | ||
|
||
"section" | ||
"namespace" | ||
] @keyword | ||
|
||
(attributes | ||
(identifier) @function) | ||
|
||
(abbrev | ||
name: (identifier) @type) | ||
(def | ||
name: (identifier) @function) | ||
(theorem | ||
name: (identifier) @function) | ||
(constant | ||
name: (identifier) @type) | ||
(instance | ||
name: (identifier) @function) | ||
(instance | ||
type: (identifier) @type) | ||
(axiom | ||
name: (identifier) @function) | ||
(structure | ||
name: (identifier) @type) | ||
(structure | ||
extends: (identifier) @type) | ||
|
||
(where_decl | ||
type: (identifier) @type) | ||
|
||
(proj | ||
name: (identifier) @field) | ||
|
||
(binders | ||
type: (identifier) @type) | ||
|
||
["if" "then" "else"] @keyword.control.conditional | ||
|
||
["for" "in" "do"] @keyword.control.repeat | ||
|
||
(import) @include | ||
|
||
; Tokens | ||
|
||
[ | ||
"!" | ||
"$" | ||
"%" | ||
"&&" | ||
"*" | ||
"*>" | ||
"+" | ||
"++" | ||
"-" | ||
"/" | ||
"::" | ||
":=" | ||
"<" | ||
"<$>" | ||
"<*" | ||
"<*>" | ||
"<=" | ||
"<|" | ||
"<|>" | ||
"=" | ||
"==" | ||
"=>" | ||
">" | ||
">" | ||
">=" | ||
">>" | ||
">>=" | ||
"@" | ||
"^" | ||
"|>" | ||
"|>." | ||
"||" | ||
"←" | ||
"→" | ||
"↔" | ||
"∘" | ||
"∧" | ||
"∨" | ||
"≠" | ||
"≤" | ||
"≥" | ||
] @operator | ||
|
||
[ | ||
"@&" | ||
] @operator | ||
|
||
[ | ||
"attribute" | ||
"by" | ||
"end" | ||
"export" | ||
"extends" | ||
"fun" | ||
"let" | ||
"have" | ||
"match" | ||
"open" | ||
"return" | ||
"universe" | ||
"variable" | ||
"where" | ||
"with" | ||
"λ" | ||
(hash_command) | ||
(prelude) | ||
(sorry) | ||
] @keyword | ||
|
||
[ | ||
"prefix" | ||
"infix" | ||
"infixl" | ||
"infixr" | ||
"postfix" | ||
"notation" | ||
"macro_rules" | ||
"syntax" | ||
"elab" | ||
"builtin_initialize" | ||
] @keyword | ||
|
||
[ | ||
"noncomputable" | ||
"partial" | ||
"private" | ||
"protected" | ||
"unsafe" | ||
] @keyword | ||
|
||
[ | ||
"apply" | ||
"exact" | ||
"rewrite" | ||
"rw" | ||
"simp" | ||
(trivial) | ||
] @keyword | ||
|
||
[ | ||
"catch" | ||
"finally" | ||
"try" | ||
] @exception | ||
|
||
((apply | ||
name: (identifier) @exception) | ||
(#match? @exception "throw")) | ||
|
||
[ | ||
"unless" | ||
"mut" | ||
] @keyword | ||
|
||
[(true) (false)] @boolean | ||
|
||
(number) @constant.numeric.integer | ||
(float) @constant.numeric.float | ||
|
||
(comment) @comment | ||
(char) @character | ||
(string) @string | ||
(interpolated_string) @string | ||
; (escape_sequence) @string.escape | ||
|
||
; Reset highlighing in string interpolation | ||
(interpolation) @none | ||
|
||
(interpolation | ||
"{" @punctuation.special | ||
"}" @punctuation.special) | ||
|
||
["(" ")" "[" "]" "{" "}" "⟨" "⟩"] @punctuation.bracket | ||
|
||
["|" "," "." ":" ";"] @punctuation.delimiter | ||
|
||
(sorry) @error | ||
|
||
;; Error | ||
(ERROR) @error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
((comment) @markdown | ||
(#offset! @markdown 0 3 0 -2)) | ||
Anderssorby marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(module) @scope | ||
(namespace) @scope | ||
(section) @scope | ||
Anderssorby marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.