diff options
| author | moxie <moxie@3kgcat.fi> | 2026-03-15 23:56:23 +0200 |
|---|---|---|
| committer | moxie <moxie@3kgcat.fi> | 2026-03-15 23:58:12 +0200 |
| commit | 2e831e569296acc3f90f83a1b8c5dd79c0631175 (patch) | |
| tree | c6aaaa3716fc7ce0b9fdce52a02dbc8725ccdb7f | |
| parent | c7a268de6279f4aef74e5d410c8cb084b55f8bc8 (diff) | |
chore: update readme/doc
| -rw-r--r-- | README.md | 46 | ||||
| -rw-r--r-- | doc/muwiki.txt | 16 | ||||
| -rw-r--r-- | lua/muwiki/config.lua | 2 |
3 files changed, 51 insertions, 13 deletions
@@ -108,9 +108,44 @@ vim.api.nvim_create_autocmd("BufWritePre", { 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 (wiki→nvim, web/files→xdg-open) +- `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 @@ -120,15 +155,6 @@ See `:help muwiki-autocmd` for more examples. See `:help muwiki-api` for detailed function documentation. -## Link Format - -```text -[Wiki page](page.md) -[Website](https://example.com) -[Relative path](file://../document.pdf) -[Absolute path](file:///tmp/image.png) -``` - ## Recommended Plugins These plugins work well with muwiki.nvim: diff --git a/doc/muwiki.txt b/doc/muwiki.txt index e4d06de..c22acb1 100644 --- a/doc/muwiki.txt +++ b/doc/muwiki.txt @@ -73,6 +73,14 @@ dirs List of wiki directories. index_file Name of the index file for each wiki. Default: 'index.md' + *muwiki-opt-text_extensions* +text_extensions List of file extensions that open directly in Neovim + for file:// links. Files with matching extensions + bypass xdg-open and open in a Neovim buffer. + Extensions can be specified with or without leading + dot (e.g., 'txt' or '.txt'). + Default: {} + Example Configuration~ > local muwiki = require('muwiki') @@ -83,6 +91,9 @@ Example Configuration~ { name = 'work', path = '~/work/wiki' }, }, index_file = 'index.md', + -- Open these file types directly in Neovim (bypass xdg-open) + -- Note: Even binary files like PNG can be opened in Neovim + text_extensions = { 'txt', 'md', 'png' }, }) < @@ -120,8 +131,9 @@ muwiki.setup({opts}) *muwiki.setup()* muwiki.open_link() *muwiki.open_link()* Open the link under cursor. - Wiki links: open in Neovim buffer - - Web links: open with xdg-open - - File links: open with xdg-open + - Web links (http/https): open with xdg-open + - File links (file://): open with xdg-open, unless the file extension + matches |muwiki-opt-text_extensions|, in which case opens in Neovim muwiki.next_link() *muwiki.next_link()* Jump to the next markdown link in the buffer. diff --git a/lua/muwiki/config.lua b/lua/muwiki/config.lua index a2121b1..831e406 100644 --- a/lua/muwiki/config.lua +++ b/lua/muwiki/config.lua @@ -3,7 +3,7 @@ local M = {} M.options = { dirs = nil, index_file = 'index.md', - text_extensions = { 'txt', 'py', 'rb', 'js', 'ts', 'lua', 'sh', 'bash', 'zsh', 'vim', 'json', 'yaml', 'yml', 'toml', 'xml', 'html', 'css' }, + text_extensions = {}, } function M.setup(opts) |
