Added actions.opts.use_sys_clipboard, [issue: 789 ] (#1141)
This commit is contained in:
@@ -179,6 +179,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
|||||||
timeout = 400,
|
timeout = 400,
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
|
use_system_clipboard = true,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
enable = true,
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ function.
|
|||||||
timeout = 400,
|
timeout = 400,
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
|
use_system_clipboard = true,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
enable = true,
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
@@ -480,6 +481,13 @@ Here is a list of the options available in the setup call:
|
|||||||
`buftype = { "nofile", "terminal", "help", }`
|
`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*
|
*nvim-tree.log*
|
||||||
|log|: configuration for diagnostic logging
|
|log|: configuration for diagnostic logging
|
||||||
|
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
timeout = 400,
|
timeout = 400,
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
|
use_system_clipboard = true,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
enable = true,
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
|
|||||||
@@ -212,9 +212,15 @@ function M.print_clipboard()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function copy_to_clipboard(content)
|
local function copy_to_clipboard(content)
|
||||||
vim.fn.setreg("+", 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))
|
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
|
end
|
||||||
|
|
||||||
function M.copy_filename(node)
|
function M.copy_filename(node)
|
||||||
@@ -234,4 +240,8 @@ function M.copy_absolute_path(node)
|
|||||||
return copy_to_clipboard(content)
|
return copy_to_clipboard(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.setup(opts)
|
||||||
|
M.use_sys_clipboard = opts.actions.use_sys_clipboard
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ function M.setup(opts)
|
|||||||
require("nvim-tree.actions.trash").setup(opts.trash)
|
require("nvim-tree.actions.trash").setup(opts.trash)
|
||||||
require("nvim-tree.actions.open-file").setup(opts)
|
require("nvim-tree.actions.open-file").setup(opts)
|
||||||
require("nvim-tree.actions.change-dir").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 user_map_config = (opts.view or {}).mappings or {}
|
||||||
local options = vim.tbl_deep_extend("force", DEFAULT_MAPPING_CONFIG, user_map_config)
|
local options = vim.tbl_deep_extend("force", DEFAULT_MAPPING_CONFIG, user_map_config)
|
||||||
|
|||||||
Reference in New Issue
Block a user