|
| 1 | +# Introduction |
| 2 | +Sourcery is a standards compliant Language Server as defined by the [LSP spec](https://microsoft.github.io/language-server-protocol/specifications/specification-current/). |
| 3 | + |
| 4 | +To create a fully working client (code editor extension) you only need to: |
| 5 | +1. Download and unpack the binaries. |
| 6 | +2. Start up the relevant binary for the current OS. |
| 7 | +3. Initialize the Sourcery Language Server with Sourcery specific initialization options. |
| 8 | +4. Follow the standard LSP spec (almost all editors have libraries for doing this). |
| 9 | +5. Tell us about it so we can spread the word! |
| 10 | + |
| 11 | +## Binaries |
| 12 | +The latest binaries are available on the [sourcery-ai/sourcery releases page](https://github.com/sourcery-ai/sourcery/releases/latest). Once downloaded they must be unpacked before they can be run. |
| 13 | + |
| 14 | +The unpacked binaries can be checked on your system by running `path_to_binary/sourcery --verify` which will print out a message similar to: |
| 15 | +``` |
| 16 | +sourcery, version 0.7.11 |
| 17 | +
|
| 18 | +Verifying server availability https://api.sourcery.ai/health - success |
| 19 | +Verifying refactoring functionality - success |
| 20 | +``` |
| 21 | + |
| 22 | +## Startup and Initialisation |
| 23 | +The client communicates with The Sourcery Language Server through standard input and output. To run the Sourcery Language Server execute `path_to_binary/sourcery --lsp`. |
| 24 | + |
| 25 | +The Sourcery Server is initialised with the standard [LSP initialize request](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize). It requires the `initializationOptions` param to be populated as shown below and will respond with the list of ServerCapabilities that it supports. |
| 26 | + |
| 27 | +```ts |
| 28 | +interface SourceryInitializationOptions: { |
| 29 | + /** |
| 30 | + * The Sourcery token for authenticating the user. |
| 31 | + * This is retrieved from the Sourcery website and must be |
| 32 | + * provided by each user. The extension must provide a |
| 33 | + * configuration option for the user to provide this value. |
| 34 | + */ |
| 35 | + token: string; |
| 36 | + |
| 37 | + /** |
| 38 | + * The extension's name and version as defined by the extension. |
| 39 | + * e.g. sourcery-ai/vscode 0.7.6 |
| 40 | + */ |
| 41 | + extension_version: string; |
| 42 | + |
| 43 | + /** |
| 44 | + * The editor's name and version as defined by the editor. |
| 45 | + * e.g. vscode 1.44.0 |
| 46 | + */ |
| 47 | + editor_version: string; |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +Once the Sourcery Language Server is initialized is will act in a fully LSP compliant manner providing refactoring suggestions and hover functionality. |
| 52 | + |
| 53 | +## Let us know! |
| 54 | +if you implement a new client for a editor we'd love to hear about it and are happy to help if you need any assistance. Just drop us a line at [email protected] |
0 commit comments