aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md23
-rw-r--r--doc/muwiki.txt84
2 files changed, 21 insertions, 86 deletions
diff --git a/README.md b/README.md
index 02f4f37..e2d7df1 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ A lightweight wiki plugin for Neovim using standard markdown syntax.
## Requirements
- Neovim v0.10+
-- Treesitter markdown parser (`:TSInstall markdown`)
+- Treesitter markdown parsers (`:TSInstall markdown markdown_inline`)
## Features
@@ -26,17 +26,11 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
url = "https://git.3kgcat.fi/muwiki.nvim",
opts = {
-- Wiki directories (REQUIRED - configure at least one)
- dirs = {
- { name = 'default', path = '~/wiki' },
- },
- index_file = 'index.md',
- use_template = false,
- use_external_handlers = false,
- create_missing_dirs = false,
+ dirs = {{ name = 'default', path = '~/wiki' }},
},
+ -- No defaults, add your own:
keys = {
{ "<leader>ww", function() require("muwiki").open_index("default") end, desc = "Open wiki index" },
- { "<leader>oo", function() require("muwiki").open_link_with() end, ft = "markdown", desc = "Open link menu to choose external handler" },
{ "<CR>", function() require("muwiki").open_link() end, ft = "markdown", desc = "Open wiki link" },
{ "<Tab>", function() require("muwiki").next_link() end, ft = "markdown", desc = "Next wiki link" },
{ "<S-Tab>", function() require("muwiki").prev_link() end, ft = "markdown", desc = "Previous wiki link" },
@@ -45,13 +39,11 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
}
```
-**Note:** The `ft = "markdown"` condition ensures keymaps are only active in markdown files. Actions automatically check if the buffer is within a configured wiki directory and do nothing if not.
-
## Keymaps
Configure keymaps using lazy.nvim's `keys` option or set them up manually:
-**Default keymaps (lazy.nvim):**
+**Keymaps (lazy.nvim):**
```lua
keys = {
{ "<CR>", function() require("muwiki").open_link() end, ft = "markdown" },
@@ -78,11 +70,12 @@ vim.api.nvim_create_autocmd('BufEnter', {
Note: Actions check if the buffer is within a configured wiki directory and do nothing if not.
**Available actions:**
+
- `open_link()` - Open link under cursor
- `next_link()` - Jump to next markdown link
- `prev_link()` - Jump to previous markdown link
-- `open_link_with()` - Open link with custom external handler
- `create_link()` - Create link from visual selection
+- `open_link_with()` - Open link with custom external handler
See `:help muwiki-commands` for complete API documentation.
@@ -136,7 +129,7 @@ external_handlers = {
{
name = 'Copy URL',
cmd = function(url)
- vim.fn.jobstart({ 'wl-copy', url }, { detach = true })
+ vim.system({ 'wl-copy', url }, { detach = true })
vim.notify('URL copied to clipboard', vim.log.levels.INFO)
end,
pattern = '.*',
@@ -151,6 +144,7 @@ external_handlers = {
```
**Handler properties:**
+
- `name` - Display name in the handler menu
- `cmd` - Command string or Lua function
- `pattern` - Lua pattern(s) to match URLs (string or table of strings; optional, matches all if omitted)
@@ -169,6 +163,7 @@ create_missing_dirs = 'notify', -- or 'silent', 'prompt', or false (default)
```
**Options:**
+
- `false` - Don't create directories (default)
- `true` or `'notify'` - Create directories and show notification
- `'silent'` - Create directories without notification
diff --git a/doc/muwiki.txt b/doc/muwiki.txt
index 7183e9e..4344a1e 100644
--- a/doc/muwiki.txt
+++ b/doc/muwiki.txt
@@ -21,7 +21,7 @@ muwiki.nvim is a lightweight wiki plugin for Neovim that uses standard
markdown syntax for creating and navigating wiki-style documentation.
Features:~
-- Standard markdown links `[text](url)` - compatible with any markdown renderer
+- Standard markdown links `[text](url)`
- Multiple wiki directories support
- External link handlers for custom URL/file opening
- Automatic templates for new pages
@@ -29,7 +29,7 @@ Features:~
Requirements:~
- Neovim v0.10+
-- Treesitter markdown parser (install with :TSInstall markdown)
+- Treesitter markdown parsers (`:TSInstall markdown markdown_inline`)
==============================================================================
2. INSTALLATION *muwiki-installation*
@@ -38,83 +38,23 @@ Using lazy.nvim:~
>lua
{
url = "https://git.3kgcat.fi/muwiki.nvim",
+ opts = {
+ -- Wiki directories (REQUIRED - configure at least one)
+ dirs = {{ name = 'default', path = '~/wiki' }},
+ },
+ -- No defaults, add your own:
keys = {
{ "<leader>ww", function() require("muwiki").open_index("default") end, desc = "Open wiki index" },
+ { "<CR>", function() require("muwiki").open_link() end, ft = "markdown", desc = "Open wiki link" },
+ { "<Tab>", function() require("muwiki").next_link() end, ft = "markdown", desc = "Next wiki link" },
+ { "<S-Tab>", function() require("muwiki").prev_link() end, ft = "markdown", desc = "Previous wiki link" },
+ { "<CR>", function() require("muwiki").create_link() end, ft = "markdown", mode = "v", desc = "Create wiki link from selection" },
},
- opts = {
- dirs = {
- { name = 'default', path = '~/wiki' },
- },
- index_file = 'index.md',
- date_fmt = '%Y-%m-%d',
- use_template = false,
- use_external_handlers = false,
- external_handlers = {
- {
- name = 'xdg-open',
- cmd = 'xdg-open',
- pattern = '.*',
- },
- },
- text_extensions = { 'md', 'txt' },
- },
- config = function(_, opts)
- local muwiki = require('muwiki')
- muwiki.setup(opts)
-
- local function setup_keymaps()
- local keymap_opts = { buffer = 0, silent = true, nowait = true }
- vim.keymap.set('n', '<CR>', function() muwiki.open_link() end, keymap_opts)
- vim.keymap.set('n', '<Tab>', function() muwiki.next_link() end, keymap_opts)
- vim.keymap.set('n', '<S-Tab>', function() muwiki.prev_link() end, keymap_opts)
- end
-
- vim.schedule(setup_keymaps)
- vim.api.nvim_create_autocmd('BufEnter', {
- pattern = '*.md',
- callback = setup_keymaps,
- })
- end,
- lazy = true,
}
<
==============================================================================
3. CONFIGURATION *muwiki-configuration*
- *muwiki.setup()*
->lua
- require("muwiki").setup({
- -- Wiki directories (REQUIRED - configure at least one)
- dirs = {
- { name = 'default', path = '~/wiki' },
- { name = 'test', path = '~/wiki_test' },
- },
-
- index_file = 'index.md',
- date_fmt = '%Y-%m-%d',
- use_template = false,
- template = [[
----
-title: ${title}
-date: ${date}
----
-]],
-
- use_external_handlers = false,
- -- External handler definitions (see |muwiki-external-handlers|)
- external_handlers = {
- {
- name = 'xdg-open',
- cmd = 'xdg-open',
- pattern = '.*',
- },
- },
-
- -- File extensions to open in Neovim (bypasses external handlers)
- -- Tip: Add binary extensions like 'png' here to open them as hex/text for inspection
- text_extensions = { 'md', 'txt' },
- })
-<
Configuration Options:~
dirs List of wiki directories (required)
@@ -364,7 +304,7 @@ Handler Examples:~
{
name = 'Copy URL',
cmd = function(url)
- vim.fn.jobstart({ 'wl-copy', url }, { detach = true })
+ vim.system({ 'wl-copy', url }, { detach = true })
vim.notify('URL copied to clipboard', vim.log.levels.INFO)
end,
pattern = '.*',