This uses the lexer for highlighting. It will highlight strings, numbers, keywords, but doesn't understand how to highlight nodes like types, function params, etc.
The reason for this is because a single line of code by itself may not be grammatically valid.
Sample screenshots:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/1385
**Author:** [@bioball](https://github.com/bioball)
**Created:** 12/24/2025
**Status:** 🔄 Open
**Base:** `main` ← **Head:** `syntax-highlighting`
---
### 📝 Commits (1)
- [`56b8607`](https://github.com/apple/pkl/commit/56b8607ab3f076378d9189f3fa7b86dfc2b60e16) Add syntax highlighting of Pkl code
### 📊 Changes
**8 files changed** (+270 additions, -22 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-cli/src/main/kotlin/org/pkl/cli/CliRepl.kt` (+1 -1)
📝 `pkl-cli/src/main/kotlin/org/pkl/cli/repl/Repl.kt` (+39 -11)
📝 `pkl-core/src/main/java/org/pkl/core/repl/ReplServer.java` (+7 -2)
📝 `pkl-core/src/main/java/org/pkl/core/runtime/StackTraceRenderer.java` (+7 -4)
📝 `pkl-core/src/main/java/org/pkl/core/util/AnsiStringBuilder.java` (+25 -2)
📝 `pkl-core/src/main/java/org/pkl/core/util/AnsiTheme.java` (+12 -2)
➕ `pkl-core/src/main/java/org/pkl/core/util/SyntaxHighlighter.java` (+171 -0)
📝 `pkl-parser/src/main/java/org/pkl/parser/Lexer.java` (+8 -0)
</details>
### 📄 Description
This adds syntax highlighting of Pkl code!
It adds highlighting for:
* Stack frames within error messages
* CLI REPL (highlights as you type, highlights error output)
* Power assertions (coming in https://github.com/apple/pkl/pull/1384)
This uses the lexer for highlighting. It will highlight strings, numbers, keywords, but doesn't understand how to highlight nodes like types, function params, etc.
The reason for this is because a single line of code by itself may not be grammatically valid.
Sample screenshots:
<img width="456" height="436" alt="Screenshot 2025-12-23 at 10 32 37 PM" src="https://github.com/user-attachments/assets/b96fc23a-2f59-4064-a6da-273d94aae8d3" />
<img width="1136" height="350" alt="Screenshot 2025-12-23 at 10 39 10 PM" src="https://github.com/user-attachments/assets/71c79396-7dc3-445e-81b4-f5011c7ef6be" />
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/1385
Author: @bioball
Created: 12/24/2025
Status: 🔄 Open
Base:
main← Head:syntax-highlighting📝 Commits (1)
56b8607Add syntax highlighting of Pkl code📊 Changes
8 files changed (+270 additions, -22 deletions)
View changed files
📝
pkl-cli/src/main/kotlin/org/pkl/cli/CliRepl.kt(+1 -1)📝
pkl-cli/src/main/kotlin/org/pkl/cli/repl/Repl.kt(+39 -11)📝
pkl-core/src/main/java/org/pkl/core/repl/ReplServer.java(+7 -2)📝
pkl-core/src/main/java/org/pkl/core/runtime/StackTraceRenderer.java(+7 -4)📝
pkl-core/src/main/java/org/pkl/core/util/AnsiStringBuilder.java(+25 -2)📝
pkl-core/src/main/java/org/pkl/core/util/AnsiTheme.java(+12 -2)➕
pkl-core/src/main/java/org/pkl/core/util/SyntaxHighlighter.java(+171 -0)📝
pkl-parser/src/main/java/org/pkl/parser/Lexer.java(+8 -0)📄 Description
This adds syntax highlighting of Pkl code!
It adds highlighting for:
This uses the lexer for highlighting. It will highlight strings, numbers, keywords, but doesn't understand how to highlight nodes like types, function params, etc.
The reason for this is because a single line of code by itself may not be grammatically valid.
Sample screenshots:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.