1

When an nvim-cmp popup show there is no indication of what source actually provided the completion nvim_lsp, luasnip, buffer, path, copilot, codeium, etc.

screenshot of nvim-cmp menu

Is there any way to include the source name in the nvim-cmp floating window / menu?

1 Answer 1

1

Yes, via nvim_cmp configuration formatting.format like so

local cmp = require("cmp")
cmp.setup({
  formatting = {
    format = function(entry, vim_item)
      vim_item.menu = entry.source.name
      return vim_item
    end,
  }, -- formatting
  -- rest of configuration for nvim-cmp
})

enter image description here

If you want to combine with other formatting functions like lspkind (which adds symbols ) you can:

local lspkind = require("lspkind")
local lspkind = require("lspkind")
local lspkind_cmp_format = lspkind.cmp_format({})

cmp.setup({
  formatting = {
    format = function(entry, vim_item)
      vim_item.menu = entry.source.name
      kreturn lspkind.cmp_format({})(entry, vim_item)
    end,
  }, -- formatting
  -- rest of configuration for nvim-cmp
})

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.