mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +00:00
languages/csharp: add roslyn-nvim extension
This commit is contained in:
parent
99c2594edd
commit
c73e781a3d
2 changed files with 68 additions and 15 deletions
|
|
@ -5,17 +5,20 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) concatMap;
|
inherit (builtins) concatMap;
|
||||||
|
inherit (builtins) elem;
|
||||||
inherit (lib) genAttrs;
|
inherit (lib) genAttrs;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
inherit (lib.types) enum listOf;
|
inherit (lib.types) enum listOf;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
|
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption enumWithRename luaInline;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
extraServerPlugins = {
|
extraServerPlugins = {
|
||||||
omnisharp = ["omnisharp-extended-lsp-nvim"];
|
omnisharp = ["omnisharp-extended-lsp-nvim"];
|
||||||
csharp_ls = ["csharpls-extended-lsp-nvim"];
|
csharp_ls = ["csharpls-extended-lsp-nvim"];
|
||||||
roslyn_ls = [];
|
roslyn-ls = [];
|
||||||
roslyn = ["roslyn-nvim"];
|
|
||||||
};
|
};
|
||||||
defaultServers = ["csharp-ls"];
|
defaultServers = ["csharp-ls"];
|
||||||
servers = ["csharp-ls" "omnisharp" "roslyn-ls"];
|
servers = ["csharp-ls" "omnisharp" "roslyn-ls"];
|
||||||
|
|
@ -44,13 +47,56 @@ in {
|
||||||
extensions = {
|
extensions = {
|
||||||
roslyn-nvim = {
|
roslyn-nvim = {
|
||||||
enable = mkEnableOption ''
|
enable = mkEnableOption ''
|
||||||
Roslyn LSP plugin for neovim
|
Roslyn LSP plugin for Neovim that adds Razor support and works with multiple solutions
|
||||||
|
|
||||||
::: {.note}
|
::: {.note}
|
||||||
This feature only works for `roslyn-ls`.
|
This feature only works for `roslyn-ls`.
|
||||||
:::
|
:::
|
||||||
'';
|
'';
|
||||||
setupOpts = mkPluginSetupOption "roslyn-nvim" {};
|
setupOpts = mkPluginSetupOption "roslyn-nvim" {
|
||||||
|
filewatching = mkOption {
|
||||||
|
description = ''
|
||||||
|
"auto" | "roslyn" | "off"
|
||||||
|
|
||||||
|
- "auto": Does nothing for filewatching, leaving everything as default
|
||||||
|
- "roslyn": Turns off neovim filewatching which will make roslyn do the filewatching
|
||||||
|
- "off": Hack to turn off all filewatching.
|
||||||
|
|
||||||
|
::: {.tip}
|
||||||
|
Set to "off" if you notice performance issues
|
||||||
|
:::
|
||||||
|
'';
|
||||||
|
type = enum ["auto" "roslyn" "off"];
|
||||||
|
default = "auto";
|
||||||
|
};
|
||||||
|
extensions.razor = {
|
||||||
|
enabled =
|
||||||
|
(mkEnableOption "Additional roslyn extensions (for example Roslynator/Razor)")
|
||||||
|
// {default = true;};
|
||||||
|
config = mkOption {
|
||||||
|
description = "Configuration for the additional roslyn extensions";
|
||||||
|
type = luaInline;
|
||||||
|
default = let
|
||||||
|
pkg = pkgs.vscode-extensions.ms-dotnettools.csharp;
|
||||||
|
pluginRoot = "${pkg}/share/vscode/extensions/ms-dotnettools.csharp";
|
||||||
|
razorExtension = "${pluginRoot}/.razorExtension/Microsoft.VisualStudioCode.RazorExtension.dll";
|
||||||
|
razorSourceGenerator = "${pluginRoot}/.razorExtension/Microsoft.CodeAnalysis.Razor.Compiler.dll";
|
||||||
|
razorDesignTimePath = "${pluginRoot}/.razorExtension/Targets/Microsoft.NET.Sdk.Razor.DesignTime.targets";
|
||||||
|
in
|
||||||
|
mkLuaInline ''
|
||||||
|
function()
|
||||||
|
return {
|
||||||
|
path = '${razorExtension}',
|
||||||
|
args = {
|
||||||
|
'--razorSourceGenerator=${razorSourceGenerator}',
|
||||||
|
'--razorDesignTimePath=${razorDesignTimePath}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -74,7 +120,11 @@ in {
|
||||||
};
|
};
|
||||||
servers = mkOption {
|
servers = mkOption {
|
||||||
description = "C# LSP server to use";
|
description = "C# LSP server to use";
|
||||||
type = listOf (enum servers);
|
type = listOf (enumWithRename
|
||||||
|
"vim.languages.csharp.lsp.servers"
|
||||||
|
servers {
|
||||||
|
roslyn_ls = "roslyn-ls";
|
||||||
|
});
|
||||||
default = defaultServers;
|
default = defaultServers;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -111,12 +161,15 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(mkIf cfg.extensions.roslyn-nvim.enable {
|
(mkIf (cfg.lsp.enable
|
||||||
vim = mkMerge [
|
&& cfg.extensions.roslyn-nvim.enable
|
||||||
{
|
&& (elem "roslyn-ls" cfg.lsp.servers)) {
|
||||||
|
vim = {
|
||||||
startPlugins = ["roslyn-nvim"];
|
startPlugins = ["roslyn-nvim"];
|
||||||
}
|
pluginRC.roslyn-nvim = entryAnywhere "require('roslyn').setup(${toLuaObject cfg.extensions.roslyn-nvim.setupOpts})";
|
||||||
];
|
lsp.servers.roslyn-ls.enable = false;
|
||||||
|
extraPackages = with pkgs; [roslyn-ls];
|
||||||
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2524,9 +2524,9 @@
|
||||||
},
|
},
|
||||||
"branch": "main",
|
"branch": "main",
|
||||||
"submodules": false,
|
"submodules": false,
|
||||||
"revision": "24f7c91ee5e09c63104deaab68f932620f25c24a",
|
"revision": "946e559db19bfc5c7bf8be524a9c1acfde8ffffe",
|
||||||
"url": "https://github.com/seblyng/roslyn.nvim/archive/24f7c91ee5e09c63104deaab68f932620f25c24a.tar.gz",
|
"url": "https://github.com/seblyng/roslyn.nvim/archive/946e559db19bfc5c7bf8be524a9c1acfde8ffffe.tar.gz",
|
||||||
"hash": "sha256-a/Slmkrz/4P/rfRhPa1W5kGV7joQNTN0Un7bbncCnk0="
|
"hash": "sha256-pkWZ9z2eLnaVUAjTaj1+AdgqR1GLY+RT6pxbpe50SOU="
|
||||||
},
|
},
|
||||||
"rtp-nvim": {
|
"rtp-nvim": {
|
||||||
"type": "Git",
|
"type": "Git",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue