From 89df407737d0eb457ba48b2f73e23e7a8c21de71 Mon Sep 17 00:00:00 2001 From: Kristijan Husak Date: Tue, 21 Jul 2020 15:14:05 +0200 Subject: [PATCH] Add command to print clipboard content. --- doc/nvim-tree-lua.txt | 4 ++++ lua/lib/fs.lua | 18 ++++++++++++++++++ lua/tree.lua | 4 ++++ plugin/tree.vim | 1 + 4 files changed, 27 insertions(+) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index bc4b3ff3..3f5f05a6 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -45,6 +45,10 @@ It will also open the leafs of the tree leading to the file in the buffer (if you opened a file with something else than the LuaTree, like `fzf` or `:split`) +|:LuaTreeClipboard| *:LuaTreeClipboard* + +Print clipboard content for both cut and copy + ============================================================================== OPTIONS *nvim-tree-options* diff --git a/lua/lib/fs.lua b/lua/lib/fs.lua index 7bcf8aec..5df4f830 100644 --- a/lua/lib/fs.lua +++ b/lua/lib/fs.lua @@ -262,4 +262,22 @@ function M.paste(node) return do_paste(node, 'copy', do_copy) end +function M.print_clipboard() + local content = {} + if #clipboard.move > 0 then + table.insert(content, 'Cut') + for _, item in pairs(clipboard.move) do + table.insert(content, ' * '..item.absolute_path) + end + end + if #clipboard.copy > 0 then + table.insert(content, 'Copy') + for _, item in pairs(clipboard.copy) do + table.insert(content, ' * '..item.absolute_path) + end + end + + return api.nvim_out_write(table.concat(content, '\n')..'\n') +end + return M diff --git a/lua/tree.lua b/lua/tree.lua index 2b8b4e54..5ca4e8aa 100644 --- a/lua/tree.lua +++ b/lua/tree.lua @@ -79,6 +79,10 @@ function M.refresh() lib.refresh_tree() end +function M.print_clipboard() + fs.print_clipboard() +end + function M.on_enter() local bufnr = api.nvim_get_current_buf() local bufname = api.nvim_buf_get_name(bufnr) diff --git a/plugin/tree.vim b/plugin/tree.vim index 37b5bef7..55846582 100644 --- a/plugin/tree.vim +++ b/plugin/tree.vim @@ -22,6 +22,7 @@ command! LuaTreeOpen lua require'tree'.open() command! LuaTreeClose lua require'tree'.close() command! LuaTreeToggle lua require'tree'.toggle() command! LuaTreeRefresh lua require'tree'.refresh() +command! LuaTreeClipboard lua require'tree'.print_clipboard() command! LuaTreeFindFile lua require'tree'.find_file() let &cpo = s:save_cpo