禁用竞争语言服务器/代码突出显示
我想添加一个语言服务器来处理文件的完成/突出显示/等。 作为测试内容的基础,我使用 Microsoft 的示例( https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-sample)并将其更改为对任何文件都有效。该语言服务器突出显示所有大写字母的任何单词。
打开 C++ 文件时,我会突出显示/完成我的语言服务器和 C++ 的默认语言服务器(参见图片)。
我想检测某个文件的其他扩展/内置荧光笔是否处于活动状态,如果不可能,则为此工作区或当前文件停用它对于当前的工作区)
- 有没有一种方法可以以通用方式执行此操作,而我不必知道哪些扩展正在突出显示代码?
- 如果不是,如果我知道一组我想要停用的扩展,有没有办法做到这一点?
I want to add a language server to handle completion / highlighting / etc. for a file.
As a basis for testing stuff I am using an example from Microsoft (https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-sample) and changed it to be active for any File. This language server highlights any word in all capital letters.
When opening a C++ File, I get the highlighting / completion of my language server and the default one for C++ (See image).
I would like to detect if some other extension / build in highlighter is active for a file and deactivate it for this workspace or the current file if it is impossible for the current workspace)
- Is there a way to do this in a generic way where I do not have to know which extensions are highlighting code?
- If no, is there a way to do this, if I know a set of extensions I want to deactivate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于有足够的时间进行更多尝试,发现为相同的扩展提供您自己的语言就足够了。
在
package.json
中,我在contributes.languages
中添加了一个元素,其中extensions
包含.cpp
(因为我正在使用cpp 文件用于测试)。我还复制了一些实现代码来自示例。
这抑制了 cpp 文件的默认荧光笔和代码完成。由于我只实现 语义令牌提供程序,我可以在我的提供商接管之前查看默认突出显示。 (我认为这可以通过添加 语法荧光笔 来解决,但这对于我的初步测试来说已经足够了)
我不确定,所有这些作为插件有多稳定(我只在扩展开发主机模式下进行了测试)
这里是结果的图像:

I finally had enough time to try around a bit more and found that providing your own language for the same extension is enough.
In
package.json
I added an element incontributes.languages
withextensions
containing.cpp
(since I am using cpp files for testing).I also copied over some implementation code from an example.
This suppressed the default highlighter and code completion for cpp files. Since i am only implementing a semantic token provider, I can see the default highlighting before my provider takes over. (I think this could be solved by adding a syntax highlighter, but this is already sufficient fo my preliminary testing)
I am not sure, how stable all of this would be as a plugin (I only tested in Extension Development Host mode)
Here an image of the results:
