Skip to content

nvim plugin to wrap the visual selection in brackets and quotes

Notifications You must be signed in to change notification settings

doums/tenaille.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

tenaille.nvim

Wrap the visual selection in brackets and quotes

Install

As usual using your plugin manager, e.g. lazy.nvim

local P = {
  -- plugin spec
  'doums/tenaille.nvim',
  config = true,
}

Config

local tenaille = require('tenaille')

-- Default config
tenaille.setup({
  -- generate default mapping for each pair using
  -- <leader>_open-character_
  -- i.e.
  -- <leader>" for double quotes ""
  -- <leader>[ for brackets []
  -- <leader>{ for curly braces {} and so on...
  default_mapping = true,
  -- supported brackets and quotes pairs
  -- ⚠ only 2 character pairs are supported
  pairs = {
    { '"', '"' },
    { "'", "'" },
    { '`', '`' },
    { '{', '}' },
    { '[', ']' },
    { '(', ')' },
    { '<', '>' },
  },
})

Usage

Select the text you want to wrap then press the relevant key mapping

before key after
|text| <Leader>[ [|text|]
|text| <Leader>" "|text|"
|[text]| <Leader>( (|text|)
|"text"| <Leader>' '|text|'
|"text"| <Leader>" "|text|"

|…| selection

note: multiline selections are supported

Custom mapping

tenaille.setup({
  -- disable default key mapping
  default_mapping = false,
)}

local wrap = require('tenaille').wrap

vim.keymap.set('v', '"', function() wrap({ '"', '"' }) end)
vim.keymap.set('v', "'", function() wrap({ "'", "'" }) end)
vim.keymap.set('v', '`', function() wrap({ '`', '`' }) end)
vim.keymap.set('v', '(', function() wrap({ '(', ')' }) end)
vim.keymap.set('v', '[', function() wrap({ '[', ']' }) end)
vim.keymap.set('v', '{', function() wrap({ '{', '}' }) end)
vim.keymap.set('v', '<', function() wrap({ '<', '>' }) end)

License

Mozilla Public License 2.0

About

nvim plugin to wrap the visual selection in brackets and quotes

Topics

Resources

Stars

Watchers

Forks

Languages