thejustinwalsh / textproto-grammar

Syntax Highlighting for the Protocol Buffer Text Format
https://marketplace.visualstudio.com/items?itemName=thejustinwalsh.textproto-grammer
MIT License
14 stars 2 forks source link

refactor: better syntax highlight & string support #6

Closed thejustinwalsh closed 3 years ago

thejustinwalsh commented 3 years ago
image
thejustinwalsh commented 3 years ago

Example from vscode-pbtxt repo: https://raw.githubusercontent.com/thesofakillers/vscode-pbtxt/master/.vscode-test/test.pbtxt

Example from Nvidia libs: https://raw.githubusercontent.com/google/nvidia_libs_test/master/cudnn_benchmarks.textproto

thejustinwalsh commented 3 years ago

Ok, I think this might be the ticket now.

thejustinwalsh commented 3 years ago

List of scopes in this stack overflow: https://stackoverflow.com/questions/10834765/where-to-find-a-list-of-scopes-for-sublime2-or-textmate

thejustinwalsh commented 3 years ago
name: "main"
scale_along_z: 0
embedded_instances {
  id: "ts-defold-logo"
  data: "components {\n"
  "  id: \"main\"\n"
  "  component: \"/scripts/main.script\"\n"
  "  position {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "  }\n"
  "  rotation {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "    w: 1.0\n"
  "  }\n"
  "  properties {\n"
  "    id: \"excitement\"\n"
  "    value: \"200.0\"\n"
  "    type: PROPERTY_TYPE_NUMBER\n"
  "  }\n"
  "}\n"
  "embedded_components {\n"
  "  id: \"sprite\"\n"
  "  type: \"sprite\"\n"
  "  data: \"tile_set: \\\"/main/sprites.atlas\\\"\\n"
  "default_animation: \\\"ts-defold\\\"\\n"
  "material: \\\"/builtins/materials/sprite.material\\\"\\n"
  "blend_mode: BLEND_MODE_ALPHA\\n"
  "\"\n"
  "  position {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "  }\n"
  "  rotation {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "    w: 1.0\n"
  "  }\n"
  "}\n"
  ""
  position {
    x: 400.0
    y: 400.0
    z: 0.0
  }
  rotation {
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0
  }
  scale3 {
    x: 0.45
    y: 0.45
    z: 1.0
  }
}
embedded_instances {
  id: "lua-ring"
  data: "components {\n"
  "  id: \"orbit\"\n"
  "  component: \"/scripts/orbit.script\"\n"
  "  position {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "  }\n"
  "  rotation {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "    w: 1.0\n"
  "  }\n"
  "  properties {\n"
  "    id: \"speed\"\n"
  "    value: \"0.1\"\n"
  "    type: PROPERTY_TYPE_NUMBER\n"
  "  }\n"
  "}\n"
  "embedded_components {\n"
  "  id: \"sprite\"\n"
  "  type: \"sprite\"\n"
  "  data: \"tile_set: \\\"/main/sprites.atlas\\\"\\n"
  "default_animation: \\\"lua-ring\\\"\\n"
  "material: \\\"/builtins/materials/sprite.material\\\"\\n"
  "blend_mode: BLEND_MODE_ALPHA\\n"
  "\"\n"
  "  position {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "  }\n"
  "  rotation {\n"
  "    x: 0.0\n"
  "    y: 0.0\n"
  "    z: 0.0\n"
  "    w: 1.0\n"
  "  }\n"
  "}\n"
  ""
  position {
    x: 400.0
    y: 400.0
    z: 1.0
  }
  rotation {
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0
  }
  scale3 {
    x: 1.0
    y: 1.0
    z: 1.0
  }
}

Here is an example that totally destroys my key-value matcher. Looks like you can concatenate strings as a value of a key, not sure off the top of my head how to capture this? Maybe a string value to a key needs a begin and end with allows patterns inside?

marcusrbrown commented 3 years ago

The changes look good - anything else needed for this PR? I'd recommend trying a feature where we generate from YAML in a similar vein as the official vscode extensions. That process may offer a bit of clarity to help handle those funky edges, as well as open up another testing pipeline. I'm happy to get the ball rolling and get you a draft PR.

thejustinwalsh commented 3 years ago

The changes look good - anything else needed for this PR? I'd recommend trying a feature where we generate from YAML in a similar vein as the official vscode extensions. That process may offer a bit of clarity to help handle those funky edges, as well as open up another testing pipeline. I'm happy to get the ball rolling and get you a draft PR.

Would love to see this. Just to be sure I understand.