1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 03:40:05 +08:00
SpaceVim/bundle/nvim-tree.lua/lua/nvim-tree/actions/run-command.lua
2022-05-19 09:03:59 +08:00

23 lines
550 B
Lua
Vendored

local utils = require "nvim-tree.utils"
local core = require "nvim-tree.core"
local M = {}
---Retrieves the absolute path to the node.
---Safely handles the node representing the current directory
---(the topmost node in the nvim-tree window)
local function get_node_path(node)
if node.name == ".." then
return utils.path_remove_trailing(core.get_cwd())
else
return node.absolute_path
end
end
function M.run_file_command(node)
local node_path = get_node_path(node)
vim.api.nvim_input(": " .. node_path .. "<Home>")
end
return M