From f0caf2e8a5dceb63a00080861220299ff0fda6f8 Mon Sep 17 00:00:00 2001 From: Hinell Date: Fri, 20 Oct 2023 02:02:09 +0300 Subject: [PATCH] docs(functions): describe new mode=field Fixes #413 --- doc/table_structures/FUNCTIONS.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/table_structures/FUNCTIONS.md b/doc/table_structures/FUNCTIONS.md index ff9e1706..9f529d08 100644 --- a/doc/table_structures/FUNCTIONS.md +++ b/doc/table_structures/FUNCTIONS.md @@ -32,6 +32,27 @@ local functions = { } ``` +## Specifying mode + +By default, the funciton is shown and run in `*` (all) modes. +You can use `mode` property to narrow function's scope, so it always run in specified mode: + +```lua +local functions = { + { + mode = 'x', description = 'My function', + function() print('only runs in charwise-visual and selection mode!') end + }, + { + description = 'Buffer: git: stage selected hunk' + mode = { 'x', 'V', 'v' }, + function() + gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end + } +} +``` + ## Options You can also pass options via the `opts` property: