Skip to content

Latest commit

 

History

History
185 lines (144 loc) · 3.54 KB

tabnine.md

File metadata and controls

185 lines (144 loc) · 3.54 KB

TabNine

Enable this extra to use the TabNine LLM for code completion.

:::info You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed. :::

Alternatively, you can add it to your lazy.nvim imports
require("lazy").setup({
  spec = {
    { "LazyVim/LazyVim", import = "lazyvim.plugins" },
    { import = "lazyvim.plugins.extras.coding.tabnine" },
    { import = "plugins" },
  },
})

Below you can find a list of included plugins and their default settings.

:::caution You don't need to copy the default settings to your config. They are only shown here for reference. :::

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Tabnine cmp source

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
{
  "nvim-cmp",
  dependencies = {
    {
      "tzachar/cmp-tabnine",
      build = {
        Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh",
        ":CmpTabnineHub",
      },
      dependencies = "hrsh7th/nvim-cmp",
      opts = {
        max_lines = 1000,
        max_num_results = 3,
        sort = true,
      },
      config = function(_, opts)
        require("cmp_tabnine.config"):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,
}
opts = {
  max_lines = 1000,
  max_num_results = 3,
  sort = true,
}
{
  "tzachar/cmp-tabnine",
  build = {
    Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh",
    ":CmpTabnineHub",
  },
  dependencies = "hrsh7th/nvim-cmp",
  opts = {
    max_lines = 1000,
    max_num_results = 3,
    sort = true,
  },
  config = function(_, opts)
    require("cmp_tabnine.config"):setup(opts)
  end,
}

lualine.nvim (optional)

Show TabNine status in lualine

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