nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

Returned completion item does not show in list

Open PhilRunninger opened this issue 3 years ago • 0 comments

FAQ

  • [X] I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

call plug#begin('~/.config/bundles')
Plug 'hrsh7th/nvim-cmp'
Plug 'PhilRunninger/cmp-rpncalc'
call plug#end()

set completeopt=menu,menuone,noselect

lua <<EOF

local cmp = require "cmp"

cmp.setup({
    sources = { { name = "rpncalc" } }
})
EOF

Description

Thanks for your work on this hobby project. Great work!

I am working on a completion plugin - cmp-rpncalc - similar to your nvim-calc, but instead, it uses RPN. I have run into an issue that I think could be a bug in nvim-cmp. My intention is to return these two items for completion:

  1. The result of the RPN expression. It could be a single number, or the stack if the expression is incomplete.
  2. The RPN expression followed by the result of that expression.
If I type... I want to see these completion items:
5 5 and
5 ▶ 5
5 2 5 2 and
5 2 ▶ 5 2
5 2 * 10 and
5 2 * ▶ 10
pi 3.1415926535898 and
pi ▶ 3.1415926535898

Everything works except the last one. The only completion item it shows is: pi ▶ 3.1415926535898

Steps to reproduce

  1. Start neovim with the included minimal setup.
  2. Start insert mode.
  3. Type pi and you will see only one item in the completion list.
  4. I have debug statements in my plug-in. Enter the :messages command and scroll to the bottom. You will see both items, but only the second is displayed.
    {
      items = { {
          label = "3.1415926535898",
          textEdit = {
            newText = "3.1415926535898",
            range = {
              end = {
                character = 2,
                line = 0
              },
              start = {
                character = 0,
                line = 0
              }
            }
          },
          word = "pi"
        }, {
          label = "pi ▶ 3.1415926535898",
          textEdit = {
            newText = "pi ▶ 3.1415926535898",
            range = {
              end = {
                character = 2,
                line = 0
              },
              start = {
                character = 0,
                line = 0
              }
            }
          },
          word = "pi ▶ 3.1415926535898"
        } }
    }
    
  5. The same behavior can be seen by typing a number with many digits. In insert mode, type a number - 1.234... for instance. Keep adding digits to the end of the string. It starts out well with two completion items shown, but at some point, the introduction of the next digit causes the first completion item to be dropped.

Expected behavior

I expect both completion items to always be displayed.

Actual behavior

The first completion item is sometimes dropped from the list. I've looked through both my code and yours, but since I'm relatively new to lua, I can't say that I understand all that's going on. The issue could very well be in my code, but I thought I'd run this by you in case there was something obvious that you can think of.

Thanks!

Additional context

No response

PhilRunninger avatar Jul 05 '22 06:07 PhilRunninger