AstroNvim / astrocommunity

A community repository of common plugin specifications
GNU General Public License v3.0
1.13k stars 233 forks source link

Add tabnine #137

Closed proline closed 1 year ago

proline commented 1 year ago

Is your feature related to a problem?

The good point with Astrovim is you can have a full ide easily but if you don't know to much of lua, it is too difficult to implement it.

Describe the new feature

Tabnine is a useful tool to develop

Additional context

No response

mehalter commented 1 year ago

@proline this is out of the scope of what should be included in the base installation of AstroNvim. I have transfered this request to Astrocommunity and marked it as help wanted so a community member can maybe add it to the community repository. You can also join the AstroNvim Discord and ask questions there as many users are using things like Tabnine.

luxus commented 1 year ago

looks like not much interest.. i will close it for now, people can make a new issue or commenting here and we can reopen it.

KyleKing commented 1 year ago

FWIW, I think something like this might be all you need to add to user.lua:

  {
    "codota/tabnine-nvim",
    config = function()
      require("tabnine").setup {
        disable_auto_comment = true,
        accept_keymap = "<Tab>",
      }
    end,
  },

For reference, my (very minimal) user config is here: https://github.com/KyleKing/AstroNvim-User

mehalter commented 1 year ago

Cool thanks for the recommendation @KyleKing ! I made a PR for this. Next time, it would be awesome if you wanted to contribute a PR to the community repo since this is only led and developed by users.

KyleKing commented 1 year ago

Turns out that my configuration didn't actually work 😓. The official TabNine plugin is still in alpha (https://www.tabnine.com/install/neovim), so it might be too early to make it part of the repo

There is an alternative one that I'm testing out: https://github.com/tzachar/cmp-tabnine

I would be happy to open a PR once I get a better handle on the configuration!

mehalter commented 1 year ago

That's alright! Still good to have any and all plugins installable through AstroCommunity :)

mehalter commented 1 year ago

If you are curious @KyleKing I updated the PR with a working version and bound the accept key to <C-e> to not conflict with nvim-cmp

mehalter commented 1 year ago

Also when you get a good configuration for cmp-tabnine that would also be great to contribute to AstroCommunity as well :)

KyleKing commented 1 year ago

Thanks!

I'm not getting completions with the AstroCommunity plugin, but login seems to work. I'll followup after work. Update: I spoke too soon, I'm getting completions now after running :Lazy, when restarts after configuring TabeninHub didn't help

I made progress, but couldn't get TabNine to be recognized by cmp when configuring cmp-tabnine like this. I'm not sure what was missing, but I'll leave this here in case it helps someone else:

{
  -- https://github.com/tzachar/cmp-tabnine#setup
  "tzachar/cmp-tabnine",
  event = "UIEnter", -- Should be InsertEnter
  build = "./install.sh",
  dependencies = "hrsh7th/nvim-cmp",
  config = function()
    local tabnine = require "cmp_tabnine.config"
    tabnine:setup {
      -- max_lines = 1000,
      -- max_num_results = 20,
      -- sort = true,
      -- run_on_every_keystroke = true,
      -- snippet_placeholder = "..",
      show_prediction_strength = true,
    }
  end,
},
-- Add more sources from: https://astronvim.com/Recipes/cmp#add-more-sources
{
  "hrsh7th/nvim-cmp",
  dependencies = {
    "tzachar/cmp-tabnine",
  },
  -- override the options table that is used in the `require("cmp").setup()` call
  opts = function(_, opts)
    local cmp = require "cmp"
    opts.sources = cmp.config.sources {
      { name = "TabNine", priority = 1001 },
    }
    return opts
  end,
},