Skip to content

Commit

Permalink
[nvim] smart-pairs and nvim-cmp compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
odrling committed Feb 28, 2022
1 parent 133c5b5 commit 8cf0e32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
19 changes: 15 additions & 4 deletions .config/nvim/lua/config/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ cmp.setup {
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
["<CR>"] = cmp.mapping(function(fallback)
if not cmp.confirm({ select = false }) then
require("pairs.enter").type()
end
end),
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
Expand All @@ -99,6 +100,16 @@ cmp.setup {
},
}

local kind = cmp.lsp.CompletionItemKind

cmp.event:on("confirm_done", function(event)
local item = event.entry:get_completion_item()
local parensDisabled = item.data and item.data.funcParensDisabled or false
if not parensDisabled and (item.kind == kind.Method or item.kind == kind.Function) then
require("pairs.bracket").type_left("(")
end
end)

local saga = require 'lspsaga'
saga.init_lsp_saga()

Expand Down
10 changes: 9 additions & 1 deletion .config/nvim/packer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ require('packer').startup {
require('Comment').setup()
end
}
use {'ZhiyuanLck/smart-pairs', event = 'InsertEnter', config = function() require('pairs'):setup() end}
use {'ZhiyuanLck/smart-pairs',
event = 'InsertEnter',
config = function()
require('pairs'):setup({
enter = {
enable_mapping = false
}
})
end}
use 'tpope/vim-repeat'
use 'tpope/vim-surround'
use 'kenn7/vim-arsync'
Expand Down

0 comments on commit 8cf0e32

Please sign in to comment.