turbo-editors/turbo-rustpublic Fork 0
v1.0.2
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-rust.git
git clone ssh://git@rickub.com/turbo-editors/turbo-rust.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

📦 Turbo Rust 713ea5c · on v1.0.2 · k33g · 9h ago
enable-completion.md · 95 lines · 4.7 KBmarkdown
Blame HistoryOpen raw

How to enable Rust completion

This guide shows how to get completion, hovers and go-to-definition working. It assumes Turbo Rust is already installed and that you know what a Cargo crate is.

Completion comes from rust-analyzer, the official Rust language server. Turbo Rust does not bundle it: editing and colouring work without it, and only completion is lost.

1. Install rust-analyzer

rustup component add rust-analyzer

2. Make sure Turbo Rust can find it

Turbo Rust looks on PATH first, then in $GOBIN, then in $GOPATH/bin. go install writes to the last of those, which is very often not on PATH — so this usually works without any further step. Check:

rust-analyzer version

If that says "command not found" but Turbo Rust still finds it, that is expected and fine.

3. Open a file inside a module

cd /path/to/your/module   # the directory holding Cargo.toml
turbo-rust main.rs

Turbo Rust walks up from the file looking for Cargo.toml and starts rust-analyzer in the directory it finds. Outside a module, rust-analyzer has very little to say — this is the most common reason completion appears not to work.

4. Ask for a completion

Put the cursor after a dot and press Ctrl-Space:

fmt.

A list drops down under the cursor. Keep typing to narrow it, ↑ ↓ to walk it, Enter or Tab to accept, Escape to dismiss.

Typing a . asks for a completion by itself, so most of the time you do not press anything.

Checking what the server is doing

The right-hand end of the status bar shows the language server's state: LSP: starting…, LSP: ready, or why there is none. Run ▸ Language server status shows the same thing in a box.

Variants

You do not want a language server at all:

turbo-rust -no-lsp main.rs

Completion is dead in a window that started without a name. An Untitled window has no file to announce to rust-analyzer until it is saved — press F2 and give it a name ending in .rs, somewhere under the crate. From that save on, completion, hover and the error marks work in that window; there is no need to quit and relaunch.

Completion is empty in a file that does compile. rust-analyzer needs the file's package to build. Check cargo build first — a package that does not compile often yields nothing useful.

The first completion after opening a large module is slow. rust-analyzer is loading the module graph. The status bar says LSP: starting… until it is ready; requests made before then are refused rather than queued.

A request takes too long. Every request gives up after three seconds, so a stuck server slows the editor but never freezes it. The status bar reports the failure.

The list is empty in a file that does not compile. rust-analyzer answers nothing at all — no error, an empty list — for a package it cannot load. A duplicate declaration or an unresolved import is enough. The editor now says which problem is in the way:

No completions — this file does not compile: main redeclared in this block

Run ▸ Language server status shows the same thing with the server's path, the workspace root, and whether it has been told about this file. Fix the package first — cargo build is the quickest check.

Ctrl-Space does nothing. tmux, screen and IDE terminals frequently claim Ctrl-Space before the editor sees it. Type a . instead, which asks for a completion by itself, or use Run ▸ Completion.

What else the server gives you

Completion is the loudest thing it does and the least of what it knows. The same connection answers eight more questions, all of them in the Code menu and all of them about the symbol under the cursor — no selection needed.

Key What it does
Ctrl-Space Completion list
F1 Describe the symbol under the cursor
F12 Jump to where it is declared
Shift-F12 List everywhere it is used
Ctrl-T Find a symbol by name anywhere in the project

And, without a key: Go to type definition, Find implementations…, Symbol in file… and Problems….

Problems it finds arrive unasked. The first error in the file you are editing appears on the right of the status bar, prefixed with ; every line with a problem gets a mark in the gutter (× for an error, ! for a warning); and Code ▸ Problems… lists all of them, for every file the server has loaded.

How to ask what the code means walks through all of it.

See also

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# How to enable Rust completion

This guide shows how to get completion, hovers and go-to-definition working. It assumes Turbo Rust is already installed and that you know what a Cargo crate is.

Completion comes from **rust-analyzer**, the official Rust language server. Turbo Rust does not bundle it: editing and colouring work without it, and only completion is lost.

## 1. Install rust-analyzer

```bash
rustup component add rust-analyzer
```

## 2. Make sure Turbo Rust can find it

Turbo Rust looks on `PATH` first, then in `$GOBIN`, then in `$GOPATH/bin`. `go install` writes to the last of those, which is very often not on `PATH` — so this usually works without any further step. Check:

```bash
rust-analyzer version
```

If that says "command not found" but Turbo Rust still finds it, that is expected and fine.

## 3. Open a file inside a module

```bash
cd /path/to/your/module   # the directory holding Cargo.toml
turbo-rust main.rs
```

Turbo Rust walks up from the file looking for `Cargo.toml` and starts rust-analyzer in the directory it finds. **Outside a module, rust-analyzer has very little to say** — this is the most common reason completion appears not to work.

## 4. Ask for a completion

Put the cursor after a dot and press **Ctrl-Space**:

```go
fmt.
```

A list drops down under the cursor. Keep typing to narrow it, **↑ ↓** to walk it, **Enter** or **Tab** to accept, **Escape** to dismiss.

Typing a `.` asks for a completion by itself, so most of the time you do not press anything.

## Checking what the server is doing

The right-hand end of the status bar shows the language server's state: `LSP: starting…`, `LSP: ready`, or why there is none. `Run ▸ Language server status` shows the same thing in a box.

## Variants

**You do not want a language server at all:**

```bash
turbo-rust -no-lsp main.rs
```

**Completion is dead in a window that started without a name.** An Untitled window has no file to announce to rust-analyzer until it is saved — press **F2** and give it a name ending in `.rs`, somewhere under the crate. From that save on, completion, hover and the error marks work in that window; there is no need to quit and relaunch.

**Completion is empty in a file that does compile.** rust-analyzer needs the file's package to build. Check `cargo build` first — a package that does not compile often yields nothing useful.

**The first completion after opening a large module is slow.** rust-analyzer is loading the module graph. The status bar says `LSP: starting…` until it is ready; requests made before then are refused rather than queued.

**A request takes too long.** Every request gives up after three seconds, so a stuck server slows the editor but never freezes it. The status bar reports the failure.

**The list is empty in a file that does not compile.** rust-analyzer answers *nothing at all* — no error, an empty list — for a package it cannot load. A duplicate declaration or an unresolved import is enough. The editor now says which problem is in the way:

```
No completions — this file does not compile: main redeclared in this block
```

`Run ▸ Language server status` shows the same thing with the server's path, the workspace root, and whether it has been told about this file. Fix the package first — `cargo build` is the quickest check.

**Ctrl-Space does nothing.** tmux, screen and IDE terminals frequently claim `Ctrl-Space` before the editor sees it. Type a `.` instead, which asks for a completion by itself, or use `Run ▸ Completion`.

## What else the server gives you

Completion is the loudest thing it does and the least of what it knows. The same connection answers eight more questions, all of them in the **Code** menu and all of them about the symbol under the cursor — no selection needed.

| Key | What it does |
| --- | --- |
| **Ctrl-Space** | Completion list |
| **F1** | Describe the symbol under the cursor |
| **F12** | Jump to where it is declared |
| **Shift-F12** | List everywhere it is used |
| **Ctrl-T** | Find a symbol by name anywhere in the project |

And, without a key: *Go to type definition*, *Find implementations…*, *Symbol in file…* and *Problems…*.

Problems it finds arrive unasked. The first error in the file you are editing appears on the right of the status bar, prefixed with `⚠`; every line with a problem gets a mark in the gutter (`×` for an error, `!` for a warning); and **Code ▸ Problems…** lists all of them, for every file the server has loaded.

[How to ask what the code means](ask-about-code.md) walks through all of it.

## See also

- Why the server is optional: [Colouring and completion](../explanation/colouring-and-completion.md)
- Every key: [keyboard reference](../reference/keyboard.md)