Skip to content

Conversation

@mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Dec 4, 2025

Most tree-sitter styles do not use indirection for anonymous nodes as it impacts readability:
https://github.com/tree-sitter/tree-sitter-rust/blob/261b20226c04ef601adbdf185a800512a5f66291/grammar.js#L249-L262

This PR is a style proposal so discussion is welcome/expected

@blindFS
Copy link
Contributor

blindFS commented Dec 5, 2025

I'm cool with this change, should we ask for the opinion of the original author?

@fdncred
Copy link
Contributor

fdncred commented Dec 5, 2025

I'm good with it. Is the CI broke due to the npm thing or something else?

@mkatychev
Copy link
Contributor Author

I can do a follow up doing the same with brackets and other glyphs, this PR was to test the waters.

@mkatychev
Copy link
Contributor Author

mkatychev commented Dec 5, 2025

I'm good with it. Is the CI broke due to the npm thing or something else?

It's the NPM thing :\ https://github.com/nushell/tree-sitter-nu/actions/runs/19937120301/job/57165001540?pr=236#step:5:861: https://github.com/nushell/tree-sitter-nu/actions/runs/19937120301/job/57165001540?pr=236#step:5:861

EDIT: I can do the patch here before merge @fdncred

@mkatychev
Copy link
Contributor Author

@fdncred should be ready for re-review

Comment on lines 1306 to 1307
const func = immediate ? token.immediate : token;
const excluded = '\\[\\]\\-{}<>="`\'@?,:.';
Copy link
Contributor Author

@mkatychev mkatychev Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blindFS @fdncred Just want to call out that these kind of const declarations are a tree-sitter DSL antipattern.

These decls bypass a lot of potential optimizations by inlining where it's not needed.

EDIT: that may only apply to extras 🤔

Copy link
Contributor

@blindFS blindFS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fdncred fdncred merged commit 64ba3f8 into nushell:main Dec 6, 2025
4 checks passed
@fdncred
Copy link
Contributor

fdncred commented Dec 6, 2025

Thanks

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