Skip to content

Conversation

@dejmedus
Copy link
Contributor

@dejmedus dejmedus commented Oct 17, 2025

What are you adding in this PR?

While rendering an inline snippet that contains a doc tag we should be offered argument completion suggestions

inline-snippets-arg-completion
Demo
render-arguments-completion-demo.mov

How to test

Pull down the branch gh pr checkout 1075

  • Completion options defined a snippets doc tag should display as expected
  • Only unused options should display
  • Options from nested snippet doc tags should not be offered, only the current scope

Notes: Since this branch isn't based off of the doc tags branch red squiggles will show up on snippets, but render completion should work as expected. VSCode displays param definitions, Cursor does not

Before you deploy

  • I included a minor bump changeset
  • My feature is backward compatible

@dejmedus dejmedus force-pushed the jb-inline-snippets-args-completion branch from 402e7be to b332d3d Compare October 18, 2025 00:07
@dejmedus dejmedus marked this pull request as ready for review October 18, 2025 00:18
@dejmedus dejmedus requested a review from a team as a code owner October 18, 2025 00:18
Comment on lines 94 to 139
function getInlineSnippetDocParams(
params: LiquidCompletionParams,
snippet: LiquidVariableLookup,
): LiquidDocParameter[] {
const ast = params.document.ast;
if (ast instanceof Error || ast.type !== NodeTypes.Document) return [];

if (!snippet.name) return [];

let snippetNode: LiquidTagSnippet | undefined;

visit(ast, {
LiquidTag(node: LiquidTag) {
if (
node.name === 'snippet' &&
typeof node.markup !== 'string' &&
node.markup.type === NodeTypes.VariableLookup &&
node.markup.name === snippet.name
) {
snippetNode = node as LiquidTagSnippet;
}
},
});

if (!snippetNode?.children) return [];

const docNode = snippetNode.children.find(
(node): node is LiquidRawTag => node.type === NodeTypes.LiquidRawTag && node.name === 'doc',
);

if (!docNode) return [];

const paramNodes = (docNode.body.nodes as LiquidHtmlNode[]).filter(
(node): node is LiquidDocParamNode => node.type === NodeTypes.LiquidDocParamNode,
);

return paramNodes.map(
(node): LiquidDocParameter => ({
nodeType: 'param',
name: node.paramName.value,
description: node.paramDescription?.value ?? null,
type: node.paramType?.value ?? null,
required: node.required,
}),
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be worth moving this helper function into an utils file like liquidDoc since this could be a very helpful function for hovering and some theme checks like MissingRenderSnippetArguments or UnrecognizedRenderSnippetArgument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! I moved it out:)

Copy link
Contributor

@shoplando shoplando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a nit comment, but overall looks good for me! Tophatting also worked as expected 👍

Argument completion suggestions should be offered
while rendering an inline snippet. This commit adds
this functionality by selecting and displaying
arguments defined in an inline snippets doc tag
@shoplando shoplando added the #gsd: 48097 Inline Snippets label Oct 29, 2025
@dejmedus dejmedus marked this pull request as draft November 6, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd: 48097 Inline Snippets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants