Closed mystilleef closed 2 years ago
Hi @mystilleef! I think that would be nice. By whitespace do you mean indentation?
Btw, if you want this functionality sooner, PRs are most welcome :)
@AckslD Correct. Clipboard items that contain only spaces, tabs, newlines, or empty lines should be ignored. If I wasn't so busy, I'd look at making a PR.
Ah yeah that makes sense! But you don't mean dedenting indented text?
Ah yeah that makes sense! But you don't mean dedenting indented text?
I'm not sure if that's of much benefit. Besides, I think most users would prefer you don't manipulate their clipboard items.
So, I think it's best to leave indented texts alone.
I just don't like seeing a bunch of empty clipboard items in the Telescope
results list taking up valuable space.
this does the job for me:
nnoremap <expr> dd (getline('.') =~ '^\s*$' && v:register == '"' ? '"_' : '').'dd'
@mystilleef I haven't gotten the time to implement this yet. Avoiding duplicates takes some reorganising of the current code. Anyway to at least not store pure whitespace yanks you can add the following to your config:
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
require('neoclip').setup({
...
filter = function(data)
return not all(data.event.regcontents, is_whitespace)
end,
...
})
Thanks for that.
@mystilleef This is now implemented in #54 and I'll merge it probably in a few days to leave some room for trying it out. Feel free to give it a shot and see if it works as intended for you.
I made pretty big refactor of the underlying data structure storing the yanked entries and wrote a bit of a summary here if you're interested :): https://www.reddit.com/r/neovim/comments/swhmpm/neoclip_updates_some_rambling_about_fun/
Lovely, I'll try it tonight.
Does this mean I can remove the is_whitespace
filter from my config?
No, this just avoids identical duplicate entries. And adds possibility to delete individual ones manually.
Since it is quite easy to add the filter I thought I keep it like this, maybe someone wants the whitespace yanks :)
Is it possible to provide convenience options to remove duplicates and whitespaces? I'm sure the
filter
option can be used for this. However, these convenience options are for lazy users, like me. 😁