diff options
| author | Paul Buetow <paul@buetow.org> | 2025-08-22 17:10:58 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-08-22 17:10:58 +0300 |
| commit | 529595010c347eb7f671a6028409f6e29fe4ffe7 (patch) | |
| tree | 1d1ba77a90e73e085b37e76d3fc3d36302631b0c | |
| parent | 23c2fdd627704fbafec7a499c1ba94fdff876a96 (diff) | |
lsp: treat manual completion as trigger; remove space from default triggers; avoid auto after whitespace
| -rw-r--r-- | internal/lsp/handlers.go | 8 | ||||
| -rw-r--r-- | internal/lsp/server.go | 4 |
2 files changed, 8 insertions, 4 deletions
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...) } |
