|
7 | 7 | )](https://ci.appveyor.com/project/sourcegraph/javascript-typescript-langserver/branch/master) |
8 | 8 | [](https://codecov.io/gh/sourcegraph/javascript-typescript-langserver) |
9 | 9 | [](https://david-dm.org/sourcegraph/javascript-typescript-langserver) |
| 10 | +[](http://opentracing.io) |
10 | 11 | [](https://gitter.im/sourcegraph/javascript-typescript-langserver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) |
11 | 12 |
|
12 | 13 | This is a language server for JavaScript and TypeScript that adheres to the [Language Server Protocol (LSP)](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md). It uses [TypeScript's](http://www.typescriptlang.org/) LanguageService to perform source code analysis. |
13 | 14 |
|
14 | | -## Getting started |
15 | 15 |
|
16 | | -1. `npm install` |
17 | | -1. `npm run build` |
18 | | -1. `node lib/language-server.js` |
| 16 | +## Try it out |
19 | 17 |
|
20 | | -To try it in [Visual Studio Code](https://code.visualstudio.com), install the [vscode-client](https://github.com/sourcegraph/langserver/tree/master/vscode-client) extension and then open up a `.ts` file. |
| 18 | + - On [sourcegraph.com](https://sourcegraph.com/github.com/sourcegraph/javascript-typescript-langserver/-/blob/src/typescript-service.ts) |
| 19 | + - In [Visual Studio Code](https://github.com/sourcegraph/vscode-javascript-typescript) (as an alternative to the built-in TypeScript integration) |
| 20 | + - In [Eclipse Che](https://eclipse.org/che/) |
| 21 | + - In [NeoVim](https://github.com/autozimu/LanguageClient-neovim) |
21 | 22 |
|
22 | | -## Development |
| 23 | +## Features |
23 | 24 |
|
24 | | -Run `npm run watch`. |
| 25 | + - Hovers |
| 26 | + - Goto definition |
| 27 | + - Find all references |
| 28 | + - Document symbols |
| 29 | + - Workspace symbol search |
| 30 | + - Rename |
| 31 | + - Completion |
| 32 | + - Signature help |
| 33 | + - Diagnostics |
| 34 | + - Quick fixes |
25 | 35 |
|
26 | | -## Tests |
| 36 | +## Run it from source |
27 | 37 |
|
28 | | -Run `npm test`. |
| 38 | +```bash |
| 39 | +# install dependencies |
| 40 | +npm install |
29 | 41 |
|
30 | | -## Command line arguments |
| 42 | +# compile |
| 43 | +npm run build |
| 44 | +# or compile on file changes |
| 45 | +npm run watch |
31 | 46 |
|
32 | | -* `-p, --port` specifies port to use, default one is `2089` |
33 | | -* `-s, --strict` enables strict mode where server expects all files to be receives in `didOpen` notification requests |
34 | | -* `-c, --cluster` specifies number of concurrent cluster workers (defaults to number of CPUs) |
35 | | -* `-t, --trace` enables printing of all incoming and outgoing messages |
36 | | -* `-l, --logfile` specifies log file to print all messages to |
| 47 | +# run over STDIO |
| 48 | +node lib/language-server-stdio |
| 49 | +# or run over TCP |
| 50 | +node lib/language-server |
37 | 51 |
|
38 | | -## Supported LSP requests |
| 52 | +# run tests |
| 53 | +npm test |
| 54 | +``` |
39 | 55 |
|
40 | | -### `initialize` |
41 | | -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. |
42 | | -### `exit` |
43 | | -Implementation closes underlying communication channel |
44 | | -### `shutdown` |
45 | | -Does nothing opposite to LSP specification that expects server to exit |
46 | | -### `textDocument/hover` |
47 | | -### `textDocument/definition` |
48 | | -### `textDocument/references` |
49 | | -### `workspace/symbols` |
50 | | -Introduces `limit` parameter to limit number of symbols to return |
| 56 | +## Options |
51 | 57 |
|
52 | | -## Differences from LSP protocol specification |
53 | | -In strict mode LSP server does not touch underlying file system, instead it uses the [LSP files extension](https://github.com/sourcegraph/language-server-protocol/blob/master/extension-files.md) to retrieve workspace files and file contents. |
| 58 | +``` |
| 59 | + Usage: language-server [options] |
54 | 60 |
|
55 | | -## Known issues |
| 61 | + Options: |
56 | 62 |
|
57 | | -* 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. |
| 63 | + -h, --help output usage information |
| 64 | + -V, --version output the version number |
| 65 | + -s, --strict enabled strict mode |
| 66 | + -p, --port [port] specifies LSP port to use (2089) |
| 67 | + -c, --cluster [num] number of concurrent cluster workers (defaults to number of CPUs, 8) |
| 68 | + -t, --trace print all requests and responses |
| 69 | + -l, --logfile [file] log to this file |
| 70 | +``` |
58 | 71 |
|
| 72 | +## Extensions |
| 73 | + |
| 74 | +This language server implements some LSP extensions, prefixed with an `x`. |
| 75 | + |
| 76 | +- **[Files extension](https://github.com/sourcegraph/language-server-protocol/blob/master/extension-files.md)** |
| 77 | + Allows the server to request file contents without accessing the file system |
| 78 | +- **[SymbolDescriptor extension](https://github.com/sourcegraph/language-server-protocol/blob/master/extension-workspace-references.md)** |
| 79 | + Get a SymbolDescriptor for a symbol, search the workspace for symbols or references to it |
| 80 | +- **[Streaming](https://github.com/sourcegraph/language-server-protocol/blob/streaming/protocol.md#partialResult)** |
| 81 | + Supports streaming partial results for all endpoints through JSON Patches |
| 82 | +- **Packages extension** |
| 83 | + Methods to get information about dependencies |
| 84 | +- **TCP / multiple client support** |
| 85 | + When running over TCP, the `exit` notification will not kill the process, but close the TCP socket |
| 86 | + |
| 87 | +## Versioning |
| 88 | + |
| 89 | +This project follows [semver](http://semver.org/) for command line arguments and standard LSP methods. |
| 90 | +Any change to command line arguments, Node version or protocol breaking changes will result in a major version increase. |
0 commit comments