diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 2dac9739..fae1f4fd 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -1335,6 +1335,20 @@ exists. - navigate.prev - navigate.select +api.config.mappings.active() *nvim-tree.api.config.mappings.active()* + Retrieve a clone of the currently active mappings: + |nvim-tree-default-mappings| with |nvim-tree.view.mappings| applied. + Changing the active mappings will require a call to |nvim-tree-setup| + + Return: ~ + (table) as per |nvim-tree.view.mappings.list| + +api.config.mappings.default() *nvim-tree.api.config.mappings.default()* + Retrieve a clone of the default mappings: |nvim-tree-default-mappings| + + Return: ~ + (table) as per |nvim-tree.view.mappings.list| + ============================================================================== 6. MAPPINGS *nvim-tree-mappings* diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index b1f12c9a..7a9fad21 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -399,6 +399,18 @@ local DEFAULT_MAPPING_CONFIG = { list = {}, } +--- clone default for the user +--- @return table +function M.default_mappings_clone() + return vim.deepcopy(DEFAULT_MAPPINGS) +end + +--- clone active for the user +--- @return table +function M.active_mappings_clone() + return vim.deepcopy(M.mappings) +end + function M.setup(opts) require("nvim-tree.actions.fs.trash").setup(opts) require("nvim-tree.actions.node.system-open").setup(opts) diff --git a/lua/nvim-tree/api.lua b/lua/nvim-tree/api.lua index 515d9ffd..e40bfcd6 100644 --- a/lua/nvim-tree/api.lua +++ b/lua/nvim-tree/api.lua @@ -6,6 +6,7 @@ local Api = { fs = { copy = {} }, git = {}, live_filter = {}, + config = { mappings = {} }, } local function inject_node(f) @@ -127,4 +128,7 @@ Api.marks.navigate.next = require("nvim-tree.marks.navigation").next Api.marks.navigate.prev = require("nvim-tree.marks.navigation").prev Api.marks.navigate.select = require("nvim-tree.marks.navigation").select +Api.config.mappings.active = require("nvim-tree.actions").active_mappings_clone +Api.config.mappings.default = require("nvim-tree.actions").default_mappings_clone + return Api