leona / helix-gpt

Code assistant language server for Helix with support for Copilot/OpenAI/Codeium/Ollama
MIT License
285 stars 19 forks source link

Remove all triggers #21

Closed cd-a closed 4 months ago

cd-a commented 4 months ago

Is there a way to remove all triggers and just trigger it manually with C-x?

I know you can override them, but I tried passing empty string and it didn't work.

[language-server.gpt]
command = "bun"
args = ["run", "/Users/att/.local/bin/helix-gpt.js"]
triggerCharacters = ""
leona commented 4 months ago

Try this

[language-server.gpt]
command = "bun"
args = ["run", "/Users/att/.local/bin/helix-gpt.js", "--triggerCharacters"]

Helix still triggers them sometimes anyway though, so it's hard to disable the automatic ones entirely.

cd-a commented 4 months ago

This does not work, this is the helix log output:

2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- "TypeError: Option '--triggerCharacters <value>' argument missing\n"
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- " code: \"ERR_PARSE_ARGS_INVALID_OPTION_VALUE\"\n"
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- "\n"
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- "      at /Users/att/.local/bin/helix-gpt.js:2:853\n"
2024-02-12T10:18:29.127 helix_lsp [ERROR] failed to initialize language server: server closed the stream
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err: <- StreamClosed
leona commented 4 months ago

This does not work, this is the helix log output:

2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- "TypeError: Option '--triggerCharacters <value>' argument missing\n"
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- " code: \"ERR_PARSE_ARGS_INVALID_OPTION_VALUE\"\n"
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- "\n"
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err <- "      at /Users/att/.local/bin/helix-gpt.js:2:853\n"
2024-02-12T10:18:29.127 helix_lsp [ERROR] failed to initialize language server: server closed the stream
2024-02-12T10:18:29.127 helix_lsp::transport [ERROR] gpt err: <- StreamClosed

Ok you'll need to set the value then, I thought it might accept it. Just set it to something like ""

cd-a commented 4 months ago

Thanks. This works (without errors now), but I don't really see much of a difference since it's still triggering all the time on its own :)

hnorkowski commented 4 months ago

You need a pattern that matches nothing. The regex "" matches on anything. You could try the following regexs:

leona commented 4 months ago

You need a pattern that matches nothing. The regex "" matches on anything. You could try the following regexs:

  • (?!): This is a zero-width negative lookahead assertion that always fails to match because it looks ahead to ensure that nothing follows the current position 1.
  • \A\Z: This pattern uses the anchors \A (beginning of the string) and \Z (end of the string) to assert that the string must begin and end simultaneously, which means it must be empty 1.
  • $^: This combination of anchors attempts to match the position right after the end of the string ($) and right before the start of the string (^). It should theoretically match nothing, but its behavior may vary depending on the implementation and flags used 1.
  • /(?:)/: This pattern defines a non-capturing group with no content inside. Since the group is empty, it cannot match anything 3.

It's currently a list of characters, no regex. Although I'm pretty sure I can check if it was triggered by a character instead of a keybind, so I'll look at adding a config option to disable automatic completions.

hnorkowski commented 4 months ago

It also looks like the even if there are no triggers detected the debounce delay is still executed before returning no auto-completions to helix. therefore you always have to wait for the debounce time before you get auto-completions. Would be great to only debounce when there are triggers.

leona commented 4 months ago

So unfortunately Helix doesn't support the additional context (here) I need to detect if it was a manual completion. I'll add this to the list and keep an eye out for Helix support.

cd-a commented 4 months ago

Is this the related issue? https://github.com/helix-editor/helix/issues/9656