/* tree_sitter_language_base.h This file is a template from which you can set up new languages for syntax highlighting, go-to-definition, and virtual whitespace in 4coder. BEFORE YOU START: go read the Adding a Language instructions in README.md 1. find and replace "NEWLANG" with Example: "NEWLANG" -> "RUST" and "newlang" -> "rust" 2. Go through each TODO in this file and complete it 3. Include this file from "code/custom/4coder_tree_sitter.cpp" 4. Add "tree_sitter_register_newlang(app);" to 4coder_tree_sitter.cpp::register_all_languages() 5. Compile and run If you are confused about what to do, go look at tree_sitter_cpp.h as a working example. */ #ifndef TREE_SITTER_LANGUAGE_BASE_H #define TREE_SITTER_LANGUAGE_BASE_H String_Const_u8 TS_NEWLANG_EXTENSIONS[] = [ // TODO(PS): fill out this array with the extensions you want to be treated // as this language. SCu8("ext1"), SCu8("ext2"), ]; String_Const_u8 TS_NEWLANG_TAGS_QUERY_SCM = string_u8_litexpr(R"DONE( ; TODO - paste your grammars tags query here ; Important - if you want virtual indentation, leave these tag queries here (_ "{" @scope_begin "}" @scope_end ) (_ "(" @scope_begin ")" @scope_end ) (_ "[" @scope_begin "]" @scope_end ) )DONE"); String_Const_u8 TS_NEWLANG_HIGHLIGHT_QUERY_SCM = string_u8_litexpr(R"DONE( ; TODO - paste your grammars highlights query here )DONE"); // NOTE(PS): depending on how you built your scanner, it might not need to be inside an extern "C" block extern "C" { TSLanguage* tree_sitter_newlang; } void tree_sitter_register_newlang(Application_Links* app) { TSLanguage* language = tree_sitter_newlang(); Tree_Sitter_Language_Queries queries = {}; queries.ptr[Tree_Sitter_Language_Query_Highlights] = tree_sitter_query_new(app, language, TS_NEWLANG_HIGHLIGHT_QUERY_SCM); queries.ptr[Tree_Sitter_Language_Query_Tags] = tree_sitter_query_new(app, language, TS_NEWLANG_TAGS_QUERY_SCM); // TODO(PS): set this to zero if your language can not make use of virtual indentation (like python) Tree_Sitter_Language_Flags flags = ( Tree_Sitter_Language_Can_Receive_Virtual_Indent ); for (int i = 0; i < ArrayCount(TS_NEWLANG_EXTENSIONS); i++) { String_Const_u8 ext = TS_NEWLANG_EXTENSIONS[i]; tree_sitter_register_language(ext, language, queries, flags); } } #endif //TREE_SITTER_LANGUAGE_BASE_H