Kubebuilder Highlight
Do you often find yourself looking at // +kubebuilder: annotations alongside other actual comments and you have to mentally parse that these are not comments like the rest but markers that have functional significance? What if you misspell a letter? Good luck tracking that.
Kubebuilder Highlight makes kubebuilder / controller-gen markers stand out in Go files and flags the ones controller-gen will silently ignore, so that you can easily focus on what matters and get a fighting chance when the keyboard does not behave.
Quick Start
Requires VS Code 1.87 or newer.
Search for Kubebuilder Highlight in the Extensions view (Ctrl+Shift+X), or from the command palette:
ext install hafslundkraft.kubebuilder-highlight
or from a terminal:
code --install-extension hafslundkraft.kubebuilder-highlight
Open a Go file with // +kubebuilder: markers and they colour straight away — reload the window if it's your first install. There's nothing to configure and no repo-side config to commit. example/markers.go in this repo exercises every rule at once if you want to see the whole palette.
Rolling it out to the team
Drop a workspace recommendation into your operator repos, and anyone opening one gets prompted to install it:
// .vscode/extensions.json
{
"recommendations": ["hafslundkraft.kubebuilder-highlight"]
}
How it looks
Before, and with the extension installed:
| Plain VS Code |
Kubebuilder Highlight |
 |
 |
 |
 |
Markers are split into three segments—namespace, name, arguments—and anything controller-gen doesn't recognise gets a red badge. For the full colour scheme, how the marker vocabulary is derived, and what the extension does not catch, see Technical details.
Customization
To retune, override the rule in settings.json (either local to a repo or on your system).
kubebuilderHighlight.colors is the setting to reach for. Ten named entries, one per colour, each with its own description in the Settings UI. Set only the ones you want to change:
{
"kubebuilderHighlight.colors": {
"nameDark": "#4EC9B0",
"argumentsDark": "#B5CEA8"
}
}
| Entry |
What it colours |
namespaceDark / namespaceLight |
Segment 1 — +kubebuilder |
nameDark / nameLight |
Segment 2 — :rbac |
argumentsDark / argumentsLight |
Segment 3 — :groups=core,verbs=get |
malformedBackground / malformedForeground |
The red badge on an unrecognised marker |
malformedArgumentsDark / malformedArgumentsLight |
Its arguments |
Any CSS colour works, including rgba(). A value may also be theme.<id> to pull from the workbench colour registry instead of hardcoding — "malformedBackground": "theme.editorError.foreground" makes the badge track whatever red your theme uses for errors.
To change the matching rules rather than their colours, or to disable one, see Changing the rules themselves. Short version: use the palette above for colours, because the rule keys are thousands of characters long and shift whenever the vocabulary is refreshed.
Credits
Forked from vscode-highlight by Fabio Spampinato, MIT. The highlighting engine is essentially unchanged; this fork renames the configuration namespace to kubebuilderHighlight.* and ships kubebuilder marker rules as defaults.
Because the namespace differs, this extension and the original can be installed side by side without fighting over the same settings.