Skip to content

Add Go syntax highlighting definition#198

Merged
tig merged 1 commit into
developfrom
tig/fix-go-syntax-highlighting
May 20, 2026
Merged

Add Go syntax highlighting definition#198
tig merged 1 commit into
developfrom
tig/fix-go-syntax-highlighting

Conversation

@tig
Copy link
Copy Markdown
Member

@tig tig commented May 20, 2026

Summary

Adds Go syntax highlighting support so .go files are properly colorized when opened in ted.

Fixes #196

Changes

  • New file: src/Terminal.Gui.Editor/Highlighting/Resources/Go-Mode.xshd — Go syntax definition covering:

    • All 25 Go keywords + predeclared constants (true, false, nil, iota)
    • Built-in functions (append, len, make, cap, close, copy, delete, new, panic, recover, etc.)
    • Interpreted strings (with escape sequences) and raw string literals (backtick)
    • Rune literals
    • Line (//) and block (/* */) comments with TODO/FIXME markers
    • Number literals (decimal, hex, octal, binary, float, imaginary)
    • Function/method call highlighting
  • Modified: src/Terminal.Gui.Editor/Highlighting/Resources/Resources.cs — registered .go extension

Testing

  • All 534 unit tests pass
  • No .csproj change needed (wildcard *.xshd already embeds all definitions)

Add Go-Mode.xshd with support for:
- Keywords (all 25 Go keywords + predeclared constants)
- Built-in functions (append, len, make, etc.)
- String literals (interpreted and raw/backtick)
- Rune literals
- Line and block comments
- Number literals (decimal, hex, octal, binary, float, imaginary)
- Function/method call highlighting

Register .go extension in the highlighting manager.

Fixes #196

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig merged commit e0a0738 into develop May 20, 2026
8 checks passed
@tig tig deleted the tig/fix-go-syntax-highlighting branch May 20, 2026 22:34
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.

Go syntax highlighting not working

1 participant