# Language Servers

VS Code leverages language servers to enhance user experience by running background processes for various languages. These servers operate in separate processes from the main editor, ensuring smooth performance. They provide:

1. **Diagnostics:** Language servers can analyze content in real time or on-demand, identifying errors and warnings. This feedback is then displayed to the user, helping to catch issues early in the development process. The diagnostic levels are error, warning, info, and hint (see [LSP spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic)).
2. **Formatting/Content Updates:** They also offer automated formatting and content updates, ensuring consistency and adherence to pre-defined standards. Users can trigger these features manually or configure them to run automatically upon saving or editing files.

### Example

For our [translators-copilot](../../../translators-copilot "mention") server, we need several basic tools that an AI agent can leverage. One of these is spell checking. When a user makes a change in a file, the content of the file is sent to the language server, and the language server tokenizes the file content. It then refers to the user's project dictionary, and sends back a warning to the user for any word that is in the file but not in the dictionary.&#x20;

Beyond publishing these diagnostics, the language server suggests several fixes the user might opt for:

1. The user might add the word to which the warning applies to their dictionary, or
2. The user might correct the word by replacing it with one of several relevant options identified by the language server, or
3. The user might add all the words in the current line to the dictionary at once

### How do I create a language server?

You need to specify some file types that will trigger activation of your server. Once you do this, you need to instantiate the server in your `extension.ts` file. For a detailed guide to creating a language server extension, see the [official VS Code docs on Language Server Extensions](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide).

For a hello-world example using a background Node server, see the [LSP Sample](https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-sample) repo.

### What programming language do I have to use for a language server?

You can theoretically use any programming language. The whole idea of a language server is that you need to analyze Python code in the editor using Python as backend language, or JS in the editor using JS, etc.&#x20;

We chose to do a lot of our analysis using a Python server, since Python has numerous off-the-shelf NLP libraries and solutions for our purposes.
