Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install in NvChad? #47

Closed
ghost opened this issue May 15, 2022 · 11 comments
Closed

How to install in NvChad? #47

ghost opened this issue May 15, 2022 · 11 comments

Comments

@ghost
Copy link

ghost commented May 15, 2022

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" },
          },
      }
   }
}
@tzachar
Copy link
Owner

tzachar commented May 15, 2022

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.

@tzachar tzachar closed this as completed May 15, 2022
@shanestillwell
Copy link

shanestillwell commented Aug 11, 2022

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,
}

@JasonDorn
Copy link

JasonDorn commented Nov 14, 2022

My setup appears to not be able to hook into tabnine at all.
image
When I run: :CmpStatus I can see that it's ready

When I run: LspInfo i get:
image

But when I check Packer:
image

I can see it's installed properly.

Does anyone know how I can get cmp to load my tab nine data?

Even my Tabnine hub seems to be picking up my sources and everything
image

@tzachar
Copy link
Owner

tzachar commented Nov 15, 2022

Did you add cmp_tabnine to cmp's sources list?

@JasonDorn
Copy link

JasonDorn commented Nov 15, 2022

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:

image

@tzachar
Copy link
Owner

tzachar commented Nov 15, 2022

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

@JasonDorn
Copy link

JasonDorn commented Nov 15, 2022

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:
image
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

@tzachar
Copy link
Owner

tzachar commented Nov 16, 2022

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.

@ansidev
Copy link

ansidev commented Mar 29, 2023

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,
  },

@tzachar
Copy link
Owner

tzachar commented Mar 30, 2023

You should call setup with a :

require('cmp_tabnine.config'):setup

@siduck
Copy link

siduck commented Apr 9, 2023

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,
      },
    },
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants