Internals
Everything documented in this page is internal and subject to breaking changes. These are provided here for those curious about how JuliaSyntaxHighlighting
works, and as a reference for contributors.
JuliaSyntaxHighlighting.MAX_PAREN_HIGHLIGHT_DEPTH
— ConstantMAX_PAREN_HIGHLIGHT_DEPTH
The number of julia_rainbow_{paren,bracket_curly}_{n}
faces from HIGHLIGHT_FACES
that can be cycled through.
JuliaSyntaxHighlighting.RAINBOW_DELIMITERS_ENABLED
— ConstantRAINBOW_DELIMITERS_ENABLED
Whether to use julia_rainbow_{paren,bracket_curly}_{n}
faces for delimitors/parentheses (()
, []
, {}
) as opposed to just using julia_parentheses
.
JuliaSyntaxHighlighting.UNMATCHED_DELIMITERS_ENABLED
— ConstantUNMATCHED_DELIMITERS_ENABLED
Whether to apply the julia_unpaired_parentheses
face to unpaired closing parenthesis ()
, ]
, '}').
JuliaSyntaxHighlighting.SINGLETON_IDENTIFIERS
— ConstantSINGLETON_IDENTIFIERS
Symbols that represent identifiers known to be instances of a singleton type, currently just Nothing
and Missing
.
JuliaSyntaxHighlighting.BUILTIN_FUNCTIONS
— ConstantBUILTIN_FUNCTIONS
A set of identifiers that are defined in Core
and a Core.Builtin
.
JuliaSyntaxHighlighting.OPERATOR_KINDS
— ConstantOPERATOR_KINDS
A set of known operator kind strings.
This is a workaround for operators that are classified as K"Identifier"
.
JuliaSyntaxHighlighting.HIGHLIGHT_FACES
— ConstantHIGHLIGHT_FACES
A list of name => Face(...)
pairs that define the faces in JuliaSyntaxHighlighting
. These are registered during module initialisation.
JuliaSyntaxHighlighting.paren_type
— Functionparen_type(k::Kind) -> (Int, Symbol)
Return a pair of values giving the change in nesting depth caused by the paren k
(+1 or -1), as well as a symbol indicating the kind of parenthesis:
(
and)
are aparen
[
and]
are abracket
{
and}
are acurly
Anything else is of type none
, and produced a depth change of 0
.
JuliaSyntaxHighlighting._hl_annotations
— Function_hl_annotations(content::AbstractString, ast::GreenNode)
-> Vector{@NamedTuple{region::UnitRange{Int}, label::Symbol, value::Any}}
Generate a list of annotations for the given content
and ast
.
Each annotation takes the form of a @NamedTuple{region::UnitRange{Int}, label::Symbol, value::Any}
, where the region indexes into content
and the value is a julia_*
face name.
This is a small wrapper around _hl_annotations!
for convenience.
JuliaSyntaxHighlighting._hl_annotations!
— Function_hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int}, label::Symbol, value::Any}},
lineage::GreenLineage, ctx::HighlightContext)
Populate highlights
with annotations for the given lineage
and ctx
, where lineage
is expected to be consistent with ctx.offset
and ctx.lnode
.