Skip to content

feat: Add syntax highlighting for shell scripts (sh/bash/zsh) - #66

Merged
unhappychoice merged 3 commits into
mainfrom
feature/add-shell-syntax-highlighting
Nov 18, 2025
Merged

unhappychoice merged 3 commits into
mainfrom
feature/add-shell-syntax-highlighting

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 18, 2025 •

Copy link
Copy Markdown
Owner

close: #49

Summary

  • Add syntax highlighting support for shell scripts (.sh, .bash, .zsh)
  • Integrate tree-sitter-bash parser for accurate shell script parsing
  • Enable highlighting for common shell script files like install.sh and build scripts

Changes

  • Add tree-sitter-bash dependency (v0.23)
  • Create bash language module with tree-sitter integration
  • Register file extensions: .sh, .bash, .zsh

Test plan

  • cargo check passes
  • cargo test passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo fmt applied
  • Shell script files (install.sh, generate_changelog.sh) are now recognized

Example files that benefit

  • install.sh (commit: fd0d92b)
  • generate_changelog.sh (commit: 4714f72)
  • Other shell scripts in the repository

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added Bash scripting language support with syntax highlighting for bash, sh, and zsh files. Detected shell scripts will now receive language-specific highlighting and improved rendering within the editor.

unhappychoice and others added 2 commits November 19, 2025 02:54
Add tree-sitter-bash 0.23 to support shell script syntax highlighting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
close: #49

Implement syntax highlighting support for shell scripts (.sh, .bash, .zsh) using tree-sitter-bash parser.

Changes:
- Add bash language module with tree-sitter-bash integration
- Register .sh, .bash, and .zsh file extensions
- Enable syntax highlighting for common shell script files

This allows shell scripts like install.sh and build scripts to be displayed with proper syntax highlighting during commit replay.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds Bash/shell syntax highlighting: new tree-sitter-bash dependency, a bash language module exposing language() and HIGHLIGHT_QUERY, and registration of sh/bash/zsh in the language registry.

Changes

Cohort / File(s) Summary
Dependency Addition
Cargo.toml
Adds tree-sitter-bash = "0.25" to [dependencies].
Bash Language Module
src/syntax/languages/bash.rs
New public language() -> tree_sitter::Language function and pub const HIGHLIGHT_QUERY: &str exposing tree_sitter_bash symbols.
Language Registry Update
src/syntax/languages/mod.rs
Adds pub mod bash and extends get_language() to return (bash::language(), bash::HIGHLIGHT_QUERY) for `"sh"

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Requester
    participant LangMod as languages/mod.rs
    participant GetLang as get_language(ext)
    participant BashMod as bash.rs

    Caller->>LangMod: ask for language for file.ext
    LangMod->>GetLang: get_language(ext)
    GetLang->>GetLang: match ext ("sh"/"bash"/"zsh")
    alt matched
        GetLang->>BashMod: call bash::language()
        BashMod-->>GetLang: returns tree_sitter::Language
        GetLang->>BashMod: read bash::HIGHLIGHT_QUERY
        BashMod-->>GetLang: returns query str
        GetLang-->>LangMod: returns (Language, Query)
        LangMod-->>Caller: provide parser + highlight query
    else no match
        GetLang-->>LangMod: returns None
        LangMod-->>Caller: no syntax config
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Focus review on dependency version bump and ensuring tree_sitter_bash symbols are correctly referenced.
  • Verify HIGHLIGHT_QUERY string integration and that get_language pattern matches align with other language entries.

Poem

🐰✨ I hopped through trees and parsed the bash,
Added queries in a gentle flash.
Now scripts wear colors, bright and new—
Shells dance in syntax, snug and true.
Cheers from a rabbit, soft and rash! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements core requirements from issue #49: adds tree-sitter-bash dependency, creates bash language module, and registers file extensions (sh/bash/zsh). However, it uses v0.25 instead of recommended v0.23, and omits .fish support and shebang detection mentioned in the issue. Either document why v0.25 was chosen over v0.23, add .fish file extension support, or implement shebang-based detection for shell scripts to fully satisfy issue #49 requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding syntax highlighting for shell scripts (sh/bash/zsh), which is clearly reflected in the code changes.
Out of Scope Changes check ✅ Passed All changes are directly related to adding shell script syntax highlighting support. No unrelated modifications to other features or unscoped refactoring detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/add-shell-syntax-highlighting

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76f68e2 and aa16451.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build (windows-latest)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3edc3ab and 76f68e2.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • src/syntax/languages/bash.rs (1 hunks)
  • src/syntax/languages/mod.rs (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/syntax/languages/mod.rs (1)
src/syntax/languages/bash.rs (1)
  • language (1-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build (windows-latest)
🔇 Additional comments (3)
src/syntax/languages/mod.rs (2)

1-1: LGTM!

The module declaration is correctly placed alphabetically and follows the existing pattern.


40-40: The review comment is based on incorrect assumptions about PR scope.

The actual commit (76f68e2) explicitly states the PR objectives are to implement syntax highlighting for shell scripts by registering .sh, .bash, and .zsh file extensions. The commit message makes no mention of shebang detection or extensionless file support. The current implementation correctly fulfills the stated PR scope.

The review appears to be suggesting additional feature enhancements rather than identifying missing requirements from the PR objectives.

Likely an incorrect or invalid review comment.

src/syntax/languages/bash.rs (1)

1-5: LGTM!

The implementation follows the exact pattern used by other language modules in the codebase. The language() function correctly converts tree_sitter_bash::LANGUAGE to tree_sitter::Language, and the HIGHLIGHT_QUERY constant properly re-exports the query from the tree-sitter-bash crate.

Comment thread Cargo.toml Resolved
Update tree-sitter-bash from v0.23 to v0.25 to use the latest version.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@unhappychoice
unhappychoice merged commit b949f2f into main Nov 18, 2025
@unhappychoice
unhappychoice deleted the feature/add-shell-syntax-highlighting branch November 18, 2025 19:48
@coderabbitai coderabbitai Bot mentioned this pull request Nov 26, 2025
4 tasks done
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.

feat: Add syntax highlighting for shell scripts (sh/bash/zsh)

1 participant