Compile some languages into your app, and declare them:
rust
extern "C" tree_sitter_python();
extern "C" tree_sitter_javascript();
Create a tag context. You need one of these for each thread that you're using for tag computation:
```rust use treesittertags::TagsContext;
let context = TagsContext::new(); ```
Load some tagging queries from the queries
directory of some language repositories:
```rust use treesitterhighlight::TagsConfiguration;
let pythonlanguage = unsafe { treesitterpython() }; let javascriptlanguage = unsafe { treesitterjavascript() };
let pythonconfig = HighlightConfiguration::new( pythonlanguage, &fs::readtostring("./tree-sitter-python/queries/tags.scm").unwrap(), &fs::readtostring("./tree-sitter-python/queries/locals.scm").unwrap(), ).unwrap();
let javascriptconfig = HighlightConfiguration::new( javascriptlanguage, &fs::readtostring("./tree-sitter-javascript/queries/tags.scm").unwrap(), &fs::readtostring("./tree-sitter-javascript/queries/locals.scm").unwrap(), ).unwrap(); ```
Compute code navigation tags for some source code:
```rust use treesitterhighlight::HighlightEvent;
let tags = context.generatetags( &javascriptconfig, b"class A { getB() { return c(); } }", None, |_| None );
for tag in tags { println!("kind: {:?}", tag.kind); println!("range: {:?}", tag.range); println!("namerange: {:?}", tag.namerange); println!("docs: {:?}", tag.docs); } ```