Open sonderistic opened 4 days ago
Hi @sonderistic, I'm coming from the neovim issue you linked, thanks for that! The reason why the workaround didn't work for you, because the workaround is to not use Custom handlers (marked as suboptimal), but use Custom commands / keymaps (marked as optimal) instead: https://github.com/Hoffs/omnisharp-extended-lsp.nvim?tab=readme-ov-file#how-to-use.
However AstroNvim uses custom handlers at https://github.com/AstroNvim/astrocommunity/blob/bb7988ac0efe0c17936c350c6da19051765f0e71/lua/astrocommunity/pack/cs-omnisharp/init.lua#L35, I advise the developers to use custom commands instead for nvim 0.11+ compatibility.
As a user I'm not sure what's the best solution as I haven't used a nvim distro, if you cant find a way to turn off the built in omnisharp-extended plugin or config, or override that, you can make a fork where that is removed and use that in your config until it's fixed.
Hello @gepbird, thanks for your input. I have replaced the suboptimal solution with the one you prescribed (I think- I ChatGPT'd it), but am still getting the same error so it must be wrongly implemented:
return {
-- CSharp support
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "c_sharp" })
end
end,
},
{
"jay-babu/mason-null-ls.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "csharpier" })
end,
},
{
"williamboman/mason-lspconfig.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "omnisharp" })
end,
},
{
"Hoffs/omnisharp-extended-lsp.nvim",
dependencies = {
{
"AstroNvim/astrolsp",
opts = {
config = {
csharp_ls = {
on_attach = function(_, bufnr)
-- Helper function for setting key mappings
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local opts = { noremap = true, silent = true }
-- All mappings
buf_set_keymap("n", "gd", "<cmd>lua require('omnisharp_extended').lsp_definition()<cr>", opts)
buf_set_keymap("n", "<leader>D", "<cmd>lua require('omnisharp_extended').lsp_type_definition()<cr>", opts)
buf_set_keymap("n", "gr", "<cmd>lua require('omnisharp_extended').lsp_references()<cr>", opts)
buf_set_keymap("n", "gi", "<cmd>lua require('omnisharp_extended').lsp_implementation()<cr>", opts)
buf_set_keymap("n", "gr", "<cmd>lua require('omnisharp_extended').telescope_lsp_references()<cr>", opts)
buf_set_keymap("n", "gd", "<cmd>lua require('omnisharp_extended').telescope_lsp_definition({ jump_type = 'vsplit' })<cr>", opts)
buf_set_keymap("n", "<leader>D", "<cmd>lua require('omnisharp_extended').telescope_lsp_type_definition()<cr>", opts)
buf_set_keymap("n", "gi", "<cmd>lua require('omnisharp_extended').telescope_lsp_implementation()<cr>", opts)
end,
},
},
},
},
},
},
{
"jay-babu/mason-nvim-dap.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "coreclr" })
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed =
require("astrocore").list_insert_unique(opts.ensure_installed, { "omnisharp", "csharpier", "netcoredbg" })
end,
},
{
"nvim-neotest/neotest",
optional = true,
dependencies = { "Issafalcon/neotest-dotnet", config = function() end },
opts = function(_, opts)
if not opts.adapters then opts.adapters = {} end
table.insert(opts.adapters, require "neotest-dotnet"(require("astrocore").plugin_opts "neotest-dotnet"))
end,
},
}
Could you please advise me on how to properly use the optimal solution?
@sonderistic at first sight that looks good, are you sure that configuration is being used and not the default AstroVim?
Also "downgrading" to the latest stable nvim release (0.10.2) should also get rid of the error.
If you still want to use the nightly nvim, please share more context (like another minimal reproduction) with your modified/overridden AstroNvim config (or wait for maintainers to fix it)
Checklist
repro.lua
provided belowNeovim version (nvim -v)
v0.10.2
Operating system/version
macOS 15.0
Terminal/GUI
iTerm2
Describe the bug
Omnisharp simply does not work on the M1 Mac. Attempting to "go to definition" yields the error seen in the screencap. What's puzzling is that autocomplete suggestions seem to be present, but accepting a suggestion will yield the same error.
Steps to Reproduce
dotnet new mvc
via terminal)nvim -u repro.lua
Expected behavior
LSP should work.
Screenshots
No response
Additional Context
Looks like someone else has this exact problem on the Neovim repo: https://github.com/neovim/neovim/issues/30908
Minimal configuration