windwp / Nvim Autopairs
Licence: mit
autopairs for neovim written by lua
Stars: ✭ 112
Programming Languages
lua
6591 projects
Projects that are alternatives of or similar to Nvim Autopairs
Nvim Completion Manager
⚠️ PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
Stars: ✭ 950 (+748.21%)
Mutual labels: neovim, nvim
Deoplete Phpactor
Phpactor integration for deoplete.nvim
Stars: ✭ 17 (-84.82%)
Mutual labels: neovim, nvim
Nvim Nonicons
Icon set using nonicons for neovim plugins and settings
Stars: ✭ 77 (-31.25%)
Mutual labels: neovim, nvim
Packer.nvim
A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
Stars: ✭ 418 (+273.21%)
Mutual labels: neovim, nvim
Chadtree
File manager for Neovim. Better than NERDTree.
Stars: ✭ 653 (+483.04%)
Mutual labels: neovim, nvim
Neovim
Vim-fork focused on extensibility and usability
Stars: ✭ 49,389 (+43997.32%)
Mutual labels: neovim, nvim
Semshi
🌈 Semantic Highlighting for Python in Neovim
Stars: ✭ 758 (+576.79%)
Mutual labels: neovim, nvim
Nvim Compe
Auto completion plugin for nvim that written in Lua.
Stars: ✭ 433 (+286.61%)
Mutual labels: neovim, nvim
Defx.nvim
📁 The dark powered file explorer implementation
Stars: ✭ 917 (+718.75%)
Mutual labels: neovim, nvim
Rigel
🌌 Colorscheme for vim, terminal, vscode and slack - based on the star Rigel ✨.
Stars: ✭ 324 (+189.29%)
Mutual labels: neovim, nvim
Awesome Dotfiles
Dotfiles for awesome people using the awesomewm linux environment
Stars: ✭ 409 (+265.18%)
Mutual labels: neovim, nvim
nvim-autopairs
A minimalist autopairs for Neovim written by Lua.
Requires neovim 0.5+
Setup
require('nvim-autopairs').setup()
Default values
local pairs_map = {
["'"] = "'",
['"'] = '"',
['('] = ')',
['['] = ']',
['{'] = '}',
['`'] = '`',
}
local disable_filetype = { "TelescopePrompt" }
local break_line_filetype = nil -- mean all file type
local html_break_line_filetype = {'html' , 'vue' , 'typescriptreact' , 'svelte' , 'javascriptreact'}
local ignored_next_char = "%w"
Override default values
require('nvim-autopairs').setup({
disable_filetype = { "TelescopePrompt" , "vim" },
})
Rule
- Pairs map only accept 1 character
- You can use regex on filetype
Break line on html or inside pairs
By default nvim-autopairs don't mapping <CR>
on insert mode
if you want to do that you need to mapping it by your self
Before Input After
------------------------------------
{|} <CR> {
|
}
------------------------------------
<div>|</div> <CR> <div>
|
</div>
<CR>
Sample of mapping using completion nvim
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
-- skip it, if you use another global object
_G.MUtils= {}
vim.g.completion_confirm_key = ""
MUtils.completion_confirm=function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info()["selected"] ~= -1 then
require'completion'.confirmCompletion()
return npairs.esc("<c-y>")
else
vim.fn.nvim_select_popupmenu_item(0 , false , false ,{})
require'completion'.confirmCompletion()
return npairs.esc("<c-n><c-y>")
end
else
return npairs.check_break_line_char()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
using nvim-compe
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
-- skip it, if you use another global object
_G.MUtils= {}
vim.g.completion_confirm_key = ""
MUtils.completion_confirm=function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info()["selected"] ~= -1 then
vim.fn["compe#confirm"]()
return npairs.esc("<c-y>")
else
vim.defer_fn(function()
vim.fn["compe#confirm"]("<cr>")
end, 20)
return npairs.esc("<c-n>")
end
else
return npairs.check_break_line_char()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
Don't add pairs if it already have a close pairs in same line
if next character is a close pairs and it doesn't have an open pairs in same line then it will not add a close pairs
Before Input After
------------------------------------
( |)) ( ( (|))
-- default is true if you want to disable it set it to false
require('nvim-autopairs').setup({
check_line_pair = false
})
Don't add pairs if the next char is alphanumeric
By default, nvim-autopairs will do this
Before Input After
------------------------------------
|foobar ( (|foobar
|.foobar ( (|).foobar
|+foobar ( (|)+foobar
You can customize how nvim-autopairs will behave if it encounters a specific character
require('nvim-autopairs').setup({
ignored_next_char = "[%w%.]" -- will ignore alphanumeric and `.` symbol
})
Before Input After
------------------------------------
|foobar ( (|foobar
|.foobar ( (|.foobar
|+foobar ( (|)+foobar
FAQ
- Is this support autopair of 2 character?
No, Any PR is welcome :)
- Do you have any plan to add more feature (flymode ,end-wise) ?
No, It is a minimalist autopairs. I don't want to make everything complicated.
If you want a flymode or something else you can use jiangmiao autopairs
If you want more feature please try to use lexima
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].