Skip to content

Fixes Mojo alias highlighting in VS Code by post-processing semantic tokens returned from LSP server#214

Open
simutisernestas wants to merge 1 commit into
modular:mainfrom
simutisernestas:main
Open

Fixes Mojo alias highlighting in VS Code by post-processing semantic tokens returned from LSP server#214
simutisernestas wants to merge 1 commit into
modular:mainfrom
simutisernestas:main

Conversation

@simutisernestas

Copy link
Copy Markdown

The LSP currently resolves aliases like Some for hover, but emits them as variable semantic tokens. This patch reclassifies variable tokens as type only when they appear in syntactic type positions, such as:

  • parameter annotations: writer: Some[Writer]
  • variable annotations: var x: MyAlias
  • return annotations: -> MyAlias
  • trait/inheritance lists: struct Foo(Copyable, Writable)

A minimal regression test was added for the semantic-token correction behavior.

Note that, this is an extension-side workaround. The more correct long-term fix should likely live in mojo-lsp-server, which has the semantic information needed to classify aliases directly as type-like semantic tokens instead of variable.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@simutisernestas

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA.

@simutisernestas

Copy link
Copy Markdown
Author

recheck

modular-cla-bot Bot added a commit to modular/cla that referenced this pull request Jul 6, 2026
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