gbprod / yanky.nvim

Improved Yank and Put functionalities for Neovim
Do What The F*ck You Want To Public License
802 stars 22 forks source link

Can't ignore primary register "* #165

Closed seqizz closed 6 months ago

seqizz commented 7 months ago

Hi :wave:

First of all, thank you, this is a useful tool.

I am trying to ignore Linux primary selection but couldn't succeed. Here is the config I use (might be outdated):

local utils = require("yanky.utils")
local mapping = require("yanky.telescope.mapping")
require("yanky").setup({
  ring = {
    ignore_registers = { "_", '"*' },
    sync_with_numbered_registers = false,
  },
  picker = {
    select = {
      action = nil, -- nil to use default put action
    },
    highlight = {
      on_put = true,
      on_yank = true,
      timer = 1500,
    },
    telescope = {
      mappings = {
        default = mapping.set_register(utils.get_default_register()),
        i = {
          ["<C-p>"] = mapping.put("p"),
          ["<C-P>"] = mapping.put("P"),
        },
      }
    },
  },
})

Also tried with ignore_registers = { "_", "*" }, and making sync to numbered true but no joy, it always show primary selection. Is this related with telescope? Should I pass another thing as set_register?

Thanks!

gbprod commented 6 months ago

Hello,

I'm not sure to understand what you want to achieve. Do you want yanky not to be synchronized with system register ?

Maybe you could try to set this option to false :

  system_clipboard = {
    sync_with_ring = true,
  },
seqizz commented 6 months ago

I would like to add system clipboard to the ring, but not the primary one. Take this example output of :reg command for example:

Type Name Content
  l  ""     system_clipboard = {^J    sync_with_ring = true,^J  }^J
  l  "0     system_clipboard = {^J    sync_with_ring = true,^J  }^J
  l  "1     system_clipboard = {^J    sync_with_ring = true,^J  }^J
  l  "2   pick 79110d02 fix^J
  l  "3   @pytest.fixture^J
  l  "4       isinstance(result, dict)^J
  l  "5   from . import loose^J
  l  "6       assert x+1 == y,"test failed"^J    assert x == y,"test failed"^J
  l  "7       y=6^J
  l  "8       x=5^J
  l  "9   ^J
  c  "a   ^[a^[
  c  "-   LBs
  c  "*   this text is only selected by mouse (on firefox)
  c  "+   this text is copied with ctrl-c (on firefox)
  c  ".
  c  ":   reg
  c  "/   Not

I'd like to ignore "* (a.k.a. primary selection) on yanky. system_clipboard option sadly did not do that.

seqizz commented 6 months ago

Nevermind, after checking the source I realized that I was missing was:

vim.opt.clipboard = "unnamedplus"

plus setting sync_with_ring to false for desired behavior. I am still trying to understand but works so far, thanks!