opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Add syntax highlighting support for Clojure (.clj) files

Open tonthanhhung opened this issue 2 months ago • 2 comments

Feature Request: Clojure (.clj) Syntax Highlighting Support

Problem

OpenCode currently does not provide syntax highlighting for Clojure (.clj) files. When viewing diffs for .clj files, they appear as plain text without any color/syntax highlighting, making them difficult to read and review.

Proposed Solution

Add syntax highlighting support for Clojure (.clj) files by:

  1. Integrate Tree-sitter Clojure grammar: Add tree-sitter-clojure grammar to OpenTUI
  2. File extension recognition: Update file type detection to recognize .clj files
  3. Syntax highlighting rules: Create Tree-sitter queries for Clojure syntax elements
  4. Theme integration: Map Clojure syntax constructs to existing theme properties

Implementation Details

  • Location: Changes needed in both OpenTUI (core syntax highlighting) and OpenCode (file type detection)
  • Framework: Use existing Tree-sitter-based syntax highlighting system
  • Compatibility: Ensure integration with existing diff highlighting and theme system

Use Case

Clojure developers would benefit from proper syntax highlighting when:

  • Reviewing code changes in diffs
  • Reading Clojure source files
  • Identifying syntax elements (functions, macros, special forms, etc.)
  • Improving overall code readability and developer experience

Additional Context

Clojure is a mature Lisp dialect with a growing ecosystem. Adding support would make OpenCode more inclusive for the Clojure community and align with the goal of supporting a wide range of programming languages.

The existing theme system already has the necessary properties (syntaxComment, syntaxKeyword, syntaxFunction, etc.) that can be mapped to Clojure syntax elements.

tonthanhhung avatar Nov 05 '25 01:11 tonthanhhung

i think someone said they got this working so i think i can merge their pr

rekram1-node avatar Nov 05 '25 01:11 rekram1-node

Should be closed when this https://github.com/sst/opencode/pull/3912 is merged

tonthanhhung avatar Nov 05 '25 03:11 tonthanhhung