nushell / vscode-nushell-lang

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

new command regex #83

Closed fdncred closed 1 year ago

fdncred commented 1 year ago

@glcraft Can you please help? I just ran list-to-tree on this attached file and it generated a big regex that I tweaked and put in the tmLanguage file under "command".

"match": "(a(?:l(?:ias|l)|n(?:si(?: (?:gradient|link|strip))?|y)|ppend|st)|b(?:its(?: (?:and|not|or|ro(?:l|r)|sh(?:l|r)|xor))?|reak|ytes(?: (?:a(?:dd|t)|build|collect|ends-with|index-of|length|re(?:move|place|verse)|starts-with))?)|c(?:al|d|har|lear|o(?:l(?:lect|umns)|m(?:mandline|p(?:act|lete))|n(?:fig(?: (?:env|nu|reset))?|st|tinue))|p|ustom-value (?:generate(?:2)?|update))|d(?:ate(?: (?:format|humanize|list-timezone|now|to-(?:record|t(?:able|imezone))))?|e(?:bug|code(?: base64)?|f(?:-env|ault)?|scribe|tect columns)|fr (?:a(?:gg(?:-groups)?|ll-(?:false|true)|ppend|rg-(?:m(?:ax|in)|sort|true|unique|where)|s(?:-date(?:time)?)?)|c(?:ache|o(?:l(?:lect|umns)?|n(?:cat(?:-str|enate)|tains)|unt(?:-null)?)|umulative)|d(?:rop(?:-(?:duplicates|nulls))?|types|ummies)|exp(?:lode|r-not)|f(?:etch|i(?:l(?:l-n(?:an|ull)|ter(?:-with)?)|rst(?)?)|latten)|g(?:et(?:-(?:day|hour|m(?:inute|onth)|nanosecond|ordinal|second|week(?:day)?|year))?|roup-by)|i(?:nto-(?:df|lazy|nu(?)?)|s-(?:duplicated|in(?)?|n(?:ot-null(?)?|ull(?)?)|unique))|join|l(?:ast(?)?|i(?:st|t)|owercase|s)|m(?:ax(?)?|e(?:an(?)?|dian(?)?|lt)|in(?)?)|n(?:-unique(?)?|ot)|o(?:pen|therwise)|qu(?:antile(?)?|ery)|r(?:e(?:name|place(?:-all)?|verse)|olling)|s(?:ample|e(?:lect|t(?:-with-idx)?)|h(?:ape|ift)|lice|ort-by|t(?:d(?)?|r(?:-(?:lengths|slice)|ftime))|um(?:(?:mary)?))|t(?:ake|o-(?:arrow|csv|parquet))|u(?:nique|ppercase)|va(?:lue-counts|r(?)?)|w(?:hen|ith-column))|o|rop(?: (?:column|nth))?|u)|e(?:ach(?: while)?|cho|n(?:code(?: base64)?|ter|umerate)|rror make|very|x(?:ec|it|p(?:l(?:ain|ore)|ort(?: (?:alias|def(?:-env)?|extern|old-alias|use)|-env)?)|tern))|f(?:i(?:l(?:l|ter)|nd|rst)|latten|mt|or(?:mat(?: filesize)?)?|rom(?: (?:csv|eml|i(?:cs|ni)|json|nuon|ods|p(?:arquet|list)|ssv|t(?:oml|sv)|url|vcf|x(?:lsx|ml)|y(?:aml|ml)))?)|g(?:et|lob|r(?:id|oup(?:-by)?)|stat)?|h(?:ash(?: (?:base64|md5|sha256))?|e(?:aders|lp(?: (?:aliases|commands|modules|operators))?)|i(?:de(?:-env)?|st(?:o(?:gram|ry(?: session)?))?)|ttp(?: (?:delete|get|head|p(?:atch|ost|ut)))?)|i(?:f|gnore|n(?:c|put|s(?:ert|pect)|to(?: (?:b(?:inary|ool)|d(?:atetime|ecimal|uration)|filesize|int|record|s(?:qlite|tring)))?)|s-(?:admin|empty))|json path|k(?:eybindings(?: (?:default|list(?:en)?))?|ill)|l(?:ast|e(?:ngth|t(?:-env)?)|ines|o(?:ad-env|op)|s)|m(?:ath(?: (?:a(?:bs|rc(?:cos(?:h)?|sin(?:h)?|tan(?:h)?)|vg)|c(?:eil|os(?:h)?)|e(?:val)?|floor|l(?:n|og)|m(?:ax|edian|in|ode)|p(?:i|roduct)|round|s(?:in(?:h)?|qrt|tddev|um)|ta(?:n(?:h)?|u)|variance))?|e(?:rge|tadata)|kdir|o(?:dule|ve)|ut|v)|n(?:u-(?:check|example-(?:1|2|3)|highlight))?|o(?:ld-alias|pen|verlay(?: (?:hide|list|new|use))?)|p(?:a(?:r(?:-each|se)|th(?: (?:basename|dirname|ex(?:ists|pand)|join|parse|relative-to|split|type))?)|eriodic-table|lot|net|ort|r(?:epend|int|ofile)|s)?|query(?: (?:db|json|web|xml))?|r(?:an(?:dom(?: (?:bool|chars|d(?:ecimal|ice)|integer|uuid))?|ge)|e(?:duce|g(?:ex|ist(?:er|ry query))|ject|name|turn|verse)|m|o(?:ll(?: (?:down|left|right|up))?|tate)|un-external)|s(?:ave|chema|e(?:lect|q(?: (?:char|date))?)|h(?:ells|uffle)|ize|kip(?: (?:until|while))?|leep|o(?:rt(?:-by)?|urce(?:-env)?)|plit(?: (?:c(?:hars|olumn)|list|row|words)|-by)?|t(?:art|r(?: (?:c(?:a(?:mel-case|pitalize)|o(?:llect|ntains))|d(?:istance|owncase)|ends-with|find-replace|index-of|join|kebab-case|l(?:ength|pad)|pascal-case|r(?:e(?:place|verse)|pad)|s(?:creaming-snake-case|nake-case|tarts-with|ubstring)|t(?:itle-case|o-(?:d(?:atetime|ecimal)|int)|rim)|upcase))?)|ys)|t(?:a(?:ble|ke(?: (?:until|while))?)|erm size|imeit|o(?: (?:csv|html|json|md|nuon|t(?:ext|oml|sv)|xml|yaml)|uch)?|r(?:anspose|y)|utor)|u(?:niq(?:-by)?|p(?:date(?: cells)?|sert)|rl(?: (?:build-query|encode|join|parse))?|se)|v(?:alues|ersion|iew(?: (?:files|s(?:ource|pan)))?)|w(?:atch|h(?:ere|i(?:ch|le))|i(?:ndow|th-env)|rap)|xyplot|zip)(?![\\w-])( (.*))?",

win-cmds.txt

I'm not sure what exactly that I've done wrong but the syntax highlighting it's quite right. You can see that some things aren't colored at all image

I look at things like this print command and it has scopes assigned but the foreground color is wrong. image

For comparison, here's what the current syntax highlighting looks like. image

Looks like the scopes may be different too image

glcraft commented 1 year ago

It seems there is a bug in list-to-tree : As you can see here, there are weird pattern that doesn't looks good regexes The top one is from the main branch, the bottom is from your capture

image

I'm going to check that

glcraft commented 1 year ago

I think I caught the issue There are multiple doubles in your list image

list-to-tree only works with unique values 😄. I'll correct that to discard doubles in list-to-tree

fdncred commented 1 year ago

Odd that there are dupes, all I did was this help commands | get name | to text | save win-cmds.txt

Ahh, I see it. There's a dfr mean for dataframe and a dfr mean for lazyframe.

glcraft commented 1 year ago

Ah yeah, nushell interpret that as two different command each, that could explain the result.

I just fixed the issue, git pull list-to-regex and retry with the new regex 👍

fdncred commented 1 year ago

Looks better. Thanks for the fix. image