-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-defined user snippets to roadmap (#192)
Co-authored-by: Jonathan Ingall <jonny@mondago.com>
- Loading branch information
Showing
6 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Adding Custom Snippets | ||
|
||
You can add custom snippets whilst the default set of snippets are decided by following the below steps: | ||
|
||
1. `Cmd` + `Shift` + `P` (`Ctrl` + `Shift` + `P` for Windows), type `snippets` and select `Preferences: Configure User Snippets`. | ||
2. The command palette will remain in focus. Search for `markdown` and select the entry entitled `markdown.json (Markdown)`. | ||
3. A JSON file will open. You can author your own snippets using the [documentation](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets) to help you, or if you're using a snippet shared by another Foam user then you can copy and paste it in, as the below GIF demonstrates: | ||
![Demonstrating adding a custom snippet](./assets/images/custom-snippet.gif) | ||
|
||
To get started, you might consider replacing the entire contents of the `markdown.json` file opened by the steps above with the JSON in [this comment](https://github.com/foambubble/foam/pull/192#issuecomment-666736270). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Pre-defined User Snippets | ||
|
||
Having pre-defined user snippets would enable us to introduce Roam style commands to Foam. Consider the below snippets: | ||
|
||
```json | ||
{ | ||
"Zettelkasten Id": { | ||
"scope": "markdown", | ||
"prefix": "/id", | ||
"description": "Zettelkasten Id", | ||
"body": [ | ||
"${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}" | ||
] | ||
}, | ||
"Current date": { | ||
"scope": "markdown", | ||
"prefix": "/date", | ||
"description": "Current date", | ||
"body": [ | ||
"${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
Which would look like: | ||
![GIF demonstrating User Snippets](./assets/images/snippets.gif) | ||
|
||
Using snippets enables Foam users to add [[custom-snippets]] themselves so they live alongside the first-class `/commands`. | ||
|
||
## Notes & Considerations | ||
|
||
- VS Code supplies "commands" already via the command palette | ||
- Consider the UX around this. Users less familiar with VS Code are more likely to be familiar with `/` to trigger a command menu. Experienced VS Code users may be more likely to favour the command palette. | ||
- We can use `TabCompletionProvider` and `snippets` and mix them (maybe) via the following VS Code setting: `"editor.snippetSuggestions": "inline" | "top" | "bottom" | "none"` | ||
- For more discussion, consult the PR [here](https://github.com/foambubble/foam/pull/192). | ||
|
||
## Simplifying Markdown Syntax | ||
|
||
Some markdown syntax is difficult for users who have never authored markdown before. Take for example a checkbox/todo. The following syntax is required: | ||
|
||
``` | ||
- [ ] Something todo... | ||
``` | ||
|
||
We could provide snippets that expand out into the associated markdown syntax, like in the below GIF: | ||
![GIF demonstrating markdown snippets](./assets/images/markdown-snippets.gif) | ||
|
||
The JSON for these snippets can be found [here](https://github.com/foambubble/foam/pull/192#issuecomment-666736270). | ||
|
||
[//begin]: # 'Autogenerated link references for markdown compatibility' | ||
[custom-snippets]: custom-snippets 'Adding Custom Snippets' | ||
[//end]: # 'Autogenerated link references' | ||
[//begin]: # 'Autogenerated link references for markdown compatibility' | ||
[custom-snippets]: custom-snippets 'Adding Custom Snippets' | ||
[//end]: # 'Autogenerated link references' | ||
[//begin]: # 'Autogenerated link references for markdown compatibility' | ||
[custom-snippets]: custom-snippets 'Adding Custom Snippets' | ||
[//end]: # 'Autogenerated link references' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters