mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-12-23 05:44:52 +01:00
feat: allow sharing from neo-tree view
This commit is contained in:
parent
637a6ee11d
commit
f6561ad361
1 changed files with 23 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
local cc = require("neo-tree.sources.common.commands")
|
||||
local utils = require("neo-tree.utils")
|
||||
local codemp_utils = require("codemp.utils")
|
||||
local manager = require("neo-tree.sources.manager")
|
||||
local session = require("codemp.session")
|
||||
local buf_manager = require("codemp.buffers")
|
||||
|
@ -63,14 +64,32 @@ end
|
|||
M.move = function(state, path, extra)
|
||||
local selected = state.tree:get_node()
|
||||
if selected.type == "buffer" then
|
||||
local window = utils.get_appropriate_window(state)
|
||||
local buf = vim.api.nvim_win_get_buf(window)
|
||||
buf_manager.attach(selected.name, buf)
|
||||
return
|
||||
return vim.ui.input({ prompt = "move content into open buffer?" }, function (input)
|
||||
if input == nil then return end
|
||||
if not vim.startswith("y", string.lower(input)) then return end
|
||||
local window = utils.get_appropriate_window(state)
|
||||
local buf = vim.api.nvim_win_get_buf(window)
|
||||
buf_manager.attach(selected.name, buf)
|
||||
end)
|
||||
end
|
||||
error("only buffers can be moved to current file")
|
||||
end
|
||||
|
||||
M.copy = function(state, path, extra)
|
||||
local selected = state.tree:get_node()
|
||||
if selected.type == "buffer" then
|
||||
return vim.ui.input({ prompt = "copy content to remote buffer?" }, function (input)
|
||||
if input == nil then return end
|
||||
if not vim.startswith("y", string.lower(input)) then return end
|
||||
local window = utils.get_appropriate_window(state)
|
||||
local buf = vim.api.nvim_win_get_buf(window)
|
||||
local content = codemp_utils.buffer.get_content(buf)
|
||||
buf_manager.attach(selected.name, buf, content)
|
||||
end)
|
||||
end
|
||||
error("current file can only be copied into buffers")
|
||||
end
|
||||
|
||||
M.delete = function(state, path, extra)
|
||||
local selected = state.tree:get_node()
|
||||
if selected.type == "root" and vim.startswith(selected.name, "#") then
|
||||
|
|
Loading…
Reference in a new issue