From 7fdebda12a0446d2189258b6d3d589a803c886c4 Mon Sep 17 00:00:00 2001 From: Eugene Ma Date: Thu, 22 Aug 2024 23:19:33 -0700 Subject: [PATCH] assist: set completion window to itself --- cmd/L/main.go | 2 +- cmd/Lone/main.go | 2 +- internal/lsp/acmelsp/assist.go | 2 +- internal/lsp/acmelsp/remote.go | 9 +++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/L/main.go b/cmd/L/main.go index 9979fd6..33514d9 100644 --- a/cmd/L/main.go +++ b/cmd/L/main.go @@ -220,7 +220,7 @@ func run(cfg *config.Config, args []string) error { } } - return rc.Completion(ctx, kind) + return rc.Completion(ctx, kind, nil) case "def": args = args[1:] return rc.Definition(ctx, len(args) > 0 && args[0] == "-p") diff --git a/cmd/Lone/main.go b/cmd/Lone/main.go index f8407d8..9f50c37 100644 --- a/cmd/Lone/main.go +++ b/cmd/Lone/main.go @@ -142,7 +142,7 @@ func run(cfg *config.Config, args []string) error { switch args[0] { case "comp": - err = rc.Completion(ctx, acmelsp.CompleteNoEdit) + err = rc.Completion(ctx, acmelsp.CompleteNoEdit, nil) case "def": err = rc.Definition(ctx, false) case "fmt": diff --git a/internal/lsp/acmelsp/assist.go b/internal/lsp/acmelsp/assist.go index 8f141e5..3ab84aa 100644 --- a/internal/lsp/acmelsp/assist.go +++ b/internal/lsp/acmelsp/assist.go @@ -220,7 +220,7 @@ func (w *outputWin) Update(fw *focusWin, server proxy.Server, cmd string) { w.Clear() switch cmd { case "comp": - err := rc.Completion(ctx, CompleteNoEdit) + err := rc.Completion(ctx, CompleteNoEdit, w) if err != nil { dprintf("Completion failed: %v\n", err) } diff --git a/internal/lsp/acmelsp/remote.go b/internal/lsp/acmelsp/remote.go index dcbf36f..616c3bb 100644 --- a/internal/lsp/acmelsp/remote.go +++ b/internal/lsp/acmelsp/remote.go @@ -81,7 +81,7 @@ const ( CompleteInsertFirstMatch ) -func (rc *RemoteCmd) Completion(ctx context.Context, kind CompletionKind) error { +func (rc *RemoteCmd) Completion(ctx context.Context, kind CompletionKind, output *outputWin) error { w, err := acmeutil.OpenWin(rc.winid) if err != nil { return err @@ -124,7 +124,12 @@ func (rc *RemoteCmd) Completion(ctx context.Context, kind CompletionKind) error fmt.Fprintf(&sb, "%v\t%v\n", item.Label, item.Detail) } - if kind == CompleteInsertFirstMatch { + if output != nil { + defer output.Win.Ctl("clean") + + output.Clear() + output.PrintTabbed(sb.String()) + } else if kind == CompleteInsertFirstMatch { cw, err := acmeutil.Hijack("/LSP/Completions") if err != nil { cw, err = acmeutil.NewWin()