Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

JavaScript and TypeScript code intelligence through the Language Server Protocol

License

Notifications You must be signed in to change notification settings

sourcegraph/javascript-typescript-langserver

Repository files navigation

JavaScript/TypeScript language server

npm npm Build Status Windows Build Status codecov Dependencies Gitter

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.

Getting started

  1. npm install
  2. npm run build
  3. node lib/language-server.js

To try it in Visual Studio Code, install the vscode-client extension and then open up a .ts file.

Development

Run npm run watch.

Tests

Run npm test.

Command line arguments

  • -p, --port specifies port to use, default one is 2089
  • -s, --strict enables strict mode where server expects all files to be receives in didOpen notification requests
  • -c, --cluster specifies number of concurrent cluster workers (defaults to number of CPUs)
  • -t, --trace enables printing of all incoming and outgoing messages
  • -l, --logfile specifies log file to print all messages to

Supported LSP requests

initialize

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.

exit

Implementation closes underlying communication channel

shutdown

Does nothing opposite to LSP specification that expects server to exit

textDocument/hover

textDocument/definition

textDocument/references

workspace/symbols

Introduces limit parameter to limit number of symbols to return

Differences from LSP protocol specification

In strict mode LSP server does not touch underlying file system, instead it uses the LSP files extension to retrieve workspace files and file contents.

Known issues

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