-
Notifications
You must be signed in to change notification settings - Fork 22
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
nvim queries: Highlight built-in commands #100
Conversation
a0066bf
to
8e2160e
Compare
I like the idea, but it seems like there's a lot of commands missing like the commands with spaces in the name, also plugins (unless we don't want them) and ones like registry query that only exist on Windows. I'm also not sure why core commands are excluded. I think if we can get a complete list, this will be a nice add. I have to do the same thing for the vscode extension so I may have a script laying around somewhere. |
With the vscode-extension I just do this on windows and mac/linux, combine the files and sort uniq them for the complete list. You also have to have the plugins installed and registered when doing this, unless we don't want to include the plugins. (i'd probably include them though) scope commands | where type == built-in | get name | to text | save mac-cmds.txt |
I didn't see an easy way to include them because subcommands are parsed as arguments and not part of the command itself. If we match the command and subcommand separately there will be incorrect highlighting (eg
I'm not sure if that's a good idea, wouldn't that be different for everyone? The highlight file will have to be the same, at least for nvim.
Ah, good point!
They are already specified in the highlight file and highlighted as keywords, which I've explained in the PR description :), see below:
|
ok, let's move forward with this then. thanks! |
I've got an idea how built-in subcommands can also be highlighted, I'll PR if it works -- indeed, for completeness highlighting both words would be the ideal situation. |
@fdncred I've gotten it to work, but it's a little verbose -- though the simplest I could find: Here, Query for a single command: (command (
(cmd_identifier) @function.builtin (#eq? @function.builtin "str")
.
(val_string) @function.builtin.subcommand (#eq? @function.builtin.subcommand "starts-with")
)) The With this method, all subcommands for all built-in commands will have to be repeated as a separate query. If all efforts to find a simpler solution using only the default predicates ( What do we think? |
Apologies, in #100 I hadn't realized the where command is special-cased in the parser and hence requires a separate capture to highlight properly. This ensures the `where` command is also highlighted as built-in.
"we" like it. I'd go for it because it's better than what we had before. |
I thought it'd be great to highlight built-in commands differently to custom commands similar to what Nu does in the prompt line. It should be fairly easy to use the oneliner included in the comments on later versions of Nu to update the list.
Reference:
Core built-ins are filtered out because they are already specified higher up in the file as keywords.
All commands that aren't in the list are still highlighted with
@function