/helix-gpt

Code completion LSP for Helix

Primary LanguageTypeScriptMIT LicenseMIT

helix-gpt

Code completion LSP for Helix utilising the OpenAI chat API.

Goals

  • No dependencies
  • Straight completion. No code improvements/explanations.
  • No key bindings, just automatic completion suggestions.

Usage

Configuration

You can configure helix-gpt by exposing either the environment variables below, or passing the command line options directly to helix-gpt in the helix configuration step.

Environment vars

OPENAI_MODEL=gpt-3.5-turbo-16k # Optional
OPENAI_API_KEY=123 # required
OPENAI_MAX_TOKENS=7000 # optional
OPENAI_CONTEXT="A terrible code completion assistant" # Optional
OPENAI_ENDPOINT=https://api.openai.com/v1/chat/completions # Optional
LOG_FILE=/app/debug-helix-gpt.log # Optional

Args (add to command = "helix-gpt" below)

--openaiModel gpt-3.5-turbo --openaiKey 123 --logFile /app/debug-helix-gpt.log --openaiContext "A terrible code completion assistant"

Helix configuration

TypeScript example .helix/languages.toml tested with helix 23.10 (older versions may not support multiple LSPs)

[language-server.gpt]
command = "helix-gpt"

[language-server.ts]
command = "typescript-language-server"
args = ["--stdio"]
language-id = "javascript"

[[language]]
name = "typescript"
language-servers = [
    "ts",
    "gpt"
]

If you choose not to use the precompiled binary, modify the first command to be:

[language-server.gpt]
command = "bun"
args = ["run", "/app/helix-gpt.js"]

helix-gpt install

This was made to run with Bun, but you can find a binary below with the runtime included.

Without bun

wget https://github.com/leona/helix-gpt/releases/download/0.1/helix-gpt-0.1-x86_64-linux.tar.gz -O /tmp/helix-gpt.tar.gz && tar -zxvf helix-gpt.tar.gz && mv helix-gpt-0.1-x86_64-linux /usr/bin/helix-gpt && chmod +x /usr/bin/helix-gpt

With bun (must use the args option in the previous step)

wget https://github.com/leona/helix-gpt/releases/download/0.1/helix-gpt-0.1.js -O helix-gpt.js

All done

If you are having issues, check both the helix-gpt and helix log files.

tail -f /root/.cache/helix/helix.log
tail -f /app/helix-gpt.log

Thanks

rsc1975 for their bun Dockerfile

Todo

  • Copilot support
  • Self hosted model support
  • inlineCompletionProvider (if/when Helix gets support)
  • Error fixing assistant