Replies: 13 comments
-
I would say it might be better to just rewrite the symbol provider example given that it's not reflective of what is in the document at all. Perhaps it could be "improved" to clearly state that it is for a visual check of what the icons look like rather than an accurate representation of a correctly implemented symbol provider. 🤔 |
Beta Was this translation helpful? Give feedback.
-
@hawkerm Are you confused about any specific language feature provider? |
Beta Was this translation helpful? Give feedback.
-
@rcjsuen it's partly about understanding the features themselves (if they linked to any VS Code documentation on the feature for instance that could be helpful). I think a couple of places in the Monaco API docs do this, but not all. The playground is a nice way to explore the APIs, test them, and understand the mapping of all the parameters to their function in modifying behaviors of the editor. It makes it really easy to tweak values and see different outcomes. I've been writing a C# UWP wrapper, now used in a few apps, but it's difficult without a good sample of some features to translate them over and have a known test case to compare against. |
Beta Was this translation helpful? Give feedback.
-
@hawkerm Do you have a ranking of which providers you need samples for or do you not care and just want every provider to have a sample? |
Beta Was this translation helpful? Give feedback.
-
while the monaco editor playground shows a good provider example or two, there could be more. it would be especially nice to have an example that shows how to introduce a custom language service worker, that leverages the worker in the providers. in addition to one with amd, it would be nice to have an example of this using |
Beta Was this translation helpful? Give feedback.
-
@acao What are the advantages of using a language service worker? I don't use any workers in my Dockerfile editor but maybe that's because I don't have a complicated use case? |
Beta Was this translation helpful? Give feedback.
-
@rcjsuen I already have Color, CompletionItem, and Hover figured out, so I'd probably order the rest as:
I mean ideally every feature of the editor has some sort of sample or tie to the existing explanation of the VS Code editor docs (or both). Some of the gap is that from the docs I just don't have an idea of what the feature does as it describes the function with the function name itself. E.g.
So, I need to know what a "semantic tokens provider" does. So just linking to a document like this would be a big help. 😊 |
Beta Was this translation helpful? Give feedback.
-
@hawkerm This document may help if you haven't already seen it. |
Beta Was this translation helpful? Give feedback.
-
monaco-json may be a good example of a language implementation for Monaco. It lacks some of the features such as code actions and go-to-definition though. |
Beta Was this translation helpful? Give feedback.
-
This link should be in top menu of Monaco Editor site |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@redexp Yeah, it wouldn't hurt. I don't work for Microsoft though so I have no say here. You could try opening a pull request with your suggestion by modifying the
@hawkerm Your var editor = monaco.editor.create(document.getElementById("container"), {
value: "{\n\t\"dependencies\": {\n\t\t\"hello\": \"world\"\n\t}\n}\n",
language: "json"
});
var commandId = editor.addCommand(0, function () {
// services available in `ctx`
alert('my command is executing!');
}, '');
monaco.languages.registerCodeActionProvider('json', {
provideCodeActions: function (model, range, context, token) {
// Should have an if to see if we're in the right spot?
return {
actions: [
{
title: "This is a test action.",
kind: "quickfix",
command: {
id: commandId,
title: "A Command Here"
},
diagnostics: [
{
code: "2344",
message: "A warning",
severity: "Warning",
startLineNumber: 3,
startColumn: 1,
endLineNumber: 3,
endColumn: 12,
}
],
edit: {
edits: [
{
edit: {
text: "test text",
range: {
startLineNumber: 3,
startColumn: 1,
endLineNumber: 3,
endColumn: 12
}
},
// this was missing which made your edit
// unrecognizable, exception thrown
resource: editor.getModel().uri
}
]
}
}
],
dispose: () => {}
};
},
}); |
Beta Was this translation helpful? Give feedback.
-
Thanks @rcjsuen I thought I had still had that in there, seems to be working in Monaco Playground, though I'm on 21.3 still and having issues, so opening another bug. |
Beta Was this translation helpful? Give feedback.
-
Language providers are very powerful, but not all the ones supported in Monaco have examples in the Playground to show how to use them and how they work. Some of the existing samples provide a blank document, so it's unclear on what to do in order to see the key results.
It'd be great for more comments/information for each of the provider samples (like the symbol provider) be given as well as new samples for thinks like code actions, declaration, definition, documentHighlight, link, rename, onTypeFormattingEdit, etc...
Beta Was this translation helpful? Give feedback.
All reactions