Skip to content

syntax: highlight the Go predeclared identifiers added since 1.18 - #4253

Open
yu2971512385-ui wants to merge 1 commit into
micro-editor:masterfrom
yu2971512385-ui:go-syntax-predeclared-identifiers
Open

yu2971512385-ui wants to merge 1 commit into
micro-editor:masterfrom
yu2971512385-ui:go-syntax-predeclared-identifiers

Conversation

@yu2971512385-ui

Copy link
Copy Markdown

runtime/syntax/go.yaml lists Go's predeclared identifiers, but five of them are missing, so they stay unhighlighted while their neighbours in the same rules are highlighted:

identifier added in today with this change
any 1.18 (unhighlighted) type, like error
comparable 1.18 (unhighlighted) type
clear, min, max 1.21 (unhighlighted) preproc, like len

Checked with micro's own highlighter (pkg/highlight):

before: "var payload any = 1"  ->  0:preproc 16:symbol.operator 18:constant.number
after : "var payload any = 1"  ->  0:preproc 12:type 16:symbol.operator 18:constant.number

before: "clear(m)"             ->  5:symbol.brackets
after : "clear(m)"             ->  0:preproc 5:symbol.brackets

error, len and everything else are unaffected: the two types join the existing type rule, the three functions the existing preproc rule that already holds make, new, copy, len, cap and the rest.

AI assistance (Claude) was used to find this — by running language snippets through highlighters and flagging what comes back unstyled — and to draft this description. I verified the before/after with micro's highlighter myself.

🤖 Generated with Claude Code

The Go syntax file lists the predeclared types and functions, but stops
before any (1.18), comparable (1.18) and clear/min/max (1.21), so they are
left unhighlighted while error and len next to them are not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@Andriamanitra Andriamanitra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice addition.

I noticed that the built-in functions complex, real, and imag are also missing from the syntax.

It's also pretty weird that println is special but print is preproc (since #1455). I would rather highlight builtin functions as identifier, but maybe we shouldn't mess with it more than we need to if users have already gotten used to this "wrong" highlighting in Go...

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.

2 participants