Skip to content

🎨 Overhaul syntax highlighting#119

Merged
timfennis merged 2 commits intomasterfrom
housekeeping/syntax-highlighting-overhaul
Mar 21, 2026
Merged

🎨 Overhaul syntax highlighting#119
timfennis merged 2 commits intomasterfrom
housekeeping/syntax-highlighting-overhaul

Conversation

@timfennis
Copy link
Owner

@timfennis timfennis commented Mar 21, 2026

Summary

  • New color scheme (One Dark-inspired) with distinct colors per category: keywords (coral red), functions (yellow/gold), variables (blue), strings (green), numbers (orange), operators (purple), delimiters (gray), assignment/arrows (cyan)
  • Parser-based function detection — walks the parsed AST to find identifiers in function-call position, correctly highlighting dot-call syntax like foo.len and "hello".upper as functions rather than variables
  • Token heuristic fallback — when parsing fails (e.g. incomplete REPL input), falls back to identifier( and fn identifier heuristics
  • Both REPL and highlight subcommand use the parser-enhanced path

Test plan

  • All 267 existing tests pass
  • cargo clippy clean
  • Verified function vs variable coloring on files using dot-call syntax (tests/programs/005_functions/037_method_call_skips_non_function_binding.ndc)
  • Manual REPL test — incomplete input should still highlight correctly

🤖 Generated with Claude Code

…etection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
use ndc_lexer::{Lexer, Token};
use ndc_lexer::{Lexer, Token, TokenLocation};
use ndc_parser::{Expression, ExpressionLocation, ForBody, ForIteration};
use std::collections::HashSet;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Maybe use ahash here

}
}
// Literals, identifiers (non-call), etc. — nothing to collect
_ => {}
Copy link
Owner Author

Choose a reason for hiding this comment

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

maybe exhaust all options so we are reminded to update this match if we ever add an expression type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@timfennis timfennis enabled auto-merge (squash) March 21, 2026 21:26
@timfennis timfennis merged commit be1eaad into master Mar 21, 2026
1 check passed
@timfennis timfennis deleted the housekeeping/syntax-highlighting-overhaul branch March 21, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant