micro-editor/micro · error

Color-link statement is not valid: %s

Error message

Color-link statement is not valid: %s

What it means

Returned by ParseColorscheme when a non-comment line in a .micro colorscheme file does not match the color-link grammar: it must be a 'color-link <group> <colors>' statement captured by the colorParser regex (3 submatches). The offending line is included verbatim so you can find it; parsing continues and the error is returned after the loop.

Source

Thrown at internal/config/colorscheme.go:154

					c[k] = v
				}
			}
			continue
		}

		matches = colorParser.FindSubmatch([]byte(line))
		if len(matches) == 3 {
			link := string(matches[1])
			colors := string(matches[2])

			style := StringToStyle(colors)
			c[link] = style

			if link == "default" {
				DefStyle = style
			}
		} else {
			err = errors.New("Color-link statement is not valid: " + line)
		}
	}

	return c, err
}

// StringToStyle returns a style from a string
// The strings must be in the format "extra foregroundcolor,backgroundcolor"
// The 'extra' can be bold, reverse, italic or underline
func StringToStyle(str string) tcell.Style {
	var fg, bg string
	spaceSplit := strings.Split(str, " ")
	split := strings.Split(spaceSplit[len(spaceSplit)-1], ",")
	if len(split) > 1 {
		fg, bg = split[0], split[1]
	} else {
		fg = split[0]
	}

View on GitHub (pinned to 1c8b82b32e)

Solutions

  1. Open the named file and go to the reported line; rewrite it as: color-link <group> <fg>,<bg> (bg optional), e.g. color-link keyword bold red,#222222.
  2. Ensure every non-comment line starts with 'color-link '; prefix unused lines with '#'.
  3. Validate after editing: run `micro` and `set colorscheme <name>` again; the error line text tells you exactly which statement failed.
  4. If the scheme came from a plugin, update/reinstall the plugin to get a fixed file.

Example fix

# before (~/.config/micro/colorschemes/mine.micro):
link identifier blue
color-link keyword red

# after:
color-link identifier blue
color-link keyword red
Defensive patterns

Strategy: validation

Validate before calling

var colorLinkRe = regexp.MustCompile(`^color-link\s+(\S+)\s+(.+)$`)

func validSchemeLine(line string) bool {
    line = strings.TrimSpace(line)
    return line == "" || strings.HasPrefix(line, "#") || colorLinkRe.MatchString(line)
}

Try / catch

styles, err := config.ParseColorscheme(name, data, &parsed)
if err != nil && strings.HasPrefix(err.Error(), "Color-link statement is not valid") {
    // report file+line, keep previously loaded styles map as fallback
}

Prevention

When it happens

Trigger: Hand-editing a colorscheme and writing 'link color-group red' instead of 'color-link color-group red', missing the color pair, stray characters/quotes around the line, or a plugin-shipped .micro file with a typo. Only lines whose regex match length != 3 hit the branch at internal/config/colorscheme.go:154.

Common situations: Users customizing syntax groups in their scheme, copy-pasting scheme snippets from tutorials that use a different syntax, or trailing smart-quotes/punctuation from rich-text editors corrupting lines.

Related errors


AI-assisted analysis of micro-editor/micro@1c8b82b32e (2026-08-15). Data as JSON: /api/errors/df2aa0663516608b. Report an issue: GitHub.