llvm-project/lldb/cmake/modules/FindTreeSitter.cmake
Jonas Devlieghere f03ff95ce2
[lldb] Add tree-sitter based syntax highlighting (#181279)
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.
2026-02-16 09:19:55 -08:00

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
)