summaryrefslogtreecommitdiff
path: root/internal/lsp
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-22 17:18:25 +0300
committerPaul Buetow <paul@buetow.org>2025-08-22 17:18:25 +0300
commitda350b02d395d0135d9193015f969706c7d257a7 (patch)
treedd37d77a41261d59bc445c61cdaeb51537005a10 /internal/lsp
parent529595010c347eb7f671a6028409f6e29fe4ffe7 (diff)
lsp: relax short-prefix check for manual invoke and after ')' in signatures
Diffstat (limited to 'internal/lsp')
-rw-r--r--internal/lsp/handlers.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/internal/lsp/handlers.go b/internal/lsp/handlers.go
index f054cc9..cb8b0e4 100644
--- a/internal/lsp/handlers.go
+++ b/internal/lsp/handlers.go
@@ -714,6 +714,23 @@ func (s *Server) tryLLMCompletion(p CompletionParams, above, current, below, fun
inParams := inParamList(current, p.Position.Character)
+ // Detect manual invoke so we can relax prefix heuristics when user pressed completion key.
+ manualInvoke := false
+ if p.Context != nil {
+ var c struct{
+ TriggerKind int `json:"triggerKind"`
+ }
+ if raw, ok := p.Context.(json.RawMessage); ok {
+ _ = json.Unmarshal(raw, &c)
+ } else {
+ b, _ := json.Marshal(p.Context)
+ _ = json.Unmarshal(b, &c)
+ }
+ if c.TriggerKind == 1 { // Invoked
+ manualInvoke = true
+ }
+ }
+
// Build a cache key for this completion context (ignore trailing whitespace
// before the cursor when forming the key) and try cache before any LLM call.
key := s.completionCacheKey(p, above, current, below, funcCtx, inParams, hasExtra, extraText)
@@ -733,9 +750,12 @@ func (s *Server) tryLLMCompletion(p CompletionParams, above, current, below, fun
if idx > len(current) { idx = len(current) }
// Structural triggers allow no prefix
allowNoPrefix := false
+ if manualInvoke {
+ allowNoPrefix = true
+ }
if idx > 0 {
ch := current[idx-1]
- if ch == '.' || ch == ':' || ch == '/' || ch == '_' {
+ if ch == '.' || ch == ':' || ch == '/' || ch == '_' || ch == ')' {
allowNoPrefix = true
}
}