turbo-editors/turbo-gopublic Fork 0
v1.0.0
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-go.git
git clone ssh://git@rickub.com/turbo-editors/turbo-go.git

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

enable-completion.md · 95 lines · 4.6 KBmarkdown Blame HistoryRaw
📦 Turbo Go 3d7798b k33g 9h ago1# How to enable Go completion
2
3This guide shows how to get completion, hovers and go-to-definition working. It assumes Turbo Go is already installed and that you know what a Go module is.
4
5Completion comes from **gopls**, the official Go language server. Turbo Go does not bundle it: editing and colouring work without it, and only completion is lost.
6
7## 1. Install gopls
8
9```bash
10go install golang.org/x/tools/gopls@latest
11```
12
13## 2. Make sure Turbo Go can find it
14
15Turbo Go 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:
16
17```bash
18gopls version
19```
20
21If that says "command not found" but Turbo Go still finds it, that is expected and fine.
22
23## 3. Open a file inside a module
24
25```bash
26cd /path/to/your/module # the directory holding go.mod
27turbo-go main.go
28```
29
30Turbo Go walks up from the file looking for `go.mod` and starts gopls in the directory it finds. **Outside a module, gopls has very little to say** — this is the most common reason completion appears not to work.
31
32## 4. Ask for a completion
33
34Put the cursor after a dot and press **Ctrl-Space**:
35
36```go
37fmt.
38```
39
40A list drops down under the cursor. Keep typing to narrow it, **↑ ↓** to walk it, **Enter** or **Tab** to accept, **Escape** to dismiss.
41
42Typing a `.` asks for a completion by itself, so most of the time you do not press anything.
43
44## Checking what the server is doing
45
46The 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.
47
48## Variants
49
50**You do not want a language server at all:**
51
52```bash
53turbo-go -no-lsp main.go
54```
55
56**Completion is dead in a window that started without a name.** An Untitled window has no file to announce to gopls until it is saved — press **F2** and give it a name ending in `.go`, somewhere under the module. From that save on, completion, hover and the error marks work in that window; there is no need to quit and relaunch.
57
58**Completion is empty in a file that does compile.** gopls needs the file's package to build. Check `go build ./...` first — a package that does not compile often yields nothing useful.
59
60**The first completion after opening a large module is slow.** gopls is loading the module graph. The status bar says `LSP: starting…` until it is ready; requests made before then are refused rather than queued.
61
62**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.
63
64**The list is empty in a file that does not compile.** gopls 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:
65
66```
67No completions — this file does not compile: main redeclared in this block
68```
69
70`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 — `go build ./...` is the quickest check.
71
72**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`.
73
74## What else the server gives you
75
76Completion 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.
77
78| Key | What it does |
79| --- | --- |
80| **Ctrl-Space** | Completion list |
81| **F1** | Describe the symbol under the cursor |
82| **F12** | Jump to where it is declared |
83| **Shift-F12** | List everywhere it is used |
84| **Ctrl-T** | Find a symbol by name anywhere in the project |
85
86And, without a key: *Go to type definition*, *Find implementations…*, *Symbol in file…* and *Problems…*.
87
88Problems 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.
89
90[How to ask what the code means](ask-about-code.md) walks through all of it.
91
92## See also
93
94- Why the server is optional: [Colouring and completion](../explanation/colouring-and-completion.md)
95- Every key: [keyboard reference](../reference/keyboard.md)