Skip to content

Commit 54ebe3b

Browse files
plugins/lsp: add omnisharp language server
Co-authored-by: garaiza-93 <57430880+garaiza-93@users.noreply.github.com>
1 parent f1aaef4 commit 54ebe3b

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

plugins/lsp/language-servers/default.nix

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,60 @@ with lib; let
377377
};
378378
};
379379
}
380+
{
381+
name = "omnisharp";
382+
description = "Enable omnisharp language server, for C#";
383+
package = pkgs.omnisharp-roslyn;
384+
cmd = cfg: ["${cfg.package}/bin/OmniSharp"];
385+
settings = cfg: {omnisharp = cfg;};
386+
settingsOptions = {
387+
enableEditorConfigSupport = helpers.defaultNullOpts.mkBool true ''
388+
Enables support for reading code style, naming convention and analyzer settings from
389+
`.editorconfig`.
390+
'';
391+
392+
enableMsBuildLoadProjectsOnDemand = helpers.defaultNullOpts.mkBool false ''
393+
If true, MSBuild project system will only load projects for files that were opened in the
394+
editor.
395+
This setting is useful for big C# codebases and allows for faster initialization of code
396+
navigation features only for projects that are relevant to code that is being edited.
397+
With this setting enabled OmniSharp may load fewer projects and may thus display
398+
incomplete reference lists for symbols.
399+
'';
400+
401+
enableRoslynAnalyzers = helpers.defaultNullOpts.mkBool false ''
402+
If true, MSBuild project system will only load projects for files that were opened in the
403+
editor.
404+
This setting is useful for big C# codebases and allows for faster initialization of code
405+
navigation features only for projects that are relevant to code that is being edited.
406+
With this setting enabled OmniSharp may load fewer projects and may thus display
407+
incomplete reference lists for symbols.
408+
'';
409+
410+
organizeImportsOnFormat = helpers.defaultNullOpts.mkBool false ''
411+
Specifies whether 'using' directives should be grouped and sorted during document
412+
formatting.
413+
'';
414+
415+
enableImportCompletion = helpers.defaultNullOpts.mkBool false ''
416+
Enables support for showing unimported types and unimported extension methods in
417+
completion lists.
418+
When committed, the appropriate using directive will be added at the top of the current
419+
file.
420+
This option can have a negative impact on initial completion responsiveness, particularly
421+
for the first few completion sessions after opening a solution.
422+
'';
423+
424+
sdkIncludePrereleases = helpers.defaultNullOpts.mkBool true ''
425+
Specifies whether to include preview versions of the .NET SDK when determining which
426+
version to use for project loading.
427+
'';
428+
429+
analyzeOpenDocumentsOnly = helpers.defaultNullOpts.mkBool true ''
430+
Only run analyzers against open files when 'enableRoslynAnalyzers' is true.
431+
'';
432+
};
433+
}
380434
{
381435
name = "pylsp";
382436
description = "Enable pylsp, for Python.";

tests/test-sources/plugins/lsp/nixd.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{pkgs}: {
1+
{
22
example = {
33
plugins.lsp = {
44
enable = true;

tests/test-sources/plugins/lsp/nvim-lsp.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
metals.enable = true;
9393
nil_ls.enable = true;
9494
nixd.enable = true;
95+
omnisharp.enable = true;
9596
pylsp.enable = true;
9697
pyright.enable = true;
9798
rnix-lsp.enable = true;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
defaults = {
3+
plugins.lsp = {
4+
enable = true;
5+
6+
servers.omnisharp = {
7+
enable = true;
8+
9+
settings = {
10+
enableEditorConfigSupport = true;
11+
enableMsBuildLoadProjectsOnDemand = false;
12+
enableRoslynAnalyzers = false;
13+
organizeImportsOnFormat = false;
14+
enableImportCompletion = false;
15+
sdkIncludePrereleases = true;
16+
analyzeOpenDocumentsOnly = true;
17+
};
18+
};
19+
};
20+
};
21+
}

0 commit comments

Comments
 (0)