-
Notifications
You must be signed in to change notification settings - Fork 30
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
Should we try to minimize the amount of keywords? #179
Comments
My overall goal would be for someone to be able to use tree-sitter-nu as a nushell parser and recreate nushell if they wanted to. I'd like it to be at least that accurate. So, I'm fine with reducing into the command category as long as it meets the first overall goal. My second overall goal is to have excellent syntax highlighting so, i wouldn't want any change to affect that. |
In terms of semantic accuracy/completeness, I think it's better to keep as it is.
|
I wouldn't worry about categories too much, they can change pretty easily.
❯ scope commands | group-by type
╭──────────┬──────────────────╮
│ custom │ [table 137 rows] │
│ keyword │ [table 34 rows] │
│ built-in │ [table 396 rows] │
│ plugin │ [table 163 rows] │
│ external │ [table 110 rows] │
╰──────────┴──────────────────╯ help commands breaks this out a little differently, which is probably a bug. ❯ help commands | group-by command_type
╭──────────┬──────────────────╮
│ custom │ [table 137 rows] │
│ keyword │ [table 34 rows] │
│ built-in │ [table 396 rows] │
│ alias │ [table 170 rows] │
│ plugin │ [table 163 rows] │
│ external │ [table 110 rows] │
╰──────────┴──────────────────╯ |
I overlooked the type column I guess, it's hidden behind Some of the rules that are not in the list of
Surprised to see I guess we are safe to remove the first 3 rules from the grammar? |
|
I think we can on hold the cleansing task since it's a breaking change that won't bring much benefit. But this thread can be used to keep track of the obsolete rules. And we can clean them from time to time when the list gets long. |
Background:
there are many special rules of internal commands in tree-sitter-nu ATM, which have not much difference to general commands, such as
This can cause errors when users accidentally shadow them with customized definitions, e.g.
https://github.com/nushell/nu_scripts/blob/a83a40dff05e91daf90bb42e7a23c5e70c85a759/sourced/misc/nu_defs.nu#L492
It is actually a common issue among tree-sitter parsers, official doc suggests using keyword-extraction to handle it.
But it's not feasible in tree-sitter-nu, at least for now, since we already have
identifier
asword
and we can't ignore the subtle differences betweencmd_identifier
andidentifier
.So, what I'm suggesting here is removing those trivial rules and reduce them all into the
command
category.As for the highlighting, we can still make them highlighted as keywords if we want to.
The text was updated successfully, but these errors were encountered: