Skip to content

Conversation

@CaueAnjos
Copy link

@CaueAnjos CaueAnjos commented Dec 10, 2025

It adds the roslyn-ls configuration and the roslyn-nvim plugin. Razor support works partially. The roslyn-nvim team announced that they now support Razor, but I think the version of roslyn-ls available in nixpkgs isn’t up to date. Because of that, Razor files may still produce errors. Aside from this, everything works fine.

This PR should fix #1268

Sanity Checking

  • I have updated the changelog as per my changes
  • I have tested, and self-reviewed my code
  • My changes fit guidelines found in hacking nvf
  • Style and consistency
    • I ran Alejandra to format my code (nix fmt)
    • My code conforms to the editorconfig configuration of the project
    • My changes are consistent with the rest of the codebase
  • If new changes are particularly complex:
    • My code includes comments in particularly complex areas
    • I have added a section in the manual
    • (For breaking changes) I have included a migration guide
  • Package(s) built:
    • .#nix (default package)
    • .#maximal
    • .#docs-html (manual, must build)
    • .#docs-linkcheck (optional, please build if adding links)
  • Tested on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin

@github-actions
Copy link

github-actions bot commented Dec 10, 2025

🚀 Live preview deployed from 4555319

View it here:

Debug Information

Triggered by: CaueAnjos

HEAD at: feat/roslyn-ls

Reruns: 1747

@NotAShelf
Copy link
Owner

Could you target the v0.8 branch? The LSP experience was mostly overhauled and improved, so this PR will likely benefit from the new API.

@CaueAnjos CaueAnjos changed the base branch from main to v0.8 December 11, 2025 13:01
@CaueAnjos
Copy link
Author

I've noticed a lot has changed. I’m working on it! 😁

@Soliprem
Copy link
Collaborator

we merged 0.8 into main! So you can target main directly, now (sorry for the double switch)

@CaueAnjos CaueAnjos changed the base branch from v0.8 to main December 12, 2025 19:16
github-actions bot pushed a commit that referenced this pull request Dec 13, 2025
@CaueAnjos
Copy link
Author

I figured it out! It wasn't a roslyn-ls version problem. Razor wasn't working correctly because the .razorExtension wasn't being mapped. Now everything works perfectly.

github-actions bot pushed a commit that referenced this pull request Dec 13, 2025
github-actions bot pushed a commit that referenced this pull request Dec 13, 2025
@poseidon-rises
Copy link
Contributor

I actually added roslyn-ls in v8.0 already, you should be able to use it now that's pulled into main.

@CaueAnjos
Copy link
Author

I actually added roslyn-ls in v8.0 already, you should be able to use it now that's pulled into main.

I noticed. It’s a pretty good implementation. I’ve just added Razor support. Your implementation doesn’t have that, and I need it for Blazor projects.

@CaueAnjos CaueAnjos changed the title languages/csharp: add roslyn-ls support languages/csharp: add razor support Dec 17, 2025
github-actions bot pushed a commit that referenced this pull request Dec 18, 2025
Copy link
Collaborator

@horriblename horriblename left a comment

Choose a reason for hiding this comment

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

Thanks, but overall, I think we should wait for the nixpkgs PR to land first before adding razor support (see my other comments)

(mkIf (cfg.lsp.enable && lib.elem "roslyn" cfg.lsp.servers) {
vim.luaConfigRC.roslyn-path = ''
-- NOTE: this is required by roslyn-nvim to find roslyn
vim.env.PATH = vim.env.PATH .. ":${pkgs.roslyn-ls}/bin"
Copy link
Collaborator

@horriblename horriblename Dec 19, 2025

Choose a reason for hiding this comment

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

  1. add the package to vim.extraPackages instead
    2. the package needs to be overridable somehow, preferably with vim.lsp.servers.roslyn.cmd, or if it's really not doable, add an option vim.languages.csharp.lsp.package (this deviates from our usual pattern so an appropriate warning in case cmd is used would be appreciated) doesn't really apply if we wait for the nixpkgs PR

Comment on lines 187 to 198
vim.env.MASON = vim.fn.expand("~/.local/share/nvf/mason")
local expanded_mason = vim.fn.expand("$MASON")
local mason = expanded_mason == "$MASON"
and vim.fs.joinpath(vim.fn.stdpath("data"), "mason")
or expanded_mason
local mason_packages = vim.fs.joinpath(mason, "packages")
-- Define target paths
local targets = {
vim.fs.joinpath(mason_packages, "roslyn", "libexec", ".razorExtension"),
vim.fs.joinpath(mason_packages, "roslyn-unstable", "libexec", ".razorExtension"),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

use vim.fn.stdpath("data") .. "/mason" instead of hard-coding ~/.local/share

I don't really like this approach overall. I would rather wait until https://github.com/NixOS/nixpkgs/issues/472357 is merged. Will probably need to patch out the warning in roslyn-nvim unless they start supporting it themselves though

omnisharp = ["omnisharp-extended-lsp-nvim"];
csharp_ls = ["csharpls-extended-lsp-nvim"];
roslyn_ls = [];
roslyn = ["roslyn-nvim"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is technically a breaking change, a warning about removal of "roslyn_ls" in lsp.servers would be nice

github-actions bot pushed a commit that referenced this pull request Dec 22, 2025
github-actions bot pushed a commit that referenced this pull request Dec 23, 2025
It adds roslyn-ls configuration and roslyn-nvim plugin
github-actions bot pushed a commit that referenced this pull request Dec 23, 2025
@CaueAnjos
Copy link
Author

CaueAnjos commented Dec 23, 2025

I don't really like this approach overall. I would rather wait until https://github.com/NixOS/nixpkgs/issues/472357 is merged. Will probably need to patch out the warning in roslyn-nvim unless they start supporting it themselves though

I’ve rethought the symlink approach, and I now believe this solution is more reproducible and, overall, more stable.
The code is also prepared for the future .razorExtension bundled with roslyn-ls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roslyn-ls and rz-ls for csharp

5 participants