Skip to content

Feature/tree sitter#3306

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

Feature/tree sitter#3306
sdottaka wants to merge 16 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>
Comment thread Externals/crystaledit/editlib/TreeSitterParser.cpp Fixed
sdottaka and others added 7 commits April 12, 2026 07:03
* Doc - Italian language - Updated (#3319)

* Update Italian.po

* Fix issue #3321: [BUG] Incorrect string used with beta releases

* Show error message when entering path in header bar (#3322)

* Prioritize explicitly selected plugins over archive detection (#3324)

* Prioritize explicitly selected plugins over archive detection

* Update Src/7zCommon.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Src/7zCommon.cpp

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Use 7-Zip IsArc API for archive detection and refactor format guessing logic (#3323)

* Use 7-Zip IsArc API for archive detection and refactor format guessing logic

* Update ArchiveSupport/Merge7z/Merge7zCommon.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Restore extension-only fallback in GuessFormatEx and handle NEED_MORE result

Agent-Logs-Url: https://github.com/WinMerge/winmerge/sessions/47af4d0f-fc0a-4e33-ab81-8ec95c0f599e

Co-authored-by: sdottaka <98126+sdottaka@users.noreply.github.com>

* Use 7-Zip IsArc API for archive detection and refactor format guessing logic (2)

* Use 7-Zip IsArc API for archive detection and refactor format guessing logic (3)

* Prioritize explicitly selected plugins over archive detection

* Update Src/7zCommon.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Src/7zCommon.cpp

* Update Merge7zCommon.cpp

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sdottaka <98126+sdottaka@users.noreply.github.com>

* Merge7z: Bump revision to 2600.1

* Merge7z: Bump revision to 2600.1 (2)

* Update French Manual (#3325)

* Refactor: unify open parameters and move recurse to OpenFolderParams (#3326)

* Update Manual/French.po

* Refactor: unify open parameters and move recurse to OpenFolderParams (#3326) (2)

(cherry picked from commit 83af229)

* Add Folder comparison mode with archive extraction support (#3320)

* Update Manual/French.po

* Update Brazilian.po (#3328)

Added translation for "Add Folder comparison mode with archive extraction support (#3320)"

* Update German.po (#3329)

* update zh-cn translation (#3331)

* Update Turkish.po (#3333)

New string entries

* Update Korean (#3334)

* Code review fixes for 5 oldest source files#3327 #1

* Code review fixes for 5 oldest source files#3327 #2

* Update Turkish.po

* Update TranslationsStatus

* Update ChangeLog&ReleaseNotes

* Italian language (#3335)

* Stabilize tree-sitter highlight precedence

Make overlapping captures resolve deterministically so syntax colors stay consistent across panes and languages. Also accept local.* capture prefixes so newer query conventions keep local symbol highlighting working.

* Unify tree-sitter block ordering

Use one parser-wide block order counter so injected-language highlights cannot collide with primary highlight ordering when the final precedence tie-breaker runs.

---------

Co-authored-by: bovirus <1262554+bovirus@users.noreply.github.com>
Co-authored-by: Takashi Sawanaka <sdottaka@users.sourceforge.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sdottaka <98126+sdottaka@users.noreply.github.com>
Co-authored-by: t3chnob0y <t3chnob0y@users.noreply.github.com>
Co-authored-by: Marcellomco <70959309+Marcellomco@users.noreply.github.com>
Co-authored-by: René T. Nicolaus <12006431+Havoc7891@users.noreply.github.com>
Co-authored-by: YG <1246410+yingang@users.noreply.github.com>
Co-authored-by: bilimiyorum <131397022+bilimiyorum@users.noreply.github.com>
Co-authored-by: VenusGirl❤ <venusgirl@outlook.com>
* Finish tree-sitter runtime integration for compare views

Wire the runtime grammar bundle, compare-view UI, and same-file navigation together so tree-sitter features are actually available in built binaries. This also updates the F# grammar bundle to include tags and disables Go to Definition when the current caret position cannot resolve.

* Fix tree-sitter follow-up packaging issues

Guard the WiX grammar component reference when harvested files are absent, and remove the redundant TreeSitterWrapper include to avoid the _T macro redefinition warning.
# Conflicts:
#	ArchiveSupport/Merge7z/BuildArc.cmd
#	Docs/Users/ChangeLog.html
#	Docs/Users/ChangeLog.md
#	Docs/Users/ReleaseNotes.html
#	Docs/Users/ReleaseNotes.md
#	DownloadDeps.cmd
#	Src/FilepathEdit.cpp
#	Src/Merge.vcxproj.filters
#	Src/res/new_folder.bmp
#	Translations/TranslationsStatus.md
#	Translations/WinMerge/Arabic.po
#	Translations/WinMerge/Basque.po
#	Translations/WinMerge/Brazilian.po
#	Translations/WinMerge/Bulgarian.po
#	Translations/WinMerge/Catalan.po
#	Translations/WinMerge/ChineseSimplified.po
#	Translations/WinMerge/ChineseTraditional.po
#	Translations/WinMerge/Corsican.po
#	Translations/WinMerge/Croatian.po
#	Translations/WinMerge/Czech.po
#	Translations/WinMerge/Danish.po
#	Translations/WinMerge/Dutch.po
#	Translations/WinMerge/English.pot
#	Translations/WinMerge/Finnish.po
#	Translations/WinMerge/French.po
#	Translations/WinMerge/Galician.po
#	Translations/WinMerge/German.po
#	Translations/WinMerge/Greek.po
#	Translations/WinMerge/Hebrew.po
#	Translations/WinMerge/Hungarian.po
#	Translations/WinMerge/Italian.po
#	Translations/WinMerge/Japanese.po
#	Translations/WinMerge/Korean.po
#	Translations/WinMerge/Lithuanian.po
#	Translations/WinMerge/Norwegian.po
#	Translations/WinMerge/Persian.po
#	Translations/WinMerge/Polish.po
#	Translations/WinMerge/Portuguese.po
#	Translations/WinMerge/Romanian.po
#	Translations/WinMerge/Russian.po
#	Translations/WinMerge/Serbian.po
#	Translations/WinMerge/Sinhala.po
#	Translations/WinMerge/Slovak.po
#	Translations/WinMerge/Slovenian.po
#	Translations/WinMerge/Spanish.po
#	Translations/WinMerge/Swedish.po
#	Translations/WinMerge/Tamil.po
#	Translations/WinMerge/Turkish.po
#	Translations/WinMerge/Ukrainian.po
#	Translations/WinMerge/Vietnamese.po
…s and FolderCompare projects are not yet buildable. MFC dependencies still need to be removed from TreeSitterParser.
* Fix tree-sitter go to definition from context menus

Update right-click navigation to resolve the symbol under the mouse and prefer tagged type definitions when the position-based lookup stays on the current line.

* Update tree-sitter context-menu definition handling
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