visual-studio-codevscode-extensions

Is it possible to access a VSCode language server from another application?


According to the overview at https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/, VSCode language servers are essentially JSON-RPC servers. Once VSCode is open and running at least 1 language server, how can you tell what port that language server is running on in order to access it from outside of VSCode?

I want to make an experimental application where a VSCode language server is the back-end for a custom code editor that runs in a separate process.


Solution

  • A language server is usually a console application launched by VSCode based on configuration, and its stdin/stdout streams are redirected. There is no port opened usually. Aka, JSON-RPC is a protocol over stdin/stdout, not JSON over HTTP.

    If you want to integrate a language server with your own editor, you might fully implement the language server protocol client on the editor side, so that it can perform the same language server process management and stdin/stdout stream redirection. There are many open source projects out there for famous editors, such as

    Depending on the programming language your editor is built upon, you can find more specific examples to follow.

    However, certain language servers are not open sourced and licensed to be used with VS Code exclusively. Thus, you shouldn’t use them elsewhere.