luaneovimnvim-lspconfignvim.cmp

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


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.


Solution

  • 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