Is there any way to disable the code descriptions showing up on the autocompletion list performed by cmp plugin?

116 views Asked by At

I'm a newbie in Neovim and I've built my almost overall configuration based on Nvchad.

And, here's an only thing that I could never find the way to change:

enter image description here

Notice the texts that I pointed out with yellow on the screenshot. I don't even know what those are called. Code "descriptions," I guess?

So, they remain a little bit of too much disturbing to me and I want to remove them. If I'm not mistaken, this must be something related to the cmp plugin although I read doc/cmp.txt and found nothing helpful. I also checked out doc/lspconfig.txt if this was related to lsp.

I would appreciate if anyone could teach me the way.

2

There are 2 answers

0
DrShahinstein On BEST ANSWER

I've found the trick. Here's my overall cmp.lua:

local lspkind = require "lspkind"
local default_options = require "plugins.configs.cmp"

local overriding_options = {
  completion = {
    keyword_length = 3,
  },
  performance = {
    max_view_entries = 7,
  },
  view = {
    docs = {
      auto_open = false,
    },
  },

  -- that's it
  formatting = {
    format = lspkind.cmp_format {
      before = function(_entry, vim_item)
        if vim_item.menu ~= nil and string.len(vim_item.menu) > 0 then
          vim_item.menu = string.sub(vim_item.menu, 1, 0) .. ""
        end
        return vim_item
      end,
    },
  },
}

local overall_options = vim.tbl_deep_extend("force", default_options, overriding_options)

return overall_options

And the result: enter image description here

2
Khabir On

The area highlighted in yellow is referred to as the Documentation window. To customize its behavior, you can explore the available options documented in :help cmp-config.window. For a specific solution, you can refer to the :help cmp-faq, particularly the section likely titled How to disable the documentation window?.

To disable the Documentation window, use the following Lua code in your Neovim configuration:

require"cmp".setup{
  -- Other configuration options here
  window = {
    documentation = cmp.config.disable
  }
  -- More configuration options here
}