Code navigation
Go to definition, find references and jump history in the Files tab, with standard-library sources, language docs and external code search.
On this page
The Files tab's code view can jump to a symbol's definition and list its references without a language server. Each lookup is one quick search of your disk (ripgrep, else git grep), so there is no index to build and nothing runs in the background between lookups. When one hit clearly wins, Flow opens it. When several could be right, they open in the file picker and you choose. If nothing on disk matches, the language's docs and an external code search are one keystroke away.
Code navigation works in Rust, Python, Java, JavaScript / TypeScript, shell (sh, bash, zsh), C and C++. The language comes from the file extension. A file with no extension counts as shell when its #! line names sh, bash, zsh, dash or ksh. In any other file type, a lookup shows No code navigation for this file type in the tab's footer.
Look up a symbol
Open a file in a Files tab first. Then:
| Gesture or key | What it does |
|---|---|
| ⌘-hover | Underlines the word a ⌘-click would look up, and the pointer becomes a hand |
| ⌘-click | Moves the caret to the word and goes to its definition |
| ⌥⌘-click | Finds references |
| ⇧⌘-click | Goes to the definition. If nothing on disk defines it, opens the first escape row directly: the docs, else the external search, in the other place (see Where links open) |
⌘B | Go to definition at the caret (keyboard.go_to_definition) |
⇧⌘B | Find references at the caret (keyboard.find_references) |
F12 / ⇧F12 | Definition / references at the caret, while the code view holds the keyboard |
⌃- / ⌃⇧- | Back / forward through the jump history, while the code view holds the keyboard |
Esc | Cancels a lookup that is still running |
"Go to definition" and "Find references" are also in the command palette, and you can rebind them in Settings › Keyboard. They act on the focused Files tab's caret, so with no Files tab focused or no caret they do nothing. The code view holds the keyboard after you click in the code or land on a jump (the caret shows). Clicking in the explorer gives the keyboard back to the explorer.
While a lookup runs, the footer reads Finding X…. Pressing ⌘-click again, or moving on before it answers, drops the old answer. Moving on means another line, tab, group or page, or a palette you opened yourself, so a late answer never pulls you back.
What opens
- One clear winner opens straight away, with the caret on the symbol. A file under the tab's folder opens in the same tab. A file outside it (a dependency, or the repository top above the tab's folder) opens in a Files tab rooted at that file's own folder.
- Several plausible hits open the file picker in Defs mode with the ranked hits already listed and the first one selected and previewed.
- The caret is already on the definition: you get its references instead, as in an IDE. This also covers a struct field, an enum variant, a TypeScript class field (
name: string;) and a Pythonself.x = 0in__init__. A C prototype is not a definition, so its caret goes to the function. - Find references always opens the picker in Refs mode, even when there are no references. Then the list is empty and its first escape row is selected, so
↩searches outside. - Nothing on disk: the Defs picker opens empty with its first escape row selected, which is the docs for a language word, else Search for more on github.com… (or your configured host).
- A keyword (
fn,def,class,if) searches nothing and goes straight to the empty picker with its docs row.
Where Flow looks
Every lookup searches your disk first. The docs and the external search come only after that. In order, stopping at the first step that answers:
- The file itself. Unless the word is a member access (
obj.x,self.x,p->x) or an import binds it, Flow takes the nearest binding at or above the caret:let, a parameter,for … in, destructuring,with … as,local xor a shell function. - A Rust enum variant (
Verdict::Jump,Self::Empty, orSome/None/Ok/Err). Flow finds the enum first, then the variant inside it. - The repository. The search root is the file's git top level. Flow matches the language's definition shapes (functions, types, classes, methods, constants, macros) and respects
.gitignore. Hidden folders are skipped, except.github,.husky,.circleci,.buildkite,.devcontainer,.gitlaband.config. Agents' worktree copies under.claude/and.worktrees/are never searched. The open file's own definitions always count, even when the file is untracked or has no extension. - Fields, attributes and variants, for a member access that found no method or function. This covers struct fields, enum variants, Python
self.xattributes, JS / TS class fields,this.x =andexports.x =. - Dependencies on disk (local tabs only):
- JS / TS: a bare import's nearest
node_modulespackage. - Python: a package in a virtualenv's
site-packages($VIRTUAL_ENV,.venv,venv,env). - Rust: a crate's sources under
$CARGO_HOME/registry/src, at the versionCargo.locknames. - Java, C, C++ and shell have no dependency step.
- JS / TS: a bare import's nearest
- The standard library (local tabs only). Flow searches the version chosen in Settings › Code › Languages for built-ins and standard names such as
derive,Vec,len,setTimeoutandprintf. For C and C++ it searches the SDK headers for any name. These hits show their origin in the picker, for examplefn · std · Rust 1.83. - Escape rows. Nothing on disk: the empty Defs picker described above.
How hits are ranked
Flow drops lines that only look like definitions: calls, uses (struct S *p) and whole-line comments. The remaining hits rank by:
- Where they are. A path matching the file's import ranks far above the rest, then the same file, the same folder and shared parent folders.
- What they define. Types, functions and modules rank above methods, then macros and constants, then variables. A declaration (a C prototype, a forward
struct S;) never ranks above a definition. - Tests and build output. Test files and vendored or build folders rank lower.
Each picker row ends with a tag that says what the line defines and why it ranks, for example fn · imported, local · same file, method or var · reference.
Defs and Refs in the file picker
Defs and Refs are modes of the file picker, after Grep. ⇥ cycles to them. When a Files tab lookup opened the picker, it ranks with that lookup's language, imports and file for as long as the query is still that symbol. Type any other symbol (two characters or more) and the picker searches every supported language's definitions (Defs) or whole-word occurrences (Refs) in the picker's folder.
| Key | What it does |
|---|---|
↩ | Opens the hit at its line with the caret on the symbol (a lookup's pick is recorded in the jump history) |
⌘↩ | Opens it in a new split |
⌥↩ | Reveals its folder in the explorer |
⌃↩ | Runs the first escape row, from any row |
⇧↩ on an escape row, ⌃⇧↩ on any row | The same, opening the URL in the other place |
⌃D | Pins the hit as a search-result pin |
Escape rows
A Defs, Refs or Grep list ends with extra rows once its search is done:
- Language docs, such as
Rust docs: derive…, for one of the language's own words or a symbol the standard library defined. In shell this row isman lsinstead (man bash: iffor a keyword or bash builtin;man zshbuiltins,man zshzleorman zshcompsysfor zsh-only ones). It opens a new terminal tab runningman, which closes when you quit the page. - Search for more on github.com… (or your configured host).
Escape rows are not counted as hits, and the preview shows the URL or command instead of a file. Grep lists have only the search row. Files, Changed, Recent and Pinned have none. With nothing to run, ⌃↩ explains in the footer: Type a query to search for more or Type at least 2 characters.
Language words and their docs
Some words belong to the language rather than your code:
- Keywords:
fn,def,class,if,then. - Built-ins:
- Rust attributes inside
#[…](derive,cfg,test) and std macros called with!(println!,vec!). - Java annotations (
@Override). - Python builtins and decorators (
len,print,property,dataclass). - C preprocessor directives on a
#line. - Shell builtins (
echo,cd).
- Rust attributes inside
- Standard names:
- Rust's prelude (
Vec,Option) and anything throughstd::. - Python names through a stdlib module (
os.path.join). - JS / TS globals (
setTimeout,Promise,console.log). - Java's
java.langnames. - C's libc (
printf,malloc) and C++'sstd::names.
- Rust's prelude (
For these words, the picker's escape rows start with the docs, at the version you use:
| Language | Docs URL | Version used |
|---|---|---|
| Rust | https://doc.rust-lang.org/{version}/std/?search={symbol} | The chosen or on-disk toolchain (stable without one) |
| Python | https://docs.python.org/{version}/search.html?q={symbol} | major.minor (3 without one) |
| JS / TS | https://developer.mozilla.org/en-US/search?q={symbol} | none |
| Java | https://docs.oracle.com/en/java/javase/{version}/docs/api/search.html?q={symbol} | The JDK's feature release (21 without one) |
| C / C++ | https://en.cppreference.com/mwiki/index.php?search={symbol} | none |
| Shell | man in a terminal tab | none |
You can replace a language's docs URL in Settings › Code › Per language, or with code_search.docs in .flowspace.json (see below). An override for shell gives shell a docs row too.
Standard library sources
The standard-library step searches one copy of each language's sources. Settings › Code › Languages has one row per language. Each row shows what is on disk (version and origin) and what is downloaded (with its size), and has a version picker: Auto (what is on disk) or a specific version. The row also has Download / Remove buttons (Java: Extract sources / Remove), and Cancel while one runs.
| Language | Found on disk | Download |
|---|---|---|
| Rust | rust-src of a rustup toolchain (rustup component add rust-src), a stable one first | rust-src from static.rust-lang.org, checked against its published SHA-256 |
| Python | The stdlib of the repository's .venv / venv base interpreter, else python3's | The Python source tarball from python.org (HTTPS only, no checksum) |
| JS / TS | The repository's node_modules/typescript/lib | The typescript package from the npm registry, checked against its sha512 integrity |
| Java | Installed JDKs (9 or later), each lib/src.zip | None. Extract sources unzips a JDK's java.* modules once |
| C / C++ | The Xcode SDK's usr/include (C++ adds usr/include/c++/v1) | None |
| Shell | Nothing (uses man) | None |
Rust and Python offer recent stable releases. TypeScript offers the npm registry's tags, and Download latest never picks a beta or release candidate. Downloads are stored in ~/Library/Application Support/flow/lang/ and shared by every worktree. A failed or cancelled download leaves nothing behind. A missing tool (no rustup, python3, JDK or Xcode) simply reads as "not found". Flow never triggers the Command Line Tools install prompt.
| Setting | Type | Default | Effect |
|---|---|---|---|
code_nav.lang.rust.version (also python, jsts, java, c, shell) | string | auto | The version the standard-library step searches when it is installed (else the one on disk), and the version the docs links name. C++ uses the c key |
Jump history
Every jump records where the caret was, whether the jump was direct or a pick from a lookup's picker. Each session has one history, shared by all its Files tabs.
- The history holds up to 50 places. A repeat collapses into one entry, and a new jump clears the forward list.
⌃-goes back. It brings the place's tab to the front and reopens its file, so⌃-in a dependency's tab returns you to the tab you jumped from.⌃⇧-goes forward.
The history lasts until Flow quits.
External code search
When you run a Search for more row, Flow opens a code-search URL. By default that is GitHub code search: https://github.com/search?type=code&q={query}.
Settings › Code
The Code search block picks the engine: GitHub (the default), Sourcegraph (with a base URL for a self-hosted instance) or Custom (one URL template). The Per language block has a search template and a docs template for each language. An empty field uses the engine, or the language's built-in docs. Enter saves a field, and anything but an http:// or https:// URL is refused. Changes apply at once, with no restart. The block's first row says which search is in use for the active session's checkout and which layer set it (for example github.com · repo .flowspace.json overrides Settings).
| Setting | Type | Default | Effect |
|---|---|---|---|
code_search.engine | github, sourcegraph or custom | github | Where Search for more goes |
code_search.sourcegraph_url | URL | empty (https://sourcegraph.com) | The Sourcegraph instance, when the engine is Sourcegraph |
code_search.url | URL template | empty (GitHub) | The template, when the engine is Custom |
code_search.by_lang.LANG | URL template | empty (the engine) | One language's search template, in place of the engine |
code_search.docs.LANG | URL template | empty (built-in docs) | One language's docs row |
LANG is one of rust, python, java, jsts, shell, c, cpp.
code_search in .flowspace.json
A repository can set its own search in .flowspace.json under the code_search key. A language without a by_lang entry uses url:
{
"code_search": {
"url": "https://sourcegraph.com/search?q=context:global+{symbol}+lang:{lang}",
"by_lang": {
"java": "https://opengrok.example.com/source/search?defs={symbol}&project=main"
},
"docs": {
"shell": "https://docs.example.com/search?q={symbol}"
}
}
}
A subdirectory's file, your per-repository file and the repository's own .flowspace.json all beat Settings › Code, one field and one language at a time. Settings fill whatever the files leave out. To make your Settings win everywhere, mark code_search !important at the User scope: use the toggle on Settings › Repos, or add "!important": ["code_search"] to ~/.flow/flowspace.json. See Settings scopes and .flowspace.json.
Placeholders in a template (each URL-encoded):
| Placeholder | Is |
|---|---|
{symbol} | The name looked up, with an import alias resolved to its original name. {text} is the same |
{lang} | GitHub's language name (Rust, TypeScript, C++, …) |
{module} | The import's module as written (serde::de, os.path, ./x) |
{package} | The module's first segment (serde, react) |
{path} | The current file, relative to the search root |
{repo} | owner/name of the repository's origin, when known |
{query} | GitHub-style: symbol:NAME language:LANG for a definition, NAME language:LANG for references, plus the package for a third-party import |
Note: Only the built-in Sourcegraph engine speaks Sourcegraph's query syntax. Every template you write yourself keeps the GitHub-style {query}, so a template for a Sourcegraph instance should use {symbol}, as in the example above.
A query you type in the picker with no Files tab behind it (Grep, or a free-typed Defs / Refs symbol) has no language. It always uses url, never a by_lang template, and {lang}, {module}, {package} and {path} are empty. A remote tab uses Settings alone, and {repo} is empty there.
Where links open
The search and docs URLs open like any other web link, as set by links.open_in (Settings › General › Tabs, "Open links in", shown while the web tabs experiment is on):
| Setting | Type | Default | Effect |
|---|---|---|---|
links.open_in | browser or app | browser | Opens web links in your browser, or in a webview tab in Flow |
In the picker, ⇧↩ on the Search for more row (or ⌃⇧↩ anywhere) flips that choice for one search. A ⇧⌘-click with no local definition also goes to the other place. Opening links in Flow needs the web tabs experiment (features.web_tabs). While it is off, links always open in the browser and ⇧ flips nothing. See Webview tabs.
From the command line
Scripts and agents can drive code navigation through flow-cli (see flow-cli):
# Go to definition / find references at a 1-based line and 0-based column
# of the focused group's Files tab (or at the caret)
flow-cli files-nav def 120 8
flow-cli files-nav refs
# Step the jump history
flow-cli files-nav back
flow-cli files-nav forward
# Settings › Code › Languages
flow-cli lang-sources list
flow-cli lang-sources download rust 1.83.0
flow-cli lang-sources cancel rust
files-nav also takes --group NAME. flow-cli state reports each Files tab's last lookup under nav.
Limits
- Pattern matching, not type resolution. An overloaded name, a method called on an expression of unclear type, or a macro-generated item may rank wrong or not be found.
obj.len()finds everylenmethod, ranked by path. The picker is there for these cases. - Remote tabs skip the dependency and standard-library steps and use the code search from Settings only. The repository search runs on the host.
- Files on a paired device have no code navigation (Go to definition is not available for files on another device).
- Searches stop at 200 definition hits, 500 reference hits, 20 hits per file and 1 MB files (8 MB for standard-library files). Without ripgrep or a git checkout nothing can be searched.
- You can look up a word inside a comment, but a whole-line comment never counts as a definition, and in Refs, comment-only lines rank last.
Sources
Written from these files in the Flow app repo
docs/code-navigation.mdsrc/code_nav.rssrc/code_nav_ui.rssrc/lang_ref.rssrc/lang_sources.rssrc/files_code_ui.rssrc/files_ui.rssrc/file_picker.rssrc/file_picker_ui.rssrc/settings_catalog.rssrc/scope.rssrc/link_open.rssrc/pages.rssrc/bin/flow-cli.rs