From bef3f4fba57f8cbb53eca39b371be55d2ba8de91 Mon Sep 17 00:00:00 2001 From: Ahmet Sen Date: Sun, 13 Oct 2024 19:01:19 +0300 Subject: [PATCH 1/2] feat(cs-omnisharp): add csharp support with omnisharp --- .../pack/cs-omnisharp/README.md | 12 +++ lua/astrocommunity/pack/cs-omnisharp/init.lua | 74 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 lua/astrocommunity/pack/cs-omnisharp/README.md create mode 100644 lua/astrocommunity/pack/cs-omnisharp/init.lua diff --git a/lua/astrocommunity/pack/cs-omnisharp/README.md b/lua/astrocommunity/pack/cs-omnisharp/README.md new file mode 100644 index 000000000..c12c56dd5 --- /dev/null +++ b/lua/astrocommunity/pack/cs-omnisharp/README.md @@ -0,0 +1,12 @@ +# C# Language Pack + +**Requirements:** `dotnet` must be in your `PATH` and executable + +This plugin pack does the following: + +- Adds `c_sharp` Treesitter parsers +- Adds `omnisharp` language server +- Adds [`omnisharp-extended-lsp.nvim`](https://github.com/Hoffs/omnisharp-extended-lsp.nvim) for better go to definition/type definition +- Adds the following `null-ls` sources: + - [csharpier](https://github.com/belav/csharpier) +- Adds `coreclr` debug adapters for nvim-dap diff --git a/lua/astrocommunity/pack/cs-omnisharp/init.lua b/lua/astrocommunity/pack/cs-omnisharp/init.lua new file mode 100644 index 000000000..347b24586 --- /dev/null +++ b/lua/astrocommunity/pack/cs-omnisharp/init.lua @@ -0,0 +1,74 @@ +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 = { + handlers = { + ["textDocument/definition"] = function(...) require("omnisharp_extended").definition_handler(...) end, + ["textDocument/typeDefinition"] = function(...) + require("omnisharp_extended").type_definition_handler(...) + end, + ["textDocument/references"] = function(...) require("omnisharp_extended").references_handler(...) end, + ["textDocument/implementation"] = function(...) + require("omnisharp_extended").implementation_handler(...) + 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, + }, +} From 59b75ed2d9144383d5c30b518427e5fee1faf701 Mon Sep 17 00:00:00 2001 From: Ahmet Sen Date: Fri, 29 Nov 2024 11:41:46 +0300 Subject: [PATCH 2/2] fix(cs-omnisharp): `omnisharp-extended-lsp.nvim` handler registration --- lua/astrocommunity/pack/cs-omnisharp/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/astrocommunity/pack/cs-omnisharp/init.lua b/lua/astrocommunity/pack/cs-omnisharp/init.lua index 347b24586..5e37b3afd 100644 --- a/lua/astrocommunity/pack/cs-omnisharp/init.lua +++ b/lua/astrocommunity/pack/cs-omnisharp/init.lua @@ -30,7 +30,7 @@ return { "AstroNvim/astrolsp", opts = { config = { - csharp_ls = { + omnisharp = { handlers = { ["textDocument/definition"] = function(...) require("omnisharp_extended").definition_handler(...) end, ["textDocument/typeDefinition"] = function(...)