MordFustang21 / ide-gopls

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

referencing package corrupts import block #20

Open hareldvd opened 10 months ago

hareldvd commented 10 months ago

Greetings.

When I add reference to a package that is not yet defined in the import block the automatic import mechanism corrupts the import block. Here is a review of what happens when I added a reference to the package "db" (reside in findbom/golang/db)

before making the reference:

import (
    "testing"
    "net/http"

    "github.com/stretchr/testify/assert"
)

after making the reference

import (
               "tesftdolang/dbbom/ing"
               "net/http"
               "testing"

    "github.com/stretchr/testify/assert"
)

expected import block

import (
    "testing"
    "net/http"

    "findbom/golang/db"
    "github.com/stretchr/testify/assert"
)

Please note that in the editor, I changed tab space to 4 spaces. Maybe that is the reason.

Thanks for the great work you do on this package

MordFustang21 commented 10 months ago

It should be injecting directly whatever change came from gopls which should be tab characters. I'm assuming the issue is something similar to what you suggested where there's a mix of tabs and spaces in the file. As for the imports not being grouped like in the expected import block there's a separate part of the spec that has to be called to get that which is

         **
     * Base kind for an organize imports source action:
     * `source.organizeImports`.
     */
    export const SourceOrganizeImports: [CodeActionKind](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) =
        'source.organizeImports';

And I don't think that's actually implemented in atom. Also curious are you running this in atom or in the pulsar fork?

hareldvd commented 10 months ago

Thanks for your reply.

The behaviour of this feature damages my code over and over again therefore I would rather disable it. In order to disable it I commented out all references to: CodeActionKind.SourceOrganizeImports = 'source.organizeImports'; statements, this feels like the wrong thing to do but since I don't know that much about Pulsar/Atom I didn't find anything else to do. I will be grateful. If you can correct me.

After the Atom sunset I switched to Pulsar but I feel quite lonely there. like the phrase: "Last one to turn off the ligths". I love this IDE so I hope I am wrong again.

On Fri, Aug 25, 2023 at 10:59 PM Derrick Laird @.***> wrote:

It should be injecting directly whatever change came from gopls which should be tab characters. I'm assuming the issue is something similar to what you suggested where there's a mix of tabs and spaces in the file. As for the imports not being grouped like in the expected import block there's a separate part of the spec that has to be called to get that which is

     **
  • Base kind for an organize imports source action:
  • source.organizeImports. */ export const SourceOrganizeImports: CodeActionKind = 'source.organizeImports';

And I don't think that's actually implemented in atom. Also curious are you running this in atom or in the pulsar fork?

— Reply to this email directly, view it on GitHub https://github.com/MordFustang21/ide-gopls/issues/20#issuecomment-1693867423, or unsubscribe https://github.com/notifications/unsubscribe-auth/BARBYUAQJFQTTSJVSOKTFZTXXD72HANCNFSM6AAAAAA34RP4TE . You are receiving this because you authored the thread.Message ID: @.***>

-- דוד הראל עמוקה ד.נ. מרום הגליל 1380200 טל: 054-2263892