Comments (3)
@hunleyd, wanted to mention that thanks to this issue I decided to slightly redesign mapping process in 'mini.pairs' to make it (hopefully) more user-friendly. Now you can make global mappings in config
and they will be automatically registered for <BS>
and <CR>
(if not changed explicitly). Also work with pair mappings now should be done with MiniPairs.map()
, MiniPairs.map_buf()
, MiniPairs.unmap()
, MiniPairs.unmap_buf()
.
For example, global mappings for
, <
, and >
can look something like this:
require('mini.pairs').setup({
mappings = {
[' '] = { action = 'open', pair = ' ', neigh_pattern = '[%(%[{][%)%]}]' },
['<'] = { action = 'open', pair = '<>' },
['>'] = { action = 'close', pair = '<>' },
},
})
Also, all previous mappings (except ones with MiniPairs.bs()
and MiniPairs.cr()
which use custom pair list) still work as before.
from mini.nvim.
Thank you for your kind words!
Originally, informal general idea of 'mini.pairs' is this: "here are a bunch of autopairs-related actions; use them to make mappings for keys that you want; common ones are already done by default". I might rethink this in future, because coming back to it, this might be a little bit heavy on user-friendliness.
So about spaces. There are three actions supported: open()
, close()
, closeopen()
. All of them work if cursor neighborhood (characters to left and right of cursor) is matched with supplied twochars_pattern
(which is a Lua pattern). Unfortunately, Lua patterns don't seem to support alteration. So user can't say "match if neighborhood is this, or this, or this". The closest behavior to this might be "match if left character is one of these and right character is one of these". To add this behavior to space which checks for ([{
to the right and )]}
to the left, make a standard Neovim mapping:
- In Lua:
vim.api.nvim_set_keymap('i', ' ', [[v:lua.MiniPairs.open(' ', '[%(%[{][%)%]}]')]], { expr = true, noremap = true })
- In Vimscript:
inoremap <expr> <space> v:lua.MiniPairs.open(' ', '[%(%[{][%)%]}]')
With <>
everything is the same: make mappings. You, probably, would want something like this:
- In Lua:
vim.api.nvim_set_keymap('i', '<', [[v:lua.MiniPairs.open('<>', '[^\\].')]], { expr = true, noremap = true }) vim.api.nvim_set_keymap('i', '>', [[v:lua.MiniPairs.close('<>', '[^\\].')]], { expr = true, noremap = true })
- In Vimscript:
inoremap <expr> < v:lua.MiniPairs.open('<>', '[^\\].') inoremap <expr> > v:lua.MiniPairs.close('<>', '[^\\].')
A big NOTE though. Currently all this does is mapping a key to an action. To make <BS>
and <CR>
respect new pairs, you need to remap them accordingly (supply full table of cursor neighborhoods in which those should act).
from mini.nvim.
excellent, thank you! i have this working as desired now.
from mini.nvim.
Related Issues (20)
- mini.cursorword: Define custom highlighting groups HOT 1
- Rename through blockwise selection triggers a move operation. HOT 8
- 'MiniPick.builtin.grep_live' with 'rg' not showing any result HOT 12
- Trailspace: make functions available through module HOT 4
- Support setting 'winbar' option in statusline module HOT 1
- mini.ai: use different search_method for treesitter textobjects?
- Repeatable movement across modules with `;` and `,` HOT 1
- In WSL2 :Git commit results in error in sockconnect HOT 5
- mini.hipatterns throws a "buffer not found" error if the buffer no longer exists HOT 2
- mini.convert plugin to handle conversion of colors between hsv, rgb and hex, conversion of sizes, etc HOT 1
- [mini.git] filetype is set incorrectly for ":Git show" HOT 2
- [surround] Add insert mode surround mappings HOT 2
- (mini.icons) Extension is not resolved when contains multiple dots HOT 4
- Maybe a better way to hide cursor HOT 4
- Mini.operators: if you have a custom mapping on _ (underscore), the line (grr, gxx, gmm) operators break HOT 2
- (mini.clue) overriding default keymap descriptions HOT 1
- [mini.files] Case insensitive file name detection HOT 4
- Mini.Ai: add more options for movement mappings HOT 1
- Statusline virtcol display doesn't respect neovim `positive count` requirement HOT 3
- mini.ai changes latest visual selection HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mini.nvim.