# muwiki.nvim A lightweight wiki plugin for Neovim using standard markdown syntax. ## Requirements - Neovim v0.10+ - Treesitter markdown parsers (`:TSInstall markdown markdown_inline`) ## Features - Standard markdown links `[text](url)` - Multiple wiki directories - Link navigation and xdg-open for web/file links - Extensible via autocmds (mkdir, templates, custom handlers) See `:help muwiki` for complete documentation and configuration options. ## Installation ### Using vim.pack (Neovim 0.12+) ```lua vim.pack.add({ { src = "https://git.3kgcat.fi/muwiki.nvim" } }) ``` ### Using lazy.nvim ```lua { url = "https://git.3kgcat.fi/muwiki.nvim", keys = { { "ww", function() require("muwiki").open_index("default") end, desc = "Open wiki index" }, }, opts = { dirs = {{ name = 'default', path = '~/wiki' }}, }, config = function(_, opts) local muwiki = require('muwiki') muwiki.setup(opts) local group = vim.api.nvim_create_augroup("muwiki", { 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 keymap_opts = { buffer = ev.buf, silent = true, nowait = true } vim.keymap.set('n', '', muwiki.open_link, keymap_opts) vim.keymap.set('n', '', muwiki.next_link, keymap_opts) vim.keymap.set('n', '', muwiki.prev_link, keymap_opts) vim.keymap.set('v', '', muwiki.create_link, keymap_opts) end, }) end, } ``` ## Quick Start Add this to your config for basic wiki functionality: ```lua local muwiki = require('muwiki') -- Configure wiki directories muwiki.setup({ dirs = {{ name = 'default', path = '~/wiki' }}, }) -- Quick access to wiki index vim.keymap.set('n', 'ww', function() muwiki.open_index("default") end, { desc = "Open wiki index" }) -- Keymaps for wiki navigation (only active in wiki files) vim.api.nvim_create_autocmd("FileType", { pattern = "markdown", callback = function(args) if not muwiki.wiki_root(args.buf) then return end local opts = { buffer = args.buf, silent = 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) end, }) -- Auto-create directories when saving new files vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.md", callback = function(args) local wiki_root = muwiki.wiki_root(args.buf) if not wiki_root then return end local dir = vim.fn.fnamemodify(args.file, ":h") if vim.fn.isdirectory(dir) == 0 then vim.fn.mkdir(dir, "p") end end, }) ``` See `:help muwiki-autocmd` for more examples. ## Configuration Options ### text_extensions Controls which file extensions open directly in Neovim when using `file://` links. Files with matching extensions bypass `xdg-open` and open in a Neovim buffer instead. **Default:** `{}` (empty - all file:// links open with xdg-open) **Format:** Accepts extensions with or without leading dot (e.g., `'txt'` or `'.txt'`) **Example:** ```lua muwiki.setup({ dirs = {{ name = 'default', path = '~/wiki' }}, -- Open these file types directly in Neovim text_extensions = { 'txt', 'md', 'png' }, }) ``` This allows you to open binary files like PNG images directly in Neovim for hex editing or inspection instead of xdg-open. **Behavior:** **xdg-open:** - `[Link](https://example.com)` - `[Link](file:///path/to/file.mp4)` **Neovim:** - `[Link](file://../relative/path/to/image.png)` → matches text_extensions - `[Link](/absolute/path/to/file.txt)` - `[Link](../relative/path/to/file.txt)` - `[Link](SomePage.md)` ## Available Actions - `open_link()` - Open link under cursor - `next_link()` - Jump to next markdown link - `prev_link()` - Jump to previous markdown link - `create_link()` - Create link from visual selection - `get_link()` - Get link info at cursor - `open_index(name)` - Open wiki index file - `open_with_menu(handlers)` - Open link with selectable handler See `:help muwiki-api` for detailed function documentation. ## Recommended Plugins These plugins work well with muwiki.nvim: - [render-markdown.nvim](https://github.com/MeanderingProgrammer/render-markdown.nvim) - Improve markdown rendering in Neovim - [outline.nvim](https://github.com/hedyhli/outline.nvim) - Navigate document structure with symbols outline See `:help muwiki` for full documentation.