Skip to content

Commit af72767

Browse files
committed
docs: guide to code intelligence and autocomplete
The web UI guide gains a section on the two settings: live errors, hover documentation and go to definition (code intelligence), and completion and signature help (autocomplete); how to turn them on and install the language servers once with cstudy doctor --fix; the keys and mouse, Vim included; the languages, now and next. The README feature list and the docs index point to it. Behaviour change: basic completion is now off unless autocomplete is on. Earlier versions of the page always offered CodeMirror's completion; with the default settings the editor now offers no completion list and no signature help, so a learner can practise recall. Turn on code intelligence and autocomplete in Settings to get completion back.
1 parent cd0bb52 commit af72767

3 files changed

Lines changed: 88 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The website, [coding-study.com](https://coding-study.com/?utm_source=github&utm_
1010
- **More than algorithms.** Data structures and algorithms, multi-level practical problems, low-level design, concurrency, debugging, system design, and code review.
1111
- **Optimality, not only correctness.** `cstudy bench` measures how your solution grows with input size and compares it with the reference approaches.
1212
- **Spaced repetition.** `cstudy next` brings back what is due and picks new problems from your weakest pattern.
13+
- **Code intelligence in the browser, when you want it.** The practice page can show errors as you type, documentation on hover, go to definition and completion for Python and TypeScript from language servers on your computer. Each is a setting, off by default, so you can also practise without any help.
1314

1415
## Install
1516

@@ -87,7 +88,9 @@ cstudy serve --open # Ctrl-C stops it
8788

8889
![The attempt view of cstudy serve: the file tree, the editor, a run's results and the statement](docs/images/web-ui-attempt-light.png)
8990

90-
[Practise in your browser](docs/guides/web-ui.md) covers the views, editing and runs, the keyboard, and what keeps the page private to you.
91+
The editor can also show errors as you type, documentation on hover, go to definition and, behind a second setting, completion and signature help, for Python and TypeScript now, with Java and Kotlin, then Go and Rust, to follow. Both settings are off by default, and with autocomplete off the editor offers no completion at all, so you can practise recall; `cstudy doctor --fix` installs the language servers once (about 46 MB), and practice works offline after that.
92+
93+
[Practise in your browser](docs/guides/web-ui.md) covers the views, editing and runs, [code intelligence and autocomplete](docs/guides/web-ui.md#code-intelligence-and-autocomplete), the keyboard, and what keeps the page private to you.
9194

9295
## Your workspace is your repository
9396

@@ -149,7 +152,7 @@ The [authoring guide](docs/specs/authoring.md) covers the workflow and the ready
149152
| [coding-study.com](https://coding-study.com/docs?utm_source=github&utm_medium=readme&utm_campaign=coding-study&utm_content=docs-table) | Install and usage guides on the website |
150153
| [Documentation index](docs/README.md) | The PRD, architecture, specs, and decision records |
151154
| [CLI reference](docs/specs/cli.md) | Every command, flag, output, and exit code |
152-
| [Practise in your browser](docs/guides/web-ui.md) | `cstudy serve`: the views, editing and runs, the keyboard, troubleshooting |
155+
| [Practise in your browser](docs/guides/web-ui.md) | `cstudy serve`: the views, editing and runs, code intelligence and autocomplete, the keyboard, troubleshooting |
153156
| [Contributing](CONTRIBUTING.md) | Development setup, checks, authoring content, and commit conventions |
154157
| [Versioning](docs/specs/versioning.md) and [changelog](CHANGELOG.md) | How releases are numbered from Conventional Commits |
155158

‎docs/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ coding-study is a local, IDE-first interview-prep system: original problems stor
3131
| Guide | Covers | Read when |
3232
|-------|--------|-----------|
3333
| [toolchains](guides/toolchains.md) | Installing and checking uv and Python 3.13, Node.js and pnpm, and a JDK 21 to 26 on macOS and Linux | Setting up a machine, or when `cstudy doctor` reports a missing toolchain |
34-
| [web-ui](guides/web-ui.md) | `cstudy serve`: starting it, the views, editing and runs, project files, hints, solutions and mocks, preferences, the keyboard, troubleshooting and security | Practising in the browser |
34+
| [web-ui](guides/web-ui.md) | `cstudy serve`: starting it, the views, editing and runs, project files, hints, solutions and mocks, preferences, code intelligence and autocomplete (live errors, hover, go to definition, completion), the keyboard, troubleshooting and security | Practising in the browser, or turning the editor's help on or off |
3535

3636
## Decisions
3737

‎docs/guides/web-ui.md‎

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,79 @@ Open a file by choosing it in the tree; each opens in a tab of its own.
6262
- **Leaving asks first.** Closing a tab, leaving the view or closing the page with unsaved edits asks before anything is lost.
6363
- **Generated test files** of a project are editable, as in the terminal, but editing one never changes a grade.
6464

65-
The editor highlights Python, TypeScript, Java, Kotlin, Go, Rust, JSON, TOML and Markdown. It has no code completion: errors come from the runs, as underlines and gutter markers on the lines they name.
65+
The editor highlights Python, TypeScript, Java, Kotlin, Go, Rust, JSON, TOML and Markdown. Errors from a run show as underlines and gutter markers on the lines they name. Turn on [code intelligence and autocomplete](#code-intelligence-and-autocomplete) for live errors, documentation on hover, go to definition and completion; until you do, the editor offers no completion list at all.
66+
67+
## Code intelligence and autocomplete
68+
69+
Two settings give the editor what an IDE gives: errors as you type, documentation, jumps to definitions, and completion. They use language servers that run on your computer, and both are off by default, so the editor stays as plain as a notepad until you turn them on.
70+
71+
| Setting | What it does |
72+
|---------|--------------|
73+
| Code intelligence | Live errors, warnings and unused code; documentation when you hover; go to definition into your files and into read-only library sources |
74+
| Autocomplete | Completion as you type or with <kbd>Ctrl</kbd>+<kbd>Space</kbd>, and signature help when you open a call |
75+
76+
**Autocomplete controls all completion.** With it off, the editor offers no completion list and no signature help, not even the basic completion of earlier versions of the page. That is the reason for the setting: you can practise recalling names and signatures with nothing to prompt you, and turn the help on when you want it. Closing brackets as you type is not completion and stays.
77+
78+
### Turn them on
79+
80+
1. Choose **Settings** and check **Code intelligence**. **Autocomplete** is greyed out with `Turn on code intelligence first` until you do; it keeps its choice if you turn code intelligence off, and does nothing until both are on.
81+
2. Install the language servers once. In the terminal, run:
82+
83+
```bash
84+
cstudy doctor --fix
85+
```
86+
87+
(or choose **Fix** in the Health view). This downloads about 46 MB into `.cs/lsp/` in your workspace, and needs the network that one time. After that practice works offline: nothing else is downloaded and no server reaches the network. Deleting `.cs/lsp/` is safe; `--fix` installs it again.
88+
3. Check the result. `cstudy doctor` shows a row per language while code intelligence is on, and the Settings view lists each language's state:
89+
90+
```text
91+
ok code intelligence python basedpyright 1.40.2
92+
ok code intelligence typescript typescript-language-server 6.0.3
93+
```
94+
95+
4. Open a file. The status bar under the editor shows `python · basedpyright · ready` when its server is up, and **Restart** if it stopped.
96+
97+
If a server is not installed, or starts slowly, the editor works as it does without code intelligence, and with Autocomplete on it falls back to the editor's own basic completion until the server is ready.
98+
99+
### What you see
100+
101+
- **Errors and warnings.** They are underlined about half a second after you stop typing in Python and about a second in TypeScript, with a marker in the gutter and counts in the status bar. Unused code fades, deprecated code is struck through, and hints get no underline. The errors of your last run stay, marked `last run`, and a run error that the server repeats shows once.
102+
- **Hover documentation.** Rest the pointer on a name, or press the keys below, to read its type and documentation. An error on that name shows above the documentation.
103+
- **Go to definition.** A name in your own file jumps within it; a name from another file of the attempt opens that file's tab; a name from the standard library or a package opens a **library** tab, read-only, with the file's path beside the code. A library tab cannot be saved, and closing it loses nothing. <kbd>Ctrl</kbd>+<kbd>-</kbd> goes back to where the jump started.
104+
- **Reference solutions stay hidden.** A definition never opens a reference solution, and the servers cannot read the folders that hold them: an import of one fails as an import of a missing file. You see a solution only through **Solution…**, and its question.
105+
106+
### Autocomplete in the editor
107+
108+
- **Completion.** The list opens as you type a name or a `.`, and with <kbd>Ctrl</kbd>+<kbd>Space</kbd>. Move with the arrows, accept with <kbd>Enter</kbd>, close with <kbd>Escape</kbd>. The selected item's documentation shows beside the list. Accepting inserts plain text: no snippets with placeholders, and no imports added for you.
109+
- **Signature help.** Typing `(` or `,` in a call shows the signature with the current parameter in bold. <kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>Space</kbd> opens it inside a call.
110+
111+
### Keys and mouse
112+
113+
Read <kbd>Ctrl</kbd> for <kbd>Cmd</kbd> on Linux and Windows. These work while code intelligence applies to the file, except where the last column says otherwise.
114+
115+
| Do | Keys or mouse | With Vim, in normal mode |
116+
|----|---------------|--------------------------|
117+
| Go to definition | <kbd>Cmd</kbd>-click on macOS, <kbd>Ctrl</kbd>-click elsewhere, or <kbd>F12</kbd> | <kbd>g</kbd><kbd>d</kbd>, <kbd>Ctrl</kbd>+<kbd>]</kbd>; the click and <kbd>F12</kbd> work too |
118+
| Back to where the jump started | <kbd>Ctrl</kbd>+<kbd>-</kbd> | <kbd>Ctrl</kbd>+<kbd>o</kbd> |
119+
| Hover documentation | Rest the pointer; or <kbd>Cmd</kbd>+<kbd>K</kbd> then <kbd>Cmd</kbd>+<kbd>I</kbd>; <kbd>Escape</kbd> closes it | <kbd>K</kbd> |
120+
| Next and previous error | <kbd>F8</kbd> and <kbd>Shift</kbd>+<kbd>F8</kbd>, skipping hints | <kbd>]</kbd><kbd>d</kbd> and <kbd>[</kbd><kbd>d</kbd> |
121+
| List the file's errors | <kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>M</kbd> | The same |
122+
| Completion (Autocomplete on) | Type, or <kbd>Ctrl</kbd>+<kbd>Space</kbd>; on macOS also <kbd>Option</kbd>+<kbd>`</kbd> and <kbd>Option</kbd>+<kbd>I</kbd>, since macOS may take <kbd>Ctrl</kbd>+<kbd>Space</kbd> for its input sources | In insert mode the same; <kbd>Escape</kbd> closes the list and leaves insert mode |
123+
| Signature help (Autocomplete on) | <kbd>(</kbd> or <kbd>,</kbd> in a call, or <kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>Space</kbd> | In insert mode the same |
124+
| Add a second cursor, with the settings on or off | <kbd>Alt</kbd>+<kbd>Shift</kbd>-click (<kbd>Option</kbd>+<kbd>Shift</kbd>-click on macOS) | The same |
125+
126+
<kbd>Cmd</kbd>-click and <kbd>Ctrl</kbd>-click never add a cursor any more: with code intelligence on they go to the definition, and with it off they are a plain click. Adding a cursor is <kbd>Alt</kbd>+<kbd>Shift</kbd>-click in both modes, so turning a setting on or off never changes what a click does to your selection.
127+
128+
### Languages
129+
130+
| Language | Server | State |
131+
|----------|--------|-------|
132+
| Python | basedpyright | Available |
133+
| TypeScript | typescript-language-server | Available |
134+
| Java and Kotlin | | Next. Kotlin starts from a check of its server; if that falls short, Java comes alone |
135+
| Go and Rust | | After that |
136+
137+
A file in a language without a server shows a one-line notice in the status bar and works as it does without code intelligence. A language's state also shows in Settings.
66138

67139
## Run the tests and submit
68140

@@ -125,6 +197,8 @@ Settings apply at once and are stored in `.cs/serve/preferences.json` in the wor
125197
| Run on save | off | Each save, from the page or from your IDE, runs the tests again, as `cstudy test --watch` does |
126198
| Type-check TypeScript | on | TypeScript runs type-check, so type errors show in the editor |
127199
| Theme | system | Light or dark, or follow your system |
200+
| Code intelligence | off | Live errors, hover documentation and go to definition from a language server on your computer; needs `cstudy doctor --fix` once ([details](#code-intelligence-and-autocomplete)) |
201+
| Autocomplete | off | Completion and signature help, while code intelligence is also on. Off, the editor offers no completion at all |
128202

129203
## Keyboard
130204

@@ -137,7 +211,9 @@ Every view works with the keyboard alone. On Linux, read <kbd>Ctrl</kbd> for <kb
137211
| <kbd>Cmd</kbd>+<kbd>Enter</kbd> | Run the tests |
138212
| <kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>Enter</kbd> | Submit a project level |
139213
| <kbd>Escape</kbd> in the results | Cancel the run, after a question |
140-
| <kbd>F8</kbd> | Go to the next error in the editor |
214+
| <kbd>F8</kbd>, <kbd>Shift</kbd>+<kbd>F8</kbd> | Go to the next and the previous error in the editor |
215+
| <kbd>F12</kbd>, <kbd>Cmd</kbd>-click, <kbd>Ctrl</kbd>+<kbd>-</kbd> | Go to a definition, and back: [code intelligence](#code-intelligence-and-autocomplete) |
216+
| <kbd>Alt</kbd>+<kbd>Shift</kbd>-click in the editor | Add a second cursor |
141217
| <kbd>Tab</kbd> in the editor | Indent; <kbd>Escape</kbd> then <kbd>Tab</kbd> moves on to the next control |
142218
| <kbd>Alt</kbd>+<kbd>Shift</kbd>+<kbd>M</kbd> (<kbd>Ctrl</kbd>+<kbd>M</kbd> on Linux) | Make <kbd>Tab</kbd> move the focus out of the editor until pressed again |
143219
| <kbd>Shift</kbd>+<kbd>F10</kbd>, <kbd>F2</kbd>, <kbd>Delete</kbd> in the tree | A file's actions, rename, delete |
@@ -162,6 +238,9 @@ A few things stay in the terminal: `cstudy init`, `cstudy ide`, `cstudy new`, `c
162238
| `cstudy serve` exits 4, or `cstudy doctor` warns on `web ui assets` or `web server` | The page's files or the web server libraries are missing or damaged: reinstall `cstudy` with the command `cstudy doctor` prints, which names the install that runs; if it also warns on `installs`, keep one install first |
163239
| A language fails in the Health view | Install its toolchain ([toolchains](toolchains.md)), then use **Fix**, which runs `cstudy doctor --fix` |
164240
| The first Java or Kotlin run is slow | Gradle warms up on the first build, as in the terminal |
241+
| `not installed: run cstudy doctor --fix` in Settings, or `not installed` in the status bar | Run `cstudy doctor --fix` once, with the network on, then open the file again |
242+
| `stopped: exit 1` in the status bar | The language server ended: choose **Restart**, or run `cstudy doctor` to check the install |
243+
| Ctrl-Space shows nothing | Autocomplete is off, or code intelligence is: turn both on in Settings. With Autocomplete off the editor offers no completion at all |
165244
| <kbd>Tab</kbd> skips buttons and links in Safari | Use <kbd>Option</kbd>+<kbd>Tab</kbd>, or turn on "Press Tab to highlight each item on a webpage" in Safari's Advanced settings |
166245

167246
## Security, in plain words
@@ -171,4 +250,5 @@ A few things stay in the terminal: `cstudy init`, `cstudy ide`, `cstudy new`, `c
171250
- **Other websites cannot use it.** The page refuses requests that come from other sites, even from tabs in the same browser.
172251
- **It runs your code, as `cstudy test` does.** Saving a file and running it executes that code as you, which is why the page asks for the token.
173252
- **It touches only your attempt's files.** The page edits the files of the attempts in progress and nothing else, and never follows a link out of them.
253+
- **Language servers stay on your computer.** With code intelligence on, the servers run as you, one per tab and project, and read only what a definition names, as read-only text. They cannot reach the network or the folders that hold reference solutions.
174254
- **Nothing leaves your machine.** The page loads everything from the server and sends nothing elsewhere.

0 commit comments

Comments
 (0)