seblj / roslyn.nvim

Roslyn LSP plugin for neovim
MIT License
107 stars 10 forks source link

Support otter.nvim #40

Closed SchnozzleCat closed 3 days ago

SchnozzleCat commented 2 weeks ago

I think it would be neat if the plugin could interact with otter.nvim, a plugin that launches language servers in hidden buffers for each codeblock it finds, so that those code blocks have full access to all LSP features.

While the roslyn LS seems to start fine (as long as the working directory has either a csproj or sln file), it immediately stops with return code 0. I tried debugging it a bit but I'm far from an expert on the neovim LSP API.

This would be especially useful with the jupyter kernel for dotnet to have the language server available inside notebooks. While still usable without LSP support, having code completion and the like is always nice I think.

Here's a quick demo of the issue with the plugin and jupyter kernel usage in action:

https://github.com/user-attachments/assets/ac51171a-b4a5-48db-a87e-71f8a1750c7c

seblj commented 2 weeks ago

Are you able to something similar in vscode? By that I mean, are you able to extract a snippet manually and have the language server attach to that file both with and without a csproj or sln file?

If that works, then I could look into it, because then I would assume there is some configuration I could do, or having some single file support or something.

If that doesn't work, then I would not implement a major hack for this

seblj commented 2 weeks ago

So it does not look like vscode support single file for roslyn (might be impossible with roslyn). However, you might probably work around this by just adding a .csproj like you are trying.

Do you have a minimal project where I can try it out myself and see if I can figure out why it is crashing?

SchnozzleCat commented 1 week ago

I looked into this a bit more, and the issue seems to stem from the fact that it is only a buffer, and not an actual file. Enabling buffers.write_to_disk in otter.nvim seems to fix the issue.

While having the buffers show up in the bufline is somewhat annoying, it's by no means a deal breaker.

I'm not sure if the issue stems from this plugin or the language server (not supporting file-less buffers), so feel free to close this if it is not relevant for the project.

Here's a demo of it working in action (this also demonstrates what otter.nvim actually does under the hood):

https://github.com/user-attachments/assets/72a9a316-bb87-4e35-8235-7df46042e16a

SchnozzleCat commented 1 week ago

After playing around with it a bit more it is somewhat inconsistent.

I think its a timing issue between otter.nvim creating the file, and the roslyn server being launched. If the file is created too slowly the server will stop again.

Interestingly, switching to the LSP buffer that otter creates starts the server again and it works.

Maybe something like what was mentioned here would also fix this (the server running even without a file)?

seblj commented 1 week ago

Hmm, I think I need to look into the LPS logs to see what is happening. Ideally it would be cool to run in a single file mode without sln or csproj, but it seems like the server doesn't support that.

I can try to install otter.nvim when I have some time, and see if I can figure out what happens

seblj commented 3 days ago

I tried to install it and just activate it, and I have tried it very minimal, and it seems to work okay for me for autocompletion and such. I couldn't get diagnostics, but that is probably because I am doing something a bit hacky to make them appear normally.

So I don't think there is much more to do for me here, so I am going to close this