This is a language server for JavaScript and TypeScript that adheres to the Language Server Protocol (LSP). It uses TypeScript's LanguageService to perform source code analysis.
npm install
node_modules/.bin/tsc
node build/language-server.js
To try it in Visual Studio Code, install the vscode-client extension and then open up a .ts
file.
Run node_modules/.bin/tsc --watch
.
Run npm test
or yarn test
.
-p, --port
specifies port to use, default one is2089
-s, --strict
enables strict mode where server expects all files to be receives indidOpen
notification requests.
In strict mode we expect rootPath
to be equal file:///
while in non-strict mode VSCode usually sends absolute file URL. In both modes does not track existence of calling process.
Implementation closes underlying communication channel
Does nothing opposite to LSP specification that expects server to exit
Introduces limit
parameter to limit number of symbols to return
In strict mode LSP server does not touches underlying file system, instead it uses addition to LSP protocol to fetch information about workspace structure and files content by sending proprietary fs/...
requests back to the caller (fs/readDir
, fs/readFile
) and keeping results in memory.
We are using forked copy of TypeScript compiler to achieve the following goals:
- Add ability to append files on demand. Instead of parsing and analyzing the whole workspace, we are adding files on demand. For example, to extract hover information we only need to add explicitly one file (compiler will implicitly add all the imports and references)
- Allow searching for workspace symbols without a query string specified. Standard TypeScript's method returns no results for empty query while our modification returns first N symbols. We are working to propose our changes into TypeScript upstream repository.
- You need to disable VSCode's built-in TypeScript support to avoid weird conflicts on TypeScript files (double hover tooltips, etc.). There's a hacky way to do this: add the setting
{"typescript.tsdk": "/dev/null"}
to your VSCode user or workspace settings.