How to install in NvChad?
opened this issue · comments
I can't figure out how to install this on NvChad perhaps someone who has the same problem can help me? This is what I've done:
-- NvChad/lua/custom/plugins/init.lua
return {
["tzachar/cmp-tabnine"] = {
after = "cmp-path",
config = function()
require "custom.plugins.tabnine"
end,
},
}
-- NvChad/lua/custom/plugins/tabnine.lua
require('cmp_tabnine.config').setup({
max_lines = 1000;
max_num_results = 20;
sort = true;
run_on_every_keystroke = true;
snippet_placeholder = '..';
ignored_file_types = { -- default is not to ignore
-- uncomment to ignore in lua:
-- lua = true
};
show_prediction_strength = false;
})
-- NvChad/lua/custom/chardrc.lua
M.plugins = {
override = {
["hrsh7th/nvim-cmp"] = {
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "cmp-tabnine" },
},
}
}
}
Never used NvChad. But one issue that comes to mind is that you need to run the install.sh script.
No Idea how to do that in NvChad.
You can also call the install.sh script by hand once, which will solve the issue.
FWIW. This is how I got TabNine working in NvChad
custom/plugins/init.lua
return {
["tzachar/cmp-tabnine"] = {
after = "nvim-cmp",
run = "./install.sh",
config = function()
require "custom.plugins.configs.tabnine"
end,
},
}
custom/plugins/configs/tabnine.lua
local present, cmp = pcall(require, "cmp")
if not present then
return
end
local sources = {
{ name = 'cmp_tabnine' },
}
cmp.setup {
sources = sources,
}
Did you add cmp_tabnine to cmp's sources list?
I believe so, I assume that's why it's available in my first screen shot when I run :CmpStatus 🤔
It almost feels like it gets picked up by cmp but not wired up to the lsp client itself.
The one language client that seems to get picked up by my LSP client is:
lspconfig.sumneko_lua.setup {
on_attach = M.on_attach,
capabilities = M.capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
},
maxPreload = 100000,
preloadFileSize = 10000,
},
},
},
}
because if have this config. I'm trying to figure out how to do the same for:
lspconfig.cmp_tabnine.setup {
on_attach = M.on_attach,
capabilities = M.capabilities,
}
This is my compiled packer file:
["cmp-tabnine"] = {
after_files = { "/Users/jasondorn/.local/share/nvim/site/pack/packer/opt/cmp-tabnine/after/plugin/cmp-tabnine.lua" },
config = { "\27LJ\2\ni\0\0\1\0\1\0\0025\0\0\0L\0\2\0\1\0\5\29show_prediction_strength\1\27run_on_every_keystroke\2\20max_num_results\3\5\14max_lines\3è\a\tsort\2\0" },
load_after = {
["nvim-cmp"] = true
},
loaded = false,
needs_bufread = false,
path = "/Users/jasondorn/.local/share/nvim/site/pack/packer/opt/cmp-tabnine",
url = "https://github.com/tzachar/cmp-tabnine"
},
Seems to load everything properly?
New Error:
I don't know why you keep bringing up LSP. TabNine does not interface into any LSP, but operates on its own.
This plugin only plugs TabNine into cmp.
You need to remove all LSP config which references tabnine.
Anyway, I was asking if you added cmp_tabnine
as a source for cmp
Sorry, newer to these configs, trying to make sense of it all.
I did!
sources = {
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "cmp_tabnine"}
},
Running :CmpStatus
yields:
So I believe it's ready to be used? My issue is probably less with your work and why my nvim-lsp isn't picking up on my cmp configs
Again, nvim lsp is not connected to cmp. Its the other way around.
cmp will use nvim_lsp to get completion from the running lsp.
My config for NvChad v2.0
File: lua/custom/plugins.lua
{
"tzachar/cmp-tabnine",
lazy = false,
dependencies = "hrsh7th/nvim-cmp",
build = "./install.sh",
config = function()
require("cmp").setup {
sources = {
{ name = 'cmp_tabnine' },
},
}
require('cmp_tabnine.config').setup {
max_lines = 1000,
max_num_results = 20,
sort = true,
run_on_every_keystroke = true,
snippet_placeholder = '..',
show_prediction_strength = false
}
end,
},
You should call setup
with a :
require('cmp_tabnine.config'):setup
author of nvchad here. i'd suggest using this as it doesnt load the plugin at startup.
@ansidev
{
"hrsh7th/nvim-cmp",
opts = {
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "cmp_tabnine" },
},
},
dependencies = {
{
"tzachar/cmp-tabnine",
build = "./install.sh",
config = function()
local tabnine = require "cmp_tabnine.config"
tabnine:setup {} -- put your options here
end,
},
},
},