Code intelligence and language servers
Studio can complete names, jump to definitions, find usages, show what a symbol is and report errors as you type. This works for BT out of the box. You can add other languages, such as C, by configuring a language server (a separate program that understands that language).
Using it
| Command | Shortcut | Action |
|---|---|---|
| Code: Complete | Ctrl+Space | Lists completions at the cursor in the Code Intelligence view. Click one to insert it. |
| Code: Go to Definition | F12 | Opens the definition of the symbol at the cursor. If you are already on the definition, lists its usages instead. |
| Code: Find Usages | Shift+F12 | Lists every use of the symbol, including its declaration. Click one to open it. |
| Code: Inspect Symbol | — | Shows information about the symbol at the cursor in the Code Intelligence summary line. |
| Code: Toggle Language Servers | — | Turns code intelligence off, or back on (restarting all servers). |
The first four are also on the Source Editor's right-click menu, where they act on the word under the pointer.
Other features:
- Hover information. Leave the cursor on a symbol for about half a second and its description appears in the Code Intelligence summary line.
- Highlight occurrences. Click a name to highlight other uses of that symbol in the file.
- Errors as you type. Errors and warnings from the server appear in Output. Click one to go to its line.
Code Intelligence view
The Code Intelligence view (bottom area) opens when you run one of the commands above. Its summary line shows symbol information or the server's status, for example "starting…", "unavailable" or "No language server for this file". Its list shows completions, definitions or usages; click an entry to use it, and click again to expand or collapse its full text.
Definitions in the engine's standard library or other dependencies open as read-only tabs.
The built-in BT server
BT files (.bt) use the BT language server that ships with Studio. It finds
your project's modules and their dependencies automatically. Its options are
described in bt-lsp.
Adding language servers
Add servers to the languageServers list in your user settings file
(cturtle-studio.settings; location in
Studio settings files),
then restart Studio. For example, to use clangd for C and C++:
{
"autosave": 0,
"languageServers": [{
"name": "C/C++",
"languageId": "cpp",
"extensions": [".c", ".h", ".cpp", ".hpp"],
"command": ["clangd", "--background-index"]
}]
}
| Field | Description |
|---|---|
name | Name shown in Studio. Required. |
languageId | The language's standard LSP identifier, such as cpp or python. Required. |
extensions | File extensions this server handles, each starting with .. Case is ignored. At least one. |
command | The program to run, followed by its arguments. |
An argument that is exactly one of these placeholders is replaced:
| Placeholder | Replaced with |
|---|---|
{root} | The project folder |
{manifest} | The full path of the open project file |
{studio} | The Studio installation folder |
Servers run in the project folder and apply to every project. A server listed
for .bt replaces the built-in BT server. Servers see your unsaved changes.
Limits
- At most 100 completions or locations are listed per request.
- Hover text is shown on one line, without formatting.
- Not implemented: completion as you type, parameter hints, rename, code actions, formatting, document outline and semantic coloring. Completions insert plain text, without snippet placeholders.
- If a server crashes, Output shows the error and the summary shows "unavailable". Run Code: Toggle Language Servers twice to restart it.
- The server must support UTF-16 positions (most do); Studio rejects servers that do not.