nushell / vscode-nushell-lang

A Nushell grammar for Visual Studio Code with IDE support
https://www.nushell.sh/
MIT License
122 stars 27 forks source link

Add spread to syntax highlighting #174

Closed texastoland closed 9 months ago

texastoland commented 9 months ago

Fixes #173.

Generated tokens for:

def cmd [--flag (-f) ...rest] {
  [ ...$rest ]
  { ...$rest }
  all --flag -f ...$rest
}
cmd --flag -f ...$rest
^cmd --flag -f ...$rest
fdncred commented 9 months ago

The only thing that I'm not quite sure about is having ...$rest as a custom command parameter instead of ...rest. They resolve to two different things.

...rest is all variable.parameter.nushell where ...$rest is ... = keyword.control.nushell, $ = meta.function.parameter.nushell, and rest = variable.parameter.nushell

It may be ok like this, it just gives me pause.

texastoland commented 9 months ago

...rest is all variable.parameter.nushell

@fdncred Fixed. Copied from Discord whether to highlight flags too:

def cmd [ --flag ] {}
#         ^^ highlighted?
cmd --flag
#   ^^ here too
fdncred commented 9 months ago

My answer from Disord was I think yes to both since -- and flag mean something different than --flag. Thanks for working on this stuff.

texastoland commented 9 months ago

Ready again. I wasn't happy with my first pass but I discovered an expression that wasn't working before and fixed it. I didn't update the scope list (above) with flag tokens but can if it helps review! LGTM :shipit:

fdncred commented 9 months ago

I think it looks good now. Thanks!