дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Adds an optional syntax-decorations-provider export on plugin API 1.20: a plugin paints foreground colours on ranges of an open text editor from a bounded slice of the editor's own syntax tree (no second parser). A mark is a theme token (rainbow-1 … rainbow-5, mapped onto --syn-rainbow-*) or its own dark and light colours (#rrggbb / #rrggbbaa, the set-styled format; SyntaxMark::colored in the SDK). The host validates the snapshot, drops marks with unknown tokens or invalid colours, debounces and cancels superseded requests, and the editor stylesheet picks the dark or light colour, so a theme change does not ask the plugin again. Sticky Scroll lines keep the marks. Co-authored-by: fsk <[email protected]>
70 рядки
2.7 KiB
Plaintext
70 рядки
2.7 KiB
Plaintext
package openidea:[email protected];
|
|
|
|
/// Optional export (world `plugin-syntax-decorations`): foreground marks for
|
|
/// documents of the languages declared with the `syntax-decorations` provider
|
|
/// kind. The host sends the ranges it is painting and a bounded slice of the
|
|
/// editor's existing syntax tree. The plugin does not parse, and the host does
|
|
/// not run a second parser.
|
|
///
|
|
/// Node `name`s come from that editor's parser. They are not a stable
|
|
/// vocabulary across languages or parser implementations. Ranges use the
|
|
/// shared UTF-16 `types.range` (0-based line, UTF-16 column).
|
|
///
|
|
/// A mark paints its `foreground` colours when it has them, otherwise its
|
|
/// `token`: `rainbow-1` … `rainbow-5`, which the host maps onto the theme's
|
|
/// existing `--syn-rainbow-1` … `--syn-rainbow-5` colours. A mark with an
|
|
/// invalid colour or an unknown token is dropped. Only the foreground changes.
|
|
/// API 1.20.
|
|
interface syntax-decorations-provider {
|
|
use types.{range};
|
|
|
|
/// The open editor the host is asking about. `version` is the host
|
|
/// buffer version at the start of this call.
|
|
record document {
|
|
path: string,
|
|
language: string,
|
|
version: u64,
|
|
}
|
|
|
|
/// One node of the editor's current syntax tree. `parent` is an index
|
|
/// into `decoration-request.nodes`. Index 0 is a real node. The index
|
|
/// may be greater than the child's, because the list is ordered by
|
|
/// position, not parent-before-child. `parent` is none when that
|
|
/// ancestor was not included: the tree may be partial, and the node
|
|
/// budget can drop an ancestor while keeping the child. None does not
|
|
/// mean the node is the root of the real tree. `name` belongs to the
|
|
/// editor's parser and is not stable across parsers.
|
|
record syntax-node {
|
|
name: string,
|
|
range: range,
|
|
parent: option<u32>,
|
|
}
|
|
|
|
record decoration-request {
|
|
document: document,
|
|
/// Ranges the host wants marks for (visible ranges and sticky header
|
|
/// lines). At most 32.
|
|
ranges: list<range>,
|
|
/// At most 8192 nodes.
|
|
nodes: list<syntax-node>,
|
|
}
|
|
|
|
/// Foreground colours of a mark: `#rrggbb`, or `#rrggbbaa` with an alpha
|
|
/// (`ff` fully opaque), one for dark themes and one for light themes.
|
|
record syntax-foreground {
|
|
dark: string,
|
|
light: string,
|
|
}
|
|
|
|
/// A foreground mark. `token` is `rainbow-1` … `rainbow-5`, and may be
|
|
/// empty when `foreground` is set.
|
|
record syntax-mark {
|
|
range: range,
|
|
token: string,
|
|
foreground: option<syntax-foreground>,
|
|
}
|
|
|
|
/// Marks for `request`, under the edit-path budget. At most 10,000 are kept.
|
|
syntax-decorations: func(request: decoration-request) -> list<syntax-mark>;
|
|
}
|