vetur icon indicating copy to clipboard operation
vetur copied to clipboard

vls doesn't work with monaco-languageclient.

Open FoxDaxian opened this issue 2 years ago • 11 comments

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ
  • [x] 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 avatar Apr 11 '22 06:04 FoxDaxian

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();
    }
};

FoxDaxian avatar Apr 12 '22 09:04 FoxDaxian

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.

phil294 avatar Apr 12 '22 11:04 phil294

@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 avatar Apr 12 '22 11:04 FoxDaxian

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

FoxDaxian avatar Apr 17 '22 08:04 FoxDaxian

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 avatar Apr 18 '22 08:04 FoxDaxian

here is the repo about thi question: repo

FoxDaxian avatar Apr 18 '22 12:04 FoxDaxian

here is related issue

FoxDaxian avatar Apr 19 '22 09:04 FoxDaxian

anybody? help~

@HerringtonDarkholme @yoyo930021 sorry to disturb~ 🙏🏻

FoxDaxian avatar Apr 19 '22 10:04 FoxDaxian

@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.

redbullmarky avatar Apr 28 '22 08:04 redbullmarky

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

FoxDaxian avatar May 02 '22 14:05 FoxDaxian

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.

yoyo930021 avatar Oct 04 '22 12:10 yoyo930021