Add tree-sitter grammars for common languages I use.
This commit is contained in:
@@ -223,7 +223,8 @@ void apply_edit(std::vector<Span> &spans, uint32_t x, int64_t y);
|
||||
void apply_hook_insertion(Editor *editor, uint32_t line, uint32_t rows);
|
||||
void apply_hook_deletion(Editor *editor, uint32_t removal_start,
|
||||
uint32_t removal_end);
|
||||
Editor *new_editor(const char *filename, Coord position, Coord size);
|
||||
Editor *new_editor(const char *filename_arg, Coord position, Coord size);
|
||||
void save_file(Editor *editor);
|
||||
void free_editor(Editor *editor);
|
||||
void render_editor(Editor *editor);
|
||||
void fold(Editor *editor, uint32_t start_line, uint32_t end_line);
|
||||
|
||||
111
include/maps.h
111
include/maps.h
@@ -4,7 +4,22 @@
|
||||
#include "./lsp.h"
|
||||
#include "./pch.h"
|
||||
#include "./ts_def.h"
|
||||
#include <unordered_map>
|
||||
|
||||
static const std::unordered_map<uint8_t, LSP> kLsps = {
|
||||
{1,
|
||||
{"clangd",
|
||||
{
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion=never",
|
||||
"--pch-storage=memory",
|
||||
"--limit-results=50",
|
||||
"--log=error",
|
||||
nullptr,
|
||||
}}},
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, Language> kLanguages = {
|
||||
{"bash", {"bash", LANG(bash)}},
|
||||
@@ -22,29 +37,67 @@ static const std::unordered_map<std::string, Language> kLanguages = {
|
||||
{"make", {"make", LANG(make)}},
|
||||
{"python", {"python", LANG(python)}},
|
||||
{"ruby", {"ruby", LANG(ruby)}},
|
||||
};
|
||||
|
||||
static const std::unordered_map<uint8_t, LSP> kLsps = {
|
||||
{1,
|
||||
{"clangd",
|
||||
{
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion=iwyu",
|
||||
"--log=error",
|
||||
nullptr,
|
||||
}}},
|
||||
{"diff", {"diff", LANG(diff)}},
|
||||
{"embedded_template", {"embedded_template", LANG(embedded_template)}},
|
||||
{"gdscript", {"gdscript", LANG(gdscript)}},
|
||||
{"gitattributes", {"gitattributes", LANG(gitattributes)}},
|
||||
{"gitignore", {"gitignore", LANG(gitignore)}},
|
||||
{"gomod", {"gomod", LANG(gomod)}},
|
||||
{"ini", {"ini", LANG(ini)}},
|
||||
{"markdown", {"markdown", LANG(markdown)}},
|
||||
{"nginx", {"nginx", LANG(nginx)}},
|
||||
{"php", {"php", LANG(php)}},
|
||||
{"query", {"query", LANG(query)}},
|
||||
{"regex", {"regex", LANG(regex)}},
|
||||
{"sql", {"sql", LANG(sql)}},
|
||||
{"toml", {"toml", LANG(toml)}},
|
||||
{"yaml", {"yaml", LANG(yaml)}},
|
||||
{"cabal", {"cabal", LANG(cabal)}},
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, std::string> kExtToLang = {
|
||||
{"sh", "bash"}, {"bash", "bash"}, {"c", "c"}, {"cpp", "cpp"},
|
||||
{"cxx", "cpp"}, {"cc", "cpp"}, {"hpp", "h"}, {"hh", "h"},
|
||||
{"hxx", "h"}, {"h", "h"}, {"css", "css"}, {"fish", "fish"},
|
||||
{"go", "go"}, {"hs", "haskell"}, {"html", "html"}, {"htm", "html"},
|
||||
{"js", "javascript"}, {"json", "json"}, {"lua", "lua"}, {"mk", "make"},
|
||||
{"makefile", "make"}, {"py", "python"}, {"rb", "ruby"},
|
||||
{"sh", "bash"},
|
||||
{"bash", "bash"},
|
||||
{"c", "c"},
|
||||
{"cpp", "cpp"},
|
||||
{"cxx", "cpp"},
|
||||
{"cc", "cpp"},
|
||||
{"hpp", "h"},
|
||||
{"hh", "h"},
|
||||
{"hxx", "h"},
|
||||
{"h", "h"},
|
||||
{"css", "css"},
|
||||
{"fish", "fish"},
|
||||
{"go", "go"},
|
||||
{"hs", "haskell"},
|
||||
{"html", "html"},
|
||||
{"htm", "html"},
|
||||
{"js", "javascript"},
|
||||
{"json", "json"},
|
||||
{"lua", "lua"},
|
||||
{"mk", "make"},
|
||||
{"makefile", "make"},
|
||||
{"py", "python"},
|
||||
{"rb", "ruby"},
|
||||
{"diff", "diff"},
|
||||
{"erb", "embedded_template"},
|
||||
{"etlua", "embedded_template"},
|
||||
{"gd", "gdscript"},
|
||||
{"gitattributes", "gitattributes"},
|
||||
{"gitignore", "gitignore"},
|
||||
{"mod", "gomod"},
|
||||
{"ini", "ini"},
|
||||
{"md", "markdown"},
|
||||
{"markdown", "markdown"},
|
||||
{"conf", "nginx"},
|
||||
{"php", "php"},
|
||||
{"scm", "query"},
|
||||
{"regex", "regex"},
|
||||
{"sql", "sql"},
|
||||
{"toml", "toml"},
|
||||
{"yaml", "yaml"},
|
||||
{"yml", "yaml"},
|
||||
{"cabal", "cabal"},
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, std::string> kMimeToLang = {
|
||||
@@ -60,6 +113,22 @@ static const std::unordered_map<std::string, std::string> kMimeToLang = {
|
||||
{"text/x-go", "go"},
|
||||
{"text/x-haskell", "haskell"},
|
||||
{"text/x-lua", "lua"},
|
||||
{"text/x-diff", "diff"},
|
||||
{"text/x-embedded-template", "embedded_template"},
|
||||
{"text/x-gdscript", "gdscript"},
|
||||
{"text/x-gitattributes", "gitattributes"},
|
||||
{"text/x-gitignore", "gitignore"},
|
||||
{"text/x-gomod", "gomod"},
|
||||
{"text/x-ini", "ini"},
|
||||
{"text/markdown", "markdown"},
|
||||
{"text/x-nginx-conf", "nginx"},
|
||||
{"application/x-php", "php"},
|
||||
{"text/x-tree-sitter-query", "query"},
|
||||
{"text/x-regex", "regex"},
|
||||
{"text/x-sql", "sql"},
|
||||
{"text/x-toml", "toml"},
|
||||
{"text/x-yaml", "yaml"},
|
||||
{"text/x-cabal", "cabal"},
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "./pch.h"
|
||||
|
||||
#define LANG(name) tree_sitter_##name
|
||||
#define TS_DEF(name) extern "C" const TSLanguage *LANG(name)();
|
||||
#define TS_DEF(name) extern "C" const TSLanguage *LANG(name)()
|
||||
|
||||
struct Language {
|
||||
std::string name;
|
||||
@@ -12,27 +12,36 @@ struct Language {
|
||||
uint8_t lsp_id = 0;
|
||||
};
|
||||
|
||||
TS_DEF(bash)
|
||||
TS_DEF(c)
|
||||
TS_DEF(cpp)
|
||||
TS_DEF(css)
|
||||
TS_DEF(fish)
|
||||
TS_DEF(go)
|
||||
TS_DEF(haskell)
|
||||
TS_DEF(html)
|
||||
TS_DEF(javascript)
|
||||
TS_DEF(json)
|
||||
TS_DEF(lua)
|
||||
TS_DEF(make)
|
||||
TS_DEF(python)
|
||||
TS_DEF(ruby)
|
||||
TS_DEF(rust)
|
||||
|
||||
// TO ADD
|
||||
// sql
|
||||
// wasm
|
||||
// conf
|
||||
// yaml, toml
|
||||
// godot
|
||||
TS_DEF(bash);
|
||||
TS_DEF(c);
|
||||
TS_DEF(cpp);
|
||||
TS_DEF(css);
|
||||
TS_DEF(fish);
|
||||
TS_DEF(go);
|
||||
TS_DEF(haskell);
|
||||
TS_DEF(html);
|
||||
TS_DEF(javascript);
|
||||
TS_DEF(json);
|
||||
TS_DEF(lua);
|
||||
TS_DEF(make);
|
||||
TS_DEF(python);
|
||||
TS_DEF(ruby);
|
||||
TS_DEF(rust);
|
||||
TS_DEF(diff);
|
||||
TS_DEF(embedded_template);
|
||||
TS_DEF(gdscript);
|
||||
TS_DEF(gitattributes);
|
||||
TS_DEF(gitignore);
|
||||
TS_DEF(gomod);
|
||||
TS_DEF(ini);
|
||||
TS_DEF(markdown);
|
||||
TS_DEF(nginx);
|
||||
TS_DEF(php);
|
||||
TS_DEF(query);
|
||||
TS_DEF(regex);
|
||||
TS_DEF(sql);
|
||||
TS_DEF(toml);
|
||||
TS_DEF(yaml);
|
||||
TS_DEF(cabal);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -52,6 +52,7 @@ struct Coord {
|
||||
bool operator>=(const Coord &other) const { return !(*this < other); }
|
||||
};
|
||||
|
||||
std::string path_abs(const std::string &path_str);
|
||||
std::string path_to_file_uri(const std::string &path_str);
|
||||
int display_width(const char *str, size_t len);
|
||||
uint32_t get_visual_col_from_bytes(const char *line, uint32_t len,
|
||||
|
||||
Reference in New Issue
Block a user