altermo/ultimate-autopair.nvim

github github
pluginediting-support
star 76
alert-circle 1
users 6
git-branch 1
CREATED

2023-02-02

UPDATED

3 days ago


:exclamation: Ultimate-autopair is alpha software. Some things may change, and some things may break. Documentation may sometimes be inaccurate.

Ultimate-autopair.nvim 0.4.0

Ultimate-autopair plugin aims to have all possible features that an auto-pairing plugin needs.

NOTE: ultimate-autopair will be getting a major update in the following months... Some of the configurations will be broken...

Requires neovim 0.7

Summary

Ultimate-autopair is a neovim autopair plugin that is easy to extend, by the fact that it supports extensions. (Note that the extra mappings (<CR>,<BS>,...) currently use a different system of extensions) The builtin extensions includes among other things: command line support, multicharacter pairs, non one-line, fastwarp and much more...

Installation

Packer:

use{
    'altermo/ultimate-autopair.nvim',
    event={'InsertEnter','CmdlineEnter'},
    config=function ()
        require('ultimate-autopair').setup({
                --Config goes here
                })
    end,
}

Default-configuration

mapopt={noremap=true},
cmap=true,
bs={
    enable=true,
    overjump=true,
    space=true,
    multichar=true,
    fallback=nil,
    extensions=require('ultimate-autopair.maps.bs').default_extensions,
},
cr={
    enable=true,
    autoclose=false,
    multichar={
        enable=true,
        markdown={{'```','```',pair=true,noalpha=true,next=true}},
    },
    addsemi={'c','cpp','rust'},
    fallback=nil,
    extensions=require('ultimate-autopair.maps.cr').default_extensions,
},
space={
    enable=true,
    fallback=nil,
},
fastwarp={
    enable=true,
    hopout=false,
    map='<A-e>',
    rmap='<A-E>',
    Wmap='<A-C-e>',
    cmap='<A-e>',
    rcmap='<A-E>',
    Wcmap='<A-C-e>',
    multiline=true,
    fallback=nil,
    extensions=require('ultimate-autopair.maps.fastwarp').default_extensions,
    endextensions=require('ultimate-autopair.maps.fastwarp').default_endextensions,
    rextensions=require('ultimate-autopair.maps.rfastwarp').default_extensions,
    rendextensions=require('ultimate-autopair.maps.rfastwarp').default_endextensions,
},
fastend={
    enable=true,
    map='<A-$>',
    cmap='<A-$>',
    smart=false,
    fallback=nil,
},
_default_beg_filter=M.default_beg_filter,
_default_end_filter=M.default_end_filter,
extensions={
    {'cmdtype',{'/','?','@'}},
    'multichar',
    'string',
    {'treenode',{inside={'comment'}}},
    {'escape',{filter=true}},
    'rules',
    'filetype',
    {'alpha',{before={"'"}}},
    {'suround',{'"',"'"}},
    {'fly',{')','}',']',' ',match=nil,nofilter=false}},
},
internal_pairs={
    {'(',')'},
    {"'","'",rules={{'when',{'option','lisp'},{'instring'}}}},
    {"'","'",rules={{'not',{'filetype','tex'}}}},
    rules={ --only runs if the extension rules is loaded
        {[[\']],[[\']],rules={{'and',{'not',{'or',{'next',"'"},{'previous','\\',2}}},{'instring'}}}},
        {[[\"]],[[\"]],rules={{'and',{'not',{'or',{'next','"'},{'previous','\\',2}}},{'instring'}}}},
    },
    ft={
        markdown={
            {'```','```'},
            {'<!--','-->'},
        },
        TelescopePrompt={disable=true},
        ---more...
    },
    ---more...
},
----Place own pairs here...
--{'$$','$$'},

The extensions

Extension What it does
cmdtype disables for specific command types
string makes it so that inside and outside of strings don't interact with each other (treesitter support)
multichar allows for pairs which consist of multiple characters
escape don't add if it will be escaped
rules a system which allows one to add rules
filetype only allow some file types
alpha no pair before or after alpha character
surround auto surround the pair |"foo">(>("foo"|)
fly fly over ending parentheses ([{|}]) > ) > ([{}])|
treenode filter inside or outside treesitter nodes

Other plugins to supercharge auto-pairing

These are some other plugins which are related to pairing which have features that ultimate-autopair does not.

  • endwise wisely add end in lua, ruby, etc...
  • tabout tab out of parentheses
  • surround delete, change surrounding parentheses and much more...
  • autotag auto add html tags

Use npairs-integrate-upair with require('npairs-int-upair').setup({map='u'})

If you want to donate then you need to find the correct link (50₁₀):