parent
03ae60313b
commit
b18ce8be8f
@ -1960,6 +1960,13 @@ fs.copy.absolute_path({node}) *nvim-tree-api.fs.copy.absolute_path()*
|
|||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {node} (Node|nil) file or folder
|
• {node} (Node|nil) file or folder
|
||||||
|
|
||||||
|
fs.copy.basename({node}) *nvim-tree-api.fs.copy.basename()*
|
||||||
|
Copy the name of a file or folder with extension omitted to the system
|
||||||
|
clipboard.
|
||||||
|
|
||||||
|
Parameters: ~
|
||||||
|
• {node} (Node|nil) file or folder
|
||||||
|
|
||||||
fs.copy.filename({node}) *nvim-tree-api.fs.copy.filename()*
|
fs.copy.filename({node}) *nvim-tree-api.fs.copy.filename()*
|
||||||
Copy the name of a file or folder to the system clipboard.
|
Copy the name of a file or folder to the system clipboard.
|
||||||
|
|
||||||
@ -3027,6 +3034,7 @@ highlight group is not, hard linking as follows: >
|
|||||||
|nvim-tree-api.events.subscribe()|
|
|nvim-tree-api.events.subscribe()|
|
||||||
|nvim-tree-api.fs.clear_clipboard()|
|
|nvim-tree-api.fs.clear_clipboard()|
|
||||||
|nvim-tree-api.fs.copy.absolute_path()|
|
|nvim-tree-api.fs.copy.absolute_path()|
|
||||||
|
|nvim-tree-api.fs.copy.basename()|
|
||||||
|nvim-tree-api.fs.copy.filename()|
|
|nvim-tree-api.fs.copy.filename()|
|
||||||
|nvim-tree-api.fs.copy.node()|
|
|nvim-tree-api.fs.copy.node()|
|
||||||
|nvim-tree-api.fs.copy.relative_path()|
|
|nvim-tree-api.fs.copy.relative_path()|
|
||||||
|
|||||||
@ -327,17 +327,43 @@ end
|
|||||||
|
|
||||||
---@param node Node
|
---@param node Node
|
||||||
function Clipboard:copy_filename(node)
|
function Clipboard:copy_filename(node)
|
||||||
self:copy_to_reg(node.name)
|
local content
|
||||||
|
|
||||||
|
if node.name == ".." then
|
||||||
|
-- root
|
||||||
|
content = vim.fn.fnamemodify(self.explorer.absolute_path, ":t")
|
||||||
|
else
|
||||||
|
-- node
|
||||||
|
content = node.name
|
||||||
|
end
|
||||||
|
|
||||||
|
self:copy_to_reg(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param node Node
|
---@param node Node
|
||||||
function Clipboard:copy_basename(node)
|
function Clipboard:copy_basename(node)
|
||||||
local basename = vim.fn.fnamemodify(node.name, ":r")
|
local content
|
||||||
self:copy_to_reg(basename)
|
|
||||||
|
if node.name == ".." then
|
||||||
|
-- root
|
||||||
|
content = vim.fn.fnamemodify(self.explorer.absolute_path, ":t:r")
|
||||||
|
else
|
||||||
|
-- node
|
||||||
|
content = vim.fn.fnamemodify(node.name, ":r")
|
||||||
|
end
|
||||||
|
|
||||||
|
self:copy_to_reg(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param node Node
|
---@param node Node
|
||||||
function Clipboard:copy_path(node)
|
function Clipboard:copy_path(node)
|
||||||
|
local content
|
||||||
|
|
||||||
|
if node.name == ".." then
|
||||||
|
-- root
|
||||||
|
content = utils.path_add_trailing ""
|
||||||
|
else
|
||||||
|
-- node
|
||||||
local absolute_path = node.absolute_path
|
local absolute_path = node.absolute_path
|
||||||
local cwd = core.get_cwd()
|
local cwd = core.get_cwd()
|
||||||
if cwd == nil then
|
if cwd == nil then
|
||||||
@ -345,12 +371,18 @@ function Clipboard:copy_path(node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local relative_path = utils.path_relative(absolute_path, cwd)
|
local relative_path = utils.path_relative(absolute_path, cwd)
|
||||||
local content = node.nodes ~= nil and utils.path_add_trailing(relative_path) or relative_path
|
content = node.nodes ~= nil and utils.path_add_trailing(relative_path) or relative_path
|
||||||
|
end
|
||||||
|
|
||||||
self:copy_to_reg(content)
|
self:copy_to_reg(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param node Node
|
---@param node Node
|
||||||
function Clipboard:copy_absolute_path(node)
|
function Clipboard:copy_absolute_path(node)
|
||||||
|
if node.name == ".." then
|
||||||
|
node = self.explorer
|
||||||
|
end
|
||||||
|
|
||||||
local absolute_path = node.absolute_path
|
local absolute_path = node.absolute_path
|
||||||
local content = node.nodes ~= nil and utils.path_add_trailing(absolute_path) or absolute_path
|
local content = node.nodes ~= nil and utils.path_add_trailing(absolute_path) or absolute_path
|
||||||
self:copy_to_reg(content)
|
self:copy_to_reg(content)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user