Add go-to-definition for variable references → assign tags#1154
Draft
jamesmengo wants to merge 4 commits intomainfrom
Draft
Add go-to-definition for variable references → assign tags#1154jamesmengo wants to merge 4 commits intomainfrom
jamesmengo wants to merge 4 commits intomainfrom
Conversation
When a user Cmd+Clicks on a variable like {{ my_var }}, the LSP now
jumps to the {% assign my_var = ... %} that defines it.
- New VariableDefinitionProvider handles VariableLookup → AssignMarkup
- Shadowing works: later assigns win for later references
- Global/contextual variables return null (no false positives)
- 9 new tests, all 13 definition tests pass
This covers assign only. Capture, for, tablerow, and @param are
planned as follow-up tasks.
Co-authored-by: Claude <noreply@anthropic.com>
Instead of picking only the last assign before cursor, return all of
them. This handles conditional branches (if/else) where multiple
assigns could be the definition at runtime:
{% if condition %}
{% assign x = "from if" %}
{% else %}
{% assign x = "from else" %}
{% endif %}
{{ x }} ← peek menu shows both assigns
Single assign still jumps directly. Multiple results trigger the
editor's peek list — standard LSP pattern for ambiguous definitions,
same as TypeScript does for overloaded methods.
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: AI <noreply@shopify.com>
Co-authored-by: AI <noreply@shopify.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a user Cmd+Clicks (or an agent calls
textDocument/definition) on a variable like{{ my_var }}, the LSP now jumps to the{% assign my_var = ... %}that defines it.Why
This is the highest-value goToDefinition gap — no existing LSP feature provides this navigation today. It helps both human developers and AI agents navigate Liquid codebases.
How
New
VariableDefinitionProviderregistered alongside the existing translation definition providers:VariableLookupnodes with a non-nullnameAssignMarkupnodes with matching nameLocationLinkfrom the variable reference to the assign tagShadowing example
{% assign x = 1 %} {{ x }} ← jumps to first assign {% assign x = 2 %} {{ x }} ← jumps to second assignTests
9 new tests covering:
VariableLookupwithname = nullreturns nullAll 13 definition tests pass (4 existing + 9 new).
Future work
This covers
{% assign %}only. Follow-up tasks planned for:{% capture %}{% for %}/{% tablerow %}(block-scoped)@param(snippet parameters){% increment %}/{% decrement %}