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

Selected register not copied to default register " #27

Closed
erikw opened this issue Nov 15, 2022 · 8 comments
Closed

Selected register not copied to default register " #27

erikw opened this issue Nov 15, 2022 · 8 comments

Comments

@erikw
Copy link

erikw commented Nov 15, 2022

Hey,

I would really like to use this plugin. In the past I've used various yang-ring plugins but not been really satisifed. This seems to be a great take on it though!

The problem I have is that when I select a register, it seems like the content is not put in to the default register, so that I can paste it with p after selection.

In this video I start with empty registers, copy 3 pieces of texts in to register 1,2 and 3. Then I try to paste by selecting from the dialog "", however the selected content is not pasted.

Screen.Recording.2022-11-15.at.14.33.27.mov

Specs

  • Nvim: v0.8.0 (from Homebrew)
  • OS: macOS 12.6
  • nvim-peekup: tip of master branch (69b8e01)

Nvim init.vim:

Plug 'gennaro-tedesco/nvim-peekup'
@gennaro-tedesco
Copy link
Owner

Good afternoon and thank you for looking into peekup!

So, as you can see from the code all peekup does it moving the selected content into the default register @ (which is what you are pasting from when executing p). It may be that you do not have the default register set to @.

  1. after selecting the text from the peekup window, execute "@p to check what is being pasted: it must be the content you just selected. If this works it means your clipboard settings are different (from the standard ones)
  2. what is the output of set clipboard?

P. S. I noticed from your recording that there is a problem with the visual selection, it seems the selection doesn't go through the whole word. I will look into it.

@erikw
Copy link
Author

erikw commented Nov 16, 2022

Thank you @gennaro-tedesco for quick answer!

  1. after selecting the text from the peekup window, execute "@p to check what is being pasted: it must be the content you just selected. If this works it means your clipboard settings are different (from the standard ones)

After selecting in the "" dialog ,"@p seems to paste from either register 0 or 1, not sure.

In the following video:

  • Have contents in reg 1,2,3. Reg 1 was the last one I yanked to
  • "" and select reg 3
  • "@p pasted contents of reg 1
  • p also pasted content of reg 1
Screen.Recording.2022-11-16.at.09.56.27.mov

Edit.
I did this a few more times and yes, it seems like the last register that was yanked to is always going to be the register that is being pasted from no matter which was selected in the "" window

Here's another video:

  • Yank to reg 4
  • "" select reg 7
  • "@p pasted reg 4
  • "" select reg 7
  • p pasted reg 4
Screen.Recording.2022-11-16.at.10.00.01.mov
2. what is the output of `set clipboard?`
clipboard=

i.e. it's unset.

P. S. I noticed from your recording that there is a problem with the visual selection, it seems the selection doesn't go through the whole word. I will look into it.

Thx!

@gennaro-tedesco
Copy link
Owner

The problem is that you do not have the unnamed register set for your clipboard: do

set clipboard+=unnamed

and it should work.

However, peekup also gives you the possibility to configure which particular register to use to temporarily store the content you are selecting in the window by amending this option.

@erikw
Copy link
Author

erikw commented Nov 16, 2022

Ah 'clipboard' has default value of "". Maybe this should be added to the setup requirements in the README if the plugin requires it to be set to unnamed?

Setting set clipboard+=unnamed on nvim (Homebrew) macOS has the side-effect of automatically copying everything that goes in to register * to the system GUI clipboard. This is not desirable!

However setting

lua <<EOF
require('nvim-peekup.config').on_keystroke["paste_reg"] = '"'
EOF

seems to work so far! The selected register in "" is now pasted with p, without polluting the system clipboard :)

Would it be a better default with " instead of `*', so that it works out of the box (at least for macOS users)?

@gennaro-tedesco
Copy link
Owner

Would it be a better default with " instead of `*', so that it works out of the box (at least for macOS users)?

It could, but I am not sure if it will conflict with other architectures. So far most users do have their clipboard set to unnamed/unnamedplus, which is why I initially defaulted to it. I believe the best is still to just expose the variable (independent of the defaults) so that users may understand that it is where the contents are going, and handle it how they find fit.

@erikw
Copy link
Author

erikw commented Nov 16, 2022

At least it would be good if the README mention the assumption on unnamed as this isn't the default value :)

@gennaro-tedesco
Copy link
Owner

You are right: I have added a line in the README in 2e48f2e.

@erikw
Copy link
Author

erikw commented Nov 16, 2022

Thx!

@erikw erikw closed this as completed Nov 16, 2022
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

No branches or pull requests

2 participants