Skip to content

Roslyn LSP化 + LSP Clientの実装 #14

Description

@WaTaiger

Roslyn LSP のランタイム向けパッケージは以下のように NuGet で提供されています:

Microsoft.CodeAnalysis.LanguageServer.win-x64(Windows 64bit)
※ MIT ライセンスで再配布可能(Roslyn 全体が MIT)。 [blog.logrocket.com]

このパッケージをプロジェクトへ追加することで、アプリの出力フォルダに Roslyn LSP の実行ファイルが含まれるように

AvalonEdit側のClientは
OmniSharp.Extensions.LanguageClient
で実装

string serverPath = Path.Combine(
    AppContext.BaseDirectory,
    "runtimes/win-x64/native/Microsoft.CodeAnalysis.LanguageServer.exe"
);

var psi = new ProcessStartInfo {
    FileName = serverPath,
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
    UseShellExecute = false
};

var proc = Process.Start(psi);

// LSP 接続(Content-Length JSON-RPC)
var handler = new HeaderDelimitedMessageHandler(
    proc.StandardOutput.BaseStream,
    proc.StandardInput.BaseStream
);

var rpc = new JsonRpc(handler);
rpc.StartListening();

// → initialize/didOpen/didChange/completion 等の LSP を送受信

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions