generated from nvim-treesitter/module-template
-
Notifications
You must be signed in to change notification settings - Fork 195
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 Solidity language support #665
Draft
zeroaddresss
wants to merge
7
commits into
nvim-treesitter:master
Choose a base branch
from
zeroaddresss:solidity
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05587f1
added textobjects for Solidity
zeroaddresss bd2bece
adjustment after running format queries script
zeroaddresss e5a13a5
replaced 'block' nodes
zeroaddresss 33ae36d
adapted to grammar.js parser
zeroaddresss 1e35861
adjusted conditionals grammar
zeroaddresss 9bfd7ba
removed `consequence`
zeroaddresss d1ed7ac
updated patterns
zeroaddresss 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
; Solidity textobjects | ||
; Functions | ||
(function_definition | ||
body: (_)) @function.outer | ||
|
||
(function_definition | ||
body: (_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "function.inner" @_start @_end))) | ||
|
||
; Constructors | ||
(constructor_definition | ||
body: (_)) @function.outer | ||
|
||
(constructor_definition | ||
body: (_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "function.inner" @_start @_end))) | ||
|
||
; Modifiers | ||
(modifier_definition | ||
body: (_)) @function.outer | ||
|
||
(modifier_definition | ||
body: (_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "function.inner" @_start @_end))) | ||
|
||
; Contracts | ||
(contract_declaration | ||
body: (_) @class.inner) @class.outer | ||
|
||
; Interfaces | ||
(interface_declaration | ||
body: (_) @class.inner) @class.outer | ||
|
||
; Libraries | ||
(library_declaration | ||
body: (_) @class.inner) @class.outer | ||
|
||
; Structs | ||
(struct_declaration | ||
body: (_) @class.inner) @class.outer | ||
|
||
; Loops | ||
(for_statement | ||
body: (_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "loop.inner" @_start @_end))) @loop.outer | ||
|
||
(while_statement | ||
body: (_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "loop.inner" @_start @_end))) @loop.outer | ||
|
||
; Conditionals | ||
(if_statement | ||
consequence: (_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "conditional.inner" @_start @_end))) @conditional.outer | ||
|
||
(if_statement | ||
alternative: (else_clause | ||
(_ | ||
. | ||
"{" | ||
. | ||
(_) @_start @_end | ||
(_)? @_end | ||
. | ||
"}" | ||
(#make-range! "conditional.inner" @_start @_end)))) @conditional.outer | ||
|
||
(if_statement) @conditional.outer | ||
|
||
; Function calls | ||
(call_expression) @call.outer | ||
|
||
(call_expression | ||
arguments: (call_arguments | ||
. | ||
"(" | ||
. | ||
(_) @_start | ||
(_)? @_end | ||
. | ||
")" | ||
(#make-range! "call.inner" @_start @_end))) | ||
|
||
; Blocks | ||
(_ | ||
(_) @block.inner) @block.outer | ||
|
||
; Parameters | ||
(parameter_list | ||
","? @_start | ||
. | ||
(_) @parameter.inner | ||
(#make-range! "parameter.outer" @_start @parameter.inner)) | ||
|
||
(parameter_list | ||
. | ||
(_) @parameter.inner | ||
. | ||
","? @_end | ||
(#make-range! "parameter.outer" @parameter.inner @_end)) | ||
|
||
; Arguments | ||
(call_arguments | ||
","? @_start | ||
. | ||
(_) @parameter.inner | ||
(#make-range! "parameter.outer" @_start @parameter.inner)) | ||
|
||
(call_arguments | ||
. | ||
(_) @parameter.inner | ||
. | ||
","? @_end | ||
(#make-range! "parameter.outer" @parameter.inner @_end)) | ||
|
||
; Comments | ||
(comment) @comment.outer | ||
|
||
; Variable declarations | ||
(variable_declaration | ||
name: (_) @assignment.lhs | ||
value: (_) @assignment.inner @assignment.rhs) @assignment.outer | ||
|
||
(variable_declaration | ||
name: (_) @assignment.inner) | ||
|
||
; State variable declarations | ||
(state_variable_declaration | ||
name: (_) @assignment.lhs | ||
value: (_) @assignment.inner @assignment.rhs) @assignment.outer | ||
|
||
(state_variable_declaration | ||
name: (_) @assignment.inner) |
Oops, something went wrong.
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.
Where are you getting this node from? It's not in the grammar.