# deepseek_fim — DeepSeek FIM autocomplete for Vim Async autocompletion powered by the DeepSeek [Fill-in-the-Middle API](https://api-docs.deepseek.com/guides/fim_completion/) (`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](https://platform.deepseek.com/api_keys)) - To build: `gcc` + libcurl dev headers (`pkg-config libcurl`); without a C toolchain the plugin falls back to `python3`. ## Build ```sh 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 ```sh 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