From ffc0482ab89924cb35155fa82033e3d0ddc6c93d Mon Sep 17 00:00:00 2001 From: moxie Date: Sat, 14 Mar 2026 07:39:10 +0200 Subject: chore: update readme/docs --- doc/muwiki.txt | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'doc') diff --git a/doc/muwiki.txt b/doc/muwiki.txt index f6fd62a..4576388 100644 --- a/doc/muwiki.txt +++ b/doc/muwiki.txt @@ -111,7 +111,7 @@ Configuration Options:~ Default: false Example:~ - +>lua { url = "https://git.3kgcat.fi/muwiki.nvim/", keys = { @@ -185,7 +185,7 @@ Example:~ }) end, } - +< ============================================================================== 4. COMMANDS AND API *muwiki-commands* @@ -272,36 +272,29 @@ Note: Multi-line selections are not supported. muwiki.nvim provides actions that automatically check if the current buffer is within a configured wiki directory before executing. -Using lazy.nvim:~ -Configure keymaps in the `keys` table: > - { - 'muwiki.nvim', - keys = { - { '', function() require('muwiki').open_link() end, ft = 'markdown' }, - { '', function() require('muwiki').next_link() end, ft = 'markdown' }, - { '', function() require('muwiki').prev_link() end, ft = 'markdown' }, - { '', function() require('muwiki').create_link() end, - ft = 'markdown', mode = 'v' }, - { 'oo', function() require('muwiki').open_link_with() end, - ft = 'markdown', desc = 'Open link menu to choose external handler' }, - }, - } - -Manual setup:~ -For other plugin managers, set up your own autocmds: > - vim.api.nvim_create_autocmd('BufEnter', { - pattern = '*.md', - callback = function() - local opts = { buffer = true } - vim.keymap.set('n', '', require('muwiki').open_link, opts) - vim.keymap.set('n', '', require('muwiki').next_link, opts) - vim.keymap.set('n', '', require('muwiki').prev_link, opts) - vim.keymap.set('v', '', - require('muwiki').create_link, opts) +Keymap Setup:~ +Configure keymaps using an autocmd to ensure they only apply within wiki +directories: >lua + local muwiki = require('muwiki') + + local group = vim.api.nvim_create_augroup("MuWikiKeymaps", { clear = true }) + + vim.api.nvim_create_autocmd("FileType", { + group = group, + pattern = "markdown", + callback = function(ev) + if not muwiki.wiki_root(ev.buf) then return end + local opts = { buffer = ev.buf, silent = true, nowait = true } + vim.keymap.set('n', '', muwiki.open_link, opts) + vim.keymap.set('n', '', muwiki.next_link, opts) + vim.keymap.set('n', '', muwiki.prev_link, opts) + vim.keymap.set('v', '', muwiki.create_link, opts) + vim.keymap.set('n', 'oo', muwiki.open_link_with, opts) end, }) < -Note: Actions check if the buffer is within a configured wiki directory and do nothing if not. +Note: Actions check if the buffer is within a configured wiki directory and +notify the user if not. *muwiki* Actions:~ -- cgit v1.2.3