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.
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.
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.
Install the plugin with your favorite package manager:
use 'rakotomandimby/deepseek-complete.nvim'
{
"rakotomandimby/deepseek-complete.nvim"
}
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 theDEEPSEEK_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=""
}
- 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
- Add the "finish the sentence" feature (complete the current line)
- Improve the "accept line" user experience
- Add the "complete as-you-type" feature (heavy for the API!)
If you have any ideas, feel free to open an issue or PR!