Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some times vim_item.kind is nil #1939

Open
2 tasks done
Kicamon opened this issue May 21, 2024 · 6 comments · May be fixed by #1991
Open
2 tasks done

Some times vim_item.kind is nil #1939

Kicamon opened this issue May 21, 2024 · 6 comments · May be fixed by #1991
Labels
bug Something isn't working

Comments

@Kicamon
Copy link

Kicamon commented May 21, 2024

FAQ

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

Announcement

Minimal reproducible full config

return {
  'hrsh7th/nvim-cmp',
  lazy = true,
  event = 'LspAttach',
  dependencies = {
    'hrsh7th/cmp-nvim-lsp',
    {
      'saadparwaiz1/cmp_luasnip',
      dependencies = {
        'L3MON4D3/LuaSnip',
      },
    },
    'hrsh7th/cmp-buffer',
    'hrsh7th/cmp-path',
  },
  config = function()
    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 = " 󰅲 ",
    }
    local cmp = require('cmp')
    cmp.setup({
      formatting = {
        fields = { 'kind', 'abbr', 'menu' },
        format = function(_, vim_item)
          vim_item.menu = ' ' .. vim_item.kind
          vim_item.kind = cmp_kinds[vim_item.kind]
          return vim_item
        end,
      },
     }),
  end,
}

The following is normal
normal

and this is wrong
bug

Description

some times the vim_item.kind is nil

Steps to reproduce

It appears irregularly

Expected behavior

pop-ups steadily

Actual behavior

as you see

Additional context

No response

@Kicamon Kicamon added the bug Something isn't working label May 21, 2024
@Eutropios
Copy link

Eutropios commented Jul 10, 2024

Experiencing similar issues on my end. I'm running Neovim 0.10.0 on Fedora with the latest version of cmp. Running rm -rf ~/.local/share/nvim and rm -rf ~/.local/state/nvim and reinstalling the plugins seemingly fixes it for a while until it breaks again.

@Shougo
Copy link

Shougo commented Jul 11, 2024

Hm. I think your format() configuration is wrong.
If vim_item.kind may be nil, it must be checked in your format() function.

@Kicamon
Copy link
Author

Kicamon commented Jul 11, 2024

I had checked my format(), I print vim_item.kind in format(),is nil. Now I use commit "24122371810089d390847d8ba66325c1f1aa64c0", is stable

@Shougo
Copy link

Shougo commented Jul 11, 2024

Hm... If so, the commit is affected.
I don't know it is intended.

31a2939

@yioneko
Copy link
Contributor

yioneko commented Jul 12, 2024

#1931 (comment) That commit has an UB.

@Shougo
Copy link

Shougo commented Jul 12, 2024

Oh...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants