Monaco-editor: Intellisense for mixed languages ?

Created on 9 Jul 2016  路  14Comments  路  Source: microsoft/monaco-editor

Hi,
i saw a few issues about having multiple languages in the same document but they're all open or went dark.

However, I am wondering Monaco will support this one day in the near future, at least for having JS/CSS in HTML/PHP?

thanks a lot.

feature-request monaco-html

Most helpful comment

The embedded document region support which makes mixed-mode possible for HTML currently lives in the html-language-features extension within the vscode project. You can see how the autocomplete calls out to the JS, CSS, and HTML autocompleters here (and where these autocompleters are registered here).

What's the feasibility of moving this VSCode specific functionality to the vscode-html-languageservice project where Monaco users could benefit from it?

Alternatively, is there any way to directly use the html-language-features extension from Monaco itself?

All 14 comments

I have made a hack that fixes my current needs using the model.getModeIdAtPosition - but this function is not in the monaco.d.ts - so i spose it is not an official API function (will it be?). Function model.getLineTokens is also "hidden".

provideCompletionItems(model: monaco.editor.IReadOnlyModel, position: monaco.Position, token: monaco.CancellationToken): monaco.Thenable<monaco.languages.CompletionList> {
        let temp = model as any;
        /// Using unofficial API
        let mode = temp.getModeIdAtPosition(position.lineNumber, position.column);
        ...

Would be great if the completion provider automatically resolved the provider from the current mode/language - since sub-modes are fine supported by Monarch (token: 'blah', bracket: '@open', next: '@xx_block', nextEmbedded: 'xx' etc.)

Hey "AndersMad" (cool name btw!). that looks promising!
greets and thanks a lot

Resurrecting this as it's basically what I'm looking for. Mixed-html mode is already working in Visual Studio Code (i.e., you can edit and auto-complete CSS and JavaScript from within HTML files). This doesn't appear to work in the HTML Monaco Editor though.

I'm assuming that whatever VS Code is doing for HTML files to make them work with mixed mode should be somehow possible in Monaco.

This issue then could be resolved by updating documentation or the examples to show a mixed-mode HTML example in https://microsoft.github.io/monaco-editor/playground.html

The embedded document region support which makes mixed-mode possible for HTML currently lives in the html-language-features extension within the vscode project. You can see how the autocomplete calls out to the JS, CSS, and HTML autocompleters here (and where these autocompleters are registered here).

What's the feasibility of moving this VSCode specific functionality to the vscode-html-languageservice project where Monaco users could benefit from it?

Alternatively, is there any way to directly use the html-language-features extension from Monaco itself?

This is exactly what I am looking for and it would be great if this could be a part of monaco instead of a vscode feature.

Any new developments for mixed mode in Monaco? We could really use this feature ...

+1

+1

+1

+1

wow 2020 from 2016 anyways...
+1

+1

+1
I need it for cshtml & jsp files

+1

Was this page helpful?
0 / 5 - 0 ratings