[llvm-branch-commits] [lldb] [lldb] Add tree-sitter based Rust syntax highlighting (PR #181282)
Jonas Devlieghere via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Feb 13 12:57:41 PST 2026
================
@@ -0,0 +1,206 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "RustTreeSitterHighlighter.h"
+#include "lldb/Target/Language.h"
+
+LLDB_PLUGIN_DEFINE_ADV(RustTreeSitterHighlighter, HighlighterTreeSitterRust)
+
+extern "C" {
+const TSLanguage *tree_sitter_rust();
+}
+
+using namespace lldb_private;
+
+const TSLanguage *RustTreeSitterHighlighter::GetLanguage() const {
+ return tree_sitter_rust();
+}
+
+llvm::StringRef RustTreeSitterHighlighter::GetHighlightQuery() const {
+ static constexpr const llvm::StringLiteral query = R"__(
+; Identifiers
+
+(type_identifier) @type
----------------
JDevlieghere wrote:
It can come from the grammar repo (which is the base for Rust and Swift) or it can be something we write ourselves (what I did originally for C++ in my prototype). For now I don't plan to pursue the latter so the idea would be that this always come from the vendored grammar. I now use CMake to do this for us based on the original `.scm` file (see https://github.com/llvm/llvm-project/pull/181297)
https://github.com/llvm/llvm-project/pull/181282
More information about the llvm-branch-commits
mailing list