fix(neovim): update roslyn.nvim to new spec

Also finally call AstroLsp's `on_attach` function for `roslyn` and
`rzls` lsp servers.
This commit is contained in:
Alexandre Cavalheiro S. Tiago da Silva 2025-04-24 22:44:12 -03:00
parent 03e1767b2a
commit 5090767ba2
Signed by: wizardlink
GPG key ID: A5767B54367CFBDF

View file

@ -7,9 +7,15 @@ return {
dependencies = { dependencies = {
{ {
"tris203/rzls.nvim", "tris203/rzls.nvim",
---@return rzls.Config
opts = function(_, opts) opts = function(_, opts)
local has_astrolsp, astrolsp = pcall(require, "astrolsp")
local has_blink, blink = pcall(require, "blink-cmp")
opts = { opts = {
capabilities = vim.lsp.protocol.make_client_capabilities(), capabilities = has_blink and blink.get_lsp_capabilities({}, true)
or vim.lsp.protocol.make_client_capabilities(),
on_attach = has_astrolsp and astrolsp.on_attach or nil,
path = vim.fn.get_nix_store "rzls" .. "/bin/rzls", path = vim.fn.get_nix_store "rzls" .. "/bin/rzls",
} }
@ -18,12 +24,15 @@ return {
}, },
}, },
opts = function(_, opts) opts = function(_, opts)
local has_astrolsp, astrolsp = pcall(require, "astrolsp")
local rzlspath = vim.fn.get_nix_store "rzls" local rzlspath = vim.fn.get_nix_store "rzls"
require("roslyn.config").get()
opts = { opts = {
exe = "Microsoft.CodeAnalysis.LanguageServer", ---@type vim.lsp.ClientConfig
args = { ---@diagnostic disable-next-line: missing-fields
config = {
cmd = {
"Microsoft.CodeAnalysis.LanguageServer",
"--stdio", "--stdio",
"--logLevel=Information", "--logLevel=Information",
"--extensionLogDirectory=" .. vim.fs.dirname(vim.lsp.get_log_path()), "--extensionLogDirectory=" .. vim.fs.dirname(vim.lsp.get_log_path()),
@ -32,10 +41,8 @@ return {
.. rzlspath .. rzlspath
.. "/lib/rzls/Targets/Microsoft.NET.Sdk.Razor.DesignTime.targets", .. "/lib/rzls/Targets/Microsoft.NET.Sdk.Razor.DesignTime.targets",
}, },
---@type vim.lsp.ClientConfig
---@diagnostic disable-next-line: missing-fields
config = {
handlers = require "rzls.roslyn_handlers", handlers = require "rzls.roslyn_handlers",
on_attach = has_astrolsp and astrolsp.on_attach or nil,
settings = { settings = {
["csharp|inlay_hints"] = { ["csharp|inlay_hints"] = {
csharp_enable_inlay_hints_for_implicit_object_creation = true, csharp_enable_inlay_hints_for_implicit_object_creation = true,