Giter Site home page Giter Site logo

Comments (38)

seeM avatar seeM commented on September 26, 2024 3

@hrsh7th: I have the same issue as @brandoncc. I'm able to reproduce it with:

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'tpope/vim-endwise'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require'cmp'

cmp.setup {
  mapping = {
    ['<CR>'] = cmp.mapping.confirm()
  },
}
EOF

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024 2

I've fixed it.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024 1

I think it fixed by latest commit. Could you test with latest nvim-cmp?

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024 1

Thank you guys. I get the reproduce the infinite loop. I will fix it later.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024 1

Hm... I'm investigating it. I think vim-endwise define broken mapping...

{
  buffer = 0,
  expr = 0,
  lhs = "<CR>",
  lnum = 134,
  mode = "i",
  noremap = 0,
  nowait = 0,
  rhs = "<CR><Plug>DiscretionaryEnd",
  script = 0,
  sid = 16,
  silent = 0
}

The above mapping is automatically defined by vim-endwise.
But it's mapped to <CR> and feed <CR> with remap instruction... (it will cause infinite loop).

I'll investigate more deeply.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024 1

This is nvim-cmp's issue to me.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

@jackpeters667 What do you set a mapping to ?

from nvim-cmp.

jackpeters667 avatar jackpeters667 commented on September 26, 2024

It's a clean install with the default mappings you provided in README.md
I tried removing them all and enabling one by one. But the freeze still happens. Just having this causes it to freeze:

mapping = {
}

Whereas if I remove mapping field completely, then it works.

from nvim-cmp.

jackpeters667 avatar jackpeters667 commented on September 26, 2024

All's working now all of a sudden. I'll be watching it and I'll reopen with more info if I come across it again

from nvim-cmp.

 avatar commented on September 26, 2024

Me too

from nvim-cmp.

 avatar commented on September 26, 2024

When i remove the <CR> mapping's arguments, the plugin was worked. Neovim does not freeze

from nvim-cmp.

 avatar commented on September 26, 2024

Why the plugin make neovim freeze?

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

still no information. I can't reproduce.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

Please reproduce steps for this.

from nvim-cmp.

ccshao avatar ccshao commented on September 26, 2024

Faced the same issue here, and I think it might be related to the <CR> mapping. After removing it, nvim-cmp doesn't freeze neovim any more when pressing Enter.

Once freezed, ESC not working, but surprisingly <Ctrl-C> works to return to normal model. I could continue to edit, but once pressing <CR>, nvim freezes again.

I am using neovim 0.5.0 on macosx 11.4, all plugins are in their latest. Let me know what other information I need to provide.

Thanks for checking it!

Here is my init.vim setting, with <CR> mapping

Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-path'

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require'cmp'
cmp.setup {
  mapping = {
    ['<C-p>'] = cmp.mapping.prev_item(),
    ['<C-n>'] = cmp.mapping.next_item(),
    ['<C-d>'] = cmp.mapping.scroll(-4),
    ['<C-f>'] = cmp.mapping.scroll(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm({
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    })
  },

  -- You should specify your *installed* sources.
  sources = {
      { name = 'buffer' },
      { name = 'nvim_lsp' },
  },
}
EOF

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

I've tested with the following config. But still can't reproduce... Hm...

I will test it with nvim 0.5.0.

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !isdirectory(s:plug_dir)
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-path'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require'cmp'
cmp.setup {
  mapping = {
    ['<C-p>'] = cmp.mapping.prev_item(),
    ['<C-n>'] = cmp.mapping.next_item(),
    ['<C-d>'] = cmp.mapping.scroll(-4),
    ['<C-f>'] = cmp.mapping.scroll(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm({
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    })
  },

  -- You should specify your *installed* sources.
  sources = {
      { name = 'buffer' },
      { name = 'nvim_lsp' },
  },
}
EOF

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

Hm.... I've downgraded neovim to 0.5.0 and using the above configuration but still can't repdoruce...

from nvim-cmp.

ccshao avatar ccshao commented on September 26, 2024

Do you think if it is helpful to post my full init.vim? I guess there might be some conflicts among plugins, or my setting.

from nvim-cmp.

rhcher avatar rhcher commented on September 26, 2024

Do you think if it is helpful to post my full init.vim? I guess there might be some conflicts among plugins, or my setting.

I suspect that the problem is related to autopairs.

from nvim-cmp.

ccshao avatar ccshao commented on September 26, 2024

Exactly! Removed jiangmiao/auto-pairs solved the freezing issue.

from nvim-cmp.

rhcher avatar rhcher commented on September 26, 2024

Exactly! Removed jiangmiao/auto-pairs solved the freezing issue.

Emmm, I thought you were using nvim-autopairs. May be give it a try :) However, it't not a cmp issue

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

I want to support autopairs like plugins automatically.
Thank you! I will investigate it.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

Reproduced!

from nvim-cmp.

ccshao avatar ccshao commented on September 26, 2024

Works nicely with auto-pairs, thanks! @hrsh7th @rhcher

from nvim-cmp.

johnallen3d avatar johnallen3d commented on September 26, 2024

Exactly! Removed jiangmiao/auto-pairs solved the freezing issue.

For what it's worth the opposite now seems to be true for me. I don't typically use auto-pair plugins. When I setup nvim-cmp with a mapping for <CR> I had the problems described above (freezing, only <C-c> works). I then tried installing jiangmiao/auto-pairs as a trouble-shooting step and my <CR> mapping now works as expected. Is the usage of an auto-pair plugin expected/required?

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

@johnallen3d No. nvim-cmp should work without any pairwise plugins.
If you met the freeze, Could you provide minimal setup?

from nvim-cmp.

johnallen3d avatar johnallen3d commented on September 26, 2024

OK, thanks for the quick response.

With the following setup I experience the "freeze" behavior.

  • I've uninstalled jiangmiao/auto-pairs
  • Updated to the latest version of hrsh7th/nvim-cmp
  • Created the most minimal config (below)
  • Launched with that config (e.g. nvim -u ~/.config/nvim/init-basic.lua scratch.txt)
-- init-basic.lua
vim.cmd [[packadd packer.nvim]]

require('packer').startup(function()
  use { 'hrsh7th/nvim-cmp' }
end)

local cmp = require'cmp'

cmp.setup {
  mapping = {
    ['<CR>'] = cmp.mapping.confirm()
  },
}

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

I can't reproduce with this.

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require'cmp'

cmp.setup {
  mapping = {
    ['<CR>'] = cmp.mapping.confirm()
  },
}
EOF

from nvim-cmp.

johnallen3d avatar johnallen3d commented on September 26, 2024

Yeah, with that configuration I'm not experiencing the freeze. 🤔 When I did my "minimal config" I didn't point it at an alternative location for plugins. Perhaps one of my other plugins is causing the conflict. I'll try to narrow that down.

from nvim-cmp.

brandoncc avatar brandoncc commented on September 26, 2024

Thank you all for this thread!

I found that I have the same freezing issue with https://github.com/tpope/vim-endwise

I'm going to open an issue on that repo asking if there is a recommended way to resolve it. If anyone has a fix for it here, I'd love to hear it!

Thanks again.

from nvim-cmp.

0xA537FD avatar 0xA537FD commented on September 26, 2024

I'm facing the same issue and Ctrl + C allows me to return into normal mode otherwise nvim is completely dead. I'm using nvim-cmp with the lsp and luasnip plugin.

Plugin 'hrsh7th/nvim-cmp'
Plugin 'hrsh7th/cmp-buffer'
Plugin 'hrsh7th/cmp-nvim-lsp'
Plugin 'saadparwaiz1/cmp_luasnip'

Together with the config that is provided in the nvim lsp wiki:

local luasnip = require 'luasnip'

-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-p>'] = cmp.mapping.select_prev_item(),
    ['<C-n>'] = cmp.mapping.select_next_item(),
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<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,
    },
    ['<Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
      elseif luasnip.expand_or_jumpable() then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
      else
        fallback()
      end
    end,
    ['<S-Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
      elseif luasnip.jumpable(-1) then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
      else
        fallback()
      end
    end,
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  },
}

Nvim version (nightly): NVIM v0.6.0-dev+218-g3f526feeb

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

imap <CR> <CR> does not cause the infinite loop. (Maybe it is a vim's internal feature.)

from nvim-cmp.

0xA537FD avatar 0xA537FD commented on September 26, 2024

I think this might be caused by a configuration error. After further experimentation and some config tweaks I don't face this error anymore. Before that I encountered it every few seconds which made vim completely unusable.

I removed the following things from my lsp config:

_G.tab_complete = function()
  if vim.fn.pumvisible() == 1 then
    return t '<C-n>'
  elseif luasnip.expand_or_jumpable() then
    return t '<Plug>luasnip-expand-or-jump'
  elseif check_back_space() then
    return t '<Tab>'
  end
end

_G.s_tab_complete = function()
  if vim.fn.pumvisible() == 1 then
    return t '<C-p>'
  elseif luasnip.jumpable(-1) then
    return t '<Plug>luasnip-jump-prev'
  else
    return t '<S-Tab>'
  end
end


-- Map tab to the above tab complete functions
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})

Might be possible that it's completely unrelated but for some reason it worked for me and the auto-completion works just like before including LuaSnip.

from nvim-cmp.

johnallen3d avatar johnallen3d commented on September 26, 2024

I can confirm that removing vim-endwise resolves the issue for me.

from nvim-cmp.

johnallen3d avatar johnallen3d commented on September 26, 2024

Rather than waiting on changes to vim-endwise I'm trying out "windwp/nvim-autopairs" which has endwise like rules.

https://github.com/windwp/nvim-autopairs/wiki/Endwise#endwise-experiment

from nvim-cmp.

jackpeters667 avatar jackpeters667 commented on September 26, 2024

Exactly! Removed jiangmiao/auto-pairs solved the freezing issue.

Yesss this was the problem for me as well. I just checked my config and I see I don't have it.

from nvim-cmp.

ccshao avatar ccshao commented on September 26, 2024

@hrsh7th It seems that the latest version conflicts with "jiangmiao/auto-pairs" again, would you mind to check it? Thanks very much!

Following are my config:

local lspkind = require('lspkind')
local cmp = require'cmp'

cmp.setup({
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  completion = {
    completeopt = 'menu,menuone,noinsert',
    keyword_length = 2,
  },

  mapping = {
    ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
    ['<C-e>'] = cmp.mapping({
      i = cmp.mapping.abort(),
      c = cmp.mapping.close(),
    }),
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
  },

  documentation = false,

  formatting = {
    format = function(entry, vim_item)
      vim_item.kind = lspkind.presets.default[vim_item.kind]
      vim_item.menu = ({
        nvim_lsp = '[L]',
        path     = '[F]',
        vsnip    = '[S]',
        buffer   = '[B]',
      })[entry.source.name]
      vim_item.dup = ({
        buffer   = 1,
        path     = 1,
        vsnip    = 1,
        nvim_lsp = 0,
      })[entry.source.name] or 0
      return vim_item
    end
  },

  sources = cmp.config.sources({
    { name = 'buffer',
      opts = {
        get_bufnrs = function()
          return vim.api.nvim_list_bufs()
        end
       }
    },
    { name = 'nvim_lsp' },
    { name = 'vsnip' },
  })
})


  -- Use buffer source for `/`.
cmp.setup.cmdline('/', {
  sources = {
    { name = 'buffer' },
    { name = 'path' },
  }
})

-- Use cmdline & path source for ':'.
cmp.setup.cmdline(':', {
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  })
})


from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

It's possible that I recently changed that related code. I will investigate it. Thx.

from nvim-cmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.