Giter Site home page Giter Site logo

Menu customization API about nvim-cmp HOT 8 CLOSED

hrsh7th avatar hrsh7th commented on June 25, 2024
Menu customization API

from nvim-cmp.

Comments (8)

hrsh7th avatar hrsh7th commented on June 25, 2024 6

Haha, Currently nvim-cmp uses vim's native completion menu.

But my next task after nvim-cmp stabilized is it! I will use a custom completion menu via the floating window. (It realizes custom highlighting.)

from nvim-cmp.

windwp avatar windwp commented on June 25, 2024 4
vim.lsp.protocol.CompletionItemKind = {
    '', -- Text          = 1;
    '', -- Method        = 2;
    'ƒ', -- Function      = 3;
    '', -- Constructor   = 4;
    '', -- Field         = 5;
    '', -- Variable      = 6;
    '', -- Class         = 7;
    '', -- Interface     = 8;
    '', -- Module        = 9;
    '', -- Property      = 10;
    '', -- Unit          = 11;
    '', -- Value         = 12;
    '', -- Enum          = 13;
    '', -- Keyword       = 14;
    '', -- Snippet       = 15;
    '', -- Color         = 16;
    '', -- File          = 17;
    '', -- Reference     = 18;
    '', -- Folder        = 19;
    '', -- EnumMember    = 20;
    '', -- Constant      = 21;
    '', -- Struct        = 22;
    '', -- Event         = 23;
    '', -- Operator      = 24;
    '', -- TypeParameter = 25;
}
local cmp = require('cmp')
for index, value in ipairs(vim.lsp.protocol.CompletionItemKind) do
    cmp.lsp.CompletionItemKind[index] = value
end

a little snippet to implement lsplkind on nvim-cmp

from nvim-cmp.

miguelcaravantes avatar miguelcaravantes commented on June 25, 2024 1
vim.lsp.protocol.CompletionItemKind = {
    '', -- Text          = 1;
    '', -- Method        = 2;
    'ƒ', -- Function      = 3;
    '', -- Constructor   = 4;
    '', -- Field         = 5;
    '', -- Variable      = 6;
    '', -- Class         = 7;
    '', -- Interface     = 8;
    '', -- Module        = 9;
    '', -- Property      = 10;
    '', -- Unit          = 11;
    '', -- Value         = 12;
    '', -- Enum          = 13;
    '', -- Keyword       = 14;
    '', -- Snippet       = 15;
    '', -- Color         = 16;
    '', -- File          = 17;
    '', -- Reference     = 18;
    '', -- Folder        = 19;
    '', -- EnumMember    = 20;
    '', -- Constant      = 21;
    '', -- Struct        = 22;
    '', -- Event         = 23;
    '', -- Operator      = 24;
    '', -- TypeParameter = 25;
}
local cmp = require('cmp')
for index, value in ipairs(vim.lsp.protocol.CompletionItemKind) do
    cmp.lsp.CompletionItemKind[index] = value
end

a little snippet to implement lsplkind on nvim-cmp

great i am using it this way to show icon + text

for index, value in ipairs(vim.lsp.protocol.CompletionItemKind) do
    cmp.lsp.CompletionItemKind[index] = value .. ' ' ..  cmp.lsp.CompletionItemKind[index]
end

from nvim-cmp.

gegoune avatar gegoune commented on June 25, 2024

Are you using custom window to display completion candidates in cmp or standard vim/nvim one?

from nvim-cmp.

Jesse-Bakker avatar Jesse-Bakker commented on June 25, 2024

Sounds pretty cool! Will there then also be an option to just use the regular neovim completion menu?

from nvim-cmp.

akinsho avatar akinsho commented on June 25, 2024

Sounds pretty cool! Will there then also be an option to just use the regular neovim completion menu?

Sounds like you'd have to maintain two implementations to do that, one that conforms to the requirements of nvim's completion menu and one to a custom popup. I'm nowhere near the code but seems like it'd be easier to just add configuration options for whatever a person might want to disable/enable rather than implement/maintain both styles

from nvim-cmp.

Jesse-Bakker avatar Jesse-Bakker commented on June 25, 2024

I'm nowhere near the code but seems like it'd be easier to just add configuration options for whatever a person might want to disable/enable rather than implement/maintain both styles

Yeah, that's what I meant

from nvim-cmp.

hrsh7th avatar hrsh7th commented on June 25, 2024

I've added the API for it. see
https://github.com/hrsh7th/nvim-cmp#formattingformat-type-funentry-cmpentry-vim_item-vimcompleteditem-vimcompleteditem

from nvim-cmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.