简体   繁体   中英

Run node script when VSCode extension is active

I'm developing a VSCode extension using LSP (Language Server Protocol) which is activated whenever the user opens a file with extension '.ext'. It has the following structure:

LSP结构

I'm already using the Language Client/Server libraries for VSCode, and the language validation consists on a web server deployed locally on a random free port containing ANTLR4 classes which receive the content of the file the user is modifying. After analysing this content, it sends a response via HTTP to the Language Server part containing the diagnostics about the received code snippet. Then, Server sends the adapted diagnostics to Client, so they can be used by VSCode to inform the user about the errors.

The extension works fine, but I have to run the language validation server manually whenever I want to use the extension (which is writen in Node.js). Is there a way to automatically start that node server whenever the extension is activated?

Thanks in advance.

The idea of starting an http server on another machine using a VS Code extension sounds strange to me, I think you can use the ANTLR-generated parser directly in your language server. If the parser is not generated in the same language as the server's, you can just re-generate it from the grammar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM