turbo-editors/turbo-golopublic Fork 0
79b67fdd82d26f23a6b97e39c1f063d475cbbc49
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-golo.git
git clone ssh://git@rickub.com/turbo-editors/turbo-golo.git

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

ask-about-code.md · 70 lines · 4.9 KBmarkdown Blame HistoryRaw
📦 Turbo Golo d710c1b k33g 22h ago1# How to ask what the code means
2
3This guide shows how to follow a name through a Golo file: what it is, where it is declared, and what is wrong with it. It assumes Turbo Golo is installed and the language server is running — the status bar says `LSP: ready` when it is.
4
5For moving around a file — searching, jumping to a line, switching windows — see [How to move around a file](navigate-code.md) instead.
6
7## Put the cursor on a name
8
9Any character of it will do. Every question below asks about the **position of the cursor**, not about a selection, so there is nothing to highlight first.
10
11## Ask
12
13| To find | Do | Shortcut | With `golo lsp` |
14| --- | --- | --- | --- |
15| What it is | **Code ▸ Describe symbol** | `F1` | answered |
16| Where it is declared | **Code ▸ Go to definition** | `F12` | answered |
17| Where its *type* is declared | **Code ▸ Go to type definition** | | nothing found |
18| What implements it | **Code ▸ Find implementations…** | | answered — its declaration |
19| Everywhere it is used | **Code ▸ Find references…** | `Shift-F12` | answered, within the file |
20
21**One of these five reports nothing with `golo lsp`.** The server is the interpreter itself in language-server mode, and it does not advertise `typeDefinition`, so **Go to type definition** answers nothing found however good the code is. The other four work, within the file: **Find references** lists the declaration and every call, and **Find implementations** answers with the declaration — Golo has no interfaces, so a function is its own implementation. Both symbol searches below work too. See [colouring and completion](../explanation/colouring-and-completion.md) for why the one gap is written down rather than hidden behind a greyed-out menu item.
22
23What the two that work know is **the file in front**, at top level:
24
25- **Describe symbol** on a function you declared shows its signature and the `#` comments written immediately above it; on a builtin such as `println` or a symbol pulled in by `import` from an embedded module — `gololang.Errors`, `gololang.Types` — it shows the interpreter's own documentation.
26- **Go to definition** takes you to a top-level function or union declared in the same file. A function imported from a module of your own on disk is not resolved.
27
28One answer takes you straight there. Should a question ever come back with several, they open a list showing each file, its line, and the text of that line; move with the arrow keys, `Enter` to go, `Esc` to stay where you are.
29
30## When nothing comes back
31
32Three different things look alike, and the status bar tells them apart:
33
34| It says | Meaning |
35| --- | --- |
36| `No … found`, in the question's own words | The server answered, and there are none — which, for type definitions, is what this server always says |
37| `LSP: starting…` | The server has not finished starting. Wait a moment and ask again. |
38| `LSP: off` on the status bar | No server is running. See [How to enable completion](enable-completion.md). |
39| `LSP: no golo — see https://codeberg.org/TypeUnsafe/golo-script/releases` | There is no `golo` on `PATH` or in `/usr/local/bin`. See [How to install GoloScript](install-goloscript.md). |
40
41## Find something by name instead
42
43- **Code ▸ Symbol in file…** lists what the file in front declares, indented, with each symbol's kind — the top-level functions and unions, each union's variants nested under it. An outline you can walk; choosing one goes to it.
44- **Code ▸ Symbol in project…** (`Ctrl-T`) asks for a name and searches every `.golo` file under the project root, open or not — top-level functions, unions and module names. An empty name lists them all.
45
46## See what is wrong
47
48**Code ▸ Problems…** lists every problem the server has reported, for **every file it has loaded** — usually more than the one you are editing. Choosing one goes to the line.
49
50`golo lsp` reports two kinds of problem, on open and again on every edit: syntax errors from its lexer and parser, and lints for the two mistakes it sees most — `:` and `.` confused in a method call, and C-style `//` or `/* */` comments, where Golo uses `#` and `----`. A syntax error is placed on the line the message names, or on line 1 when it names none, and the whole line is marked rather than a column.
51
52Lines with a problem carry a mark in the gutter, beside the line number:
53
54| Mark | Meaning |
55| --- | --- |
56| `×` | An error |
57| `!` | A warning |
58| `i` | Information |
59| `·` | A hint |
60
61A line with more than one problem shows the worst of them.
62
63**The marks need the line numbers.** They sit in the column that separates the numbers from the text, so hiding the gutter with **Options ▸ Line numbers** hides them too.
64
65## See also
66
67- Every item and its key: [Menus](../reference/menus.md)
68- Getting a server running: [How to enable completion](enable-completion.md)
69- What the editor asks, and why: [Colouring and completion](../explanation/colouring-and-completion.md)
70- What `golo lsp` answers, exactly: [Golo tools](../reference/golo-tools.md)