Skip to content

Read trigger characters from LSP initialize responses#5121

Open
Firehed wants to merge 8 commits intodense-analysis:masterfrom
Firehed:1764/lsp-completion-trigger-characters
Open

Read trigger characters from LSP initialize responses#5121
Firehed wants to merge 8 commits intodense-analysis:masterfrom
Firehed:1764/lsp-completion-trigger-characters

Conversation

@Firehed
Copy link
Copy Markdown
Contributor

@Firehed Firehed commented Apr 17, 2026

Closes #1764

Summary

ALE already reads and stores LSP-provided triggerCharacters from server capabilities, but never actually uses them. This PR wires them up so that:

  • LSP trigger characters are used to decide when to automatically trigger completion
  • LSP trigger characters are sent to the server in completion requests
  • LSP trigger characters are used when filtering completion results
  • Falls back to hardcoded s:trigger_character_map when LSP doesn't provide triggers

Changes

  • Add ale#lsp#GetCompletionTriggerCharacters(conn_id) to retrieve stored trigger characters
  • Add ale#lsp#GetAllCompletionTriggerCharactersForBuffer(buffer) to get triggers from all active LSPs for a buffer
  • Add s:GetTriggerCharacters(filetype, conn_id) helper that prefers LSP triggers over hardcoded
  • Update ale#completion#GetTriggerCharacter() to accept optional conn_id parameter
  • Update ale#completion#GetPrefix() to check LSP trigger characters
  • Update ale#completion#Filter() to use LSP trigger characters
  • Pass connection ID through the completion flow

Test plan

  • Added tests for ale#lsp#GetCompletionTriggerCharacters
  • Added tests for ale#lsp#GetAllCompletionTriggerCharactersForBuffer
  • Added tests for ale#completion#GetTriggerCharacter with LSP triggers
  • Added tests for ale#completion#Filter with LSP triggers
  • All 3359 existing tests pass
  • Vint and custom linting rules pass
  • Manually tested with a PHP LSP server that provides custom triggers

🤖 Generated with Claude Code

Firehed and others added 8 commits April 16, 2026 16:00
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GetTriggerCharacter now accepts optional conn_id parameter to
prefer LSP-provided trigger characters over the hardcoded map.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GetPrefix now checks if the line ends with any trigger character
from LSPs active for the current buffer, enabling automatic
completion for LSP-provided triggers like > for PHP.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Firehed
Copy link
Copy Markdown
Contributor Author

Firehed commented Apr 17, 2026

I tested this out locally as well while co-developing an LSP server (which prompted me to look into this in the first place) and saw it prefer the LSP trigger characters over some hardcoded set. I use vim 9.1.1752.

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.

Read trigger characters from LSP initialize responses

1 participant