Giter Club home page Giter Club logo

tenaille.nvim's Introduction

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

tenaille.nvim's People

Contributors

doums avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tenaille.nvim's Issues

Errror - attempt to call field 'iter'

Hi, I wanted to give your plugin a try but experienced an issue. I'm quite new to nvim so I might have written something wrong.

I'm using lazy.nvim and this is the relevant config:

{
  'doums/tenaille.nvim',
  config = function() 
    require('tenaille').setup()
  end
}

Whenever I select some text and type <Leader>" I get this error:

E5108: Error executing lua: .../share/nvim/lazy/tenaille.nvim/lua/tenaille/tenaille.lua:37: attempt to call field 'iter' (a nil value)
stack traceback:
        .../share/nvim/lazy/tenaille.nvim/lua/tenaille/tenaille.lua:37: in function 'get_selection'
        .../share/nvim/lazy/tenaille.nvim/lua/tenaille/tenaille.lua:177: in function 'wrap'
        .../share/nvim/lazy/tenaille.nvim/lua/tenaille/tenaille.lua:222: in function <.../share/nvim/lazy/tenaille.nvim/lua/tenaille/tenaille.lua:221>

I'm using nvim 0.9.4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.