Skip to content

Commit

Permalink
update README with tips to autoload with :Neorg journal
Browse files Browse the repository at this point in the history
  • Loading branch information
pysan3 committed May 17, 2023
1 parent a4adafe commit 3af2fee
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 43 deletions.
55 changes: 34 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@
\* **This README is generated from [./README.norg](./README.norg).**


## Ideas
## Demo

- Using [`LuaSnip`](https://github.com/L3MON4D3/LuaSnip) to utilize the power of snippets
![templates-demo](https://user-images.githubusercontent.com/41065736/232847417-6f7e32b8-fdd3-4464-9d67-269bb28b363c.gif)

1. `:Neorg templates fload journal` (`fload = force load`: Overwrite buffer without asking)
2. `AUTHOR, TODAY...` will be automatically filled.
3. `{TITLE_INPUT}` is an `input_node` with `{TITLE}` being the default placeholder text.
- Changes the title.
4. Cursor at `{WEATHER}`.
- Choosing between options provided from `LuaSnip`'s `choice_node`.
5. Cursor ends up at `{CURSOR}` position.

### Template norg files
\* `{CURSOR}` is a magic keyword, which specifies the last position of the cursor.
More about magic keywords in [Magic Keywords](#magic-keywords).

\* You can use the same keyword in multiple places to insert the same content. Not possible in bare `LuaSnip`.


## Usage

### Template Norg Files

So, the plugin works like this. First you create a template file with placeholders for dynamic values.

Expand Down Expand Up @@ -54,22 +69,6 @@ inside your template file!
Also, I've added some useful snippets by default so you can use them out of the box!


### Demo

![templates-demo](https://user-images.githubusercontent.com/41065736/232847417-6f7e32b8-fdd3-4464-9d67-269bb28b363c.gif)

1. `:Neorg templates fload journal` (`force load`: Overwrite buffer without asking)
2. `AUTHOR, TODAY...` will be automatically filled.
3. `{TITLE_INPUT}` is an `input_node` with `{TITLE}` being the default placeholder text.
- Changes the title.
4. Cursor at `{WEATHER}`.
- Choosing between options provided from `LuaSnip`'s `choice_node`.
5. Cursor ends up at `{CURSOR}` position.

\* `{CURSOR}` is a magic keyword, which specifies the last position of the cursor.
More about magic keywords in [Magic Keywords](#magic-keywords).


## Installation

- [lazy.nvim](https://github.com/folke/lazy.nvim) installation
Expand Down Expand Up @@ -206,14 +205,28 @@ Placeholder for metadata. Generated by `core.norg.esupports.metagen`.
- In order to `:Neorg inject-metadata blog-post`, use `{METADATA:blog-post}`


## Ask for a Snippet
## Tips and Tricks

### Ask for a Snippet

If you are not familiar with `LuaSnip` post what kind of snippet you want! Maybe someone can help you out.
If you are not familiar with `LuaSnip`, post what kind of snippet you want! Maybe someone can help you out.

Post it in the [Discussions](https://github.com/pysan3/neorg-templates-draft/discussions)
with the category `✂️ Ask for a Snippet `.


### Autoload with `:Neorg journal`

> [https://github.com/nvim-neorg/neorg/issues/714#issuecomment-1551013595](https://github.com/nvim-neorg/neorg/issues/714#issuecomment-1551013595)
```lua
vim.api.nvim_create_autocmd("BufNewFile", {
command = "Neorg templates load journal",
pattern = { neorg_dir .. "journal/*.norg" },
})
```


## Useful Templates

- [pysan3](https://github.com/pysan3)
Expand Down
55 changes: 33 additions & 22 deletions README.norg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description:
authors: takuto
categories:
created: 2023-04-16
updated: 2023-05-01
updated: 2023-05-17
version: 1.0.0
@end

Expand All @@ -14,10 +14,24 @@ version: 1.0.0
#templates
\* *This README is generated from {./README.norg}.*

** Ideas
- Using {https://github.com/L3MON4D3/LuaSnip}[`LuaSnip`] to utilize the power of snippets
** Demo
!{https://user-images.githubusercontent.com/41065736/232847417-6f7e32b8-fdd3-4464-9d67-269bb28b363c.gif}[templates-demo]

*** Template norg files
~ `:Neorg templates fload journal` (`fload = force load`: Overwrite buffer without asking)
~ `AUTHOR, TODAY...` will be automatically filled.
~ `{TITLE_INPUT}` is an `input_node` with `{TITLE}` being the default placeholder text.
-- Changes the title.
~ Cursor at `{WEATHER}`.
-- Choosing between options provided from `LuaSnip`'s `choice_node`.
~ Cursor ends up at `{CURSOR}` position.

\* `{CURSOR}` is a magic keyword, which specifies the last position of the cursor.
More about magic keywords in {** Magic Keywords}.

\* You can use the same keyword in multiple places to insert the same content. Not possible in bare `LuaSnip`.

** Usage
*** Template Norg Files
So, the plugin works like this. First you create a template file with placeholders for dynamic values.

`~/.config/nvim/templates/norg/journal.norg`
Expand Down Expand Up @@ -55,20 +69,6 @@ version: 1.0.0
inside your template file!
Also, I've added some useful snippets by default so you can use them out of the box!

*** Demo
!{https://user-images.githubusercontent.com/41065736/232847417-6f7e32b8-fdd3-4464-9d67-269bb28b363c.gif}[templates-demo]

~ `:Neorg templates fload journal` (`force load`: Overwrite buffer without asking)
~ `AUTHOR, TODAY...` will be automatically filled.
~ `{TITLE_INPUT}` is an `input_node` with `{TITLE}` being the default placeholder text.
-- Changes the title.
~ Cursor at `{WEATHER}`.
-- Choosing between options provided from `LuaSnip`'s `choice_node`.
~ Cursor ends up at `{CURSOR}` position.

\* `{CURSOR}` is a magic keyword, which specifies the last position of the cursor.
More about magic keywords in {** Magic Keywords}.

** Installation
- {https://github.com/folke/lazy.nvim}[lazy.nvim] installation
@code lua
Expand Down Expand Up @@ -177,11 +177,22 @@ version: 1.0.0
- This keyword *MUST BE* at the *first line* of the template file.
- In order to `:Neorg inject-metadata blog-post`, use `{METADATA:blog-post}`

** Ask for a Snippet
If you are not familiar with `LuaSnip` post what kind of snippet you want! Maybe someone can help you out.
** Tips and Tricks
*** Ask for a Snippet
If you are not familiar with `LuaSnip`, post what kind of snippet you want! Maybe someone can help you out.

Post it in the {https://github.com/pysan3/neorg-templates-draft/discussions}[Discussions]
with the category `✂️ Ask for a Snippet `.

Post it in the {https://github.com/pysan3/neorg-templates-draft/discussions}[Discussions]
with the category `✂️ Ask for a Snippet `.
*** Autoload with `:Neorg journal`
> {https://github.com/nvim-neorg/neorg/issues/714#issuecomment-1551013595}

@code lua
vim.api.nvim_create_autocmd("BufNewFile", {
command = "Neorg templates load journal",
pattern = { neorg_dir .. "journal/*.norg" },
})
@end

** Useful Templates
- {https://github.com/pysan3}[pysan3]
Expand Down

0 comments on commit 3af2fee

Please sign in to comment.