turbo-editors/turbo-golopublic Fork 0
main
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.

enable-completion.md · 137 lines · 7.8 KBmarkdown Blame HistoryRaw
📦 Turbo Golo d710c1b k33g 16h ago1# How to enable Golo completion
2
3This guide shows how to get completion, hovers, go-to-definition and error marks working. It assumes Turbo Golo is already installed.
4
5Completion comes from **`golo lsp`** — the GoloScript interpreter itself, started in language-server mode. There is no separate server to install: a machine that can run a Golo script can complete one. Turbo Golo does not bundle the interpreter, though: editing and colouring work without it, and only completion and the error marks are lost.
6
7## 1. Install golo
8
9Either download a binary from the [releases page](https://codeberg.org/TypeUnsafe/golo-script/releases):
10
11```bash
12chmod +x golo-<version>-<platform>
13sudo mv golo-<version>-<platform> /usr/local/bin/golo
14golo --version
15```
16
17or build it from source, which also gives you the two compilers:
18
19```bash
20git clone https://codeberg.org/TypeUnsafe/golo-script.git && cd golo-script
21./install.sh
22```
23
24Turbo Golo's own installer will do the second for you: `scripts/install.sh --with-server`. [How to install GoloScript](install-goloscript.md) has the details.
25
26## 2. Make sure Turbo Golo can find it
27
28Turbo Golo looks on `PATH` first, then in `/usr/local/bin`, which is where GoloScript's installer writes. Check:
29
30```bash
31golo --version
32```
33
34```
35v0.1.1 | dev.20260802.🤓
36```
37
38If that says "command not found" but Turbo Golo still finds it, that is expected and fine: the editor searched `/usr/local/bin` itself.
39
40## 3. Open a script
41
42```bash
43cd /path/to/your/scripts
44turbo-golo main.golo
45```
46
47Golo has no project manifest, so there is nothing to look for: `golo lsp` is started in the directory of the file you opened, and it answers about that file. Where you start the editor changes nothing about completion — it decides where the Golo menu's commands run, which is a different matter.
48
49## 4. Ask for a completion
50
51Type the first letters of a name and press **Ctrl-Space**:
52
53```golo
54prin
55```
56
57A list drops down under the cursor — `print`, `println`, with their signatures. Keep typing to narrow it, **↑ ↓** to walk it, **Enter** or **Tab** to accept, **Escape** to dismiss.
58
59## What the list holds
60
61`golo lsp` offers four kinds of thing:
62
63| Offered | Example |
64| --- | --- |
65| Keywords | `function`, `foreach`, `augment` |
66| The interpreter's builtins, with their signatures and documentation | `println`, `readFile`, `httpGet`, `DynamicObject` |
67| Functions and unions declared **at top level** in the file | your own `function helper = …` |
68| Symbols pulled in by `import` from the modules embedded in the binary | `Some`, `None`, `isSome`, `either` after `import gololang.Errors` |
69
70Two things are deliberately **not** in it, and both look like a broken server if you did not know:
71
72- **A function declared inside another function.** Only top-level declarations are collected. Move it out, or accept that it will not be offered.
73- **Anything from a `.golo` file of your own.** `import` resolves the modules built into the interpreter — `gololang.Errors`, `gololang.Types`, `gololang.Ui`, `gololang.Testing`, … — and nothing on disk. A helper in `lib/util.golo` is not seen from `main.golo`.
74
75## Checking what the server is doing
76
77The right-hand end of the status bar shows the language server's state: `LSP: starting…`, `LSP: ready`, or why there is none:
78
79```
80LSP: no golo — see https://codeberg.org/TypeUnsafe/golo-script/releases
81```
82
83`Run ▸ Language server status` shows the same thing in a box, with the path it found the binary at and the directory it started it in.
84
85## Variants
86
87**You do not want a language server at all:**
88
89```bash
90turbo-golo -no-lsp main.golo
91```
92
93**Completion is dead in a window that started without a name.** An Untitled window has no file to announce to `golo lsp` until it is saved — press **F2** and give it a name ending in `.golo`. From that save on, completion, hover and the error marks work in that window; there is no need to quit and relaunch.
94
95**The list is empty.** `golo lsp` answers for any file, including one that does not parse — it lists keywords and builtins regardless — so an empty list almost always means the server is not running. Read the status bar.
96
97**Ctrl-Space does nothing.** tmux, screen and IDE terminals frequently claim `Ctrl-Space` before the editor sees it. Use `Run ▸ Completion` instead.
98
99**A request takes too long.** Every request gives up after a few seconds, so a stuck server slows the editor but never freezes it. The status bar reports the failure.
100
101**You installed golo somewhere unusual.** The editor searches `PATH` and `/usr/local/bin`, and nowhere else — there is no environment variable naming another directory. Put the directory on `PATH`, or a symbolic link in `/usr/local/bin`.
102
103## What else the server gives you
104
105Completion is the loudest thing it does and the least of what it knows. The same connection answers four more questions, all of them in the **Code** menu — three about the symbol under the cursor, no selection needed, and one about a name you type.
106
107| Key | What it does | With `golo lsp` |
108| --- | --- | --- |
109| **Ctrl-Space** | Completion list | yes |
110| **F1** | Describe the symbol under the cursor | yes — for a function you declared, the `#` comments written just above it; for a builtin, its signature and a worked example |
111| **F12** | Jump to where it is declared | yes, within the file |
112| **Shift-F12** | List everywhere it is used | yes, within the file: its declaration and every call |
113| **Ctrl-T** | Find a symbol by name anywhere in the project | yes: the top-level functions, unions and module names of every `.golo` file under the project root, open or not |
114
115And, without a key: *Symbol in file…* lists the file's top-level functions and unions, with each union's variants nested under it; *Problems…* lists every diagnostic; *Find implementations…* answers with the function's declaration, the same place **F12** goes — Golo has no interfaces, so a function is its own implementation; *Go to type definition* reports nothing found.
116
117The one that reports nothing is the server's boundary, not the editor's: `golo lsp` advertises `completion`, `hover`, `definition`, `documentSymbol`, `references`, `implementation` and `workspaceSymbol`, and not `typeDefinition`. Until GoloScript v0.2.0 it advertised only the first four and this table said so; a test in this repository failed the day the server started answering the other three, which is how the table came to be revised. The menu item stays because greying it out depending on what a server said at start-up would make the menu a different shape on different machines, and the same kind of test still fails the day a future golo answers type definitions too.
118
119## The error marks
120
121Problems the server finds arrive unasked, on open and on every edit. 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 `×` in the gutter; and **Code ▸ Problems…** lists all of them.
122
123`golo lsp` reports three kinds:
124
125- **Syntax errors** from the lexer and parser — a missing brace, a token the parser does not accept. The parser's messages carry a line and no column, so the mark lands on the whole line; a message with no line at all lands on line 1.
126- **A `:`/`.` confusion** — `obj.method()` where Golo wants `obj: method()`.
127- **A C-style comment** — `//` or `/* */`, which Golo does not have. Golo comments are `#` and `----`.
128
129A script that parses and then fails when run gets no mark: the server parses, it never runs anything.
130
131[How to ask what the code means](ask-about-code.md) walks through the Code menu.
132
133## See also
134
135- Why the server is optional, and why the interpreter is the server: [Colouring and completion](../explanation/colouring-and-completion.md)
136- Installing the interpreter: [How to install GoloScript](install-goloscript.md)
137- Every key: [keyboard reference](../reference/keyboard.md)