如何在 Neovim 中设置 Angular 语言服务
我目前的设置如下所示:
local cwd = vim.fn.getcwd()
local project_library_path = cwd .. "/node_modules"
local cmd = {
DATA_PATH .. "/lsp_servers/angularls/node_modules/@angular/language-server/bin/ngserver",
"--ngProbeLocations",
project_library_path,
"--tsProbeLocations",
project_library_path ,
"--stdio",
}
require'lspconfig'.angularls.setup{
cmd = cmd,
on_new_config = function(new_config, new_root_dir)
new_config.cmd = cmd
end
}
在 :LspInfo
上,我可以看到 cmd
是可执行的,但不知何故它没有附加。
我很难区分 @angular/language-server
和 @angular/language-service
...
我不确定 tsProbeLocations
和ngProbeLocations 执行此操作,并且我的路径是否正确。
最后,我从 Angular Language Service 网站 看到了,neovim 没有一个好的指南。 (除了coc-angular
,但我不使用coc。)
My setup at the moment looks like this:
local cwd = vim.fn.getcwd()
local project_library_path = cwd .. "/node_modules"
local cmd = {
DATA_PATH .. "/lsp_servers/angularls/node_modules/@angular/language-server/bin/ngserver",
"--ngProbeLocations",
project_library_path,
"--tsProbeLocations",
project_library_path ,
"--stdio",
}
require'lspconfig'.angularls.setup{
cmd = cmd,
on_new_config = function(new_config, new_root_dir)
new_config.cmd = cmd
end
}
On :LspInfo
, I can see that the cmd
is executable, but somehow it doesn't attach.
I have difficulty to differentiate @angular/language-server
from @angular/language-service
...
I am not sure what the tsProbeLocations
and ngProbeLocations
do and if my path is correct.
Finally, I red from Angular Language Service website and there isn't a good guideline for neovim. (except for coc-angular
, but I don't use coc.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我有类似的设置和同样的问题。确保已安装的语言服务器的版本与项目中使用的角度版本的主要版本相匹配。这为我解决了这个问题:
有了这个,标准的 lua require'lspconfig'.angularls.setup({}) 应该可以毫无问题地工作。
I had a similar setup and the same problem. Make sure that version of the installed language-server matches the major-version of the angular-version used in your project. That solved the issue for me:
With that, the standard
lua require'lspconfig'.angularls.setup({})
should work without problems.我为 lspconfig 使用了默认的
require'lspconfig'.angularls.setup{}
并安装了 @angular/language-server 作为 Angular 项目中的开发依赖项,它起作用了。通过使用 npm 和默认的 lspconfig 全局安装 Angular 语言服务器,我还看到 cmd 是可执行的,没有客户端附加到缓冲区。
I used the default
require'lspconfig'.angularls.setup{}
for my lspconfig and also installed @angular/language-server as a dev dependency in the angular project and it worked.With angular language server installed globally with npm and the default lspconfig, I also saw that the cmd is executable with no client attaching to the buffer.
代替
Replace
@domrac coc 设置不使用 coc-Angular...它使用 coc-Angular 工作。 coc-Angular 不起作用,您必须按照文档中的描述手动配置它。该文档引用了 coc-angular github 存储库中的 git hub bug 线程,
我实际上编写了有关如何在 neovim 中使用 Angular 语言服务的文档。
我认为内置的 neovim LSP 真的很糟糕。我更喜欢COC。特别是对于打字稿等。
以下是文档的 URL,了解如何将 Angular 语言服务与 neovim 结合使用。
https://v17.angular.io/guide/language-service#neovim
它也应该适用于 vim,尽管我还没有在 vim 上测试过。
我的理解是VS Code和microsoft启动了lsp并将其引入到vscode中。 COC 很好地模仿了 vscode 的实现,这是整个交易的最初先驱。
事实上,我发现内置的 neovim lsp 很荒谬。没有必要拥有它。创建它的人只是不会编写 JavaScript,所以他们愚蠢到多余地创建一个全新的交易。
coc 是第一个,通过 nvim lsp 构建重制版(内置)显示了一些 Neovim 人的愚蠢
@domrac the coc setup doesn't use coc-angular... it uses the coc-angular work around btw. coc-angular wont work, you have to configure it manually as described in the docs there. The docs reference a git hub bug thread in the coc-angular github repo
I actually wrote the documentation for how to use the angular language service in neovim.
I think the built in neovim LSP is really bad. I prefer COC. Especially for typescript and likewise.
Here is the URL to the docs, for how to use the angular language service with neovim.
https://v17.angular.io/guide/language-service#neovim
It should also work for vim, although I haven't tested it on vim.
My understanding is that VS Code and microsoft start the lsp and introduced it to vscode. And that COC does a good job imitating vscode's implementation which is the original pioneer of the whole deal.
I actually find the built in neovim lsp ridiculous. There is no need to have it. The people who created it are just incapable of writing javascript and so they are stupid enough to create a whole new deal redundantly.
coc was first, building a remake (built-in) via nvim lsp shows the stupidity of some neovim people