-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Visual Studio integration #8729
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
Comments
I have a VS extension that adds support for building and debugging cargo projects (Open Folder Extension), but obviously, this is not enough and we need good editor integration. The main problem with VS is that its implementation of the LSP client is not Language Server Protocol Specification compliant. Initially, I decided to reimplement the client part but turned out I do not have enough time. So now I just check each new VS build and hope sometime VS LSP client will work as it should. |
@vsrs Could you write more about what's wrong with VS implementation of LSP client? Is there a list of issues somewhere? |
@vsrs could you elaborate on what issues you noticed with the VS implementation of the LSP protocol? |
Some comments from the specification side: to support the evolution of enumerations a consuming side of an enumeration (usually a server) shouldn't fail on unknown values. If a server does a newer client could never use an older server although the server would still work perfectly fine with the client. I added some clarification around this to the specification. |
I don't know remember how I noticed it so feel free to ignore me, but I vaguely recall noticing that Visual Studio was using a draft version of the semantic tokens spec, and was incompatible with standard servers. |
Good call, we indeed handle enum in a suboptimal way, filed gluon-lang/lsp-types#213 for that. Would be so much easier to fix with microsoft/language-server-protocol#67 (comment) ;) |
Agree :-) |
Hi Everybody, Visual Studio 2022 RC released today has an LSP implementation that is compatible with rust-analyzer. In order to make rust-analyzer work, I had to make changes to two enums in the lsp/types repo: Quick and dirty fix to enums that are not compatible with Visual Studio. The features I tested, seem to work fine without requiring any other change to rust-analyzer. You may want to suppress these notifications though as they are very intrusive in VS: You can also consider supporting some of the LSP functionalities specific to Visual Studio for which a specification was recently released. Feel free to get in touch with me if you need any clarification. Matteo Screeshots of rust-analyzer in Visual Studio 2022 RC. |
Great news, thanks! |
Looks great! Someone (TM) will take care of gluon-lang/lsp-types#213 soon.
Fortunately, those are only shown by from-source builds. |
10551: Pull in new lsp-types for VS compat r=lnicola a=lnicola CC #8729 Depends on gluon-lang/lsp-types#218 Co-authored-by: Laurențiu Nicola <[email protected]>
@matteo-prosperi I somehow managed to miss your comment 😅 The integration looks amazing and really usable! Could you maybe share what you did to get rust-analyzer working in Visual Studio? |
@clemenswasser, what I did was only a test integration. I basically followed the guide here. [ContentType("rs")]
[Export(typeof(ILanguageClient))]
public class RustLanguageClient : ILanguageClient
{
public async Task<Connection> ActivateAsync(CancellationToken token)
{
await Task.Yield();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"rust-analyzer.exe");
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = info;
if (process.Start())
{
return new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
}
return null;
} which is almost identical to the code from the guide. I decided to package my own copy of |
@matteo-prosperi is it possible that you could share your extension? |
At some point we will probably move the Code extension out of this repository (although there are some technical reasons that make it non-trivial). |
@clemenswasser, I copied my proof of concept code here. I just built it and tested it on VS 2022 17.0.4 and it works fine. |
@matteo-prosperi It looks great! |
There is now a Visual Studio extension for RA (#14012), closing. |
@Hau-Hau @matteo-prosperi @clemenswasser @vsrs @dbaeumer @matklad @crlf0710 here it is https://marketplace.visualstudio.com/items?itemName=kitamstudios.RustAnalyzer&ssr=false#overview For now the following are functional - please feel free to use it or even better, help me out
Coming up shortly: examples integration, clippy/fmt, unit testing etc. |
Description
This issue serves as a meta-issue, where we can discuss and inform each other about the integration of rust-analyzer and Visual Studio. Visual Studio support was brought up by @vsrs and @deeprobin in #5516 and #7369.
Resources
Add a Language Server Protocol extension (Microsoft Docs)
Since @vsrs wrote that he is working on a Visual Studio Extension that integrates rust-analyzer into Visual Studio here, it would be great to hear from you, what the current status is, how we could collaborate on this and what is missing to make this usable.
The text was updated successfully, but these errors were encountered: