gbprod/cutlass.nvim

github github
editing-support
stars 200
issues 0
subscribers 3
forks 5
CREATED

2021-12-08

UPDATED

12 months ago


✂️ cutlass.nvim

Lua GitHub Workflow Status

Cutlass overrides the delete operations to actually just delete and not affect the current yank.

✨ Features

It overrides the following keys to always use the black hole register: c, C, s, S, d, D, x, X.

Note that if you have already mapped these keys to something else (like we do below with x) then it will not change it again.

🤔 Why would you want to do this?

See here. This plugin already exists in vimscript. I hope this version in lua will be more efficient :)

⚡️ Requirements

  • Neovim >= 0.7.0

(For Neovim 0.5 compatibility, you can use the compat-0.5 branch)

📦 Installation

Install the plugin with your preferred package manager:

lazy

-- Lua
{
  "gbprod/cutlass.nvim",
  opts = {
      -- your configuration comes here
      -- or don't set opts to use the default settings
      -- refer to the configuration section below
    }
}

packer

-- Lua
use({
  "gbprod/cutlass.nvim",
  config = function()
    require("cutlass").setup({
      -- your configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    })
  end
})

vim-plug

" Vim Script
Plug 'gbprod/cutlass.nvim'
lua << EOF
  require("cutlass").setup({
    " your configuration comes here
    " or leave it empty to use the default settings
    " refer to the configuration section below
  })
EOF

⚙️ Configuration

Cutlass comes with the following defaults:

{
  cut_key = nil,
  override_del = nil,
  exclude = {},
  registers = {
    select = "_",
    delete = "_",
    change = "_",
  },
}

cut_key

Default : nil

After setting up this plugin, all of these operations will simply delete and not cut. However, you will still want to have a key for 'cut', which you can add by setting the cut_key value when setting up the plugin. (m or x are recommended)

This will create those bindings :

nnoremap m d
xnoremap m d
nnoremap mm dd
nnoremap M D

override_del

Default : nil

By default, this plugin doesn't remap the <Del> key to use the blackhole register (and it will work as the old x key). By setting override_del to true, <Del> key will not cut any more and not affect your current yank.

exclude

Default: {}

For some reason, you may doesn't want cutlass to override some keys, you can exclude mappings to be set by adding this to the exclude option using format "{mode}{key}".

Eg. If you want to exclude s key in normal mode, sets exclude option to { "ns" } ; If you want to exclude <bs> key in select mode, sets exclude option to { "s<bs>" }.

registers

Default:

{
  select = "_",
  delete = "_",
  change = "_",
}

Installing cutlass.nvim will use blackhole register for delete, change and select actions. But maybe you want to redirect to a specific register, this option allows you to choose the register to use for each action.

E.g. using configuration below will use s register for select, d for delete and c for change:

{
  registers = {
    select = "s",
    delete = "d",
    change = "c",
  },
}

🤝 Integration

If you have svermeulen/vim-yoink installed, it will work seemlessly as original svermeulen/vim-cutlass. Just follow the integration instructions.

When you're using plugins like ggandor/lightspeed.nvim or ggandor/leap.nvim, you should not want cutlass to remap the s key. You can do this using the exclude option:

use({
  "gbprod/cutlass.nvim",
  config = function()
    require("cutlass").setup({
        exclude = { "ns", "nS" },
    })
  end
})

🎉 Credits

This plugin is a lua version of svermeulen/vim-cutlass (based off of vim-easyclip and also Drew Neil's ideas)

Credit to m00qek lua plugin template