Skip to content

fix: restored p5.js keyword highlighting for CM6 #3868#4141

Open
parthjadhao01 wants to merge 1 commit into
processing:develop-codemirror-v6from
parthjadhao01:fix/p5-syntax-highlighting-cm6
Open

fix: restored p5.js keyword highlighting for CM6 #3868#4141
parthjadhao01 wants to merge 1 commit into
processing:develop-codemirror-v6from
parthjadhao01:fix/p5-syntax-highlighting-cm6

Conversation

@parthjadhao01
Copy link
Copy Markdown
Contributor

@parthjadhao01 parthjadhao01 commented Jun 1, 2026

Issue:

Fixes #3868

This PR restores p5.js-specific syntax highlighting in the CodeMirror v6 branch. In the CM5 editor, p5 functions (like setup, draw, background) appeared bold blue and p5 constants/variables (like PI, mouseX, WEBGL) appeared pink. This styling was missing in the CM6 branch.

Demo:

after fix :

image

befor fix :

image

Changes:

  • Added p5Highlight.js — a CM6 ViewPlugin that walks the Lezer syntax tree over visible ranges, checks each VariableName and VariableDefinition node against the p5 keyword lists from p5-keywords.js, and applies cm-p5-function or cm-p5-variable decorations
  • Updated _editor.scss — added styles for .cm-p5-function (bold blue) and .cm-p5-variable (pink) using existing theme variables so all three themes (light, dark, high-contrast) are supported
  • Updated stateUtils.js — registered p5Highlight in the extensions array

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • has no typecheck errors (npm run typecheck)
  • is from a uniquely-named feature branch and is up to date with the develop-codemirror-v6 branch.
  • is descriptively named and links to an issue number, i.e. Fixes #3868
  • meets the standards outlined in the accessibility guidelines

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