我一直在努力为新病毒建立一个C#语言服务器(omnisharp)。主要问题是,我必须使用.NET Core5.0.17和omnisharp不再附带mono和MSBuild工具(在omnisharp回购公告部分中提到)。
当我试图编辑一个.cs文件时,我会得到一条消息:"Client 1退出,使用exist代码150并发出信号0“。当我检查lsp.log
时,我得到了"[ERROR][2022-07-20 13:09:08] .../vim/lsp/rpc.lua:420 "rpc" "dotnet" "stderr" "You must install or update .NET to run this application.\n\nApp: /home/josh/.local/share/nvim/lsp_servers/omnisharp/omnisharp/OmniSharp.dll\nArchitecture: x64\nFramework: 'Microsoft.NETCore.App', version '6.0.0-preview.7.21317.1' (x64)\n.NET location: /opt/dotnet/\n\nThe following frameworks were found:\n 5.0.17 at [/opt/dotnet/shared/Microsoft.NETCore.App]\n\nLearn about framework resolution:\nhttps://aka.ms/dotnet/app-launch-failed\n\nTo install missing framework, download:\nhttps://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0-preview.7.21317.1&arch=x64&rid=manjaro-x64\n"
为了使Omnisharp与低于6.0的.NET版本一起工作,我必须执行以下操作:
useModernNet = false
(在omnisharp-vscode回购需求部分中提到)为了解决第一个问题,我为lsp安装程序生成一个lsp/settings/omnisharp.lua
文件,用于设置cmp并按照lsp配置回购的指示设置useModernNet = false
。我将这样的文件添加到lsp/lsp-installer.lua
中,然后由lsp/init.lua
调用。
希望有人能带我找到解决方案或正确的方向。谢谢你抽出时间阅读。
nvim/lua/user/lsp/lsp-installer.lua
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then
return
end
-- Register a handler that will be called for all installed servers.
-- Alternatively, you may also register handlers on specific server instances instead (see example below).
lsp_installer.on_server_ready(function(server)
local opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
}
if server.name == "jsonls" then
local jsonls_opts = require("user.lsp.settings.jsonls")
opts = vim.tbl_deep_extend("force", jsonls_opts, opts)
end
if server.name == "sumneko_lua" then
local sumneko_opts = require("user.lsp.settings.sumneko_lua")
opts = vim.tbl_deep_extend("force", sumneko_opts, opts)
end
--------------------------------ADDED CODE--------------------------------
if server.name == "omnisharp" then
local omnisharp_opts = require("user.lsp.settings.omnisharp")
opts = vim.tbl_deep_extend("force", omnisharp_opts, opts)
end
--------------------------------------------------------------------------
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end)
nvim/lua/user/lsp/settings/omnisharp.lua
local pid = vim.fn.getpid()
local omnisharp_bin = "/home/josh/.local/share/nvim/lsp_servers/omnisharp/omnisharp/OmniSharp.dll"
return {
cmd = { omnisharp_bin, "--languageserver" , "--hostPID", tostring(pid) },
omnisharp = {
useModernNet = false,
monoPath = "/usr/bin/mono"
}
}
技术栈
系统(cat /etc/lsb-释放)
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=21.3.1
DISTRIB_CODENAME=Ruah
DISTRIB_DESCRIPTION="Manjaro Linux"
.NET (dotnet --信息)
.NET SDK (reflecting any global.json):
Version: 5.0.408
Commit: da985e2a23
Runtime Environment:
OS Name: manjaro
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /opt/dotnet/sdk/5.0.408/
global.json file:
/home/josh/storage/Documents/csharp/global.json
Host:
Version: 6.0.7
Architecture: x64
Commit: 0ec02c8c96
.NET SDKs installed:
5.0.408 [/opt/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.17 [/opt/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [/opt/dotnet/shared/Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
新病毒(nvim -版本)
NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Mono (单版本)
Mono JIT compiler version 6.12.0 (makepkg/ed0788bf61f Sun Apr 24 04:25:18 PM UTC 2022)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: supported, not enabled.
Suspend: hybrid
GC: sgen (concurrent by default)
MSBuild ()
Microsoft (R) Build Engine version 16.10.1 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.
16.10.1.15601%
发布于 2022-08-31 18:11:38
我知道我参加聚会迟到了;-)
我建议使用csharp (https://www.nuget.org/packages/csharp-ls/)。Omnisharp已经过时了我使用它与征服者完成(https://github.com/neoclide/coc.nvim)
我的coc-setting.json
看起来像:
{
"suggest.noselect": false,
"coc.preferences.formatOnSaveFiletypes": [
"csharp",
"sql",
"javascript",
"typescript",
"typescriptreact",
"json",
"javasciptreact",
"typescript.tsx",
"graphql"
],
"languageserver": {
"csharp": {
"command": "csharp-ls",
"rootPatterns": [
"*.sln",
"git"
],
"filetypes": ["cs", "csharp"]
},
"haskell": {
"command": "haskell-language-server-wrapper",
"args": ["--lsp"],
"rootPatterns": [
".stack.yaml",
".hie-bios",
"BUILD.bazel",
"cabal.config",
"package.yaml"
],
"filetypes": ["hs", "lhs", "haskell"]
}
}
}
如您所见,我使用的是两个自定义语言服务器。对象languageserver.csharp
对象应该只与完成相关。
https://stackoverflow.com/questions/73057522
复制相似问题