feat: add <Plug> mappings (#27)
## Problem Users who want keybindings must call Lua functions directly or wrap commands in closures. There is no stable public API for key binding. ## Solution Define <Plug> mappings in the plugin file and document them in a new MAPPINGS section in the vimdoc.
This commit is contained in:
parent
a59bec1ae3
commit
26dafe2f08
2 changed files with 32 additions and 3 deletions
|
|
@ -48,6 +48,27 @@ COMMANDS *live-server-commands*
|
|||
:LiveServerToggle [dir] Toggle the live server on or off. If `dir` is
|
||||
provided, toggles the server in that directory.
|
||||
|
||||
===============================================================================
|
||||
MAPPINGS *live-server-mappings*
|
||||
|
||||
*<Plug>(live-server-start)*
|
||||
<Plug>(live-server-start) Start the live server. Equivalent to
|
||||
|:LiveServerStart| with no arguments.
|
||||
|
||||
*<Plug>(live-server-stop)*
|
||||
<Plug>(live-server-stop) Stop the live server. Equivalent to
|
||||
|:LiveServerStop| with no arguments.
|
||||
|
||||
*<Plug>(live-server-toggle)*
|
||||
<Plug>(live-server-toggle) Toggle the live server. Equivalent to
|
||||
|:LiveServerToggle| with no arguments.
|
||||
|
||||
Example configuration: >lua
|
||||
vim.keymap.set('n', '<leader>ls', '<Plug>(live-server-start)')
|
||||
vim.keymap.set('n', '<leader>lx', '<Plug>(live-server-stop)')
|
||||
vim.keymap.set('n', '<leader>lt', '<Plug>(live-server-toggle)')
|
||||
<
|
||||
|
||||
===============================================================================
|
||||
API *live-server-api*
|
||||
|
||||
|
|
@ -87,9 +108,7 @@ Start server in project root: >vim
|
|||
<
|
||||
Lua keybinding to toggle server: >lua
|
||||
|
||||
vim.keymap.set('n', '<leader>ls', function()
|
||||
require('live-server').toggle()
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>ls', '<Plug>(live-server-toggle)')
|
||||
<
|
||||
Configuration with custom port and no auto-open: >lua
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue