feat(nvim): omnisharp -> roslyn-ls
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-18 16:44:21 -05:00
parent fa5fcfe8fd
commit d563c80bd0
8 changed files with 56 additions and 40 deletions

View file

@ -1,6 +1,6 @@
using System;
using System.Text.Json;
using System.Reflection;
using System.Text.Json;
using HomeAssistantGenerated;

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -50,6 +50,9 @@ in {
silent = true,
});
-- https://github.com/seblj/roslyn.nvim/issues/121#issuecomment-2544076963
vim.opt.cmdheight = 2;
-- Get rid of deprecated messages
vim.tbl_add_reverse_lookup = function(tbl)
for k, v in pairs(tbl) do

View file

@ -1,20 +1,22 @@
{
self: {
config,
lib,
pkgs,
...
}: let
inherit (lib) attrValues mkIf;
inherit (self.lib.${pkgs.system}) buildPlugin;
inherit (self.inputs) vimplugin-roslyn-nvim-src;
cfg = config.programs.neovim;
in
mkIf cfg.enableIde {
in {
config = mkIf cfg.enableIde {
programs = {
neovim = {
extraPackages = attrValues {
inherit
(pkgs)
omnisharp-roslyn
roslyn-ls
;
};
@ -26,45 +28,51 @@ in
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
local omnisharp_extended = require('omnisharp_extended');
vim.api.nvim_create_autocmd('User', {
pattern = 'RoslynInitialized',
callback = function()
vim.lsp.inlay_hint.enable();
end,
});
require('lspconfig').omnisharp.setup({
cmd = { 'dotnet', '${pkgs.omnisharp-roslyn}/lib/omnisharp-roslyn/OmniSharp.dll' },
-- FIXME: make editorconfig and format work
require('roslyn').setup({
config = {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
handlers = {
['textDocument/definition'] = omnisharp_extended.definition_handler,
['textDocument/typeDefinition'] = omnisharp_extended.type_definition_handler,
['textDocument/references'] = omnisharp_extended.references_handler,
['textDocument/implementation'] = omnisharp_extended.implementation_handler,
},
on_attach = function()
vim.lsp.inlay_hint.enable();
end,
settings = {
FormattingOptions = {
EnableEditorConfigSupport = true,
OrganizeImports = true,
},
MsBuild = {
LoadProjectsOnDemand = false,
},
RoslynExtensionsOptions = {
EnableAnalyzersSupport = true,
EnableDecompilationSupport = true,
EnableImportCompletion = true,
AnalyzeOpenDocumentsOnly = false,
},
Sdk = {
IncludePrereleases = true,
["csharp|inlay_hints"] = {
csharp_enable_inlay_hints_for_implicit_object_creation = true,
csharp_enable_inlay_hints_for_implicit_variable_types = true,
csharp_enable_inlay_hints_for_lambda_parameter_types = true,
csharp_enable_inlay_hints_for_types = true,
dotnet_enable_inlay_hints_for_indexer_parameters = true,
dotnet_enable_inlay_hints_for_literal_parameters = true,
dotnet_enable_inlay_hints_for_object_creation_parameters = true,
dotnet_enable_inlay_hints_for_other_parameters = true,
dotnet_enable_inlay_hints_for_parameters = true,
dotnet_suppress_inlay_hints_for_parameters_that_differ_only_by_suffix = true,
dotnet_suppress_inlay_hints_for_parameters_that_match_argument_name = true,
dotnet_suppress_inlay_hints_for_parameters_that_match_method_intent = true,
},
},
},
exe = 'Microsoft.CodeAnalysis.LanguageServer',
});
'';
plugins = attrValues {
inherit
(pkgs.vimPlugins)
omnisharp-extended-lsp-nvim
;
plugins = [
(buildPlugin "roslyn-nvim" vimplugin-roslyn-nvim-src)
];
};
};
};
}
# For accurate stack trace
_file = ./csharp.nix;
}

View file

@ -11,7 +11,6 @@ in {
imports = [
./bash.nix
./clang.nix
./csharp.nix
./hyprlang.nix
./java.nix
./json.nix
@ -19,6 +18,7 @@ in {
./python.nix
./rust.nix
(import ./csharp.nix self)
(import ./markdown.nix self)
(import ./nix.nix self)
(import ./web.nix self)

View file

@ -276,6 +276,11 @@ let
owner = "dmmulroy";
repo = "ts-error-translator.nvim";
}
{
name = "vimplugin-roslyn-nvim-src";
owner = "seblj";
repo = "roslyn.nvim";
}
# Overlays & packages
{

View file

@ -22,7 +22,7 @@ in {
;
});
# FIXME: Omnisharp uses dotnet6
# FIXME: Roslyn-ls uses dotnet6 https://github.com/NixOS/nixpkgs/blob/d3c42f187194c26d9f0309a8ecc469d6c878ce33/pkgs/by-name/ro/roslyn-ls/package.nix#L21
nixpkgs.config.permittedInsecurePackages = [
"dotnet-core-combined"
"dotnet-sdk-6.0.428"