Closed Kingwl closed 1 year ago
Can we add a shortcut to format code? (using Prettier?)
Alternatively, to make it easier::
import { MonacoRepl, CodemirrorRepl } from '@vue/repl'
Adapt volar into monaco.
/cc: @johnsoncodehk I'm mot familiar enough with volar, hope to get some comments.
@Justineo Might be interested in this too.
Cool! Thanks @johnsoncodehk !
I'd like to extrace the monaco impl to avoid default monaco editor implementation soon.
I implemented the part related to the Volar Language Service, I'm not familiar with the monaco part, so I'll leave it to you.
Issues have to resolve:
@vue/reactivity/dist/reactivity.d.ts
with Go to definition, you may need to provide them to monaco.workspace.applyEdit
through monaco for now.Feel free to ask me if there still have any problem about the Volar part, good luck. :)
Edit: I missed auto insertion features like auto close tag, will add it later.
Updated as webworker. But some questions here:
take over mode
can handle TypeScript and JavaScript files. Are there any possible to enable take over mode in monaco?
- Don't know where can we add the auto insert features. The worker seems cannot access editor directly.
Yes it can't access editor directly, you need to custom request listener to receive and response auto insert request. See:
- In my memory
take over mode
can handle TypeScript and JavaScript files. Are there any possible to enable take over mode in monaco?
It do not need special config in language server, just feed any project's .ts / .js files to language service apis, Volar can handle it if you have provide these files by language service host.
@yyx990803 @johnsoncodehk
How about just leave the monaco out of the repl.
The repl only support the editor props. And we can provide monaco editor in another package like: vue-repl-monaco-editor
.
@Kingwl I'm open to that
Be aware that from what I've heard Monaco doesn't work on mobile devices.
Maybe CodeMirror 6 ought to be considered?
The Monaco editor is not supported in mobile browsers or mobile web frameworks.
I just move Monaco related modules to peerDependencies
for this PR, for users who need to use Monaco editor, all related modules should list in package.json.
{
"dependencies": {
"@vue/repl": "1.3.2",
"@volar/monaco": "1.3.0-alpha.3-patch.2",
"@volar/vue-language-service": "1.2.2-alpha.0",
"monaco-editor-core": "^0.36.1",
"monaco-editor-textmate": "^4.0.0",
"monaco-textmate": "^3.0.1",
"monaco-volar": "^0.1.1",
"onigasm": "^2.2.5",
// ...
}
}
The advantage of this is to avoid over-designing now, even if we want to move the Monaco integration out of the repo, or use monorepo in the future, it is easy to migrate.
This makes the embed a lot larger - ideally, we want it to be swappable:
An editor implementation is required so that we can treeshake the one that is not used - this will be a breaking change and we can release 2.0 for that.