This adds the necessary infrastructure to use tree-sitter for syntax highlighting in LLDB. It provides the base class for a tree-sitter highlighter plugin. Its primary function is interfacing with the tree-sitter library, and converting captures to highlighting styles. Adding a new tree-sitter highlighter consists of creating an LLDB plugin that inherits from this class. The plugin has two core responsibilities: 1. Loading the tree-sitter grammar. 2. Specifying the tree-sitter syntax highlighting query. Everything else is handled by the base class, making it extremely easy to add a new language. For more context and the motivation behind using tree-sitter for syntax highlighting, see #170250.
23 lines
453 B
CMake
23 lines
453 B
CMake
# FindTreeSitter.cmake
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_path(TreeSitter_INCLUDE_DIR
|
|
NAMES tree_sitter/api.h)
|
|
|
|
find_library(TreeSitter_LIBRARY
|
|
NAMES tree-sitter treesitter)
|
|
|
|
find_program(TreeSitter_BINARY
|
|
NAMES tree-sitter)
|
|
|
|
find_package_handle_standard_args(TreeSitter
|
|
REQUIRED_VARS TreeSitter_LIBRARY TreeSitter_INCLUDE_DIR TreeSitter_BINARY
|
|
)
|
|
|
|
mark_as_advanced(
|
|
TreeSitter_INCLUDE_DIR
|
|
TreeSitter_LIBRARY
|
|
TreeSitter_BINARY
|
|
)
|