Skip to content

Conversation

johnpangalos
Copy link

Tailwind’s language server advertises -, /, :, etc. as completion triggers. Helix treated those punctuation characters as “not word characters”, cleared the current completion popup, and asked the server for a fresh list. That made Tailwind’s suggestions reset on every -.

Changes

  • On each typed character, before clearing the popup for a non-word char, look at the active LSP providers and see whether any of them list the character in completionProvider.triggerCharacters.
  • If so, keep the existing menu and just rescore items instead of removing the list.
  • Fall back to the old behaviour for punctuation that no connected server actually cares about.

NOTE: AI wrote this code but I did test it manually and check the code which looks like to me makes sense (I'm new to the codebase though)

fixes: #12541

Tailwind’s language server advertises -, /, :, etc. as completion
triggers. Helix treated those punctuation characters as “not word
characters”, cleared the current completion popup, and asked the server
for a fresh list. That made Tailwind’s suggestions reset on every -.

Changes
- On each typed character, before clearing the popup for a non-word
  char, look at the active LSP providers and see whether any of them
  list the character in completionProvider.triggerCharacters.
- If so, keep the existing menu and just rescore items instead of
  removing the list.
- Fall back to the old behaviour for punctuation that no connected
  server actually cares about.

**NOTE:** AI wrote this code but I did test it manually and check the
code which looks like to me makes sense (I'm new to the codebase though)

fixes: helix-editor#12541
@johnpangalos
Copy link
Author

Though this fixes the dash, there are still some issues with “:” and maybe slash. I’ll look into a bit more

After looking into how [neovim] does completion I've changed things
around a bit.

  - pass the triggering char into the completion refresher and send it as
    CompletionTriggerKind::TRIGGER_CHARACTER
  - fall back to TriggerForIncomplete only when the original list was
    partial

[neovim]: https://github.com/neovim/neovim/blob/d7472c061759aa56c43c36bdb5ce463e3ee8521d/runtime/lua/vim/lsp/completion.lua#L315
@johnpangalos
Copy link
Author

Okay this should work now! I tried it with "-", ":", and "/". Still could use some robustness though. Seems to be I can get it not work sometimes if I input certain strings but it doesn't crash and is better than the previous version.

Also check the typescript lsp to see if things were still working and they seem to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tailwind LS gives invalid suggestions when started after first -

1 participant