diff --git a/lua/nvim-tree/api.lua b/lua/nvim-tree/api.lua index 192ec3c24eb..c0fe06bdb77 100644 --- a/lua/nvim-tree/api.lua +++ b/lua/nvim-tree/api.lua @@ -42,8 +42,8 @@ local Api = { } --- Print error when setup not called. ----@param fn fun(...) ----@return fun(...) +---@param fn fun(...): any +---@return fun(...): any local function wrap(fn) return function(...) if vim.g.NvimTreeSetup == 1 then @@ -55,8 +55,8 @@ local function wrap(fn) end ---Inject the node as the first argument if present otherwise do nothing. ----@param fn fun(node: Node, ...) ----@return fun(node: Node, ...) +---@param fn fun(node: Node, ...): any +---@return fun(node: Node, ...): any local function wrap_node(fn) return function(node, ...) node = node or lib.get_node_at_cursor() @@ -67,8 +67,8 @@ local function wrap_node(fn) end ---Inject the node or nil as the first argument if absent. ----@param fn fun(node: Node, ...) ----@return fun(node: Node, ...) +---@param fn fun(node: Node, ...): any +---@return fun(node: Node, ...): any local function wrap_node_or_nil(fn) return function(node, ...) node = node or lib.get_node_at_cursor() @@ -79,7 +79,7 @@ end ---Invoke a method on the singleton explorer. ---Print error when setup not called. ---@param explorer_method string explorer method name ----@return fun(...) : any +---@return fun(...): any local function wrap_explorer(explorer_method) return wrap(function(...) local explorer = core.get_explorer() @@ -93,7 +93,7 @@ end ---Print error when setup not called. ---@param explorer_member string explorer member name ---@param member_method string method name to invoke on member ----@return fun(...) : any +---@return fun(...): any local function wrap_explorer_member(explorer_member, member_method) return wrap(function(...) local explorer = core.get_explorer() @@ -288,7 +288,7 @@ Api.config.mappings.default_on_attach = keymap.default_on_attach Api.diagnostics.hi_test = wrap(appearance_diagnostics.hi_test) Api.commands.get = wrap(function() - require("nvim-tree.commands").get() + return require("nvim-tree.commands").get() end) return Api