question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for placeholder in code snippets

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Motivation

Hey all, I’m trying to find a way to implement placeholders in a code snippet. I haven’t managed to find any trivial way to do so.

Specifically I’d like to be able to insert the following snippet

plugins("abc").version("[library_version]")

And the [library_version] placeholder should be replaced by the actual version of the library I’m maintaining. The library version is available inside a custom field in the docusaurus config: https://github.com/detekt/detekt/blob/47428426d0760181a4acb395abad6c6aefed4968/website/docusaurus.config.js#L182-L184

The idea is to have code snippets which are easy to copy-n-paste for the library authors.

So far I’ve looked into creating a custom component, but that’s non trivial as JSX is not playing well with the white spaces and special chars we have in a snippet. I’m looking into doing some text pre-processing before I kick off the bundler, but I’m looking into understanding if there is an easier way to do so.

More context on this is here: https://github.com/detekt/detekt/issues/4915

Self-service

  • I’d be willing to do some initial work on this proposal myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
cortinicocommented, Jun 28, 2022

We implemented it using a custom remark plugin as you suggested @Josh-Cena. If someone else is interested in a similar implementation, you can find it here: https://github.com/detekt/detekt/pull/5001

1reaction
Josh-Cenacommented, Jun 25, 2022

Better ask on the Discord server or in GitHub discussions, in that case. The issue tracker doesn’t really take feature requests like this without a corresponding request gaining some traction on Canny first. I’m going to go ahead and close this for now. It’s not rejecting your feature, just that the team has little interest in making this the default for now, without understanding how many people are interested and what are some typical use-cases. If you want us to implement it, you can submit a feature request on our Canny board. If you have problems while making your Remark plugin, feel free to reach out on Discord.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating and Using Code Snippets With Placeholders
Learn how you can create powerful live templates by customizing them with variables.
Read more >
Code Snippets Support for the HTML Editor
The code snippets might contain hint words, known as placeholders which can be easily selected and changed. The placeholders are highlighted with a ......
Read more >
visual studio code - Snippets: nested placeholders not working
I would say that is expected behaviour. Here is what is happening. In this form: ${1:first placeholder ${2:Second placeholder}}.
Read more >
Snippets in Visual Studio Code
Placeholders can have choices as values. The syntax is a comma-separated enumeration of values, enclosed with the pipe-character, for example ${1|one,two,three ...
Read more >
nested placeholder of snippet is not placeholder in "Choice" or ...
Steps to Reproduce ("Choice" placeholder):. Add a snippet like below to my go.json. "variable declaration =": { "prefix": "var= ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found