dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.51k stars 1.43k forks source link

Implement listing all returned results for LSP textDocument/implements #4755

Closed bgarber closed 5 months ago

bgarber commented 5 months ago

This PR has the intention of implementing the list feature for :ALEGoToDefinition and :ALEGoToImplementation. Specially :ALEGoToImplementation. There are times a LSP may return multiple results for the textDocument/implementation command. This is true when we try to find implementations of an abstract class or interface. The way ALE is implemented, only the first result is returned.

Take this example.

foobar.go:

type Foobarer interface {
    Do() bool
}

foobar_a.go

type FoobarA struct {
   foo int
}

func (f *FoobarA) Do() bool {
   fmt.Printf("This foobar is int (%d)\n", f.foo)
   return true
}

another_foobar.go

type AnotherFoobar struct {
   foo bool
}

func (f *AnotherFoobar) Do() bool {
   fmt.Printf("This foobar is bool (%v)\n", f.foo)
   return f.foo
}

When trying to find implementations of the Do function, it will only find the one from AnotherFoobar struct (because the LSP returns in alphabetic order). But I could want the other one. This change fixes this behavior.

Captura de tela 2024-04-14 221711

bgarber commented 5 months ago

Please, let me know if this is good to go. Thank you!