MordFustang21 / ide-gopls

Atom integration with the Go language server (gopls)
MIT License
13 stars 5 forks source link

auto complete package imports #6

Open MordFustang21 opened 4 years ago

MordFustang21 commented 4 years ago

When the editor adds the missing import it injects the completion selection incorrectly. Ex.

package main

import "fmt"

func main() {
  fmt.Println("hello world")
  log
}

becomes

package main

import (
    "log"
)
    "fmt"

func main() {
  fmt.Println("hello world")
  log
}
stamblerre commented 4 years ago

This sounds like it could be an issue in the Atom language client library. The imports are added via the additional text edits field of a completion item: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_completion.

MordFustang21 commented 4 years ago

I'm 99% sure this is an issue with ide-gopls. I had to add special code when I did this the first time around to apply the additional edits see https://github.com/MordFustang21/ide-gopls/blob/master/lib/main.js#L68

marcelkohl commented 3 years ago

fixed on PR https://github.com/MordFustang21/ide-gopls/pull/16