onsails / lspkind.nvim

vscode-like pictograms for neovim lsp completion items
MIT License
1.51k stars 39 forks source link

Does this support nvim-cmp #19

Closed zoomlogo closed 3 years ago

zoomlogo commented 3 years ago

I just switched my config to use nvim-cmp as nvim-compe is now deprecated.

I have added this plugin and this line to my init.vim:

lua require 'lspkind'.init()

But the completion menu doesn't show the pictograms. I think that this plugin does not support nvim-cmp

Gelio commented 3 years ago

I've faced the same problem and I found the following in the FAQ of nvim-cmp:

https://github.com/hrsh7th/nvim-cmp#how-to-show-name-of-item-kind-and-source-like-compe

Referencing this in the README of this plugin would probably help other people discover how to get it to work with nvim-cmp

onsails commented 3 years ago

hmm, I've just found out that nvim-compe (which I use) is deprecated. I'll switch to nvim-cmp and look at the issue.

tristan957 commented 3 years ago

See commented section

cmp.setup({
    autocomplete = cmp.TriggerEvent.TextChanged,
    sources = {
        { name = "buffer" },
        { name = "path" },
        { name = "nvim_lsp" },
        { name = "nvim_lua" },
        { name = "emoji" },
        { nane = "calc" },
    },
    mapping = {
        ["<CR>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
        ["<C-c>"] = cmp.mapping.close(),
        ["<C-space>"] = cmp.mapping.complete(),
    },
    preselect = cmp.PreselectMode.Item,
    formatting = {
        deprecated = true,
        format = function(entry, vim_item)
            -- fancy icons and a name of kind
            -- vim_item.kind = require("lspkind").presets.default[vim_item.kind] .. " " .. vim_item.kind

            -- set a name for each source
            vim_item.menu = ({
                buffer = "[Buffer]",
                nvim_lsp = "[LSP]",
                luasnip = "[LuaSnip]",
                nvim_lua = "[Lua]",
                latex_symbols = "[Latex]",
            })[entry.source.name]
            return vim_item
        end,
    },
})
onsails commented 3 years ago

Now it has native integration, thanks for the idea. Example is in readme.