0

服务器是可执行程序,它使用 stdio 作为传输。它的 repo https://github.com/PMunch/nimlsp 日志显示它有一个初始化通知和文本文档 didopen 通知,为什么它不能得到请求类型的消息?无论是悬停还是定义请求。

let args:string[] = ["/Users/bung/Nim"]
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
let options: ExecutableOptions = {
    cwd: folder.uri.fsPath,
    stdio: 'pipe',  //https://github.com/matarillo/vscode-languageserver-csharp-example/blob/master/client/src/extension.ts
    // env:{"PATH":"/Users/bung/.nimble/bin/"},
    env:process.env,
    detached: false,
    shell: false
}
console.log(serverModule)

const serverOptions: ServerOptions = {
    run:{command:serverModule,args:args,options:options},
    debug:{command:serverModule,args:args,options:options}
}

// Options to control the language client
let clientOptions: LanguageClientOptions = {
    // Register the server for plain text documents
    documentSelector: [{ language: 'nim', scheme: 'file' }],
    diagnosticCollectionName: "nim",
    synchronize: {
        // Notify the server about file changes to '.clientrc files contained in the workspace
        fileEvents: workspace.createFileSystemWatcher('{**/*.nim,**/.nimble}')
    },
    workspaceFolder:folder
};

// Create the language client and start the client.
client = new LanguageClient(
    'nim',
    'nim',
    serverOptions,
    clientOptions,
    // true
);
client.trace = Trace.Verbose;

client.onDidChangeState( (e) => {
    console.log(e)
})



client.onReady().then(() => {
    // client.registerProposedFeatures()
    client.onNotification(DidOpenTextDocumentNotification.type,x =>{
        console.log(x)
    })

    client.onRequest(HoverRequest.type.method,x =>{
        console.log(x)
    })

    console.log(client.initializeResult)
    // client.onRequest( "textDocument/definition", (_,p) => {
    //  console.log(p)
    // } )
})

// Start the client. This will also launch the server
context.subscriptions.push(client.start());
4

1 回答 1

0

嗯,最后我发现问题出在 nimlsp 方面,它有一个错误导致无限循环,这就是它无法获取请求的原因。请参阅https://github.com/PMunch/nimlsp/issues/19

于 2019-02-11T01:32:46.897 回答