Skip to content

Neovim plugin that allows you to use the DeepSeek API to do code completion in a Neovim buffer

License

Notifications You must be signed in to change notification settings

rakotomandimby/deepseek-complete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caution

Stuck development

The development of this plugin is stuck on one technical point: having a decent suggestion acceptation algorithm and codebase. Suggestion acceptation is about dealing with cursor position, word replacement, space character handling ( word separator vs indentation),...

Having a good plugin in that sense is not easy, and I am stuck on this.

Descritpion

This plugin is a Neovim plugin that allows you to use the DeepSeek API to do do code completion in a Neovim buffer.

DeepSeek is not flat cost, it is pay-as-you-go, so completions are manually triggered by the user, not as-you-type.

Context sending

The plugins sends the content all the open buffers as context to the DeepSeek API.

For example, if you open NeoVim with nvim **/*.lua *.lua and you ask DeepSeek to complete your file, it will send the content of **/*.lua and *.lua to the DeepSeek API in a multi-turn chat and then it will ask DeepSeek to complete the current buffer.

This will optimize the completions, but it will also send the content of all the files in your project to the DeepSeek API.

Be careful with this, as:

  • It can be expensive if you have a lot of open buffers.
  • Token calculation is not done before sending the context, so it the API might refuse you request if you exceed the token limit.

Installation

Install the plugin with your favorite package manager:

use 'rakotomandimby/deepseek-complete.nvim'
{
    "rakotomandimby/deepseek-complete.nvim"
}

Configuration

Users can customize the key mappings by setting vim.g.rktmb_deepseek_complete_opts in the configuration.

As of writing, the following configuration options are available:

  • deepseek_api_key: You can get it from DeepSeek. Defaults to the value of the DEEPSEEK_API_KEY environment variable.
  • suggest_keymap: The keymap to trigger completions. Defaults to <M-ESC>.
  • accept_all_keymap: The keymap to accept all completions. Defaults to <M-PageDown>.
  • acceptp_line_keymap: The keymap to accept the first line of the completion. Defaults to <M-Down>.

To change the suggest keymap to <C-j>, set the following to a lua file that is going to be read after the installation:

vim.g.rktmb_deepseek_complete_opts = {
  deepseek_api_key = "YOUR_DEEPSEEK_API_KEY"
  suggest_keymap = "<C-j>",
}

Or to disable a keymap entirely (I dont now why would you do that, but you can):

vim.g.rktmb_deepseek_complete_opts = {
  accept_all_keymap = "",
  acceptp_line_keymap=""
}

Usage

  • Enter INSERT mode
  • Type your code in the current buffer (it is better if you finish a sentence)
  • Issue <M-ESC> to trigger the completion
  • The completion will be inserted in below the current line

Next features

If you have any ideas, feel free to open an issue or PR!

About

Neovim plugin that allows you to use the DeepSeek API to do code completion in a Neovim buffer

Topics

Resources

License

Stars

Watchers

Forks

Languages