aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authormoxie <moxie@3kgcat.fi>2026-03-15 06:41:37 +0200
committermoxie <moxie@3kgcat.fi>2026-03-15 10:05:06 +0200
commit49c1e9d1fc3d6bf8748756a8543d8c1b7287940f (patch)
tree8e03c663f10c2a0a17b44bef6a3dbf575582fb2c /README.md
parentc8dc1635f8a921269f714117f414bbc7ba24f9fd (diff)
refactor: move template/mkdir features to user-configured autocmds
- Remove auto-mkdir autocmd from init.lua (now user-configured) - Remove template system entirely (now user-configured) - Rename io.lua -> utils.lua - Inline single-use functions (handle_web_link, handle_file_link, etc.) - Remove security warnings for external files - Remove unused config options: use_template, template, date_fmt - Simplify utils.resolve() without wiki root validation - Update all documentation examples BREAKING CHANGE: Users must now add their own autocmds for: - Auto-creating directories on save (BufWritePre) - Applying templates to new files (BufNewFile) See README.md for updated configuration examples.
Diffstat (limited to 'README.md')
-rw-r--r--README.md28
1 files changed, 23 insertions, 5 deletions
diff --git a/README.md b/README.md
index 56c3ea6..c43671a 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,6 @@ A lightweight wiki plugin for Neovim using standard markdown syntax.
- Standard markdown links `[text](url)`
- Multiple wiki directories
- External link handlers
-- Automatic template for new page
- Link navigation with custom keymaps
See `:help muwiki` for complete documentation and configuration options.
@@ -37,14 +36,16 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
local muwiki = require('muwiki')
muwiki.setup(opts)
- local group = vim.api.nvim_create_augroup("MuWikiKeymaps", { clear = true })
+ local group = vim.api.nvim_create_augroup("muwiki", { clear = true })
+ -- Setup wiki keymaps for markdown files
vim.api.nvim_create_autocmd("FileType", {
group = group,
pattern = "markdown",
- callback = function(ev)
- if not muwiki.wiki_root(ev.buf) then return end
- local keymap_opts = { buffer = ev.buf, silent = true, nowait = true }
+ callback = function(args)
+ if not muwiki.wiki_root(args.buf) then return end
+
+ local keymap_opts = { buffer = args.buf, silent = true, nowait = true }
vim.keymap.set('n', '<CR>', muwiki.open_link, keymap_opts)
vim.keymap.set('n', '<Tab>', muwiki.next_link, keymap_opts)
vim.keymap.set('n', '<S-Tab>', muwiki.prev_link, keymap_opts)
@@ -52,6 +53,23 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
vim.keymap.set('n', '<leader>oo', muwiki.open_link_with, keymap_opts)
end,
})
+
+ -- Auto-create parent directories when saving files in wiki
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ group = group,
+ callback = function(args)
+ local wiki_root = muwiki.wiki_root(args.buf)
+ if not wiki_root then return end
+
+ local file = args.file
+ if not vim.startswith(file, wiki_root) then return end
+
+ local dir = vim.fn.fnamemodify(file, ":h")
+ if vim.fn.isdirectory(dir) == 0 then
+ vim.fn.mkdir(dir, "p")
+ end
+ end,
+ })
end,
}
```