Skip to content

Conversation

@sgammon
Copy link
Member

@sgammon sgammon commented Jul 26, 2025

Ready for review Powered by Pull Request Badge

Summary

Adds syntax highlighting, via our REPL tools, for code emitted in other circumstances by the CLI.

Examples

Before After
image Screenshot 2025-07-26 162623
image image

@sgammon sgammon added this to the Release R18: Beta milestone Jul 26, 2025
@sgammon sgammon self-assigned this Jul 26, 2025
@sgammon sgammon added feature Large PRs or issues with full-blown features 🚧 WIP Works-in-progress. Blocks merge module:cli CLI module issues and features labels Jul 26, 2025
@sgammon sgammon added this to Elide Jul 26, 2025
@sgammon sgammon added the module:tooling Changes and issues relating to the Elide `tooling` module label Jul 26, 2025
@sgammon sgammon moved this to In Progress in Elide Jul 26, 2025
@sgammon sgammon force-pushed the feat/error-highlighting branch from ad3a6b2 to 0350286 Compare July 27, 2025 01:19
@sgammon sgammon marked this pull request as ready for review July 27, 2025 01:19
@sgammon sgammon removed the 🚧 WIP Works-in-progress. Blocks merge label Jul 27, 2025
@sgammon sgammon requested review from a team and Copilot July 27, 2025 01:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends syntax highlighting capabilities from the REPL to other CLI contexts, specifically adding highlighting for Kotlin compiler diagnostics/errors and guest-side language errors (JavaScript, Python, etc.).

  • Enhanced terminal error display with syntax highlighting for code snippets in error messages
  • Added terminal utility functions for color-mode-aware ANSI string rendering
  • Extended nano syntax highlighting configuration to support the new highlighting features

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/tooling/src/main/kotlin/elide/tooling/term/TerminalUtil.kt New utility for converting AttributedString to 256-color and true-color ANSI strings
packages/tooling/build.gradle.kts Added JLine dependencies for syntax highlighting support
packages/cli/src/main/resources/nanorc/kotlin.nanorc Enhanced Kotlin syntax highlighting with balanced delimiters and comment definitions
packages/cli/src/main/resources/nanorc/jnanorc New nano configuration file including various language syntax files
packages/cli/src/main/kotlin/elide/tool/cli/cmd/repl/ToolShellCommand.kt Major refactoring of error display logic to support syntax highlighting and improved formatting
packages/builder/src/main/kotlin/elide/tooling/kotlin/KotlinCompiler.kt Added terminal highlighting support for Kotlin compiler error messages
packages/builder/src/main/kotlin/elide/tooling/cli/Statics.kt Added trueColor property for color mode detection
Comments suppressed due to low confidence (2)

packages/cli/src/main/kotlin/elide/tool/cli/cmd/repl/ToolShellCommand.kt:924

  • [nitpick] The function name 'highlightLineMaybe' uses informal language. Consider renaming to 'highlightLineIfPossible' or 'tryHighlightLine' for better clarity.
  private fun highlightLineMaybe(line: String, langId: String?): Pair<String, Int> {

packages/builder/src/main/kotlin/elide/tooling/kotlin/KotlinCompiler.kt:160

  • [nitpick] The parameter name 'codeProcessor' is vague. Consider renaming to 'syntaxHighlighter' or 'codeHighlighter' to better describe its purpose.
  private val codeProcessor: (String) -> AttributedString = { AttributedString(it) },

sgammon added 2 commits July 27, 2025 14:42
Fixes: #1592
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
@sgammon sgammon force-pushed the feat/error-highlighting branch from 0350286 to 1b4717b Compare July 27, 2025 21:42
@codecov
Copy link

codecov bot commented Jul 27, 2025

Codecov Report

❌ Patch coverage is 2.66667% with 73 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.68%. Comparing base (5de7cd5) to head (1b4717b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...kotlin/elide/tool/cli/cmd/repl/ToolShellCommand.kt 3.57% 54 Missing ⚠️
...main/kotlin/elide/tooling/kotlin/KotlinCompiler.kt 0.00% 11 Missing ⚠️
...src/main/kotlin/elide/tooling/term/TerminalUtil.kt 0.00% 6 Missing ⚠️
...ilder/src/main/kotlin/elide/tooling/cli/Statics.kt 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1593      +/-   ##
==========================================
- Coverage   39.73%   39.68%   -0.06%     
==========================================
  Files         780      781       +1     
  Lines       37118    37169      +51     
  Branches     5244     5253       +9     
==========================================
+ Hits        14748    14749       +1     
- Misses      20602    20652      +50     
  Partials     1768     1768              
Flag Coverage Δ
jvm 39.68% <2.66%> (-0.06%) ⬇️
lib 39.68% <2.66%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ilder/src/main/kotlin/elide/tooling/cli/Statics.kt 0.00% <0.00%> (ø)
...src/main/kotlin/elide/tooling/term/TerminalUtil.kt 0.00% <0.00%> (ø)
...main/kotlin/elide/tooling/kotlin/KotlinCompiler.kt 0.00% <0.00%> (ø)
...kotlin/elide/tool/cli/cmd/repl/ToolShellCommand.kt 30.76% <3.57%> (-0.56%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5de7cd5...1b4717b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sgammon sgammon merged commit fe71087 into main Jul 28, 2025
28 of 29 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Elide Jul 28, 2025
@sgammon sgammon mentioned this pull request Sep 21, 2025
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Large PRs or issues with full-blown features module:cli CLI module issues and features module:tooling Changes and issues relating to the Elide `tooling` module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Syntax highlighting in errors

3 participants