Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system clipboard support #58

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

system clipboard support #58

wants to merge 3 commits into from

Conversation

doodleEsc
Copy link

Telescope do not show the content copied from system to nvim
#57
when telescope shows, read content in register * and + and storage
when delete, remove them and cleanup register * and *

@@ -162,6 +162,8 @@ local function get_export(register_names, typ)
if opts ~= nil and opts.extra ~= nil then
register_names = utils.join(register_names, parse_extra(opts.extra))
end
-- NOTE: use system clipboard
handlers.handle_system_yank()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wont this only show what's currently in eg "+ but not the history as for other registers?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would need some kind of event/trigger whenever these registers are changed from system but not sure that's possible, any ideas?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, history in other registers still can be seen

it just add "* and "+ into storage.yank additionally

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, but i dont find any event related to "register changed".
maybe, we can simply set a command right now.

Copy link
Owner

@AckslD AckslD Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean a command/function that a user can call to add entries to the history? If so, would calling

require('neoclip.storage').insert({
    regtype = regtype,
    contents = regcontents,
    filetype = vim.bo.filetype,
}, 'yanks')

work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look at this issue

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would require("neoclip.handlers").handle_system_yank() do differently than:

require('neoclip.storage').insert({
    regtype = regtype,
    contents = regcontents,
    filetype = vim.bo.filetype,
}, 'yanks')

? Or would that be it?

Just to make sure I understand you suggestion correctly :)

Also are you suggesting that RegStarChange be part of neoclip? I think this can be done by the user?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would require("neoclip.handlers").handle_system_yank() do differently than:

require('neoclip.storage').insert({
    regtype = regtype,
    contents = regcontents,
    filetype = vim.bo.filetype,
}, 'yanks')

nothing special but make sure that it's a unified code style, just like this

Also are you suggesting that RegStarChange be part of neoclip? I think this can be done by the user?
not necessary, user can do it in their own vimrc

I've noticed that TextPutPre and TextPutPost still working in progress, right now there's no event to trigger require("neoclip.handlers").handle_system_yank(), sad

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to add handle_system_yank if that's useful for you.

Although I don't think we should modify the registers on delete since we don't do that with other registers, rather it deletes from the history but the content of the registers remains.

Also I don't think handle_system_yank should be called in the picker. It should be the task of the user to call it prior by whatever event/action is available.

I'm not sure eg TextPutPre would help here though? Isn't that events triggered when pasting. But you want some trigger/event when a register is changed or when you copy something in your system clipboard?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure eg TextPutPre would help here though? Isn't that events triggered when pasting. But you want some trigger/event when a register is changed or when you copy something in your system clipboard?

yes, if there is a trigger, we can just simply add a autocmd

autocmd REGCHANGED * :lua require("neoclip.handlers").handle_system_yank()

But I was noticed that the team of neovim has no plans about TextPutPre and TextPutPost or other event when register is changed.

I will change problem you mentioned, thank you

if neoclip.stopped then
return
end
if not settings.enable_system_clipboard then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this setting is needed anymore since a user just wouldn't trigger this function

for _, register in ipairs({'+', '*'}) do
local event = get_register_event(register)
if #event.regcontents ~= 0 then
if should_add(event) then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about extracting a function from the current handle_text_yank which takes and event table and does the check for should_add and neoclip.stopped and we don't need to check it in more than one place?

@tuxflo
Copy link

tuxflo commented Oct 14, 2022

Any news on this? I'm highly interested in getting support for + and/or * as well.

@AckslD
Copy link
Owner

AckslD commented May 14, 2023

@tuxflo or anyone else, feel free to continue this MR

@RiteshChepuri
Copy link

Any update on this PR?

@AckslD
Copy link
Owner

AckslD commented Jan 20, 2024

Not that I know, anyone can feel free to pick this up.

@breneser
Copy link

Any update on this? I would be happy to pick this up, I wouldn't know where to begin, and I am not sure if I am knowledgable enough with Vim to work on this :(

@AckslD
Copy link
Owner

AckslD commented Mar 14, 2024

Same comment as above :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants