diff options
author | Federico Igne <git@federicoigne.com> | 2023-02-22 10:45:51 +0100 |
---|---|---|
committer | Federico Igne <git@federicoigne.com> | 2023-02-22 10:45:51 +0100 |
commit | aee25d39e76b04473b62befa6b537fa367b6a269 (patch) | |
tree | 21eef38f7ee02165fa452396ac726d385d11cd12 | |
parent | 8c6b0f886359e8cf3d0b92eb5a55cffdd243b65d (diff) | |
download | dotfiles-aee25d39e76b04473b62befa6b537fa367b6a269.tar.gz dotfiles-aee25d39e76b04473b62befa6b537fa367b6a269.zip |
[nvim] add experimental support for note resource folders in zettel
-rw-r--r-- | neovim/.config/nvim/lua/dyamon/zettel.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/dyamon/zettel.lua b/neovim/.config/nvim/lua/dyamon/zettel.lua index daf3c6a..7a10da5 100644 --- a/neovim/.config/nvim/lua/dyamon/zettel.lua +++ b/neovim/.config/nvim/lua/dyamon/zettel.lua | |||
@@ -6,6 +6,7 @@ | |||
6 | local zettel = {} | 6 | local zettel = {} |
7 | 7 | ||
8 | local api = vim.api | 8 | local api = vim.api |
9 | local cmd = vim.cmd | ||
9 | local exec = api.nvim_command | 10 | local exec = api.nvim_command |
10 | local base = vim.env.NOTES | 11 | local base = vim.env.NOTES |
11 | 12 | ||
@@ -189,6 +190,22 @@ function zettel.live_grep(mappings) | |||
189 | } | 190 | } |
190 | end | 191 | end |
191 | 192 | ||
193 | --- Returns the path of the resource folder for the current zettel. | ||
194 | function zettel.resources() | ||
195 | return 'resources/' .. vim.fn.expand('%:t:r') .. '/' | ||
196 | end | ||
197 | |||
198 | --- Opens the resource path in nnn. | ||
199 | -- | ||
200 | -- It creates the necessary directory structure if necessary. | ||
201 | function zettel.open_resources() | ||
202 | local dir = zettel.base .. '/' .. zettel.resources() | ||
203 | -- Create directory if not existent | ||
204 | vim.fn.system({'mkdir', '-p', dir}) | ||
205 | -- Open resource directory in nnn | ||
206 | cmd.NnnPicker(dir) | ||
207 | end | ||
208 | |||
192 | --- Setup zettel-specific mappings and options. | 209 | --- Setup zettel-specific mappings and options. |
193 | function zettel.setup() | 210 | function zettel.setup() |
194 | local map = require 'dyamon.util.map' | 211 | local map = require 'dyamon.util.map' |