Skip to content

Feature/tree sitter#3306

Draft
sdottaka wants to merge 11 commits intomasterfrom
feature/tree-sitter
Draft

Feature/tree sitter#3306
sdottaka wants to merge 11 commits intomasterfrom
feature/tree-sitter

Conversation

@sdottaka
Copy link
Copy Markdown
Member

@sdottaka sdottaka commented Apr 6, 2026

No description provided.

Thorium and others added 9 commits March 26, 2026 19:49
Integrate tree-sitter as an optional syntax highlighting engine that
supplements the existing keyword-based CrystalEdit parsers. When a
grammar DLL and highlight query (.scm) are present in the
TreeSitterGrammars directory, tree-sitter provides full AST-based
highlighting; otherwise the existing parser runs unchanged.

Core components:
- TreeSitterParser.h/.cpp: CTreeSitterParser, CTreeSitterColorMap,
  CTreeSitterLanguage, and TreeSitterRegistry classes
- ParseLine virtual override in CMergeEditView for tree-sitter results
- Incremental parsing via ts_tree_edit() on each edit operation
- Lazy reparse with dirty flag (fires once per paint cycle)
- Status bar indicator showing [TS:language] in encoding pane
- Post-build step to copy grammar DLLs from Release to Debug/Test

Supported languages: bash, c, c-sharp, cpp, css, dtd, flow, fsharp,
fsharp_signature, go, html, java, javascript, json, php, php_only,
python, ruby, rust, tsx, typescript, xml.

Grammar DLLs are built separately via build-grammars.ps1.
- build-grammars.ps1: downloads and compiles grammar DLLs from GitHub
  releases using MSVC cl.exe/link.exe
- grammars.json: defines 17 grammar repos and release tags
- fsharp-highlights.scm: F# syntax highlight queries for tree-sitter
Wire in scope-aware highlighting (locals.scm) and language injection
(injections.scm) alongside the existing highlights.scm support.

- CTreeSitterLanguage: add LoadQuery() helper, load all three .scm files
- CTreeSitterParser: add RunLocalsQuery() for scope/def/ref tracking,
  RunInjectionQuery() for embedded language highlighting, GetSetProperty()
  for #set! predicate parsing; RunHighlightQuery() cross-references locals
- TreeSitterRegistry: add GetLanguageForName() for injection language lookup
- build-grammars.ps1: resolve and copy locals.scm and injections.scm files
- Fix type mismatch (RefInfo vs PendingRef) and remove dead code
- Add tree-sitter shared items to solution and projects
- Update SampleStatic project to include tree-sitter
- Fix build-grammars.ps1 to use Git Bash explicitly
- Add missing <algorithm> include
- Minor solution cleanup and add Italian translation
* fix: bundle inherited tree-sitter queries for grammars

Agent-Logs-Url: https://github.com/Thorium/winmerge/sessions/234ce03d-a145-4b8c-b4c2-37eed3e33cf0

Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>

* refine tree-sitter query bundling helpers

Agent-Logs-Url: https://github.com/Thorium/winmerge/sessions/234ce03d-a145-4b8c-b4c2-37eed3e33cf0

Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>

* polish tree-sitter query bundle handling

Agent-Logs-Url: https://github.com/Thorium/winmerge/sessions/234ce03d-a145-4b8c-b4c2-37eed3e33cf0

Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>

* Earlier CoPilot feedback addressed.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Thorium <229355+Thorium@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants