Add support csharp-language-server

This commit is contained in:
Rafael Lillo 2024-06-24 20:55:20 +01:00
parent 2a7ba6d09c
commit 24e1931c89

View file

@ -0,0 +1,104 @@
return {
recommended = function()
return LazyVim.extras.wants({
ft = { "cs", "vb" },
root = { "*.sln", "*.csproj", "omnisharp.json", "function.json" },
})
end,
{ "Decodetalkers/csharpls-extended-lsp.nvim", lazy = true },
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "c_sharp" } },
},
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.csharpier)
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
cs = { "csharpier" },
},
formatters = {
csharpier = {
command = "dotnet-csharpier",
args = { "--write-stdout" },
},
},
},
},
{
"williamboman/mason.nvim",
opts = { ensure_installed = { "csharpier", "netcoredbg", "csharp-language-server" } },
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
sharp_ls = {
handlers = {
["textDocument/definition"] = function(...)
return require("csharpls_extended").handler(...)
end,
["textDocument/typeDefinition"] = function(...)
return require("csharpls_extended").handler(...)
end,
},
},
},
},
},
{
"mfussenegger/nvim-dap",
optional = true,
opts = function()
local dap = require("dap")
if not dap.adapters["netcoredbg"] then
require("dap").adapters["netcoredbg"] = {
type = "executable",
command = vim.fn.exepath("netcoredbg"),
args = { "--interpreter=vscode" },
}
end
for _, lang in ipairs({ "cs", "fsharp", "vb" }) do
if not dap.configurations[lang] then
dap.configurations[lang] = {
{
type = "netcoredbg",
name = "Launch file",
request = "launch",
---@diagnostic disable-next-line: redundant-parameter
program = function()
return vim.fn.input("Path to dll: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
},
}
end
end
end,
},
{
"nvim-neotest/neotest",
optional = true,
dependencies = {
"Issafalcon/neotest-dotnet",
},
opts = {
adapters = {
["neotest-dotnet"] = {
-- Here we can set options for neotest-dotnet
},
},
},
},
}