All Projects → windwp → Nvim Autopairs

windwp / Nvim Autopairs

Licence: mit
autopairs for neovim written by lua

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Nvim Autopairs

Thinkvim
Vim configuration in the 21st century
Stars: ✭ 832 (+642.86%)
Mutual labels:  neovim, nvim
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 Lua Guide
A guide to using Lua in Neovim
Stars: ✭ 750 (+569.64%)
Mutual labels:  neovim, nvim
Nvim Nonicons
Icon set using nonicons for neovim plugins and settings
Stars: ✭ 77 (-31.25%)
Mutual labels:  neovim, nvim
Nvim
The Ultimate NeoVim Config for Colemak Users
Stars: ✭ 754 (+573.21%)
Mutual labels:  neovim, nvim
Vim Dirvish
Directory viewer for Vim ⚡️
Stars: ✭ 929 (+729.46%)
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
Dotfiles
🏠
Stars: ✭ 60 (-46.43%)
Mutual labels:  neovim, nvim
Nvim Hlslens
Hlsearch Lens for Neovim
Stars: ✭ 55 (-50.89%)
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
Neovim Dots
most beautiful neovim cli setup
Stars: ✭ 547 (+388.39%)
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
Vimrc
📝 Vim Configuration for nerds with vim-plug
Stars: ✭ 33 (-70.54%)
Mutual labels:  neovim, nvim
Gnvim
GUI for neovim, without any web bloat
Stars: ✭ 1,271 (+1034.82%)
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>

Sample of mapping <CR>

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].