Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'docs/architecture.md')
| -rw-r--r-- | docs/architecture.md | 69 |
1 files changed, 13 insertions, 56 deletions
diff --git a/docs/architecture.md b/docs/architecture.md index eb6f0c4b..17ef296d 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,16 +1,12 @@ -| Crate | Description | -| ----------- | ----------- | -| helix-stdx | Extensions to the standard library (similar to [`rust-analyzer`'s](https://github.com/rust-lang/rust-analyzer/blob/ea413f67a8f730b4211c09e103f8207c62e7dbc3/crates/stdx/Cargo.toml#L5)) | -| helix-core | Core editing primitives, functional. | -| helix-lsp | Language server client | -| helix-lsp-types | Language Server Protocol type definitions | -| helix-dap | Debug Adapter Protocol (DAP) client | -| helix-event | Primitives for defining and handling events within the editor | -| helix-loader | Functions for building, fetching, and loading external resources | -| helix-view | UI abstractions for use in backends, imperative shell. | -| helix-term | Terminal UI | -| helix-tui | TUI primitives, forked from tui-rs, inspired by Cursive | +| Crate | Description | +| ----------- | ----------- | +| helix-core | Core editing primitives, functional. | +| helix-syntax | Tree-sitter grammars | +| helix-lsp | Language server client | +| helix-view | UI abstractions for use in backends, imperative shell. | +| helix-term | Terminal UI | +| helix-tui | TUI primitives, forked from tui-rs, inspired by Cursive | This document contains a high-level overview of Helix internals. @@ -35,7 +31,7 @@ represented by a `Selection`. Each `Range` in the selection consists of a moving a selection with a single range, with the head and the anchor in the same position. -Ropes are modified by constructing an OT-like `Transaction`. It represents +Ropes are modified by constructing an OT-like `Transaction`. It's represents a single coherent change to the document and can be applied to the rope. A transaction can be inverted to produce an undo. Selections and marks can be mapped over a transaction to translate to a position in the new text state after @@ -45,7 +41,7 @@ applying the transaction. > interface used to generate text edits. `Syntax` is the interface used to interact with tree-sitter ASTs for syntax -highlighting and other features. +highling and other features. ## View @@ -58,40 +54,15 @@ A `Document` ties together the `Rope`, `Selection`(s), `Syntax`, document file. A `View` represents an open split in the UI. It holds the currently open -document ID and other related state. Views encapsulate the gutter, status line, -diagnostics, and the inner area where the code is displayed. +document ID and other related state. > NOTE: Multiple views are able to display the same document, so the document > contains selections for each view. To retrieve, `document.selection()` takes > a `ViewId`. -`Info` is the autoinfo box that shows hints when awaiting another key with bindings -like `g` and `m`. It is attached to the viewport as a whole. - -`Surface` is like a buffer to which widgets draw themselves to, and the -surface is then rendered on the screen on each cycle. - -`Rect`s are areas (simply an x and y coordinate with the origin at the -screen top left and then a height and width) which are part of a -`Surface`. They can be used to limit the area to which a `Component` can -render. For example if we wrap a `Markdown` component in a `Popup` -(think the documentation popup with space+k), Markdown's render method -will get a Rect that is the exact size of the popup. - -Widgets are called `Component`s internally, and you can see most of them -in `helix-term/src/ui`. Some components like `Popup` and `Overlay` can take -other components as children. - -`Layer`s are how multiple components are displayed, and is simply a -`Vec<Component>`. Layers are managed by the `Compositor`. On each top -level render call, the compositor renders each component in the order -they were pushed into the stack. This makes multiple components "layer" -on top of one another. Hence we get a file picker displayed over the -editor, etc. - The `Editor` holds the global state: all the open documents, a tree -representation of all the view splits, the configuration, and a registry of -language servers. To open or close files, interact with the editor. +representation of all the view splits, and a registry of language servers. To +open or close files, interact with the editor. ## LSP @@ -112,17 +83,3 @@ The `main` function sets up a new `Application` that runs the event loop. ## TUI / Term TODO: document Component and rendering related stuff - -## Event - -The `helix-event` crate defines primitives for defining and acting on events -within the editor. "Events" cover things like opening, changing and closing of -documents, starting and stopping of language servers and more. - -`helix-event` has tools for defining events and registering _hooks_ which run -any time an event is emitted. `helix-event` also provides `AsyncHook` - a tool -for running cancellable tasks which run after events with _debouncing_. - -See the `AsyncHook` type for more information. Events can be created within the -`events!` macro. Synchronous hooks can be created with `register_hook!`. And -editor-wide events can be sent to hooks with `helix_event::dispatch`. |