kfpenn
V2EX  ›  问与答

大佬们,请教一个 cursor 的问题

  •  
  •   kfpenn · May 14, 2025 · 2411 views
    This topic created in 537 days ago, the information mentioned may be changed or developed.

    goland 转 cursor ,遇到一个问题,就是 import 排序,总是把项目包和内置包混在一起,找了个插件 Go Group Imports 也不好使,实在没办法了想要禁用自动排序,可不管怎么设置,都没用,保存的时候依然会自动排序,实在无解,求教大佬们要怎么搞啊

    9 replies  •  2025-05-15 08:34:05 +08:00
    concernedz
    concernedz
    May 14, 2025
    1


    好像排序功能就是 gopls ,只能看看怎么修改排序规则了
    fruitmonster
    fruitmonster
    May 14, 2025
    2
    cursor 写完之后,goland ,重新格式化一下代码,提交

    Vegetable
    Vegetable
    May 14, 2025
    3
    When the language server is enabled and one of default/gofmt/goimports/gofumpt is chosen, the language server will handle formatting. If custom tool is selected, the extension will use the customFormatter tool in the Go: Alternate Tools section.

    根据配置说明,默认情况下 vscode 使用 gopls 进行代码格式化,可以通过配置修改为自定义的格式化工具,比如 goimports 。你可以找一下有没有人做了 goland 的 formatter 的移植,或者探索一下其他格式化工具。
    kfpenn
    kfpenn
    OP
    May 14, 2025
    4
    @fruitmonster 哈哈哈,这也是一种办法
    kfpenn
    kfpenn
    OP
    May 14, 2025
    5
    @Vegetable 这个设置了也没用
    kfpenn
    kfpenn
    OP
    May 14, 2025
    6
    @concernedz 不知道怎么修改
    fruitmonster
    fruitmonster
    May 14, 2025
    7
    @kfpenn #4 我就开俩,因为我习惯了 goland 的 debug
    dickfu
    dickfu
    May 15, 2025
    8
    用 vim 写 go 的时候,我记得自己分好类了在不同类之间加空行,他就只在分类里自动排序了,而不会调整分类之间的顺序
    kfpenn
    kfpenn
    OP
    May 15, 2025
    9
    @dickfu 这个恶心的就是会把空行也去掉
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4255 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 00:08 · PVG 08:08 · LAX 16:08 · JFK 19:08
    ♥ Do have faith in what you're doing.