- Qt Creator Manual
- Using Language Servers
- Qt Creator Manual 6.0.2

Using FakeVim Mode ◦ Editing MIME Types

# Using Language Servers

For several programming languages, a language server is available that provides information about the code to IDEs as long as they support communication via the language server protocol (LSP). This enables the IDE to provide the following services:

- Code completion
- Sending document formatting requests to the language server to automatically format documents using the settings specified in Tools > Options > Text Editor > Behavior
- Highlighting the symbol under cursor
- Viewing function tooltips
- Semantic highlighting, as defined in Proposal of the semantic highlighting protocol extension
- Navigating in the code by using the locator or moving to the symbol definition
- Inspecting code by viewing the document outline in the Outline view or in the Symbols list on the editor toolbar
- Finding references to symbols
- Renaming the symbol under cursor
- Code actions
- Displaying diagnostics from the language server as tooltips. You can also select a code range to display diagnostics for.

By providing a client for the language server protocol, Qt Creator can support the above features for several other programming languages besides C++. However, the client does not support language servers that require special handling.

## Adding MIME Types for Language Servers

Qt Creator uses the MIME type of the file to determine which language server to request information from when you open a file for editing. Add new MIME types or file patterns to match language servers. If you do not set at least one MIME type or file pattern, no files will be sent to the language server. This is done to avoid unnecessary traffic and inaccurate information, as files are only sent to the languge server if they are known to be handled by it. For more information about how Qt Creator uses MIME types, see Editing MIME Types.

## Specifying Settings for Language Clients

You can add a generic generic stdIO language server for Python, for example. For Android development, you can add a Java language server.

### Adding Language Servers

To view a list of language servers, select Tools > Options > Language Client (or Qt Creator > Preferences > Language Client > on macOS).

To enable a language server, select the check box next to the language server name and specify settings for the server.

To remove language servers from the list, select Delete.

### Specifying Generic Settings

To add a generic language server:

1. Select Tools > Options > Language Client > Add > New Generic StdIO Language Server to add a generic language server.
2. In the Name field, enter a name for the language server. Select the (Variables) button to use a variable for the server name. For more information, see Using Qt Creator Variables.
3. In the Language field, select Set MIME Types to select the MIME types of the files to send to the language server. In the field below, you can enter file patterns to extend the MIME types, separated by semicolons.
4. In the Startup behavior field, select whether the language server is started when Qt Creator starts or when a project or file with a matching MIME type is opened. The General Messages output pane displays information about the connection to the language server.
5. In the Initialization field, you can add language server specific JSON attributes to pass to an `initialize` request.
6. In the Executable field, enter the path to the language server executable.
7. In the Arguments field, enter any required command line arguments. Select Variables to use variables as arguments.

### Specifying Java Language Server Settings

To add a Java language server:

1. Select Tools > Options > Language Client > Add > New Java Language Server to add a Java language server.

2. In the Name field, enter a name for the language server. Select the (Variables) button to use a variable for the server name. For more information, see Using Qt Creator Variables.
3. In the Java field, enter the path to the Java executable.
4. In the Java Language Server field, enter the path to the Java language server `.jar` file.

## Supported Locator Filters

The locator enables you to browse not only files, but any items defined by locator filters. The language client plugin supports the following locator filters:

- Locating symbols in the current project (`:`)
- Locating symbols in the current document (`.`)
- Locating class (`c`), enum, and function (`m`) definitions in your project

## Reporting Issues

The language service client has been mostly tested with Python and Java. If problems arise when you try them or some other language, please select Help > Report Bug to report them in the Qt Project Bug Tracker. The reports should include Qt Creator console output with the environment variable `QT_LOGGING_RULES=qtc.languageclient.*=true` set.