diff options
author | Federico Igne <git@federicoigne.com> | 2023-02-22 10:43:14 +0100 |
---|---|---|
committer | Federico Igne <git@federicoigne.com> | 2023-02-22 10:43:14 +0100 |
commit | 70b2b80f630452581b803fe9983f159ab6ad7e62 (patch) | |
tree | 6b71194784b2ffa4af140a8b3c65375292a3cc51 | |
parent | 5d442d33e1de8a582dfd9645fa0c61b964f4d257 (diff) | |
download | dotfiles-70b2b80f630452581b803fe9983f159ab6ad7e62.tar.gz dotfiles-70b2b80f630452581b803fe9983f159ab6ad7e62.zip |
[nvim] limit zettel autocommands to Markdown notes
-rw-r--r-- | neovim/.config/nvim/init.lua | 4 | ||||
-rw-r--r-- | neovim/.config/nvim/lua/dyamon/zettel.lua | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua index e5cfa02..a885327 100644 --- a/neovim/.config/nvim/init.lua +++ b/neovim/.config/nvim/init.lua | |||
@@ -331,9 +331,9 @@ cmd([[ | |||
331 | 331 | ||
332 | " Zettel autocommands | 332 | " Zettel autocommands |
333 | augroup dyamon_zettel | 333 | augroup dyamon_zettel |
334 | autocmd BufEnter $NOTES/* lcd $NOTES | 334 | autocmd BufEnter $NOTES/\d\\\{12\}.md lcd $NOTES |
335 | autocmd BufEnter $NOTES/* command! -bang -buffer ZLink call v:lua.dyamon.zettel.link_yank(<bang>0) | ||
336 | autocmd BufNewFile,BufFilePre,BufRead $NOTES/\d\\\{12\}.md set filetype=markdown.pandoc | 335 | autocmd BufNewFile,BufFilePre,BufRead $NOTES/\d\\\{12\}.md set filetype=markdown.pandoc |
336 | autocmd BufEnter $NOTES/\d\\\{12\}.md call v:lua.dyamon.zettel.setup() | ||
337 | 337 | ||
338 | " Reset autogroup | 338 | " Reset autogroup |
339 | augroup END | 339 | augroup END |
diff --git a/neovim/.config/nvim/lua/dyamon/zettel.lua b/neovim/.config/nvim/lua/dyamon/zettel.lua index 16c97a8..daf3c6a 100644 --- a/neovim/.config/nvim/lua/dyamon/zettel.lua +++ b/neovim/.config/nvim/lua/dyamon/zettel.lua | |||
@@ -189,6 +189,21 @@ function zettel.live_grep(mappings) | |||
189 | } | 189 | } |
190 | end | 190 | end |
191 | 191 | ||
192 | --- Setup zettel-specific mappings and options. | ||
193 | function zettel.setup() | ||
194 | local map = require 'dyamon.util.map' | ||
195 | |||
196 | cmd([[ | ||
197 | command! -buffer ZResources call v:lua.dyamon.zettel.open_resources() | ||
198 | command! -buffer ZTitle call v:lua.dyamon.zettel.hover_title() | ||
199 | command! -bang -buffer ZLink call v:lua.dyamon.zettel.link_yank(<bang>0) | ||
200 | ]]) | ||
201 | |||
202 | map.b.nore.n(0, '<leader>zr', '<cmd>ZResources<cr>', opts) | ||
203 | map.b.nore.n(0, 'K', '<cmd>ZTitle<cr>', opts) | ||
204 | map.b.nore.i(0, ';zr', zettel.resources(), opts) | ||
205 | end | ||
206 | |||
192 | --- Compute inbound links of a zettel | 207 | --- Compute inbound links of a zettel |
193 | -- | 208 | -- |
194 | -- @param zettel filename of a zettel (defaults to current one) | 209 | -- @param zettel filename of a zettel (defaults to current one) |