helix icon indicating copy to clipboard operation
helix copied to clipboard

Grammars: Missing support for proto2

Open sdoerner opened this issue 1 year ago • 2 comments

I'm planning to work on this, so feel free to assign (I don't have permissions).

Current situation:

  • Grammar used by Helix is https://github.com/yusdacra/tree-sitter-protobuf at 19c211a01434d9f03efff99f85e19f967591b175
  • Grammar used by nvim is https://github.com/treywood/tree-sitter-proto (at main?)

Problems of current situation:

  • no proto2 support (also no support Editions but this is not supported anywhere so out of scope for now)
  • different grammar than nvim leads to fragmentation
  • neither of the grammars' feature sets is a superset of the other one --> upstream work needed
  • inconsistent language identifier (proto vs protobuf)

Plan of action

  • [ ] agree with @yusdacra and @treywood on a unification plan. Probably consolidating on treywood/tree-sitter-proto is easier because its network graph is larger (e.g it's used by nvim-treesitter).
    • [X] reach out to @yusdacra to get agreement for that
    • [ ] reach out to @treywood about adding missing features to https://github.com/treywood/tree-sitter-proto
  • [ ] implement missing features in https://github.com/treywood/tree-sitter-proto
  • [ ] get missing features into https://github.com/treywood/tree-sitter-proto master branch
  • [ ] switch Helix over to the new grammars (and proto identifier)
  • [ ] fix reverse-query-precedence-ordering branch if needed

Analysis of missing features

Features missing for highlights.scm:

  • missing mapName, extendName, fieldName and enumVariantName
  • missing optionName - this is fixed in the fixups branch but needs merging into main

Features missing for indents.scm:

  • oneofBody, serviceBody and rpcBody are missing. You can use oneof, service and rpc instead, but this probably leads to some regressions. Not sure if there is a severe enough case to block on this. I noticed a difference with declarations like this in hybrid indent heuristic, but they actually both misbehave.
    rpc FooRpc(FooRpcRequest)
        returns (FooRpcResponse) {
      option deadline = 20.0;
    }
    

Features missing for textobjects.scm:

  • missing serviceBody

sdoerner avatar Sep 29 '24 11:09 sdoerner