Documentation
¶
Overview ¶
Package syntax wraps tree-sitter: incremental parsing and highlight spans. All CGo is confined here; the editor sees only the editor.Syntax interface.
Index ¶
- type Highlighter
- func (h *Highlighter) Close()
- func (h *Highlighter) Edit(startOff, oldEndOff, newEndOff int, start, oldEnd, newEnd [2]int)
- func (h *Highlighter) Expand(src []byte, lo, hi int) (int, int, bool)
- func (h *Highlighter) Folds(src []byte, startOff, endOff int) [][2]int
- func (h *Highlighter) Spans(src []byte, startOff, endOff int) []editor.HLSpan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
Highlighter implements editor.Syntax for one buffer.
func New ¶
func New(path string, src []byte) *Highlighter
New returns a highlighter for the file at path, or nil if the language is not supported.
func (*Highlighter) Close ¶ added in v0.6.1
func (h *Highlighter) Close()
Close frees the tree-sitter C objects — go-tree-sitter has no finalizers, so an unclosed Highlighter leaks native memory on every tab close.
func (*Highlighter) Edit ¶
func (h *Highlighter) Edit(startOff, oldEndOff, newEndOff int, start, oldEnd, newEnd [2]int)
Edit implements editor.Syntax: feed the change to the old tree and mark it for lazy reparse on the next Spans call.
func (*Highlighter) Expand ¶
Expand implements editor.Syntax: the smallest named node strictly containing [lo, hi) — structural selection.
func (*Highlighter) Folds ¶ added in v0.14.0
func (h *Highlighter) Folds(src []byte, startOff, endOff int) [][2]int
Folds implements editor.Folder: fold regions (startLine, endLine) for the outermost multi-line named nodes starting within [startOff, endOff), sorted by start line. "Outermost" per start line: DFS visits parents first, so the first node claiming a line wins.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package tsdockerfile vendors tree-sitter-dockerfile v0.2.0 (github.com/camdencheek/tree-sitter-dockerfile, MIT — see LICENSE): upstream's Go bindings module declares a broken module path and targets the old smacker tree-sitter library.
|
Package tsdockerfile vendors tree-sitter-dockerfile v0.2.0 (github.com/camdencheek/tree-sitter-dockerfile, MIT — see LICENSE): upstream's Go bindings module declares a broken module path and targets the old smacker tree-sitter library. |
|
Package tsmarkdown vendors tree-sitter-markdown v0.5.3 (github.com/tree-sitter-grammars/tree-sitter-markdown, MIT — see LICENSE): upstream ships no Go bindings.
|
Package tsmarkdown vendors tree-sitter-markdown v0.5.3 (github.com/tree-sitter-grammars/tree-sitter-markdown, MIT — see LICENSE): upstream ships no Go bindings. |