nvim-compare-with-clipboard
is a Neovim plugin that allows to compare currently selected text with contents of a clipboard using null-ls as a convenient way to make it available as a code action. You can also use plain lua api.
Using packer.nvim
use 'antosha417/nvim-compare-with-clipboard',
local null_ls = require("null-ls")
null_ls.setup({
sources = {
-- your other sources
require('compare-with-clipboard.null-ls').code_actions.compare_with_clipboard()
},
})
This is equivalent to:
local null_ls = require("null-ls")
null_ls.setup({
sources = {
-- your other sources
require('compare-with-clipboard.null-ls').code_actions.compare_with_clipboard({
-- by default splits are horizontal
vertical_split = false,
-- by default compares with `+` register
register = "+",
})
},
})
You can also setup this plugin without null-ls
. You need to call setup function only if you want to change the defaults. Otherwise it is good to go.
require('compare-with-clipboard').setup({
-- by default splits are horizontal
vertical_split = false,
})
And then you can compare contents of any two registers
:lua require('compare-with-clipboard').compare_registers("a", "b")
PRs are always welcome.