feat(treecrumbs): initial support for C++
Supports namespaces, functions, fields (including trailing return type syntax) and so on. One notable issue about this is that the tree-sitter parser for C++ returns the node *following* point if point is on whitespace, which means that at the top-level of a namespace the crumbs will often show the *next* function. I'm against adding workarounds for stuff like that, so I'll just keep it as is. Change-Id: If7e71525c4e86e128157dd4eb17c130297ed1e0a Reviewed-on: https://cl.tvl.fyi/c/depot/+/11109 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
470f7dfa45
commit
3b7e546dfc
1 changed files with 33 additions and 7 deletions
|
@ -90,6 +90,32 @@ The defined languages are stored in `treecrumbs-languages'."
|
|||
("flow_pair" . ((_) key: (_) @key))
|
||||
("flow_sequence" . "[]"))
|
||||
|
||||
(define-treecrumbs-language cpp
|
||||
;; In C++ files, crumbs are generated from namespaces and
|
||||
;; identifier declarations.
|
||||
("namespace_definition" . ([(namespace_definition
|
||||
name: (namespace_identifier) @key)
|
||||
(namespace_definition
|
||||
"namespace" @key
|
||||
!name)]))
|
||||
|
||||
("function_definition" . ((function_definition
|
||||
declarator:
|
||||
(function_declarator
|
||||
declarator: (_) @key))))
|
||||
|
||||
("class_specifier" . ((class_specifier
|
||||
name: (type_identifier) @key)))
|
||||
|
||||
("struct_specifier" . ((struct_specifier
|
||||
name: (type_identifier) @key)))
|
||||
|
||||
("field_declaration" . ((field_declaration
|
||||
declarator: (_) @key)))
|
||||
|
||||
("init_declarator" . ((init_declarator
|
||||
declarator: (_) @key))))
|
||||
|
||||
(defvar-local treecrumbs--current-crumbs nil
|
||||
"Current crumbs to display in the header line. Only updated when
|
||||
the node under point changes.")
|
||||
|
|
Loading…
Reference in a new issue