nvim-treesitter/runtime/queries/pascal/highlights.scm

524 lines
8.3 KiB
Scheme
Raw Normal View History

; -- Keywords
[
2024-01-06 15:05:50 +09:00
(kProgram)
(kLibrary)
(kUnit)
(kBegin)
(kEnd)
(kAsm)
(kVar)
(kThreadvar)
(kConst)
(kConstref)
(kResourcestring)
(kOut)
(kType)
(kLabel)
(kExports)
(kProperty)
(kRead)
(kWrite)
(kImplements)
(kClass)
(kInterface)
(kObject)
(kRecord)
(kObjcclass)
(kObjccategory)
(kObjcprotocol)
(kArray)
(kFile)
(kString)
(kSet)
(kOf)
(kHelper)
(kInherited)
(kGeneric)
(kSpecialize)
(kFunction)
(kProcedure)
(kConstructor)
(kDestructor)
(kOperator)
(kReference)
(kImplementation)
(kInitialization)
(kFinalization)
(kTry)
(kExcept)
(kFinally)
(kRaise)
(kOn)
(kCase)
(kWith)
(kGoto)
] @keyword
[
2024-01-06 15:05:50 +09:00
(kFor)
(kTo)
(kDownto)
(kDo)
(kWhile)
(kRepeat)
(kUntil)
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.repeat
[
2024-01-06 15:05:50 +09:00
(kIf)
(kThen)
(kElse)
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.conditional
[
2024-01-06 15:05:50 +09:00
(kPublished)
(kPublic)
(kProtected)
(kPrivate)
(kStrict)
(kRequired)
(kOptional)
] @keyword.modifier
[
2024-01-06 15:05:50 +09:00
(kPacked)
(kAbsolute)
] @keyword.modifier
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(kUses) @keyword.import
; -- Attributes
[
2024-01-06 15:05:50 +09:00
(kDefault)
(kIndex)
(kNodefault)
(kStored)
(kStatic)
(kVirtual)
(kAbstract)
(kSealed)
(kDynamic)
(kOverride)
(kOverload)
(kReintroduce)
(kInline)
(kForward)
(kStdcall)
(kCdecl)
(kCppdecl)
(kPascal)
(kRegister)
(kMwpascal)
(kExternal)
(kName)
(kMessage)
(kDeprecated)
(kExperimental)
(kPlatform)
(kUnimplemented)
(kCvar)
(kExport)
(kFar)
(kNear)
(kSafecall)
(kAssembler)
(kNostackframe)
(kInterrupt)
(kNoreturn)
(kIocheck)
(kLocal)
(kHardfloat)
(kSoftfloat)
(kMs_abi_default)
(kMs_abi_cdecl)
(kSaveregisters)
(kSysv_abi_default)
(kSysv_abi_cdecl)
(kVectorcall)
(kVarargs)
(kWinapi)
(kAlias)
(kDelayed)
(rttiAttributes)
(procAttribute)
] @attribute
2024-01-06 15:05:50 +09:00
(procAttribute
(kPublic) @attribute)
; -- Punctuation & operators
[
2024-01-06 15:05:50 +09:00
"("
")"
"["
"]"
] @punctuation.bracket
[
2024-01-06 15:05:50 +09:00
";"
","
":"
(kEndDot)
] @punctuation.delimiter
2024-01-06 15:05:50 +09:00
".." @punctuation.special
[
2024-01-06 15:05:50 +09:00
(kDot)
(kAdd)
(kSub)
(kMul)
(kFdiv)
(kAssign)
(kAssignAdd)
(kAssignSub)
(kAssignMul)
(kAssignDiv)
(kEq)
(kLt)
(kLte)
(kGt)
(kGte)
(kNeq)
(kAt)
(kHat)
] @operator
[
2024-01-06 15:05:50 +09:00
(kOr)
(kXor)
(kDiv)
(kMod)
(kAnd)
(kShl)
(kShr)
(kNot)
(kIs)
(kAs)
(kIn)
] @keyword.operator
; -- Builtin constants
[
2024-01-06 15:05:50 +09:00
(kTrue)
(kFalse)
] @boolean
2024-01-06 15:05:50 +09:00
(kNil) @constant.builtin
; -- Literals
2024-01-06 15:05:50 +09:00
(literalNumber) @number
2024-01-06 15:05:50 +09:00
(literalString) @string
; -- Variables
2024-01-06 15:05:50 +09:00
(exprBinary
(identifier) @variable)
2024-01-06 15:05:50 +09:00
(exprUnary
(identifier) @variable)
2024-01-06 15:05:50 +09:00
(assignment
(identifier) @variable)
(exprBrackets
(identifier) @variable)
(exprParens
(identifier) @variable)
(exprDot
(identifier) @variable)
2024-01-06 15:05:50 +09:00
(exprTpl
(identifier) @variable)
(exprArgs
(identifier) @variable)
(defaultValue
(identifier) @variable)
; -- Comments
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
2024-01-06 15:05:50 +09:00
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((comment) @comment.documentation
2024-01-06 15:05:50 +09:00
.
[
(unit)
(declProc)
])
(declTypes
(comment) @comment.documentation
2024-01-06 15:05:50 +09:00
.
(declType))
(declSection
(comment) @comment.documentation
2024-01-06 15:05:50 +09:00
.
[
(declField)
(declProc)
])
(declEnum
(comment) @comment.documentation
2024-01-06 15:05:50 +09:00
.
(declEnumValue))
(declConsts
(comment) @comment.documentation
2024-01-06 15:05:50 +09:00
.
(declConst))
(declVars
(comment) @comment.documentation
2024-01-06 15:05:50 +09:00
.
(declVar))
2024-01-06 15:05:50 +09:00
(pp) @keyword.directive
; -- Type declaration
2024-01-06 15:05:50 +09:00
(declType
name: (identifier) @type)
2024-01-06 15:05:50 +09:00
(declType
name: (genericTpl
entity: (identifier) @type))
; -- Procedure & function declarations
; foobar
2024-01-06 15:05:50 +09:00
(declProc
name: (identifier) @function)
; foobar<t>
2024-01-06 15:05:50 +09:00
(declProc
name: (genericTpl
entity: (identifier) @function))
2024-01-06 15:05:50 +09:00
; foo.bar
2024-01-06 15:05:50 +09:00
(declProc
name: (genericDot
rhs: (identifier) @function))
2024-01-06 15:05:50 +09:00
; foo.bar<t>
2024-01-06 15:05:50 +09:00
(declProc
name: (genericDot
rhs: (genericTpl
entity: (identifier) @function)))
; Treat property declarations like functions
2024-01-06 15:05:50 +09:00
(declProp
name: (identifier) @function)
2024-01-06 15:05:50 +09:00
(declProp
getter: (identifier) @variable.member)
2024-01-06 15:05:50 +09:00
(declProp
setter: (identifier) @variable.member)
2024-01-06 15:05:50 +09:00
; -- Function parameters
(declArg
name: (identifier) @variable.parameter)
; -- Template parameters
2024-01-06 15:05:50 +09:00
(genericArg
name: (identifier) @variable.parameter)
2024-01-06 15:05:50 +09:00
(genericArg
type: (typeref) @type)
2024-01-06 15:05:50 +09:00
(declProc
name: (genericDot
lhs: (identifier) @type))
2024-01-06 15:05:50 +09:00
(declType
(genericDot
(identifier) @type))
2024-01-06 15:05:50 +09:00
(genericDot
(genericTpl
(identifier) @type))
2024-01-06 15:05:50 +09:00
(genericDot
(genericDot
(identifier) @type))
2024-01-06 15:05:50 +09:00
(genericTpl
entity: (identifier) @type)
2024-01-06 15:05:50 +09:00
(genericTpl
entity: (genericDot
(identifier) @type))
2024-01-06 15:05:50 +09:00
; -- Exception parameters
(exceptionHandler
variable: (identifier) @variable.parameter)
; -- Type usage
(typeref) @type
; -- Constant usage
[
2024-01-06 15:05:50 +09:00
(caseLabel)
(label)
] @constant
2024-01-06 15:05:50 +09:00
(procAttribute
(identifier) @constant)
(procExternal
(identifier) @constant)
; -- Variable & constant declarations
; (This is only questionable because we cannot detect types of identifiers
; declared in other units, so the results will be inconsistent)
2024-01-06 15:05:50 +09:00
(declVar
name: (identifier) @variable)
(declConst
name: (identifier) @constant)
2024-01-06 15:05:50 +09:00
(declEnumValue
name: (identifier) @constant)
; -- Fields
2024-01-06 15:05:50 +09:00
(exprDot
rhs: (identifier) @variable.member)
2024-01-06 15:05:50 +09:00
(exprDot
rhs: (exprDot) @variable.member)
2024-01-06 15:05:50 +09:00
(declClass
(declField
name: (identifier) @variable.member))
2024-01-06 15:05:50 +09:00
(declSection
(declField
name: (identifier) @variable.member))
2024-01-06 15:05:50 +09:00
(declSection
(declVars
(declVar
name: (identifier) @variable.member)))
2024-01-06 15:05:50 +09:00
(recInitializerField
name: (identifier) @variable.member)
2024-01-06 15:05:50 +09:00
; ---------------------------------------------- ;;;
; EVERYTHING BELOW THIS IS OF QUESTIONABLE VALUE ;;;
; ---------------------------------------------- ;;;
; -- Procedure name in calls with parentheses
; (Pascal doesn't require parentheses for procedure calls, so this will not
; detect all calls)
; foobar
2024-01-06 15:05:50 +09:00
(exprCall
entity: (identifier) @function)
; foobar<t>
2024-01-06 15:05:50 +09:00
(exprCall
entity: (exprTpl
entity: (identifier) @function))
2024-01-06 15:05:50 +09:00
; foo.bar
2024-01-06 15:05:50 +09:00
(exprCall
entity: (exprDot
rhs: (identifier) @function))
2024-01-06 15:05:50 +09:00
; foo.bar<t>
2024-01-06 15:05:50 +09:00
(exprCall
entity: (exprDot
rhs: (exprTpl
entity: (identifier) @function)))
(inherited) @function
; -- Heuristic for procedure/function calls without parentheses
; (If a statement consists only of an identifier, assume it's a procedure)
; (This will still not match all procedure calls, and also may produce false
; positives in rare cases, but only for nonsensical code)
2024-01-06 15:05:50 +09:00
(statement
(identifier) @function)
(statement
(exprDot
rhs: (identifier) @function))
2024-01-06 15:05:50 +09:00
(statement
(exprTpl
entity: (identifier) @function))
(statement
(exprDot
rhs: (exprTpl
entity: (identifier) @function)))
; -- Break, Continue & Exit
; (Not ideal: ideally, there would be a way to check if these special
; identifiers are shadowed by a local variable)
2024-01-06 15:05:50 +09:00
(statement
((identifier) @keyword.return
(#lua-match? @keyword.return "^[eE][xX][iI][tT]$")))
2024-01-06 15:05:50 +09:00
(statement
(exprCall
entity: ((identifier) @keyword.return
(#lua-match? @keyword.return "^[eE][xX][iI][tT]$"))))
2024-01-06 15:05:50 +09:00
(statement
((identifier) @keyword.repeat
(#lua-match? @keyword.repeat "^[bB][rR][eE][aA][kK]$")))
2024-01-06 15:05:50 +09:00
(statement
((identifier) @keyword.repeat
(#lua-match? @keyword.repeat "^[cC][oO][nN][tT][iI][nN][uU][eE]$")))
; -- Identifier type inference
; VERY QUESTIONABLE: Highlighting of identifiers based on spelling
2024-01-06 15:05:50 +09:00
(exprBinary
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
(exprUnary
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
(assignment
rhs: ((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
2024-01-06 15:05:50 +09:00
(exprBrackets
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
(exprParens
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
(exprDot
rhs: ((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
2024-01-06 15:05:50 +09:00
(exprTpl
args: ((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
2024-01-06 15:05:50 +09:00
(exprArgs
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
(declEnumValue
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
(defaultValue
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))