feat: Comprehensive YARA language support upgrade (Grammar, Outlines, Folding, and Highlighting) - #2
Open
binjo wants to merge 3 commits into
Open
feat: Comprehensive YARA language support upgrade (Grammar, Outlines, Folding, and Highlighting)#2binjo wants to merge 3 commits into
binjo wants to merge 3 commits into
Conversation
- Upgrade tree-sitter-yara parser to celstur fork - Implement folding, outline, and smart indentation queries - Fix syntax highlighting rules and add modern keyword support - Patch grammar issues with anonymous indexing variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
feat: Comprehensive YARA language support upgrade (Grammar, Outlines, Folding, and Highlighting)
Description
This Pull Request delivers a massive upgrade to the
yara.zedextension, bringing it to full feature-parity with advanced editors. It replaces the basic syntax highlighter with a robust, syntactically complete YARA development environment by upgrading the tree-sitter grammar, adding structured navigation queries, patching edge-case syntax bugs, and optimizing syntax highlighting.Key Enhancements & Changes since Fork
1. ⚙️ Parser & Grammar Upgrade
egibs/tree-sitter-yaraparser withcelstur/tree-sitter-yara. This adds support for standard module namespaces, dot member accesses, and native function calls (e.g.,pe.is_dll(),math.entropy()), resolving syntax-highlighting breakage on complex rules.@) and lengths (!) (e.g.,@[j]or![j]), producing a syntax error block.Upstream Grammar Patch details for
grammar.js:To resolve this inside the tree-sitter parser,
grammar.jswas modified to make bracketed index sequences optional on anonymous offsets and lengths:The parser was then re-generated (
npx tree-sitter generate) to updatesrc/parser.cto fully support modern, complex rule indexing.2. 🎨 Enhanced Syntax Highlighting (
highlights.scm)pe,math,elf) cleanly to@type.@functionto represent them as callable components rather than plain strings.#match?regular expression queries to highlight standard built-in functions dynamically (e.g.uint16,uint32be, etc.)."!","#"and"@"from query delimiters to prevent tree-sitter parser load rejections.3. 📁 Structural Editor Features (Emacs
yara-modeParity)outline.scm): Added outline matches to display defined rule headers in Zed's Symbol/Outline navigation search (Ctrl/Cmd + Shift + O).indents.scm): Structured and aligned block-indentation scopes forrule_body,meta_section,strings_section, andcondition_section.folds.scm): Enabled vertical collapsing/folding on both rule-level blocks and individual sections (meta, strings, condition) to make analyzing large files easy.Verification and Testing
All layers of this upgrade have been tested and verified inside Zed: