Skip to content

Commit

Permalink
Add pre-defined user snippets to roadmap (#192)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Ingall <jonny@mondago.com>
  • Loading branch information
ingalless and ingalless committed Aug 5, 2020
1 parent 87f172d commit 5fabe08
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
Binary file added docs/assets/images/custom-snippet.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/markdown-snippets.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/snippets.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/custom-snippets.md
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).
59 changes: 59 additions & 0 deletions docs/predefined-user-snippets.md
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'
2 changes: 2 additions & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ If a roadmap item is a stub, **consider** opening a [GitHub issue](https://githu
- [[git-flows-for-teams]]
- [[user-settings]]
- [[link-reference-definitions]]
- [[predefined-user-snippets]]

### Publishing

Expand Down Expand Up @@ -104,6 +105,7 @@ The community is working on a number of automated scripts to help you migrate to
[git-flows-for-teams]: git-flows-for-teams "Git Flows for Teams (stub)"
[user-settings]: user-settings "User Settings (stub)"
[link-reference-definitions]: link-reference-definitions "Link Reference Definitions"
[predefined-user-snippets]: predefined-user-snippets "Pre-defined User Snippets"
[officially-support-alternative-templates]: officially-support-alternative-templates "Officially Support Alternative Templates (stub)"
[improved-static-site-generation]: improved-static-site-generation "Improved Static Site Generation (stub)"
[mdx-by-default]: mdx-by-default "MDX by Default(stub)"
Expand Down

0 comments on commit 5fabe08

Please sign in to comment.