Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Tree-sitter-based syntax-highlighting support for Dart #57880

@matthewnitschke-wk

Description

@matthewnitschke-wk

Feature request description

Current dart syntax highlighting support for sourcegraph is limited to just a .sublime-syntax file. This lacks the contextual awareness that can be provided by a tree-sitter

Adding support for a tree-sitter for dart would pair well with the existing scip-dart package, making a first class experience for dart developers within the sourcegraph platform. As one of those dart developers this is something I would love to see implemented

There exists a current tree-sitter-dart implementation that can be found here, It's licensed under MIT, and therefore should be fine to use within the sourcegraph codebase

Is your feature request related to a problem? If so, please describe.

Current syntax highlighting for dart leaves much to be desired. Implementing tree-sitter-dart would greatly improve browsing dart code within sourcegraph

example of dart syntax highlighting

Describe alternatives you've considered.

  • a scip index file currently has support for a SymbolInformation.Kind: https://github.com/sourcegraph/scip/blob/main/scip.proto#L222. From what I understand, this field is currently utilized to style the code editor within sourcegraph.com, but it is not directly populated from user uploaded scip files (instead it comes from tree-sitter implementations). If this was updated to allow user-uploaded scip files to populate this Kind field, we could bypass the need to support both a tree-sitter-dart and a scip-indexer.

  • I've also looked into just updating the Dart.sublime-syntax file within packages, google provides an official package for this, but it's specific to textmirror/vscode: https://github.com/dart-lang/dart-syntax-highlight/tree/master/grammars. I haven't yet looked whether the syntax highlighting results would be better with this grammar instead of the one provided by dart-sublime-bundle, but given the fact that this was last updated 8 years ago, I'd imagine it would be at least some improvement. This would be a stepping stone solution as the contextual awareness that tree-sitter provides would be the preferred path

Additional context

  • tree-sitter-dart currently uses an old version of tree-sitter (0.17), in order to successfully implement this within sourcegraph, a fork+update would have to be implemented (similar to what has been done for other languages)

  • tree-sitter-dart also has this strange setup with duplicate git submodules which fails when trying to depend on it from cargo. I've found that after removing the duplicate, you can successfully install the package within sourcegraph's tech stack

  • I've already spiked the necessary work to implement this tree-sitter here, I'm coming up a bit short on how to generate the snapshot tests and actually test it though. Some assistance in this area would be greatly appreciated

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions