Skip to content

Commit

Permalink
chore(build): auto-generate vimdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 14, 2024
1 parent 1d520f9 commit 5cdb771
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions doc/submode.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ Fortunately, you can define such submode as follow.
mode = "n",
enter = "<C-w>",
leave = { "q", "<ESC>" },
}, function(default)
default("h", "<C-w>h")
default("j", "<C-w>j")
default("k", "<C-w>k")
default("l", "<C-w>l")
end)
default = function(register)
register("h", "<C-w>h")
register("j", "<C-w>j")
register("k", "<C-w>k")
register("l", "<C-w>l")
end
})
<

This submode has default mappings `hjkl` for moving around windows, and you can
Expand All @@ -79,9 +80,10 @@ For example, you have a submode defined as follow.
mode = "n",
enter = "]",
leave = { "q", "<ESC>" },
}, function(default)
default("1", function() vim.notify("1") end)
end)
default = function(register)
register("1", function() vim.notify("1") end)
end,
})
<

If you want to add `2` to notify `2`, you can achieve it with the following
Expand Down Expand Up @@ -166,13 +168,14 @@ EXAMPLES *submode.nvim-submode.nvim-examples*
mode = "n",
enter = "<Space>l",
leave = { "q", "<ESC>" },
}, function(default)
default("d", vim.lsp.buf.definition)
default("D", vim.lsp.buf.declaration)
default("H", vim.lsp.buf.hover)
default("i", vim.lsp.buf.implementation)
default("r", vim.lsp.buf.references)
end)
default = function(register)
register("d", vim.lsp.buf.definition)
register("D", vim.lsp.buf.declaration)
register("H", vim.lsp.buf.hover)
register("i", vim.lsp.buf.implementation)
register("r", vim.lsp.buf.references)
end,
})
<

- Enable keymaps which is appropriate for reading help when open help.
Expand All @@ -182,13 +185,14 @@ EXAMPLES *submode.nvim-submode.nvim-examples*

submode.create("DocReader", {
mode = "n",
}, function(default)
default("<Enter>", "<C-]>")
default("u", "<cmd>po<cr>")
default("r", "<cmd>ta<cr>")
default("U", "<cmd>ta<cr>")
default("q", "<cmd>q<cr>")
end)
default = function(register)
register("<Enter>", "<C-]>")
register("u", "<cmd>po<cr>")
register("r", "<cmd>ta<cr>")
register("U", "<cmd>ta<cr>")
register("q", "<cmd>q<cr>")
end,
})

vim.api.nvim_create_augroup("DocReaderAugroup", {})
vim.api.nvim_create_autocmd("BufEnter", {
Expand Down Expand Up @@ -230,7 +234,7 @@ The following user events will be triggered.

APIS *submode.nvim-submode.nvim-apis*

- `create(name, opts, register)`
- `create(name, opts, default)`
- Create a new submode.
- `name: string` Name of this submode.
- `opts: table` Options of this submode. Have the following fields.
Expand All @@ -239,13 +243,14 @@ APIS *submode.nvim-submode.nvim-apis*
- `mode_name?: string | fun(): string` Change the value `mode()` returns.
- `enter?: string | string[]` Keys to enter to this submode.
- `leave?: string | string[]` Keys to leave from this submode.
- `default?: function` Callback to register default mappings. Take a following value:
- `register: fun(lhs: string, rhs: string | function, opts?: table)` When called, this callback register given default mapping to this submode.
- `leave_when_mode_changed?: boolean` Whether leave from current submode or not when parent mode is changed i.e. changed normal mode to visual mode. Default is false.
- `override_behavior?: string` Behavior when the submode already exist. Accept following strings.
- `"error"` Throw error. This is default.
- `"keep"` Keep current submode.
- `"override"` Override old submode.
- `default?: function` Callback to register default mappings. Take a following value:
- `register: fun(lhs: string, rhs: string | function, opts?: table)` When called, register given default mapping to this submode.
- `default?: function` Same functional as `opts.default`. This will be removed in future.
- `set(name, lhs, rhs, opts)`
- Add a mapping to `name`. Same interface as `vim.keymap.set`.
- `name: string` Name of target submode.
Expand Down

0 comments on commit 5cdb771

Please sign in to comment.