Skip to content

Commit

Permalink
assist: set completion window to itself
Browse files Browse the repository at this point in the history
  • Loading branch information
edma2 committed Aug 23, 2024
1 parent 45ed696 commit 7fdebda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/L/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cmd/Lone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/acmelsp/assist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 7 additions & 2 deletions internal/lsp/acmelsp/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7fdebda

Please sign in to comment.