From 529595010c347eb7f671a6028409f6e29fe4ffe7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 22 Aug 2025 17:10:58 +0300 Subject: lsp: treat manual completion as trigger; remove space from default triggers; avoid auto after whitespace --- internal/lsp/handlers.go | 8 ++++++-- internal/lsp/server.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/lsp/handlers.go b/internal/lsp/handlers.go index c39f359..f054cc9 100644 --- a/internal/lsp/handlers.go +++ b/internal/lsp/handlers.go @@ -735,7 +735,7 @@ func (s *Server) tryLLMCompletion(p CompletionParams, above, current, below, fun allowNoPrefix := false if idx > 0 { ch := current[idx-1] - if ch == '.' || ch == ':' || ch == '/' || ch == '_' || ch == ' ' { + if ch == '.' || ch == ':' || ch == '/' || ch == '_' { allowNoPrefix = true } } @@ -915,6 +915,10 @@ func (s *Server) isTriggerEvent(p CompletionParams, current string) bool { b, _ := json.Marshal(p.Context) _ = json.Unmarshal(b, &ctx) } + // TriggerKind 1 = Invoked (manual) — always allow + if ctx.TriggerKind == 1 { + return true + } // TriggerKind 2 is TriggerCharacter per LSP spec if ctx.TriggerKind == 2 { if ctx.TriggerCharacter != "" { @@ -928,7 +932,7 @@ func (s *Server) isTriggerEvent(p CompletionParams, current string) bool { // No character provided but reported as TriggerCharacter; be conservative return false } - // For Invoked (1) or TriggerForIncomplete (3), require manual char check below + // For TriggerForIncomplete (3), require manual char check below } // 2) Fallback: check the character immediately prior to cursor idx := p.Position.Character diff --git a/internal/lsp/server.go b/internal/lsp/server.go index edd6aca..db31d42 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -86,8 +86,8 @@ func NewServer(r io.Reader, w io.Writer, logger *log.Logger, opts ServerOptions) s.startTime = time.Now() s.llmClient = opts.Client if len(opts.TriggerCharacters) == 0 { - // Defaults (explicit space included to allow post-identifier triggers) - s.triggerChars = []string{".", ":", "/", "_", " "} + // Defaults (no space to avoid auto-trigger after whitespace) + s.triggerChars = []string{".", ":", "/", "_"} } else { s.triggerChars = append([]string{}, opts.TriggerCharacters...) } -- cgit v1.2.3