Home

Awesome

Tabby Plugin for Vim and Neovim

Tabby is a self-hosted AI coding assistant that can suggest multi-line code or full functions in real-time. For more information, please check out our website and GitHub.
If you encounter any problems or have any suggestions, please open an issue or join our Slack community for support.

Notable Changes in vim-tabby Plugin 2.0

Since version 2.0, the vim-tabby plugin is designed as two parts:

  1. LSP Client Extension:
    • Relies on an LSP client and extends it with methods (such as textDocument/inlineCompletion) to communicate with the tabby-agent.
    • Note: The Node.js script of tabby-agent is no longer a built-in part of the vim-tabby plugin. You need to install tabby-agent separately via npm, and the LSP client will launch it using the command npx tabby-agent --stdio.
  2. Inline Completion UI:
    • Automatically triggers inline completion requests when typing.
    • Renders the inline completion text as ghost text.
    • Sets up actions with keyboard shortcuts to accept or dismiss the inline completion.

Requirements

The Tabby plugin requires the following dependencies:

Installation

You can install the Tabby plugin using your favorite plugin manager by simply adding TabbyML/vim-tabby to the registry.

Here is a detailed example setup with advanced options, based on Neovim, Lazy.nvim, and nvim-lspconfig.

-- ~/.config/nvim/init.lua
require("lazy").setup({
  -- other plugins
  -- ...
  -- Tabby plugin
  { 
    "TabbyML/vim-tabby",
    lazy = false,
    dependencies = {
      "neovim/nvim-lspconfig",
    },
    init = function()
      vim.g.tabby_agent_start_command = {"npx", "tabby-agent", "--stdio"}
      vim.g.tabby_inline_completion_trigger = "auto"
    end,
  },
})

After setting up the plugin, you can open a file in Neovim and use :LspInfo to check if the Tabby plugin is successfully connected.

Getting Started

1. Setup Tabby Server

The Tabby plugin requires a Tabby server to work. Follow the documentation to install and create your account.

2. Connect to the Server

Edit the tabby-agent config file located at ~/.tabby-client/agent/config.toml to set up the server endpoint and token. This file may have been auto-created if you have previously used the tabby-agent or Tabby plugin for other IDEs. You can also manually create this file.

```toml
[server]
endpoint = "http://localhost:8080"
token = "your-auth-token"
```

3. Code Completion

Tabby suggests code completions in real-time as you write code. You can also trigger the completion manually by pressing <C-\>. To accept suggestions, simply press the <Tab> key. You can also continue typing or explicitly press <C-\> again to dismiss it.

Known Conflicts

Configurations

You can find a detailed explanation of tabby-agent configurations in the Tabby online documentation.

Here is a table of all configuration variables that can be set when the Tabby plugin initializes:

VariableDefaultDescription
g:tabby_agent_start_command["npx", "tabby-agent", "--stdio"]The command to start the tabby-agent
g:tabby_inline_completion_trigger"auto"The trigger mode of inline completion, can be "auto" or "manual"
g:tabby_inline_completion_keybinding_accept"<Tab>"The keybinding to accept the inline completion
g:tabby_inline_completion_keybinding_trigger_or_dismiss"<C-\>"The keybinding to trigger or dismiss the inline completion
g:tabby_inline_completion_insertion_leading_key"\<C-R>\<C-O>="The leading key sequence to insert the inline completion text

Contributing

Repository TabbyML/vim-tabby is for releasing Tabby plugin for Vim and Neovim. If you want to contribute to Tabby plugin, please check our main repository TabbyML/tabby.

License

Apache-2.0