SilasMarvin / lsp-ai

LSP-AI is an open-source language server that serves as a backend for AI-powered functionality, designed to assist and empower software engineers, not replace them.
MIT License
1.82k stars 55 forks source link

How do I use this in helix? #25

Closed andrejohansson closed 2 weeks ago

andrejohansson commented 2 weeks ago

Hello,

I have installed lsp-ai

❯ (Get-Command lsp-ai).Path
C:\Users\AndreJohansson\.cargo\bin\lsp-ai.exe

I have set my openai key

❯ $env:OPENAI_API_KEY
sk-proj-...

I have used your example to configure my languages file. I added rust to it.

languages.toml

...
#################################
## Configuration for languages ##
#################################

[[language]]
name = "python"
language-servers = ["pyright", "lsp-ai"]

[[language]]
name = "rust"
auto-format = true
language-servers = ["rust-analyzer", "lsp-ai"]

Then I upen a rust file in helix

hx main.rs

How would I then trigger prompts and questions etc? Please note: I'm a novice helix user, so any keyboard shortcuts and commands are helpful.

SilasMarvin commented 2 weeks ago

Hello,

I have installed lsp-ai

❯ (Get-Command lsp-ai).Path
C:\Users\AndreJohansson\.cargo\bin\lsp-ai.exe

I have set my openai key

❯ $env:OPENAI_API_KEY
sk-proj-...

I have used your example to configure my languages file. I added rust to it.

languages.toml

...
#################################
## Configuration for languages ##
#################################

[[language]]
name = "python"
language-servers = ["pyright", "lsp-ai"]

[[language]]
name = "rust"
auto-format = true
language-servers = ["rust-analyzer", "lsp-ai"]

Then I upen a rust file in helix

hx main.rs

How would I then trigger prompts and questions etc? Please note: I'm a novice helix user, so any keyboard shortcuts and commands are helpful.

Completions are triggered when typing in Helix. They pop up in the same window that completions from the rust-analyzer show up in. There are some configuration options available. See the completion-* keys: https://docs.helix-editor.com/configuration.html

For a good test to make sure your completions are working you should be able to type something like:

fn multiply_two_numbers

If you pause for a second with your cursor directly after the s in Insert mode, you should get a completion that pops up.

When helix does get plugins support we are planning to write our own Helix plugin that will offer inline completion like our VS Code plugin.

If LSP-AI completions are not displaying for you, please follow the Debug section of the wiki and share the output of the helix log file.

Thanks for checking LSP-AI out!

andrejohansson commented 2 weeks ago

It worked, thank you!