nvim-tree.lua/lua/nvim-tree/actions/node/run-command.lua
Alexander Courtis 1ae1c33ce1
chore(#2931): stylua -> EmmyLuaCodeStyle (#2932)
* stylua -> EmmyLuaCodeStyle: config and doc

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle: CI

* stylua -> EmmyLuaCodeStyle

* stylua -> EmmyLuaCodeStyle: call_arg_parentheses = always

* stylua -> EmmyLuaCodeStyle

* stylua -> EmmyLuaCodeStyle
2024-09-29 14:05:52 +10:00

27 lines
636 B
Lua

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)
---@param node Node
---@return string
local function get_node_path(node)
local cwd = core.get_cwd()
if node.name == ".." and cwd then
return utils.path_remove_trailing(cwd)
else
return node.absolute_path
end
end
---@param node Node
function M.run_file_command(node)
local node_path = get_node_path(node)
vim.api.nvim_input(": " .. node_path .. "<Home>")
end
return M