Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

Latest commit

 

History

History
78 lines (65 loc) · 1.74 KB

File metadata and controls

78 lines (65 loc) · 1.74 KB

Formatting

Features

Formatting provides additional details in cmp recommendations.

Completion Without Formatting

../repo/Completion_Without_Formatting.png

Completion With Formatting

../repo/Completion_With_Formatting.png

Setup

Setup requires setting the formatting variable in the config() function for nvim-cmp.

-- nvim-cmp.lua
{
    "hrsh7th/nvim-cmp",
    config = function()
        formatting = {
            format = function(entry, vim_item)
                if entry.source.name = "cmp_rolodex" then
                    vim_item.kind = "📇 Contact"
                    vim_item.menu = "[RLDX]"
                end
                return vim_item
            end
        }
    end
}

Integrating With Other Formatting Settings

You may already have formatting configured. Possibly like…

return {
    "hrsh7th/nvim-cmp",
    config = function()
        formatting = {
            format = lspkind.cmp_format({
            maxwidth = 50,
                ellipsis_char = "...",
            }),
        }
    end
}

In such a case, you can merge your formatting with the RLDX formatting.

return {
    "hrsh7th/nvim-cmp",
    config = function()
	   formatting = {
		   format = function(entry, vim_item)

		       -- Existing configuration
		       local format_func = lspkind.cmp_format({
				   maxwidth = 50,
				   ellipsis_char = "...",
			   })
			   vim_item = format_func(entry, vim_item)

			   -- RLDX configuration
			   if entry.source.name == "cmp_rolodex" then
				   vim_item.kind = "📇 Contact"
				   vim_item.menu = "[RLDX]"
			   end

			   return vim_item
		   end
	   }
    end
}