Mercurial > dotfiles
comparison dot_config/nvim/init.lua @ 425:10916f9b1676
Replace delimitMate with nvim-autopairs
author | zegervdv <zegervdv@me.com> |
---|---|
date | Wed, 28 Jul 2021 11:42:54 +0200 |
parents | f42ea4c4a78c |
children | 53a73096981a |
comparison
equal
deleted
inserted
replaced
424:f42ea4c4a78c | 425:10916f9b1676 |
---|---|
79 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } | 79 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } |
80 | 80 |
81 -- Parentheses etc | 81 -- Parentheses etc |
82 use { 'tpope/vim-surround' } | 82 use { 'tpope/vim-surround' } |
83 use { | 83 use { |
84 'raimondi/delimitMate', | 84 'windwp/nvim-autopairs', |
85 config = function() | 85 config = function() |
86 vim.g.delimitMate_expand_cr = 1 | 86 local npairs = require 'nvim-autopairs' |
87 vim.g.delimitMate_expand_space = 1 | 87 local Rule = require 'nvim-autopairs.rule' |
88 | |
89 npairs.setup() | |
90 | |
91 require('nvim-autopairs.completion.compe').setup { | |
92 map_cr = true, | |
93 map_complete = true, | |
94 } | |
95 | |
96 npairs.add_rules { | |
97 Rule(' ', ' '):with_pair(function(opts) | |
98 local pair = opts.line:sub(opts.col - 1, opts.col) | |
99 return vim.tbl_contains({ '()', '[]', '{}' }, pair) | |
100 end), | |
101 Rule('( ', ' )') | |
102 :with_pair(function() | |
103 return false | |
104 end) | |
105 :with_move(function(opts) | |
106 return opts.prev_char:match '.%)' ~= nil | |
107 end) | |
108 :use_key ')', | |
109 Rule('{ ', ' }') | |
110 :with_pair(function() | |
111 return false | |
112 end) | |
113 :with_move(function(opts) | |
114 return opts.prev_char:match '.%}' ~= nil | |
115 end) | |
116 :use_key '}', | |
117 Rule('[ ', ' ]') | |
118 :with_pair(function() | |
119 return false | |
120 end) | |
121 :with_move(function(opts) | |
122 return opts.prev_char:match '.%]' ~= nil | |
123 end) | |
124 :use_key ']', | |
125 } | |
88 end, | 126 end, |
89 } | 127 } |
90 | 128 |
91 -- Moving around within lines | 129 -- Moving around within lines |
92 use { 'wellle/targets.vim', event = 'InsertEnter *' } | 130 use { 'wellle/targets.vim', event = 'InsertEnter *' } |
174 vsnip = true, | 212 vsnip = true, |
175 }, | 213 }, |
176 } | 214 } |
177 | 215 |
178 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] | 216 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] |
179 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]] | 217 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] |
180 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] | |
181 end, | 218 end, |
182 } | 219 } |
183 use { | 220 use { |
184 { | 221 { |
185 'nvim-treesitter/nvim-treesitter', | 222 'nvim-treesitter/nvim-treesitter', |