feat(extras): added TabNine (#1651)
* feat: add Tabnine Add TabNine plugin for hrsh7th/nvim-cmp * fix: limit to top 3 sources for TabNine * feat: show Tabnine icon on suggestion list * fix: migrate to LazyVim v10 * refactor: tabnine * refactor --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:

committed by
GitHub

parent
1a4342abae
commit
95ff5aaa62
@ -84,6 +84,7 @@ local defaults = {
|
|||||||
Snippet = " ",
|
Snippet = " ",
|
||||||
String = " ",
|
String = " ",
|
||||||
Struct = " ",
|
Struct = " ",
|
||||||
|
TabNine = " ",
|
||||||
Text = " ",
|
Text = " ",
|
||||||
TypeParameter = " ",
|
TypeParameter = " ",
|
||||||
Unit = " ",
|
Unit = " ",
|
||||||
|
50
lua/lazyvim/plugins/extras/coding/tabnine.lua
Normal file
50
lua/lazyvim/plugins/extras/coding/tabnine.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
local Util = require("lazyvim.util")
|
||||||
|
|
||||||
|
return {
|
||||||
|
-- Tabnine cmp source
|
||||||
|
{
|
||||||
|
"nvim-cmp",
|
||||||
|
dependencies = {
|
||||||
|
-- Add TabNine support, make sure you run :CmpTabnineHub after installation.
|
||||||
|
{
|
||||||
|
"tzachar/cmp-tabnine",
|
||||||
|
build = "./install.sh",
|
||||||
|
dependencies = "hrsh7th/nvim-cmp",
|
||||||
|
opts = {
|
||||||
|
max_lines = 1000,
|
||||||
|
max_num_results = 3,
|
||||||
|
sort = true,
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
local tabnine = require("cmp_tabnine.config")
|
||||||
|
tabnine:setup(opts)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
---@param opts cmp.ConfigSchema
|
||||||
|
opts = function(_, opts)
|
||||||
|
table.insert(opts.sources, 1, {
|
||||||
|
name = "cmp_tabnine",
|
||||||
|
group_index = 1,
|
||||||
|
priority = 100,
|
||||||
|
})
|
||||||
|
|
||||||
|
opts.formatting.format = Util.inject.args(opts.formatting.format, function(entry, item)
|
||||||
|
-- Hide percentage in the menu
|
||||||
|
if entry.source.name == "cmp_tabnine" then
|
||||||
|
item.menu = ""
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- Show TabNine status in lualine
|
||||||
|
{
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
optional = true,
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = function(_, opts)
|
||||||
|
local icon = require("lazyvim.config").icons.kinds.TabNine
|
||||||
|
table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("cmp_tabnine", icon))
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
Reference in New Issue
Block a user