Added actions.opts.use_sys_clipboard, [issue: 789 ] (#1141)
This commit is contained in:
parent
347218d2db
commit
83fe370d52
@ -179,6 +179,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
|
||||
@ -146,6 +146,7 @@ function.
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
@ -479,6 +480,13 @@ Here is a list of the options available in the setup call:
|
||||
`filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", },`
|
||||
`buftype = { "nofile", "terminal", "help", }`
|
||||
`}`
|
||||
|
||||
- |actions.use_system_clipboard|: A boolean value that toggle the use of system clipboard
|
||||
when copy/paste function are invoked.
|
||||
When enabled, copied text will be stored in registers '+' (system), otherwise, it will be stored in '1' and '"'.
|
||||
type: `boolean`
|
||||
default: `true`
|
||||
|
||||
|
||||
*nvim-tree.log*
|
||||
|log|: configuration for diagnostic logging
|
||||
|
||||
@ -371,6 +371,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user