Closed bertradio closed 5 months ago
Hi @bertradio! I think you're understanding the feature correctly but I'm not sure why it's not working. Does this happen when you have one session at the time or when there's more than one in parallel?
When there is a single session. Am I correct that neoclip should remember everything until I reach the 1000 limit?
Here is my config.
-- Created: 12/06/23
-- local functions for filtering out of lines that are all whitespace
local function is_whitespace(line)
return vim.fn.match(line, [[^\s*$]]) ~= -1
end
local function all(tbl, check)
for _, entry in ipairs(tbl) do
if not check(entry) then
return false
end
end
return true
end
return {
'AckslD/nvim-neoclip.lua',
dependencies = {
{ 'kkharji/sqlite.lua', module = 'sqlite' },
'nvim-telescope/telescope.nvim',
},
config = function()
require('neoclip').setup({
-- the following lines set up so clips are stored from session to session
history = 1000,
enable_persistent_history = true,
length_limit = 1048576,
continuous_sync = false,
db_path = vim.fn.stdpath('data') .. '/databases/neoclip.sqlite3',
-- don't store entries that are all whitespace - see fns above
filter = function(data)
return not all(data.event.regcontents, is_whitespace)
end,
--stylua: ignore
keys = {
telescope = {
i = {
delete = "<c-d>", -- delete an entry
edit = "<c-e>", -- edit an entry
paste = "<c-p>",
paste_behind = "<c-k>",
replay = "<c-q>", -- replay a macro
select = "<cr>",
custom = {},
},
n = {
--- It is possible to map to more than one key.
-- paste = { 'p', '<c-p>' },
delete = "d",
edit = "e",
paste = "p",
paste_behind = "P",
replay = "q",
select = "<cr>",
custom = {},
},
},
},
})
end,
}```
I'm using the nightly:
NVIM v0.10.0-dev-2048+g367e52cc7 Build type: Release LuaJIT 2.1.1703358377
I did some more testing, using the DBviewer to see what was happening in the sqlite3 db. It turns out that neoclip is adding the entries correctly. But sometimes when I run Telescope neoclip all the entries are deleted. Is that the right command?
I found the problem. I use lazy.nvim. I require the neoclip extension when I load telescope. If I lazy load neoclip this resolves the issue.
I see, I wonder if anything can be done on neoclip
to avoid this? So you had neoclip
loaded when telescope
is and now you load neoclip
on startup instead? That you probably anyway want to record any yanks before telescope
is loaded.
I think it has to do with the fact that the order of loading modules in lazy.nvim is not consistent. So I needed to make sure that telescope was loaded before neoclip. I did this by lazy loading neoclip. Frankly I'm not sure what's going on. But now it works so I'm moving on to other things.
I am trying to use Neoclip.nvim to retain the contents of the clipboard. It works well remembering within a nvim session. But it does not always remember the history even though my settings are:
Sometimes when I re-load nvim it has the clipboards from the past session or two. But often it has nothing. The same thing happens whether continuous_sync is true or false.
Am I misunderstanding what it is supposed to do?