Normal view

There are new articles available, click to refresh the page.
Yesterday — 14 April 2025Main stream
Before yesterdayMain stream

vscode 写 go 连最基础的补全功能都做得这么差的吗

8 April 2025 at 16:30
BeautifulSoap:

一直用的都是 goland/idea 写 go ,体验了下用 vsocde 开发 go ,结果发现怎么连最基础的补全功能都这么差

有点无法理解说 vscode 写 go 的体验和 goland 差不多的是认真的吗。。。。。

下面是一个简单到不能再简单的的例子,如果是我用 vscode 姿势不对,希望有人能指出问题所在

go mod 初始化好项目用 vsocde 打开(确保 gopls 的 lsp 已经正确运行),写一个 utils 包 utils/utils.go,内容如下:

package utils

func ThisIsMyHelperFunction() string {
return "hello"

}

关掉这个文件的标签页,打开 main.go ,输入 ThisIsMy,我自然期待补全会给出对应的函数候补,结果 vscode 根本跳不出任何候补。不是,vscode 这么离谱的吗

img

然后我发现,把utils.go 文件作为非活动标签页打开在边上,然后再输 ThisIsMy ,这次候补里出现了,但是它只是作为一个纯字符串出现,vscode 甚至都无法识别出它是个函数,tab 上去之后 ctrl + . 甚至都没法正常导包,提示不存在定义

img

然后翻了半天 vscode 官网,才发现说明有这一句

As you type in a Go file, you can see IntelliSense providing you with suggested completions. This even works for members in current, imported, and not yet imported packages. Just type any package name followed by ., and you will get suggestions for the corresponding package members.

不是,你的意思是我要用一个类型 or 函数之类的,必须从所属的包开始输入吗?一个项目复杂起来,那么多目录那么多包谁能清楚记得要用的东西在哪个包啊。。。。。。

而与之相对的,在 goland/idea 中写 go 项目,我只要输入 ThisIs 就能跳出对应内容,tab 后就直接完成了补全+添加包前缀+自动 import 。我曾经以为这种功能甚至是基础到不能再基础的功能,结果没想到。。。。

img

微软这操作有点骚,自己做的不行硬是也不让别人用

By: HarrisIce
5 April 2025 at 12:06
HarrisIce:

用的 cursor ,今天写 c++项目,突然报错:

The C/C++ extension may be used only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services to develop and test your applications.

查了一下,合着微软把其他 ide 给禁了,只允许在自家 ide 里用。

https://github.com/getcursor/cursor/issues/2976

这操作好骚,本来 copilot 的功能慢半拍就匪夷所思了,现在又要强行从 cursor 抢人

❌
❌