Skip to content

Add syntax highlighting support for Clojure (.clj) files #3926

@tonthanhhung

Description

@tonthanhhung

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions