Added actions.opts.use_sys_clipboard, [issue: 789 ] (#1141)

This commit is contained in:
Lò [By The Way]
2022-04-10 15:39:36 +02:00
committed by GitHub
parent 347218d2db
commit 83fe370d52
5 changed files with 24 additions and 3 deletions

View File

@@ -371,6 +371,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
timeout = 400,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,

View File

@@ -212,9 +212,15 @@ function M.print_clipboard()
end
local function copy_to_clipboard(content)
vim.fn.setreg("+", content)
vim.fn.setreg('"', content)
return a.nvim_out_write(string.format("Copied %s to system clipboard! \n", content))
if M.use_sys_clipboard == true then
vim.fn.setreg("+", content)
vim.fn.setreg('"', content)
return a.nvim_out_write(string.format("Copied %s to system clipboard! \n", content))
else
vim.fn.setreg('"', content)
vim.fn.setreg("1", content)
return a.nvim_out_write(string.format("Copied %s to neovim clipboard \n", content))
end
end
function M.copy_filename(node)
@@ -234,4 +240,8 @@ function M.copy_absolute_path(node)
return copy_to_clipboard(content)
end
function M.setup(opts)
M.use_sys_clipboard = opts.actions.use_sys_clipboard
end
return M

View File

@@ -226,6 +226,7 @@ function M.setup(opts)
require("nvim-tree.actions.trash").setup(opts.trash)
require("nvim-tree.actions.open-file").setup(opts)
require("nvim-tree.actions.change-dir").setup(opts)
require("nvim-tree.actions.copy-paste").setup(opts)
local user_map_config = (opts.view or {}).mappings or {}
local options = vim.tbl_deep_extend("force", DEFAULT_MAPPING_CONFIG, user_map_config)