feat: snippet and snippetCompletion support custom placeholders #16

Closed
LengJunT wants to merge 2 commits from main into main
LengJunT commented 2023-06-15 16:33:11 +02:00 (Migrated from github.com)

At present, snippet cannot customize the placeholder, I hope that the placeholder can be customized instead of the fixed # and $. Because in my business scenario, ${} and #{} will be rendered as a Widget.
After the snippet can be customized, I can write it like this:
snippetCompletion('fun(${widget1}, @{p2}, @{p3})', Completion, '@')

At present, snippet cannot customize the placeholder, I hope that the placeholder can be customized instead of the fixed # and $. Because in my business scenario, ${} and #{} will be rendered as a Widget. After the snippet can be customized, I can write it like this: `snippetCompletion('fun(${widget1}, @{p2}, @{p3})', Completion, '@')`
marijnh commented 2023-06-15 17:03:14 +02:00 (Migrated from github.com)

Sorry, no. Just backslash-escape the ${} you don't want to be treated as a placeholder, as in $\{x\}

Sorry, no. Just backslash-escape the `${}` you don't want to be treated as a placeholder, as in `$\{x\}`
LengJunT commented 2023-06-16 03:25:18 +02:00 (Migrated from github.com)

Sorry, no. Just backslash-escape the ${} you don't want to be treated as a placeholder, as in $\{x\}

No, I tried.
this code:
snippet('table($\{user\}, ${t2})')
output
image

In fact, I hope
image
If you can customize it like this
snippet('table(${user}, @{t2})', '@')

> Sorry, no. Just backslash-escape the `${}` you don't want to be treated as a placeholder, as in `$\{x\}` No, I tried. this code: `snippet('table($\{user\}, ${t2})')` output <img width="130" alt="image" src="https://github.com/codemirror/autocomplete/assets/26812133/c469f813-6a1b-4da7-8303-30ee4d300da6"> In fact, I hope <img width="162" alt="image" src="https://github.com/codemirror/autocomplete/assets/26812133/8cd9a6d3-c930-4745-b40f-737ce642641b"> If you can customize it like this `snippet('table(${user}, @{t2})', '@')`
marijnh commented 2023-06-16 07:17:51 +02:00 (Migrated from github.com)

snippet('table($\{user\}, ${t2})')

Try snippet('table($\\{user\\}, ${t2})') instead—the backslashes need to be in the actual string. '\{' is just equivalent to '{'.

> `snippet('table($\{user\}, ${t2})')` Try `snippet('table($\\{user\\}, ${t2})')` instead—the backslashes need to be in the actual string. `'\{'` is just equivalent to `'{'`.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/autocomplete!16
No description provided.