Open gmr458 opened 1 year ago
@gmr458 I think this is probably the same bug I reported a couple weeks ago in #1382 . Hopefully it gets fixed soon :/ I haven't heard anything about it, but I did link the commit before this bug is present/commit that causes this issue if you are interested! Let me know if using the older commit works and we can hopefully gain some traction on this bug :)
Basically, it seems to be a lot more deep than having the super-tab stuff. You can replicate the statusline disappearing simply by setting cmdheight=0
and just setting up cmp
@mehalter using the older commit (https://github.com/hrsh7th/nvim-cmp/commit/a9c701fa7e12e9257b3162000e5288a75d280c28) didn't work, do you know why using the up and down keys doesn't have that same problem?, it seems to me that the up and down keys have the same behavior as tab and s-tab.
Ah this might be a different problem then sorry! @gmr458 thought it seemed similar
When I delete words, the statusline flickering between insert mode sign and command mode sign.
@SnakeHit this is the exact bug I reported in the linked issue above. There is a previous commit you can check out before that bug was introduced
@SnakeHit this is the exact bug I reported in the linked issue above. There is a previous commit you can check out before that bug was introduced
Sorry, I didn't look at it carefully. I am a rookie, could you tell me how use the previous version with lua? Thank you very much.
I found out that this is related to InsertEnter
autocmd as I didn't get this issue after removing the autocmd with
:au! ___cmp___ InsertEnter
:au! cmp_nvim_lsp InsertEnter
What are the consequences of disabling this?
Hey @mehalter, did you ever find a solution for this (that doesn't involve rolling back to a previous commit)?
I'm using Neovim nightly right now and the flashes are gone.
NVIM v0.10.0-dev-49efdf8
Build type: Release
LuaJIT 2.1.1702233742
https://github.com/hrsh7th/nvim-cmp/assets/53343401/80177f1f-477a-4411-992a-b7bcba82f04a
My cmp config:
local ok, luasnip, cmp
ok, luasnip = pcall(require, 'luasnip')
if not ok then
vim.notify 'luasnip could not be loaded'
return
end
ok, cmp = pcall(require, 'cmp')
if not ok then
vim.notify 'cmp could not be loaded'
return
end
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api
.nvim_buf_get_lines(0, line - 1, line, true)[1]
:sub(col, col)
:match '%s'
== nil
end
local cmp_kinds = {
Text = ' ',
Method = ' ',
Function = ' ',
Constructor = ' ',
Field = ' ',
Variable = ' ',
Class = ' ',
Interface = ' ',
Module = ' ',
Property = ' ',
Unit = ' ',
Value = ' ',
Enum = ' ',
Keyword = ' ',
Snippet = ' ',
Color = ' ',
File = ' ',
Reference = ' ',
Folder = ' ',
EnumMember = ' ',
Constant = ' ',
Struct = ' ',
Event = ' ',
Operator = ' ',
TypeParameter = ' ',
}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered { border = 'single' },
documentation = cmp.config.window.bordered { border = 'single' },
},
mapping = cmp.mapping.preset.insert {
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm { select = true },
['<C-Space>'] = cmp.mapping.complete(),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
formatting = {
fields = { 'kind', 'abbr' },
format = function(_, vim_item)
vim_item.kind = cmp_kinds[vim_item.kind] or ''
return vim_item
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'async_path' },
}, {}),
}
Still have those flashes on latest nightly when cmdheight=0 and auto-complete for cmdline is on.
Flashing for me on 0.10.0 release.
Hm...
I have created the minimal vimrc.
set rtp+=~/src/nvim-cmp
set rtp+=~/src/cmp-buffer
set rtp+=~/src/cmp-cmdline
"set rtp+=~/src/nvim-lspconfig
"set rtp+=~/src/cmp-nvim-lsp
set rtp+=~/src/vim-vsnip
set rtp+=~/src/cmp-vsnip
set cmdheight=0
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<tab>'] = cmp.mapping(cmp.mapping.confirm({ select = true }), { 'i', 's', 'c' }),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
},
sources = {
{ name = 'buffer' },
},
completion = {
autocomplete = {
cmp.TriggerEvent.TextChanged,
cmp.TriggerEvent.InsertEnter,
},
completeopt = 'menu,menuone,noselect'
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'cmdline' }
}
})
EOF
"lua << EOF
"-- Add additional capabilities supported by nvim-cmp
"local capabilities = vim.lsp.protocol.make_client_capabilities()
"capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
"
"--require'lspconfig'.sumneko_lua.setup{}
"--require'lspconfig'.cssls.setup{}
"--require'lspconfig'.pylsp.setup{}
"require'lspconfig'.tailwindcss.setup{}
"--require'lspconfig'.gopls.setup{
"-- capabilities = capabilities,
"-- init_options = {
"-- usePlaceholders = true,
"-- },
"--}
"EOF
runtime! after/plugin/*.lua
When InsertEnter
, the statuline seems gone.
It seems set laststatus=0
is needed.
OK. I have get the reason.
The feedkeys execution causes the problem.
It executes <80><fd>hcall v:lua.cmp.utils.feedkeys.call.run(1)^M
text.
diff --git a/lua/cmp/init.lua b/lua/cmp/init.lua
index 4aaf2fe..37687da 100644
--- a/lua/cmp/init.lua
+++ b/lua/cmp/init.lua
@@ -330,7 +330,7 @@ local on_insert_enter = function()
end
end
autocmd.subscribe({ 'CmdlineEnter' }, async.debounce_next_tick(on_insert_enter))
-autocmd.subscribe({ 'InsertEnter' }, async.debounce_next_tick_by_keymap(on_insert_enter))
+--autocmd.subscribe({ 'InsertEnter' }, async.debounce_next_tick_by_keymap(on_insert_enter))
-- async.throttle is needed for performance. The mapping `:<C-u>...<CR>` will fire `CmdlineChanged` for each character.
local on_text_changed = function()
It fixes the problem though.
And it is the dup of https://github.com/hrsh7th/nvim-cmp/issues/1382.
FAQ
Announcement
Minimal reproducible full config
Expected behavior
statusline doesn't flashes when using Super-Tab like mapping from the wiki
Actual behavior
statusline flashes when using Super-Tab like mapping from the wiki, using up and down keys doesn't have this problem
Additional context
No response