Rearrange code and cleanup
This commit is contained in:
74
include/ts/decl.h
Normal file
74
include/ts/decl.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef TS_DECL_H
|
||||
#define TS_DECL_H
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#define LANG(name) tree_sitter_##name
|
||||
#define TS_DEF(name) extern "C" const TSLanguage *LANG(name)()
|
||||
|
||||
struct Language {
|
||||
std::string name;
|
||||
const TSLanguage *(*fn)();
|
||||
uint8_t lsp_id = 0;
|
||||
};
|
||||
|
||||
struct Highlight {
|
||||
uint32_t fg;
|
||||
uint32_t bg;
|
||||
uint32_t flags;
|
||||
uint8_t priority;
|
||||
};
|
||||
|
||||
struct TSSetBase {
|
||||
std::string lang;
|
||||
TSParser *parser;
|
||||
std::string query_file;
|
||||
TSQuery *query;
|
||||
TSTree *tree;
|
||||
std::map<uint16_t, Highlight> query_map;
|
||||
std::map<uint16_t, Language> injection_map;
|
||||
const TSLanguage *language;
|
||||
};
|
||||
|
||||
struct TSSet : TSSetBase {
|
||||
std::vector<TSRange> ranges;
|
||||
};
|
||||
|
||||
struct TSSetMain : TSSetBase {
|
||||
std::unordered_map<std::string, TSSet> injections;
|
||||
};
|
||||
|
||||
TS_DEF(ruby);
|
||||
TS_DEF(bash);
|
||||
TS_DEF(cpp);
|
||||
TS_DEF(css);
|
||||
TS_DEF(fish);
|
||||
TS_DEF(go);
|
||||
TS_DEF(haskell);
|
||||
TS_DEF(html);
|
||||
TS_DEF(javascript);
|
||||
TS_DEF(tsx);
|
||||
TS_DEF(man);
|
||||
TS_DEF(json);
|
||||
TS_DEF(lua);
|
||||
TS_DEF(regex);
|
||||
TS_DEF(query);
|
||||
TS_DEF(markdown);
|
||||
TS_DEF(markdown_inline);
|
||||
TS_DEF(embedded_template);
|
||||
TS_DEF(php);
|
||||
TS_DEF(python);
|
||||
TS_DEF(rust);
|
||||
TS_DEF(sql);
|
||||
TS_DEF(gitattributes);
|
||||
TS_DEF(gitignore);
|
||||
TS_DEF(gomod);
|
||||
TS_DEF(nginx);
|
||||
TS_DEF(toml);
|
||||
TS_DEF(yaml);
|
||||
TS_DEF(ini);
|
||||
TS_DEF(diff);
|
||||
TS_DEF(make);
|
||||
TS_DEF(gdscript);
|
||||
|
||||
#endif
|
||||
18
include/ts/ts.h
Normal file
18
include/ts/ts.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef TS_H
|
||||
#define TS_H
|
||||
|
||||
#include "editor/editor.h"
|
||||
#include "pch.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define HEX(s) (static_cast<uint32_t>(std::stoul(s, nullptr, 16)))
|
||||
|
||||
extern std::unordered_map<std::string, pcre2_code *> regex_cache;
|
||||
|
||||
TSQuery *load_query(const char *query_path, TSSetBase *set);
|
||||
void ts_collect_spans(Editor *editor);
|
||||
bool ts_predicate(TSQuery *query, const TSQueryMatch &match,
|
||||
std::function<std::string(const TSNode *)> subject_fn);
|
||||
void clear_regex_cache();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user