Skip to content

Conversation

blindFS
Copy link
Contributor

@blindFS blindFS commented Jul 18, 2025

The idea of #179
It helps with the WASM compilation time #185 : case count 3146 -> 2592, time 2m20 -> 1m35

IMHO the target of tree-sitter-nu is only for code text manipulation, it's never gonna be as complete/semantically accurate as the native parser. And those rules are unnecessary in that regards.

@fdncred
Copy link
Contributor

fdncred commented Jul 18, 2025

Big savings. I was hoping one day to see if the tree-sitter-nu parser would be faster than the nushell parser. However, if there's no hope for ever using it for anything other than and in-editor parser, then it's probably good to optimize it for that.

@blindFS
Copy link
Contributor Author

blindFS commented Jul 18, 2025

@fdncred yeah, I understand the intention. However according to what I learned from the tree-sitter community, it's generally not recommended to use a tree-sitter parser in a compiler/interpreter.

Besides, performance-wise, I believe the new-nu-parser(current nu-parser can be slow) should be by no means slower than TS. The only thing missing is the incremental nature.

Comment on lines -55 to -62
(ctrl_return) @statement.outer @return.outer
(ctrl_do) @statement.outer

(ctrl_if) @statement.outer

(ctrl_try) @statement.outer

(ctrl_match) @statement.outer

(ctrl_while) @statement.outer

(ctrl_loop) @statement.outer
("break" "continue") @statement.outer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Bahex I've merged ctrl_do/ctrl_return/"break"/"continue" to our command rule.
I'm not sure whether some features will be missing if we remove these queries, do you have any idea?

Copy link
Member

Choose a reason for hiding this comment

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

It should be fine as far as I can tell, and even if we want to add queries for these in the future, we can just write the them for command nodes with a specific head.

Copy link
Contributor Author

@blindFS blindFS Jul 19, 2025

Choose a reason for hiding this comment

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

@Bahex Would you like to review/test this PR since there are some breaking changes?

@blindFS blindFS marked this pull request as ready for review July 19, 2025 17:25
@Bahex Bahex self-requested a review July 20, 2025 18:41
Copy link
Member

@Bahex Bahex left a comment

Choose a reason for hiding this comment

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

nvim-treesitter-context has a query that would need to be updated, but other than that I haven't found anything that breaks.

@blindFS
Copy link
Contributor Author

blindFS commented Jul 21, 2025

nvim-treesitter-context has a query that would need to be updated, but other than that I haven't found anything that breaks.

Thanks for the reminder, I haven't updated the parser-rev/query-files of nvim-treesitter since cli 0.25+ was applied in this repo.
Their main branch breaks some default configurations of the nvim distro that I'm using. I guess most users are still stuck in their frozen master branch.

@fdncred
Copy link
Contributor

fdncred commented Aug 21, 2025

Should we go ahead and land this @blindFS?

@blindFS
Copy link
Contributor Author

blindFS commented Aug 22, 2025

Should we go ahead and land this @blindFS?

I think so. Given there're already big gaps between the main branch and those locked by editors/plugins, it won't break things further.

@fdncred fdncred merged commit 7e7de17 into nushell:main Aug 22, 2025
4 checks passed
@fdncred
Copy link
Contributor

fdncred commented Aug 22, 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