sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.1k stars 1.27k forks source link

Migrate Monaco settings editor to the code mirror editor #54772

Open vovakulikov opened 1 year ago

vovakulikov commented 1 year ago

So in the past we already migrated our search box UI from monaco to the code mirror implementation thanks to @fkling. Now we want to migrate other parts of the product to it. But there are a few blockers

@top JsonText { value }

value { True | False | Null | Number | String | Object | Array }

String { string }
Object { "{" list<Property>? "}" }
Array  { "[" list<value>? "]" }

Property { PropertyName ":" value }
PropertyName { string }

@tokens {
  True  { "true" }
  False { "false" }
  Null  { "null" }

  Number { '-'? int frac? exp?  }
  int  { '0' | $[1-9] @digit* }
  frac { '.' @digit+ }
  exp  { $[eE] $[+\-]? @digit+ }

  string { '"' char* '"' }
  char { $[\u{20}\u{21}\u{23}-\u{5b}\u{5d}-\u{10ffff}] | "\\" esc }
  esc  { $["\\\/bfnrt] | "u" hex hex hex hex }
  hex  { $[0-9a-fA-F] }

  whitespace { $[ \n\r\t] }

  "{" "}" "[" "]"
}

@skip { whitespace | Comment }
@skip {} {
  Comment { "/*" (commentContent | commentLineBreak)* commentEnd }
}

@local tokens {
  commentEnd { "*/" | @eof }
  commentLineBreak { "\n" }
  @else commentContent
}

list<item> { item ("," item)* }

@external propSource jsonHighlighting from "./highlight"

@detectDelim
fkling commented 1 year ago

There is a newish package for schema-based JSON validation for codemirror 6: https://www.npmjs.com/package/codemirror-json-schema