Skip to content

fix: Support other DuckyScript commands in Syntax Highlighting - #3

Open
webbrain-one wants to merge 2 commits into
aleff-github:mainfrom
webbrain-one:webbrain/issue-2
Open

webbrain-one wants to merge 2 commits into
aleff-github:mainfrom
webbrain-one:webbrain/issue-2

Conversation

@webbrain-one

Copy link
Copy Markdown

Closes #2

Allow users to configure additional commands via settings.json to
extend syntax highlighting. This enables support for custom
extensions used by projects like USBArmyKnife and Flipper Zero.
@aleff-github

Copy link
Copy Markdown
Owner

Hi @webbrain-one ! Thanks again for the contribution. I've tested your implementation and made a few refinements on top of it. Could you please enable Allow edits from maintainers on this PR? I'd like to push the improvements directly to your branch so that your original PR and contribution remain fully credited.

Builds on @webbrain-one's implementation in aleff-github#3, which is kept as the base
of this branch.

- pass the legend to registerDocumentSemanticTokensProvider and use the
  numeric SemanticTokensBuilder.push overload (the branch did not compile)
- declare duckyscriptCustomCommand in contributes.semanticTokenTypes and
  map it to support.function.builtin.duckyscript, so any theme colours it
- enable semanticHighlighting in the two bundled themes, which shipped
  with it turned off
- match against the configured command list (escaped, case-insensitive,
  longest-first) and compute the start column correctly on indented lines
- dispose the configuration listener and emitter, honour cancellation

Closes aleff-github#2

Co-authored-by: webbrain-one <295484252+webbrain-one@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TRLqQ6ZvofMhPeunTaR8GX
@aleff-github

Copy link
Copy Markdown
Owner

Thanks again @webbrain-one — I've pushed my refinements directly onto your branch, on top of your commit, so your original work and authorship stay intact in the history and in the merge.

What I changed on top of it:

  • passed the legend to registerDocumentSemanticTokensProvider and switched to the numeric SemanticTokensBuilder.push overload, so the branch compiles
  • declared duckyscriptCustomCommand in contributes.semanticTokenTypes and mapped it to support.function.builtin.duckyscript, so custom commands get coloured in any theme
  • enabled semanticHighlighting in the two bundled themes, which shipped with it off
  • built the match from the configured command list (escaped, case-insensitive, longest-first) and fixed the start column on indented lines
  • disposed the configuration listener and emitter, and honoured the cancellation token

The feature is yours — I'll merge with a merge commit so your authorship is preserved. Thanks for pushing this forward, and thanks to @i-am-shodan for the original request.

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.

Support other DuckyScript commands in Syntax Highlighting

2 participants