Skip to content

plugins/roslyn: init #3166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KennethHoff
Copy link

No description provided.

@KennethHoff KennethHoff mentioned this pull request Apr 7, 2025
@KennethHoff KennethHoff force-pushed the roslyn-nvim branch 2 times, most recently from 43139f2 to f27337f Compare April 7, 2025 18:04
@KennethHoff KennethHoff changed the title plugins/roslyn: init plugins/roslyn-nvim: init Apr 7, 2025
@KennethHoff KennethHoff changed the title plugins/roslyn-nvim: init plugins/roslyn: init Apr 7, 2025
Comment on lines 13 to 14
-- roslyn-ls adds this command
exe = 'Microsoft.CodeAnalysis.LanguageServer'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @GaetanLepage said, we don't normally set defaults for setup() options.

It can be done with the plugins.roslyn.settings option if needed, but usually such auto-config would be gated behind a non-settings option (e.g. plugins.roslyn.configureLsp).

Again, for enablign the language server: this isn't normally done by nixvim plugins, however there are a handful of exceptions. Unless it was essentially a requirement and it never makes sense to have the plugin without the lsp, we would usually want this gated behind a non-settings option.

FYI: when working with language servers in nixvim, you typically use the plugins.lsp and plugins.lsp.servers.* options.

Having the non-settings toggle option allows users to enable/disable our custom stuff if they'd rather do it themselves a different way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It absolutely does not make sense for this plugin to exist without the LSP. The only thing the plugin does besides adding the LSP is adding a few commands to stop, restart, and configure the LSP server.

Comment on lines 11 to 14
extraConfigLua = ''
require('roslyn').setup({
-- roslyn-ls adds this command
exe = 'Microsoft.CodeAnalysis.LanguageServer'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @GaetanLepage said, we don't normally set defaults for setup() options.

It can be done with the plugins.roslyn.settings option if needed, but usually such auto-config would be gated behind a non-settings option (e.g. plugins.roslyn.configureLsp).

Again, for enablign the language server: this isn't normally done by nixvim plugins, however there are a handful of exceptions. Unless it was essentially a requirement and it never makes sense to have the plugin without the lsp, we would usually want this gated behind a non-settings option.

FYI: when working with language servers in nixvim, you typically use the plugins.lsp and plugins.lsp.servers.* options.

Having the non-settings toggle option allows users to enable/disable our custom stuff if they'd rather do it themselves a different way.


Finally, this call to setup is automatically done by mkNeovimPlugin. It converts settings from nix to lua, and calls require('roslyn').setup(settings).

Suggested change
extraConfigLua = ''
require('roslyn').setup({
-- roslyn-ls adds this command
exe = 'Microsoft.CodeAnalysis.LanguageServer'

Comment on lines 19 to 14
# TODO: Figure out how to add this package.
# home.packages = [ pkgs.roslyn-ls ];
Copy link
Member

@MattSturgeon MattSturgeon Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is a language server, what we probably want is to enable plugins.lsp.servers.roslyn.enable. However, this option doesn't seem to exist.

Our lsp server options are generated from nvim-lspconfig, so perhaps the language server is not part of that project yet?


Once there is a plugins.lsp.servers.roslyn.enable option, we'd either want some kinda warning when it should be enabled but isn't, or we'd want some non-settings option that when enabled will enable the LSP automatically. Typically, we use warnings and assume the end-user is capable of configuring plugins.lsp themselves.

Copy link
Author

@KennethHoff KennethHoff Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roslyn-nvim is essentially a language server with a few extra options, because Roslyn is very complex. It effectively supercedes the csharp_ls LSP.

The following is the summary on the Roslyn.nvim repo

This is an actively maintained & upgraded fork that interacts with the improved & open-source C# Roslyn language server, meant to replace the old and discontinued OmniSharp. This language server is currently used in the Visual Studio Code C# Extension, which is shipped with the standard C# Dev Kit.

This standalone plugin was necessary because Roslyn uses a non-standard method of initializing communication with the client and requires additional custom integrations, unlike typical LSP setups in Neovim.

I believe that this plugin ideally would be lsp.servers.roslyn.enable. Would that be possible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This standalone plugin was necessary because Roslyn uses a non-standard method of initializing communication with the client and requires additional custom integrations, unlike typical LSP setups in Neovim.

Ah interesting. So if I'm understanding correctly, the roslyn-nvim plugin exists as an alternative to nvim-lspconfig for setting up and configuring the language server?

I'm curious if the plugin does anything else and whether it is useful at all when the language server isn't installed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said here, I believe this plugin is essentially noop without the LSP

packPathName = "roslyn.nvim";
package = "roslyn-nvim";

maintainers = [ lib.maintainers.GaetanLepage ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not adding yourself as the maintainer?

Comment on lines +13 to +14
# TODO: Figure out how to add this package, as it's the source of the `Microsoft.CodeAnalysis.LanguageServer` command, which is required for the LSP to function
# home.packages = [ pkgs.roslyn-ls ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unfamiliar with this LS, so I don't know if it is better to contribute to nvim-lspconfig (so that our plugins.lsp.servers options can be used) or to assume all configuration will be done by this plugin separately from nvim-lspconfig.

If the LS can't really be configured by nvim-lspconfig, the next best thing would be to use our new dependencies options.

To do this, you would edit modules/dependencies.nix, and add "roslyn-ls" to the list. Then you would edit extraConfig here, and define dependencies.roslyn-ls.enable = lib.mkDefault true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants