New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pre-defined user snippets to roadmap #192
Conversation
Examples: https://roamhacks.com/slash-helpers-roam/ Some comments made on Discord about using |
Notion has similar slash commands |
@jsjoeio What's the best way to capture this and Just-Insane's notes in the roadmap item? Is a notes heading like this preferable? |
@ingalless I think that sounds like the best approach for now. If in addition, you wanted to write a Recipe about creating your own snippets, that could help people take advantage in the interim. Your call! When you think this is ready it be reviewed, feel free to request or @ me and I'll take a look! |
@jsjoeio sounds great! Recipe sounds a good idea too, definitely will add that Might it be sensible to write it in such a way that it encourages users to raise snippet suggestions as issues? Would be cool to see what ideas people have! Going to start a to-do list here so I remember what to do each time I come to the issue
|
Since I was one of the ones that brought this bit up, allow me to elaborate more on my thoughts. Let me start by saying I love slash commands....in more graphical-oriented environments. I literally use slash commands all the time in places like ClickUp and World of Warcraft, where the alternative is navigating a graphical menu system. But VSCode already has a similar system in place...it just isn't activated by slashes (because then it'd be getting accidentally activated all the f-ing time), but with Implementing slash commands, especially if it's with more than just snippets, seems like reinventing the wheel and trying to shoehorn a paradigm that works in other applications for specific reasons into a family of applications that already has its own paradigm and framework for running commands. It honestly struck me as a "your scientists were so preoccupied with whether they could, they never stopped to think whether they should" sort of moment. It raised some questions for me:
🤷 Just some thoughts. |
@ShaunaGordon Some good points here, thanks for contributing! You're right that it doesn't make sense to reinvent the wheel with Personally, I still think carefully curated and selected snippets that were available to the user could be great. Take the Perhaps Snippets are great for awkward syntax. Tables in markdown are awkward. Todos in markdown can be awkward to start authoring However, all the points you've made are very good and food for thought! They show the diversity of workflows. My VS Code is highly customised for focused work (only one file open at a time, no sidebar etc) and that works for me. But of course that doesn't work for everyone and my colleagues tell me as much! I'll definitely include these notes in. We don't want the commands to be invasive. |
Just dropping a quick nugget here, I found that VS Code has this setting that's set to "inline" by default:
The description of the setting is:
So this seems that if we have slash-snippets and slash-commands, it's possible that user snippets could be shown along command autocompletions. This has not been verified, just noting it down lest I forget. |
@jevakallio this is great! |
I'm not certain this is the direction we want to go to, but if we did want to teach non-markdown-writing users markdown, I was playing with the idea of having slash commands for all the standard markdown snippets. Leaving the code here in case we end up needing it {
"Heading 1": {
"scope": "markdown",
"prefix": "/h1",
"description": "Heading 1",
"body": [
"# $TM_SELECTED_TEXT"
]
},
"Heading 2": {
"scope": "markdown",
"prefix": "/h2",
"description": "Heading 3",
"body": [
"## $TM_SELECTED_TEXT"
]
},
"Heading 3": {
"scope": "markdown",
"prefix": "/h3",
"description": "Heading 3",
"body": [
"### $TM_SELECTED_TEXT"
]
},
"Insert bold text": {
"prefix": "/bold",
"body": "**${1:${TM_SELECTED_TEXT}}**$0",
"description": "Insert bold text"
},
"Insert italic text": {
"prefix": "/italic",
"body": "*${1:${TM_SELECTED_TEXT}}*$0",
"description": "Insert italic text"
},
"Insert quoted text": {
"prefix": "/quote",
"body": "> ${1:${TM_SELECTED_TEXT}}",
"description": "Insert quoted text"
},
"Insert code": {
"prefix": "/code",
"body": "`${1:${TM_SELECTED_TEXT}}`$0",
"description": "Insert code"
},
"Insert fenced code block": {
"prefix": "/multiline codeblock",
"body": [
"```${1:language}",
"${TM_SELECTED_TEXT}$0",
"```"
],
"description": "Insert fenced code block"
},
"Insert unordered list": {
"prefix": "/ul",
"body": [
"- ${1:first}",
"- ${2:second}",
"- ${3:third}",
"$0"
],
"description": "Insert unordered list"
},
"Insert ordered list": {
"prefix": "/ol",
"body": [
"1. ${1:first}",
"2. ${2:second}",
"3. ${3:third}",
"$0"
],
"description": "Insert ordered list"
},
"Insert horizontal rule": {
"prefix": "/hr",
"body": "----------\n",
"description": "Insert horizontal rule"
},
"Insert link": {
"prefix": "link",
"body": "[${TM_SELECTED_TEXT:${1:text}}](https://${2:link})$0",
"description": "Insert link"
},
"Insert image": {
"prefix": "image",
"body": "![${TM_SELECTED_TEXT:${1:alt}}](https://${2:link})$0",
"description": "Insert image"
}
} |
Since this is just adding an item to the roadmap, we could theoretically merge this, right @ingalless ? My thought is:
Thoughts? |
@jsjoeio yes, completely agree. I'd like to just add the comments made in this thread if that's alright? I can do it Monday morning before I start work! Apologies for the delay on this. I had the week of work to do some work around the home and haven't had much time for this! I'll ping you Monday morn once I've wrapped up? |
No worries at all! Do it when you have time and then ping me. Sounds great :) thanks @ingalless ! |
@jsjoeio Got round to this early. Ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work @ingalless 🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@ShaunaGordon thank you for your thoughts! Here's some back:
If we implement these, I'd definitely make them optional.
This is a tricky one. If our goal is to build a tool solely for developers, then I agree that we could tell them to just use Ctrl+Shift+P, but that has a bit of an overtone of telling people to "just RTFM". If our goal is to empower people to get used to powerful text editing tools, creating familiarity with their existing workflows while they're getting used to the new paradigm seems to me like it could act as a bridge to learning new workflows. Besides, at least to me, slash commands feel more ergonomic specifically for syntax and snippet expansion, as the option menu appears inside the text editor where the snippet is eventually inserted.
This is something I would like us to pursue once we get the basics right in extension-land first.
These are great questions. The canonical answer is Foam is for hackers, not just for programmers. If we want more segmentation, we need to do user interviews and/or just decide who we want it to be for. If anyone would be interested in doing the research work to give us that insight, I'd be very happy for it -- currently I don't personally have the bandwidth.
I don't think so. Not if it can be disabled. I believe lowering barriers to entry is valuable enough for the overhead, if the overhead is as low as implementing a few snippets and a setting to toggle it on/off.
This is the eternal question in Foam land that we need better default answers for: What belongs to the core? Expect thoughts and guidance on that in the upcoming weeks/months. For the time being I'm happy merging this as a roadmap item to that we have an idea of how we might implement this, if we choose to prioritise it. |
Thank you @ingalless for writing this, @jsjoeio for the reviews and @ShaunaGordon for the feedback! |
I know this is already merged, but I want to clarify something here for the record. Adding text snippet triggers? I'm all for that. I've got a number of my own for scaffolding out whole files. I totally agree that having them especially for awkward structures are great (hat-tip to the Emmet project, which I might add is a good source of implementation inspiration). That's not where my reservations are/were. The discussion in the Discord had gone down the path of (at least as I understood it) more powerful commands, not just text snippets. Those more powerful commands get into the realm of the command palette and are where I start to question to the wisdom of shoehorning a new system in. Perhaps it's just a matter of considering a different name from "slash commands," since that name implies more functionality than I think people are actually going for with this feature? It might also be worthwhile to include some more transparent snippet triggers. Like...why isn't auto-closing code fencing already a thing?! This could be easily solved with a snippet that is triggered off the opening marks. |
See the conversation here