Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: 5b483625617dfb36093c7c465f3e563f7081807f
Timestamp: Tue, 02 Apr 2024 19:40:38 +0000 (10 months ago)

+3 -1 +/-1 browse
rewrite tree-sitter module names to use snake_case
rewrite tree-sitter module names to use snake_case

This changes the tree-sitter module loader to re-write function calls as
snake_case as is the convention in tree-sitter. For example the module
/usr/lib/libtree-sitter-markdown-inline.so will be re-written try calling the
method tree_sitter_markdown_inline()
1diff --git a/ayllu/src/web2/highlight.rs b/ayllu/src/web2/highlight.rs
2index 462c804..ff7d9b4 100644
3--- a/ayllu/src/web2/highlight.rs
4+++ b/ayllu/src/web2/highlight.rs
5 @@ -30,7 +30,9 @@ lazy_static! {
6
7 unsafe fn load_language(path: &str, hint: &Hint) -> Language {
8 let lib = libloading::Library::new(path).unwrap();
9- let method_name = format!("tree_sitter_{}", hint.0.to_lowercase());
10+ // rewrite any dash in the module name to use snakecase as is the convention
11+ // for tree-sitter function names.
12+ let method_name = format!("tree_sitter_{}", hint.0.to_lowercase().replace('-', "_"));
13 // NOTE: maybe, probably? some security auditing that needs to happen here?
14 debug!("attempting to load method: {}", method_name);
15 let func: libloading::Symbol<unsafe extern "C" fn() -> Language> =