microsoft / monaco-editor

A browser based code editor
https://microsoft.github.io/monaco-editor/
MIT License
40.39k stars 3.6k forks source link

Lua script parsing - need Monaco Editor expert. #2554

Closed mherbold closed 1 year ago

mherbold commented 3 years ago

I've looked high and low for a public discussion forum for Monaco editor and there are none. This is literally the only place anyone can ask any questions about the Monaco editor, or to try and find some help. So here goes...

We are building a web-based Lua script editor, obviously using the Monaco editor. It is working great.

Now we are at the point where we want to try to have the Monaco editor recognize variables for auto-completion, with those variables being assigned to by custom Lua library functions.

For example -

local foo = ourLibrary.SomeFunction( "A" )

We want the editor to recognize that "foo" will be assigned a variable of a known type ("A") - the type details can be found by an AJAX call to our service. This is so that the editor can bring up some nice autocomplete when typing "foo" later in the code.

So, we are looking to find a Monaco editor expert that can help us with this. This expert will be paid for their work. Contact me via marvin dot herbold at usked dot com.

If there is a better place to post this request for help, please point it out to me. I've Googled hard, and its like the Monaco editor is some secret in the dark corner of the web that no one knows about.

rcjsuen commented 3 years ago

For example -

local foo = ourLibrary.SomeFunction( "A" )

We want the editor to recognize that "foo" will be assigned a variable of a known type ("A") - the type details can be found by an AJAX call to our service. This is so that the editor can bring up some nice autocomplete when typing "foo" later in the code.

@mherbold Have you already integrated a Lua script parser so that a proper syntax tree is built and you know what node you're on? That sounds like a hurdle that you will eventually need to cross.

Alternatively, you could consider integrating with a Lua language server instead.

mherbold commented 3 years ago

We haven't yet gone either way. Do you have experience integrating language servers into this editor? We would also need the editor to recognize and perform intellisense for types that are not defined within the lua script, but rather returned via custom libraries hooked up to lua. I'm supposing that it would be possible for Monaco to do Ajax queries to our service, which has all the info on these types.

On Tue, Jun 29, 2021, 1:51 PM Remy Suen @.***> wrote:

For example -

local foo = ourLibrary.SomeFunction( "A" )

We want the editor to recognize that "foo" will be assigned a variable of a known type ("A") - the type details can be found by an AJAX call to our service. This is so that the editor can bring up some nice autocomplete when typing "foo" later in the code.

@mherbold https://github.com/mherbold Have you already integrated a Lua script parser so that a proper syntax tree is built and you know what node you're on? That sounds like a hurdle that you will eventually need to cross.

Alternatively, you could consider integrating with a Lua language server instead.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/monaco-editor/issues/2554#issuecomment-870908442, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7NH7N6VVYIPWMAXU6KQ3TVIW6NANCNFSM47QVOCMQ .

alexdima commented 3 years ago

@mherbold Here is a sample for how to participate in suggestions -- https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example

The editor has many APIs under the monaco.languages namespace that you can use to plug in different features to the UI. All of these APIs are written with a Promise return type, so you can do server requests or spawn a web worker and compute heavy things asynchronously, etc. This is used together with a cancellation token that you can listen on to cancel long running tasks when the UI no longer needs the results. (e.g. the user is not patient enough to wait for suggestions and presses Escape to close the widget).

rcjsuen commented 3 years ago

We haven't yet gone either way. Do you have experience integrating language servers into this editor?

You should take a look at the TypeFox/monaco-languageclient repository if you want to try integrating a language server into the Monaco Editor. I've played with it for testing purposes as I maintain a language server myself but haven't used it much beyond that...considering that my day job has nothing to do with this domain. :P