I have https://github.com/arnoson/monaco-lua-example right here, which is an example of connecting a language server to the monaco editor (mine is especially hosted by webview2.)
https://github.com/NightrainsRbx/RobloxLsp Is the language server fork which has the features I need, If you use the example above, it shows “Upgrade Required” so not really to do much here as a beginner.
I also know about monaco.languages.register and registerlanguageserver and similar stuff, but I'm not really sure how I would use it.
I tried this, this is not some good code you see and works pretty bad, when you do this and type something that creates an error on purpose in monaco editor, it doesn't respond.
string lspPath = Path.Combine(Environment.CurrentDirectory, "lsp", "server");
string exePath = Path.Combine(lspPath, "lua-language-server.exe");
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = exePath;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.RedirectStandardOutput = true;
string lspPath2 = Path.Combine(Environment.CurrentDirectory, "lsp");
string exePath2 = Path.Combine(lspPath2, "lsp-ws-proxy.exe");
ProcessStartInfo startInfo2 = new ProcessStartInfo();
startInfo2.CreateNoWindow = false;
startInfo2.UseShellExecute = false;
startInfo2.FileName = exePath2;
startInfo2.WindowStyle = ProcessWindowStyle.Hidden;
startInfo2.RedirectStandardOutput = true;
Process process2 = Process.Start(startInfo2);
using (Process process = Process.Start(startInfo))
{
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Debug.WriteLine(result);
}
}
webView.Source = new Uri(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"Rosploco\rosploco.html"));
// Inject a script into the WebView2 to register the Lua language server
string script = "monaco.languages.register({ id: 'roblox-lua' }).then(function () {"
" monaco.languages.setLanguageConfiguration('lua', {"
" comments: {"
" lineComment: '--',"
" blockComment: ['--[[', ']]']"
" },"
" brackets: [["
" ['{','}'],"
" ['[',']'],"
" ['(',')']"
" ]],"
" autoClosingPairs: ["
" { open: '{', close: '}' },"
" { open: '[', close: ']' },"
" { open: '(', close: ')' },"
" { open: '\"', close: '\"' },"
" { open: '\'', close: '\'' }"
" ],"
" surroundingPairs: ["
" { open: '{', close: '}' },"
" { open: '[', close: ']' },"
" { open: '(', close: ')' },"
" { open: '\"', close: '\"' },"
" { open: '\'', close: '\'' }"
" ],"
" folding: {"
" markers: {"
" start: new RegExp('^\\s*//\\s*#region\\b'),"
" end: new RegExp('^\\s*//\\s*#endregion\\b')"
" }"
" }"
" });"
"});";
webView.ExecuteScriptAsync(script);
Update
I had to do npm run dev
in monaco-lua-example and navigate to localhost:3000, now its working and it's properly connected but I still need the webview2 to connect to it.
CodePudding user response:
Nevermind i had to do npm run dev
in monaco-lua-example and navigate to localhost:3000.