Shopify / Shopify/theme-tools

theme-language-server: add textDocument/definition for Liquid file references (render/section/content_for/asset_url)

Open
#1,139 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
234
Forks
92
Avg merge
1d 3h
Merged PRs (30d)
6

Description

Summary

textDocument/definition currently returns null for common Liquid file references, even though textDocument/documentLink already resolves them.

This breaks go-to-definition in editors that rely on definition for cmd/ctrl+click.

Reproduction

Given:

{% render 'stylesheets' %}
{% section 'header' %}
{{ 'theme.css' | asset_url }}
{% content_for 'block', type: 'feature-grid' %}

Request textDocument/definition on any quoted filename/value above.

Actual

textDocument/definition returns null.

Expected

textDocument/definition should return a LocationLink to the corresponding target file:

  • snippets/stylesheets.liquid
  • sections/header.liquid
  • assets/theme.css
  • blocks/feature-grid.liquid
Context

documentLink already resolves these paths today, so this is mainly a parity gap between providers.

Proposed fix

Reuse the existing document-link resolution in a definition provider and map the active link at cursor position to a LocationLink.

I have a patch prepared with tests and can open a PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing documentLink provider and its resolution of render, section, content_for, and asset_url references, then inspect the textDocument/definition entry point. Use the prepared tests as a guide. Done means textDocument/definition returns a LocationLink to the matching snippets, sections, assets, or blocks file for each example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.