mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat: show Tabnine icon on suggestion list
This commit is contained in:
parent
1557eaa2ea
commit
0ef7a13bab
1 changed files with 31 additions and 9 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
-- TODO: add TabNine icon if is available
|
||||||
|
local tabnine_icon = ""
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- Tabnine cmp source
|
-- Tabnine cmp source
|
||||||
{
|
{
|
||||||
|
|
@ -8,14 +11,14 @@ return {
|
||||||
"tzachar/cmp-tabnine",
|
"tzachar/cmp-tabnine",
|
||||||
build = "./install.sh",
|
build = "./install.sh",
|
||||||
dependencies = "hrsh7th/nvim-cmp",
|
dependencies = "hrsh7th/nvim-cmp",
|
||||||
-- Only limit top 3 suggestions from Tabnine
|
opts = {
|
||||||
config = function()
|
max_lines = 1000,
|
||||||
|
max_num_results = 3,
|
||||||
|
sort = true,
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
local tabnine = require("cmp_tabnine.config")
|
local tabnine = require("cmp_tabnine.config")
|
||||||
tabnine:setup({
|
tabnine:setup(opts)
|
||||||
max_lines = 1000,
|
|
||||||
max_num_results = 3,
|
|
||||||
sort = true,
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -26,6 +29,26 @@ return {
|
||||||
group_index = 1,
|
group_index = 1,
|
||||||
priority = 100,
|
priority = 100,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Format the completion menu, remove the percentage and add icons
|
||||||
|
opts.formatting.format = function(entry, vim_item)
|
||||||
|
local icons = require("lazyvim.config").icons.kinds
|
||||||
|
if icons[vim_item.kind] then
|
||||||
|
vim_item.kind = icons[vim_item.kind] .. vim_item.kind
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add tabnine icon and hide percentage in the menu
|
||||||
|
if entry.source.name == "cmp_tabnine" then
|
||||||
|
vim_item.kind = tabnine_icon .. " TabNine"
|
||||||
|
vim_item.menu = ""
|
||||||
|
|
||||||
|
if (entry.completion_item.data or {}).multiline then
|
||||||
|
vim_item.kind = vim_item.kind .. " " .. "[ML]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim_item
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
-- Show TabNine status in lualine
|
-- Show TabNine status in lualine
|
||||||
|
|
@ -62,8 +85,7 @@ return {
|
||||||
}
|
}
|
||||||
table.insert(opts.sections.lualine_x, 3, {
|
table.insert(opts.sections.lualine_x, 3, {
|
||||||
function()
|
function()
|
||||||
-- TODO: return TabNine icon if TabNine is available
|
return tabnine_icon
|
||||||
return ""
|
|
||||||
end,
|
end,
|
||||||
cond = function()
|
cond = function()
|
||||||
return status() ~= nil
|
return status() ~= nil
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue