Skip to content

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

@RomainDW

Description

@RomainDW

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions