Skip to content

[FEATURE]: Add syntax highlighting support for Kotlin, HCL, Lua, and TOML #18197

@2KAbhishek

Description

@2KAbhishek

Syntax highlighting does not work for Kotlin, HCL, Lua, and TOML

Description

Tree-sitter parser support for syntax highlighting in the TUI for the following languages is missing:

  • Kotlin
  • HCL
  • Lua
  • TOML

Screenshot

Image

Proposed Fix

Each language needs:

  1. A Tree-sitter wasm binary (from tree-sitter-grammars org or language-specific releases)
  2. Highlight queries (from nvim-treesitter or the grammar repo)
  3. Optional: locals queries for variable tracking

Implementation

Added parser entries in packages/opencode/parsers-config.ts:

Language Wasm Source Queries
kotlin fwcd/tree-sitter-kotlin v0.3.8 fwcd kotlin highlights + nvim-treesitter locals
hcl tree-sitter-grammars/tree-sitter-hcl v1.2.0 nvim-treesitter hcl highlights
lua tree-sitter-grammars/tree-sitter-lua v0.5.0 tree-sitter-grammars lua highlights + locals
toml tree-sitter-grammars/tree-sitter-toml v0.7.0 nvim-treesitter toml highlights

Verification

Restart OpenCode after updating. Tested with kotlin, hcl, lua, toml fenced code blocks in markdown.

Checklist

  • Added parser entries for kotlin, hcl, lua, toml
  • Verified typecheck passes
  • Tested in TUI after restart

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions