Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doums/tenaille.nvim
nvim plugin to wrap the visual selection in brackets and quotes
https://github.com/doums/tenaille.nvim
autopair bracket neovim nvim pair plugin quotes
Last synced: 4 days ago
JSON representation
nvim plugin to wrap the visual selection in brackets and quotes
- Host: GitHub
- URL: https://github.com/doums/tenaille.nvim
- Owner: doums
- Created: 2023-08-17T19:34:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-03T12:08:39.000Z (about 1 year ago)
- Last Synced: 2023-09-04T15:15:39.338Z (about 1 year ago)
- Topics: autopair, bracket, neovim, nvim, pair, plugin, quotes
- Language: Lua
- Homepage:
- Size: 8.79 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## tenaille.nvim
Wrap the visual selection in brackets and quotes
### Install
As usual using your plugin manager, e.g. lazy.nvim
```lua
local P = {
-- plugin spec
'doums/tenaille.nvim',
config = true,
}
```### Config
```lua
local tenaille = require('tenaille')-- Default config
tenaille.setup({
-- generate default mapping for each pair using
-- _open-character_
-- i.e.
-- " for double quotes ""
-- [ for brackets []
-- { 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\|` | `[` | `[\|text\|]` |
| `\|text\|` | `"` | `"\|text\|"` |
| `\|[text]\|` | `(` | `(\|text\|)` |
| `\|"text"\|` | `'` | `'\|text\|'` |
| `\|"text"\|` | `"` | `"\|text\|"` |`|…|` _selection_
note: multiline selections are supported
### Custom mapping
```lua
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