cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

<CR> doesn't work correctly with nvim-lua/completion-nvim #106

Closed letzabelin closed 3 years ago

letzabelin commented 3 years ago

Base configuration

-- plugins.lua
return require('packer').startup(function()
  use { 'wbthomason/packer.nvim', opt = true }
  use 'cohama/lexima.vim'
  use 'neovim/nvim-lspconfig'
  use 'nvim-lua/completion-nvim'
end)
-- lsp.lua
local lsp_config = require('lspconfig')
local lsp_completion = require('completion')
lsp_config.tsserver.setup({
  on_attach = lsp_completion.on_attach
})

Example in JS, JSX, TS, TSX:

I'm tapping '{' bracket, then tapping 'Enter' and see next: { |} // | - cursor

How can i solve this problem?

letzabelin commented 3 years ago

the problem was in completion-nvim confirm key

gegoune commented 3 years ago

@letzabelin Please provide your solution, I am facing the same issue.

letzabelin commented 3 years ago

@cloggier you can try the following:

  -- Disable the default behavior
  vim.g.completion_confirm_key = ""
  -- And set the confirm key to Enter with the condition
  vim.api.nvim_set_keymap("i", "<cr>", [[pumvisible() ? complete_info()["selected"] != "-1" ? "\<Plug>(completion_confirm_completion)" : "\<C-e>\<cr>" : "\<cr>"]], { expr = true })
gegoune commented 3 years ago

@letzabelin Works, thanks(!), but seems to break snippet expansion on <CR>.