deepseek_fim - DeepSeek FIM autocomplete for Vim
Async autocompletion powered by the DeepSeek
Fill-in-the-Middle API
(POST https://api.deepseek.com/beta/completions).
While you type in Insert mode, the code before the cursor (prefix) and
after the cursor (suffix) are sent to DeepSeek; the returned middle text
appears as grey ghost text right behind the cursor. Press Tab to accept
it, keep typing to dismiss it.
Layout
| File | What |
|---|---|
src/ds_fim.c |
C backend: stdio JSON daemon, HTTPS via libcurl |
src/ds_fim.py |
Python fallback (stdlib only), same protocol - used automatically when bin/ds_fim is missing |
bin/ds_fim |
Built binary (make) |
plugin/deepseek_fim.vim |
Commands, options, autocmds |
autoload/deepseek_fim.vim |
completefunc, async job, debounce timer |
doc/deepseek_fim.txt |
Vim help page (+ tags) |
Makefile |
Build, offline tests, install |
Requirements
- Vim with
+job+channel+timers(e.g. Vim 9.0 Huge) - API key:
export DEEPSEEK_API_KEY=sk-...(platform.deepseek.com/api_keys) - To build:
gcc+ libcurl dev headers (pkg-config libcurl); without a C toolchain the plugin falls back topython3.
Build
make # builds bin/ds_fim
make check # offline tests (no API key / network needed)
make check runs the C JSON unit tests, the Python selftest, protocol
framing checks (--once with bad input), the --check key guard, a
Vimscript syntax load, and the ghost Tab-accept regression (test/ghost.vim).
Install
make install # installs to ~/.vim/pack/ai/start/deepseek_fim/
or copy plugin/ autoload/ doc/ bin/ (plus src/ds_fim.py as fallback)
into any Vim runtime path, then :helptags <dir>/doc.
Use
Type in Insert mode - after the debounce pause the prediction appears in
grey behind the cursor. Tab accepts it, typing on dismisses it. Or trigger
manually:
CTRL-X CTRL-U(via'completefunc', same async path):DeepseekFimComplete- request a suggestion immediately:DeepseekFimAccept/:DeepseekFimDismiss- accept or dismiss the ghost:DeepseekFimEnable/:DeepseekFimDisable/:DeepseekFimRestart
Verify the backend without touching the network:
export DEEPSEEK_API_KEY=sk-...
./bin/ds_fim --check
echo '{"id":1,"prefix":"def fib(a):","suffix":" return fib(a-1)"}' \
| ./bin/ds_fim --once
Configure
Vim (in vimrc):
let g:deepseek_fim_debounce_ms = 250
let g:deepseek_fim_min_len = 2
let g:deepseek_fim_context_chars = 4000
let g:deepseek_fim_bin = '/opt/bin/ds_fim' " custom backend, optional
let g:deepseek_fim_debug = 0
let g:deepseek_fim_ghost = 1 " 0 = popup menu instead of ghost
let g:deepseek_fim_tab_accept = 1 " 0 = keep your own Tab mapping
let g:deepseek_fim_ghost_maxlines = 5 " lines shown in the ghost
Backend env: DEEPSEEK_BASE_URL (default
https://api.deepseek.com/beta), DEEPSEEK_MODEL (default
deepseek-flash), DEEPSEEK_MAX_TOKENS (default 128, FIM cap 4096),
DEEPSEEK_TIMEOUT_MS (default 10000).
See :help deepseek-fim after install for details and troubleshooting.