kevinhwang91 / nvim-hclipboard

Hijack your clipboard in Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-hclipboard

To be archives. :h ModeChanged since 0.7.0

Hijack your clipboard, make you become the host of the clipboard!!!

Hclipboard will bypass the text into clipboard for change operator in visual/select mode.

Run :help v_c or :help v_s to get more information.

Expanding snippet will enter select mode automatically which will pollute your clipboard. The initial motivation of Hclipboard is to solve this issue.

hclipboard_demo.mp4

set clipboard=unnamedplus in Neovim and use xsel as my system clipboard

Table of contents

Features

  • Hijacked your clipboard unconsciously
  • Customize your clipboard

Quickstart

Requirements

Installation

Install nvim-hclipboard with Vim-plug:

Plug 'kevinhwang91/nvim-hclipboard'

Install nvim-hclipboard with Packer.nvim:

use {'kevinhwang91/nvim-hclipboard'}

Usage

" vimscript
lua require('hclipboard').start()
-- lua
require('hclipboard').start()

Documentation

Function

Functions are all inside hclipboard module, get module by require('hclipboard')

  • start(): start to hijack clipboard provider

  • stop(): stop to hijack clipboard provider

Setup and description

{
    should_bypass_cb = {
        description = [[Callback function to decide whether to let text bypass the clipboard.
            *WIP*
            There's no guarantee that this function will not be changed in the future. If it is
            changed, it will be listed in the CHANGES file.]],
        default = nil
    },
}

Advanced configuration

-- bypass text into clipboard for change and delete operator in visual/select mode.
require('hclipboard').setup({
    -- Return true the text will be bypassed the clipboard
    -- @param regname register name
    -- @param ev vim.v.ev TextYankPost event
    should_bypass_cb = function(regname, ev)
        local ret = false
        if ev.visual and (ev.operator == 'd' or ev.operator == 'c') then
            if ev.regname == '' or ev.regname == regname then
                ret = true
            end
        end
        return ret
    end
}).start()

default behavior bypass change operator but don't bypass delete operator

Feedback

  • If you get an issue or come up with an awesome idea, don't hesitate to open an issue in github.
  • If you think this plugin is useful or cool, consider rewarding it a star.

License

The project is licensed under a BSD-3-clause license. See LICENSE file for details.

About

Hijack your clipboard in Neovim

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Lua 100.0%