V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
kfpenn
V2EX  ›  问与答

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

  •  
  •   kfpenn · 129 天前 · 1210 次点击
    这是一个创建于 129 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    9 条回复    2025-05-15 08:34:05 +08:00
    concernedz
        1
    concernedz  
       129 天前


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

    Vegetable
        3
    Vegetable  
       129 天前
    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
       129 天前
    @fruitmonster 哈哈哈,这也是一种办法
    kfpenn
        5
    kfpenn  
    OP
       129 天前
    @Vegetable 这个设置了也没用
    kfpenn
        6
    kfpenn  
    OP
       129 天前
    @concernedz 不知道怎么修改
    fruitmonster
        7
    fruitmonster  
       129 天前
    @kfpenn #4 我就开俩,因为我习惯了 goland 的 debug
    dickfu
        8
    dickfu  
       129 天前
    用 vim 写 go 的时候,我记得自己分好类了在不同类之间加空行,他就只在分类里自动排序了,而不会调整分类之间的顺序
    kfpenn
        9
    kfpenn  
    OP
       128 天前
    @dickfu 这个恶心的就是会把空行也去掉
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1321 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 17:14 · PVG 01:14 · LAX 10:14 · JFK 13:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.