File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed
Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -311,6 +311,49 @@ You probably want #2:
311311 }
312312 })
313313<
314+ CUSTOM MAPPINGS WITH ARGUMENTS
315+
316+ If you want to include options for your mappings, such as `nowait ` , you can
317+ map a key to a table that consists of the command and any options you want to
318+ use.
319+
320+ The command can be either the string name of a built-in command, or a
321+ function, and is specified either as the first element in the table or by
322+ assigning it to the `command ` key:
323+ >
324+ require("neo-tree").setup({
325+ filesystem = {
326+ window = {
327+ mappings = {
328+ ["?"] = {
329+ function(state)
330+ local node = state.tree:get_node()
331+ print(node.name)
332+ end,
333+ nowait = true
334+ },
335+ ["i"] = {
336+ command = function(state)
337+ local node = state.tree:get_node()
338+ print(node.name)
339+ end,
340+ nowait = true
341+ },
342+ ["o"] = {
343+ command = "open",
344+ nowait = true
345+ },
346+ ["O"] = {
347+ "open",
348+ nowait = true
349+ },
350+ }
351+ }
352+ }
353+ })
354+ <
355+ See | :map-arguments | for possible values to include. "buffer" and "nnoremap"
356+ are enabled by default.
314357
315358
316359================================================================================
Original file line number Diff line number Diff line change @@ -643,13 +643,21 @@ create_window = function(state)
643643 [" nop" ] = true ,
644644 [" noop" ] = true ,
645645 }
646- local map_options = { noremap = true }
647646 local mappings = utils .get_value (state , " window.mappings" , {}, true )
648647 for cmd , func in pairs (mappings ) do
649648 if utils .truthy (func ) then
650649 if skip_this_mapping [func ] then
651650 log .trace (" Skipping mapping for %s" , cmd )
652651 else
652+ local map_options = { noremap = true }
653+ if type (func ) == " table" then
654+ for key , value in pairs (func ) do
655+ if key ~= " command" and key ~= 1 then
656+ map_options [key ] = value
657+ end
658+ end
659+ func = func .command or func [1 ]
660+ end
653661 if type (func ) == " string" then
654662 func = state .commands [func ]
655663 end
You can’t perform that action at this time.
0 commit comments