Comments (15)
I also found the JSONContribution which seems interesting also in my case, but could not find a way to register my own.
from monaco-editor.
@aeschli will know
from monaco-editor.
Oh, but first we'd need to ship a new monaco-editor
that contains the now extracted monaco-json
.
from monaco-editor.
The JSON plugin has an API that lets you add schemas (and schema associations).
Check out https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts
from monaco-editor.
@aeschli I don't think we've shipped an editor version that contains the json language as a plugin yet
from monaco-editor.
up ?
I also cannot see the JsonContribution interface in https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts. Any chance to see it appearing ?
from monaco-editor.
Yes, I made the update.
Check out https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-json-defaults
from monaco-editor.
Thanks, this is one part of the solution. The other part would be to have the posibility to apply the schema based on a file pattern (eg. package.json files).
from monaco-editor.
Use the fileMatch property for that...
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
schemas: [{
uri: "http://myserver/foo-schema.json",
fileMatch: [ 'foo.json' ],
schema: {
type: "object",
properties: {
p1: {
enum: [ "v1", "v2"]
},
p2: {
$ref: "http://myserver/bar-schema.json"
}
}
}
},{
uri: "http://myserver/bar-schema.json",
schema: {
type: "object",
properties: {
q1: {
enum: [ "x1", "x2"]
}
}
}
}]
});
monaco.editor.create(document.getElementById("container"), {
model: monaco.editor.createModel("{\n}\n", 'json', "inmemory://inmemory/foo.json")
});
from monaco-editor.
great ! 👍
Is it possible also to have custom values for intellisense (like dependencies in package.json files) ?
from monaco-editor.
I added https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example to show how to add custom completions.
from monaco-editor.
awesome.
Thanks a lot.
from monaco-editor.
One question though, wouldn't it be cleaner to expose the Jsoncontribution interface and a way to add customs ?
It just looked better to my eyes as the retrieval of the current "node" is done in background.
from monaco-editor.
That's not so easy as the JSON language service runs in a web worker. Your contribution would have to be bundled as part of this web worker.
Sure possible to do, the parts are all there.
from monaco-editor.
I have tried fileMatch but useless..
from monaco-editor.
Related Issues (20)
- Can I use the latest version 0.50.0 in Vue2
- Character input causes line jumps in certain cases
- [Bug] Setting custom link provider doesn't remove the embedded one HOT 1
- How to listen for TypeScriptWorker errors when executing getEmitOutput
- [Question][Feature Request] Add ability to go from standalone editor into a diff editor
- [Bug] Incorrect CSS causes repaint with every caret blink
- [Feature Request] Align `alwaysConsumeMouseWheel` Behavior with Native textarea Scrolling
- [Question][Feature Request] is there any way to add the DAP to the monaco editor
- [Bug] new support for Python f-strings breaks with multi-line f-strings
- [Bug] Chinese input causes the line to jump abnormally
- [Feature Request] Make close icon for the details suggestions view button
- [Feature Request] How to make the autocomplete distinguish between uppercase and lowercase
- [Bug]
- Diff editor - highlight same lines
- [Feature Request]
- [Feature Request] Remove vertical scrollbar and corresponding space
- [Bug] Error: InstantiationService has been disposed
- [Bug] Error: The parameters in nameBuiltin from elixir.js are globally replaced, causing compilation errors. HOT 1
- [Feature Request] monaco-esbuild-plugin
- [Bug] Vite5+electron+monaco, load ts worker exception: Editor.vue:34 Uncaught TypeError: require2 is not a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monaco-editor.