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;
using System.Text.Json;
using System.Reflection; using System.Reflection;
using System.Text.Json;
using HomeAssistantGenerated; using HomeAssistantGenerated;

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

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

View file

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

View file

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

View file

@ -276,6 +276,11 @@ let
owner = "dmmulroy"; owner = "dmmulroy";
repo = "ts-error-translator.nvim"; repo = "ts-error-translator.nvim";
} }
{
name = "vimplugin-roslyn-nvim-src";
owner = "seblj";
repo = "roslyn.nvim";
}
# Overlays & packages # 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 = [ nixpkgs.config.permittedInsecurePackages = [
"dotnet-core-combined" "dotnet-core-combined"
"dotnet-sdk-6.0.428" "dotnet-sdk-6.0.428"