Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vls doesn't work with monaco-languageclient. #3401

Open
4 tasks done
FoxDaxian opened this issue Apr 11, 2022 · 11 comments
Open
4 tasks done

vls doesn't work with monaco-languageclient. #3401

FoxDaxian opened this issue Apr 11, 2022 · 11 comments
Labels

Comments

@FoxDaxian
Copy link
Contributor

FoxDaxian commented Apr 11, 2022

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ
  • I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: macOS
  • vls version: 0.7.6
  • VS Code version: none

Problem

I changed json to vue of node demo of monaco-languageclient as below:

import * as vls from "vls";
export function start(reader: MessageReader, writer: MessageWriter) {
    const connection = createConnection(reader, writer);
    new vls.VLS(connection);
    _vls.listen();
}

But it is not work after those change.
image

So how to connect monaco-editor with vls?

Any answer would be greatly appreciated. thank you!

Reproducible Case

As above.

@FoxDaxian
Copy link
Contributor Author

Whether to support worker like this:

import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';

import vueWorker from 'vls/vue.worker';  <--- here

self.MonacoEnvironment = {
    getWorker(_: any, label: string) {
        console.log(label, '==label');
        if (label === 'json') {
            return new jsonWorker();
        }
        if (label === 'vue') {     <---- and here
           return new vueWorker();
        }
        if (label === 'html' || label === 'handlebars' || label === 'razor') {
            return new htmlWorker();
        }
        return new editorWorker();
    }
};

@phil294
Copy link
Contributor

phil294 commented Apr 12, 2022

what errors are you seeing? Vetur has several ways to log and debug attach to lsp server. If the initialization process fails, either monaco or vetur will tell you about it afaik.

@FoxDaxian
Copy link
Contributor Author

@phil294 thank you for reply

There is no error when run server. looks like as below:
image

And code like this:

connection.onInitialize(async (params) => {
        await _vls.init(params);

        console.log("Vetur initialized =====");

        return {
            capabilities: _vls.capabilities,
        };
});

@FoxDaxian
Copy link
Contributor Author

@phil294
Sorry to disturb~
this is the lastest process: discussions

@FoxDaxian
Copy link
Contributor Author

I found textDocument/didOpen event get wrong params like:

{
  jsonrpc: '2.0',
  method: 'textDocument/didOpen',
  params: {
    textDocument: {
      uri: 'inmemory://model/1', <----- I think this is incorrect uri
      languageId: 'vue',
      version: 1,
      text: ''
    }
  }
}

I'm not pass default value for monaco-editor, so it is no content by default. and the uri of textDocument looks like the source code stored in the memory?

how to resolve this problem? thanks~

@FoxDaxian
Copy link
Contributor Author

here is the repo about thi question: repo

@FoxDaxian
Copy link
Contributor Author

here is related issue

@FoxDaxian
Copy link
Contributor Author

anybody? help~

@HerringtonDarkholme @yoyo930021 sorry to disturb~ 🙏🏻

@redbullmarky
Copy link

@FoxDaxian

i used https://github.com/wylieconlon/jsonrpc-ws-proxy and, with a couple of configuration bits inside of the client.ts, had it up and running (syntax, suggestions, etc). Only syntax highlighting to go.

the workspaceFolder inside of the clientOptions (in client.js), i set it to the folder where the server's files live.

This article was invaluable: https://medium.com/dscddu/language-server-protocol-adding-support-for-multiple-language-servers-to-monaco-editor-a3c35e42a98d

i can't pretend to know exactly how it's working as yet, because documentation on some of these things is very slim and right now it's just about getting it working - the end target is Volar, but that doesn't seem to integrate in the same way :-p

Good luck.

@FoxDaxian
Copy link
Contributor Author

@redbullmarky
thanks for reply very much. 😊
and i'll try this way what you mention.
and wish me luck. 😭

@yoyo930021
Copy link
Member

The vetur can't work well in environments other than nodejs.

Vetur is based on typescript language service.
The typescript language service can't work well for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants