kfpenn
V2EX  ›  问与答

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

  •  
  •   kfpenn · May 14, 2025 · 1974 views
    This topic created in 388 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
        1
    concernedz  
       May 14, 2025


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

    Vegetable
        3
    Vegetable  
       May 14, 2025
    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
        4
    kfpenn  
    OP
       May 14, 2025
    @fruitmonster 哈哈哈,这也是一种办法
    kfpenn
        5
    kfpenn  
    OP
       May 14, 2025
    @Vegetable 这个设置了也没用
    kfpenn
        6
    kfpenn  
    OP
       May 14, 2025
    @concernedz 不知道怎么修改
    fruitmonster
        7
    fruitmonster  
       May 14, 2025
    @kfpenn #4 我就开俩,因为我习惯了 goland 的 debug
    dickfu
        8
    dickfu  
       May 15, 2025
    用 vim 写 go 的时候,我记得自己分好类了在不同类之间加空行,他就只在分类里自动排序了,而不会调整分类之间的顺序
    kfpenn
        9
    kfpenn  
    OP
       May 15, 2025
    @dickfu 这个恶心的就是会把空行也去掉
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3024 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 09:02 · PVG 17:02 · LAX 02:02 · JFK 05:02
    ♥ Do have faith in what you're doing.