Skip to content

Commit 89df407

Browse files
Add command to print clipboard content.
1 parent 7ddee0a commit 89df407

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

doc/nvim-tree-lua.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ It will also open the leafs of the tree leading to the file in the buffer
4545
(if you opened a file with something else than the LuaTree, like `fzf` or
4646
`:split`)
4747

48+
|:LuaTreeClipboard| *:LuaTreeClipboard*
49+
50+
Print clipboard content for both cut and copy
51+
4852
==============================================================================
4953
OPTIONS *nvim-tree-options*
5054

lua/lib/fs.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,22 @@ function M.paste(node)
262262
return do_paste(node, 'copy', do_copy)
263263
end
264264

265+
function M.print_clipboard()
266+
local content = {}
267+
if #clipboard.move > 0 then
268+
table.insert(content, 'Cut')
269+
for _, item in pairs(clipboard.move) do
270+
table.insert(content, ' * '..item.absolute_path)
271+
end
272+
end
273+
if #clipboard.copy > 0 then
274+
table.insert(content, 'Copy')
275+
for _, item in pairs(clipboard.copy) do
276+
table.insert(content, ' * '..item.absolute_path)
277+
end
278+
end
279+
280+
return api.nvim_out_write(table.concat(content, '\n')..'\n')
281+
end
282+
265283
return M

lua/tree.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ function M.refresh()
7979
lib.refresh_tree()
8080
end
8181

82+
function M.print_clipboard()
83+
fs.print_clipboard()
84+
end
85+
8286
function M.on_enter()
8387
local bufnr = api.nvim_get_current_buf()
8488
local bufname = api.nvim_buf_get_name(bufnr)

plugin/tree.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ command! LuaTreeOpen lua require'tree'.open()
2222
command! LuaTreeClose lua require'tree'.close()
2323
command! LuaTreeToggle lua require'tree'.toggle()
2424
command! LuaTreeRefresh lua require'tree'.refresh()
25+
command! LuaTreeClipboard lua require'tree'.print_clipboard()
2526
command! LuaTreeFindFile lua require'tree'.find_file()
2627

2728
let &cpo = s:save_cpo

0 commit comments

Comments
 (0)