Documentation
¶
Overview ¶
Package syntax provides Tree-sitter based syntax highlighting. It tokenizes source text using Tree-sitter grammars and highlight queries, returning scope-named spans that map directly to theme scopes
Index ¶
- func FindMatchingBracket(source core.Source, cursorPos int) (int, bool)
- func HasHighlightQuery(lang string) bool
- func IndentForNewline(args IndentForNewlineArgs) (string, bool)
- func ParentNodeEnd(args SelectionArgs) (int, bool)
- func SupportedLanguages() []string
- type Cache
- type FindSurroundPairArgs
- type FindSurroundPairForArgs
- type FindTextObjectArgs
- type IndentForNewlineArgs
- type Range
- func ExpandSelection(args SelectionArgs) (Range, bool)
- func FindSurroundPair(args FindSurroundPairArgs) (Range, bool)
- func FindSurroundPairFor(args FindSurroundPairForArgs) (Range, bool)
- func FindTextObject(args FindTextObjectArgs) (Range, bool)
- func ShrinkSelection(args SelectionArgs) (Range, bool)
- type SelectionArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindMatchingBracket ¶
FindMatchingBracket returns the char position of the bracket matching the one at cursorPos, using the parse tree so string/comment brackets don't falsely match
func HasHighlightQuery ¶
HasHighlightQuery reports whether a highlight query ships for lang
func IndentForNewline ¶
func IndentForNewline(args IndentForNewlineArgs) (string, bool)
IndentForNewline returns syntax-aware indentation for a newline after Pos
func ParentNodeEnd ¶ added in v0.1.13
func ParentNodeEnd(args SelectionArgs) (int, bool)
ParentNodeEnd returns the end of the innermost named node at the cursor, which is where a syntax-aware tab jumps to; false means no node was found, which is not the same as a node whose end the cursor already sits on
func SupportedLanguages ¶
func SupportedLanguages() []string
SupportedLanguages lists the languages with bundled highlighters
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds Tree-sitter parser and query caches for a UI context
func NewSyntaxCache ¶
func NewSyntaxCache() *Cache
NewSyntaxCache returns an initialized SyntaxCache
type FindSurroundPairArgs ¶ added in v0.2.0
FindSurroundPairArgs identifies the enclosing pair to find: the Skip-th pair around Cursor, in any bracket style
type FindSurroundPairForArgs ¶ added in v0.2.0
FindSurroundPairForArgs identifies the enclosing bracket pair to find: the Skip-th pair matching Char around Cursor
type FindTextObjectArgs ¶ added in v0.2.0
FindTextObjectArgs identifies the textobject to find: the kind selected by Char at Cursor, taken inner (Inside) or whole
type IndentForNewlineArgs ¶ added in v0.2.0
type IndentForNewlineArgs struct {
Text core.Rope
Lang string
Line int
Pos int
Style core.IndentStyle
}
IndentForNewlineArgs carries the document position and style used to compute indentation for a new line
type Range ¶
Range is a character range selected by syntax
func ExpandSelection ¶
func ExpandSelection(args SelectionArgs) (Range, bool)
ExpandSelection returns the smallest Tree-sitter named node that strictly contains the current range, or the smallest named node at the cursor for an empty range
func FindSurroundPair ¶
func FindSurroundPair(args FindSurroundPairArgs) (Range, bool)
FindSurroundPair returns the Range of the Skip-th bracket pair enclosing Cursor, or (Range{}, false) if none exists at that depth
func FindSurroundPairFor ¶
func FindSurroundPairFor(args FindSurroundPairForArgs) (Range, bool)
FindSurroundPairFor returns the Range of the Skip-th enclosing pair matching Char (either bracket of the pair), or (Range{}, false) if none exists
func FindTextObject ¶
func FindTextObject(args FindTextObjectArgs) (Range, bool)
FindTextObject finds the innermost textobject at Cursor for Lang. Inside returns the node's inner content (delimiters stripped) vs its full range
func ShrinkSelection ¶
func ShrinkSelection(args SelectionArgs) (Range, bool)
ShrinkSelection returns the largest Tree-sitter named node under the cursor that is strictly contained by the current range