Add tree-sitter grammars for common languages I use.

This commit is contained in:
2025-12-25 22:01:58 +00:00
parent f3c87431a3
commit b6e40ae1a6
26 changed files with 259 additions and 54 deletions

View File

@@ -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