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

185 天前
 kfpenn

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

1467 次点击
所在节点    问与答
9 条回复
concernedz
185 天前


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

Vegetable
185 天前
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
185 天前
@fruitmonster 哈哈哈,这也是一种办法
kfpenn
185 天前
@Vegetable 这个设置了也没用
kfpenn
185 天前
@concernedz 不知道怎么修改
fruitmonster
185 天前
@kfpenn #4 我就开俩,因为我习惯了 goland 的 debug
dickfu
184 天前
用 vim 写 go 的时候,我记得自己分好类了在不同类之间加空行,他就只在分类里自动排序了,而不会调整分类之间的顺序
kfpenn
184 天前
@dickfu 这个恶心的就是会把空行也去掉

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://ex.noerr.eu.org/t/1131757

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX