comparison dot_config/nvim/init.lua @ 439:84b4f33c0403

Replace compe with cmp
author zegervdv <zegervdv@me.com>
date Fri, 27 Aug 2021 17:26:42 +0200
parents 766e63b3a8fc
children 8b5c7359dd86
comparison
equal deleted inserted replaced
438:766e63b3a8fc 439:84b4f33c0403
95 local npairs = require 'nvim-autopairs' 95 local npairs = require 'nvim-autopairs'
96 local Rule = require 'nvim-autopairs.rule' 96 local Rule = require 'nvim-autopairs.rule'
97 97
98 npairs.setup { 98 npairs.setup {
99 ignored_next_char = string.gsub([[ [%w%%%'%[%.] ]], '%s+', ''), 99 ignored_next_char = string.gsub([[ [%w%%%'%[%.] ]], '%s+', ''),
100 }
101
102 require('nvim-autopairs.completion.compe').setup {
103 map_cr = true,
104 map_complete = true,
105 } 100 }
106 101
107 npairs.add_rules { 102 npairs.add_rules {
108 Rule(' ', ' '):with_pair(function(opts) 103 Rule(' ', ' '):with_pair(function(opts)
109 local pair = opts.line:sub(opts.col - 1, opts.col) 104 local pair = opts.line:sub(opts.col - 1, opts.col)
204 } 199 }
205 200
206 -- Completion/snippets/LSP 201 -- Completion/snippets/LSP
207 use { 'neovim/nvim-lspconfig' } 202 use { 'neovim/nvim-lspconfig' }
208 use { 203 use {
209 'hrsh7th/nvim-compe', 204 'hrsh7th/nvim-cmp',
210 config = function() 205 requires = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp' },
211 require('compe').setup { 206 config = function()
212 enabled = true, 207 local cmp = require 'cmp'
213 autocomplete = true, 208 cmp.setup {
214 debug = false, 209 mapping = {
215 min_length = 1, 210 ['<C-p>'] = cmp.mapping.select_prev_item(),
216 preselect = 'enable', 211 ['<C-n>'] = cmp.mapping.select_next_item(),
217 throttle_time = 80, 212 ['<C-d>'] = cmp.mapping.scroll_docs(-4),
218 source_timeout = 1000, 213 ['<C-f>'] = cmp.mapping.scroll_docs(4),
219 incomplete_delay = 400, 214 ['<C-Space>'] = cmp.mapping.complete(),
220 max_abbr_width = 100, 215 ['<C-e>'] = cmp.mapping.close(),
221 max_kind_width = 100, 216 ['<CR>'] = cmp.mapping.confirm {
222 max_menu_width = 100, 217 behavior = cmp.ConfirmBehavior.Replace,
223 documentation = true, 218 select = true,
224 219 },
225 source = { 220 },
226 path = true, 221 sources = {
227 buffer = true, 222 { name = 'buffer' },
228 nvim_lsp = true, 223 { name = 'nvim_lsp' },
229 nvim_lua = false, 224 },
230 spell = false, 225 }
231 vsnip = true,
232 },
233 }
234
235 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]]
236 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]]
237 end, 226 end,
238 } 227 }
239 use { 228 use {
240 { 229 {
241 'nvim-treesitter/nvim-treesitter', 230 'nvim-treesitter/nvim-treesitter',