feat: add support for even more languages

scrape zed-industries/extensions
This commit is contained in:
Jozef Steinhübl 2024-07-24 23:55:36 +02:00
parent 7c693dcab4
commit 5277297f19
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F
2 changed files with 188 additions and 68 deletions

View file

@ -1,6 +1,6 @@
id = "discord_presence"
name = "Discord Presence"
version = "0.1.0"
version = "0.2.0"
schema_version = 1
authors = ["Jozef Steinhübl <contact@xhyrom.dev>"]
description = "Presence for your beautiful discord account :)"
@ -10,7 +10,92 @@ repository = "https://git.sr.ht/~hyro/zed-discord-presence"
name = "Discord Presence LSP"
# Generated by scripts/get_languages.sh
languages = [
"AsciiDoc",
"Assembly",
"Shell Script",
"Beancount",
"Bend",
"Blade",
"BQN",
"Brainfuck",
"Cadence",
"Cairo",
"Cap'n Proto",
"Cedar",
"CFEngine",
"CSV",
"Gherkin",
"CUE",
"D",
"DBML",
"Earthfile",
"Elisp",
"Handlebars",
"Exograph",
"Fish",
"FSharp",
"GDScript",
"Godot Resource",
"Gemini",
"Diff",
"Git Attributes",
"Git Commit",
"Git Config",
"Git Ignore",
"Git Rebase",
"GraphQL",
"Groovy",
"GROQ",
"ini",
"Jsonnet",
"Julia",
"Just",
"LaTeX",
"Ledger",
"LESS",
"LilyPond",
"LilyPond Scheme",
"Liquid",
"Lox",
"Luau",
"Make",
"MATLAB",
"Meson",
"Navi",
"Navi Stream",
"Nim",
"Noir",
"Nu",
"Odin",
"Pact",
"Pest",
"pica200",
"Pkl",
"QML",
"R",
"Rainbow CSV",
"Rainbow TSV",
"rego",
"ReScript",
"Roc",
"RON",
"Scala",
"SCSS",
"Smithy",
"Solidity",
"bazelrc",
"Starlark",
"Templ",
"Twig",
"Typst",
"Unison",
"V",
"Vala",
"Verilog",
"VHS",
"Wgsl",
"WIT",
"XML",
"C",
"C++",
"CSS",
@ -21,6 +106,7 @@ languages = [
"JSDoc",
"JSON",
"JSONC",
"Markdown-Inline",
"Markdown",
"proto",
"Python",
@ -61,4 +147,4 @@ languages = [
"Vue.js",
"Zig",
]
language_ids = { "Shell Script" = "bash", "C" = "c", "C++" = "cpp", "CSS" = "css", "Go" = "go", "Go Mod" = "gomod", "Go Work" = "gowork", "JavaScript" = "javascript", "JSDoc" = "jsdoc", "JSON" = "json", "JSONC" = "jsonc", "Markdown" = "markdown", "proto" = "proto", "Python" = "python", "Regex" = "regex", "Rust" = "rust", "TSX" = "tsx", "TypeScript" = "typescript", "YAML" = "yaml", "Astro" = "astro", "Clojure" = "clojure", "CSharp" = "csharp", "Dart" = "dart", "Elixir" = "elixir", "HEEX" = "heex", "Elm" = "elm", "Erlang" = "erlang", "Gleam" = "gleam", "GLSL" = "glsl", "Haskell" = "haskell", "HTML" = "html", "Lua" = "lua", "OCaml Interface" = "ocaml-interface", "OCaml" = "ocaml", "PHP" = "php", "PHPDoc" = "phpdoc", "Prisma" = "prisma", "PureScript" = "purescript", "Racket" = "racket", "ERB" = "erb", "Ruby" = "ruby", "Scheme" = "scheme", "Svelte" = "svelte", "HCL" = "hcl", "Terraform Vars" = "terraform-vars", "Terraform" = "terraform", "TOML" = "toml", "Uiua" = "uiua", "Vue.js" = "vue", "Zig" = "zig"}
language_ids = { "AsciiDoc" = "asciidoc", "Assembly" = "asm", "Shell Script" = "bash", "Beancount" = "beancount", "Bend" = "bend", "Blade" = "blade", "BQN" = "BQN", "Brainfuck" = "brainfuck", "Cadence" = "cadence", "Cairo" = "cairo", "Cap'n Proto" = "capnp", "Cedar" = "cedar", "CFEngine" = "cfengine", "CSV" = "csv", "Gherkin" = "gherkin", "CUE" = "cue", "D" = "d", "DBML" = "dbml", "Earthfile" = "earthfile", "Elisp" = "elisp", "Handlebars" = "glimmer", "Exograph" = "exograph", "Fish" = "fish", "FSharp" = "fsharp", "GDScript" = "gdscript", "Godot Resource" = "godot_resource", "Gemini" = "gemini", "Diff" = "diff", "Git Attributes" = "gitattributes", "Git Commit" = "gitcommit", "Git Config" = "gitconfig", "Git Ignore" = "gitignore", "Git Rebase" = "gitrebase", "GraphQL" = "graphql", "Groovy" = "groovy", "GROQ" = "groq", "ini" = "ini", "Jsonnet" = "jsonnet", "Julia" = "julia", "Just" = "just", "LaTeX" = "latex", "Ledger" = "ledger", "LESS" = "less", "LilyPond" = "lilypond", "LilyPond Scheme" = "lilypond_scheme", "Liquid" = "liquid", "Lox" = "lox", "Luau" = "luau", "Make" = "make", "MATLAB" = "matlab", "Meson" = "meson", "Navi" = "navi", "Navi Stream" = "navi_stream", "Nim" = "nim", "Noir" = "noir", "Nu" = "nu", "Odin" = "odin", "Pact" = "pact", "Pest" = "pest", "pica200" = "pica200", "Pkl" = "pkl", "QML" = "qml", "R" = "r", "Rainbow CSV" = "csv", "Rainbow TSV" = "tsv", "rego" = "rego", "ReScript" = "rescript", "Roc" = "roc", "RON" = "ron", "Scala" = "scala", "SCSS" = "scss", "Smithy" = "smithy", "Solidity" = "solidity", "bazelrc" = "bazelrc", "Starlark" = "starlark", "Templ" = "templ", "Twig" = "twig", "Typst" = "typst", "Unison" = "unison", "V" = "v", "Vala" = "vala", "Verilog" = "verilog", "VHS" = "vhs", "Wgsl" = "wgsl", "WIT" = "wit", "XML" = "xml", "C" = "c", "C++" = "cpp", "CSS" = "css", "Go" = "go", "Go Mod" = "gomod", "Go Work" = "gowork", "JavaScript" = "javascript", "JSDoc" = "jsdoc", "JSON" = "json", "JSONC" = "jsonc", "Markdown-Inline" = "markdown-inline", "Markdown" = "markdown", "proto" = "proto", "Python" = "python", "Regex" = "regex", "Rust" = "rust", "TSX" = "tsx", "TypeScript" = "typescript", "YAML" = "yaml", "Astro" = "astro", "Clojure" = "clojure", "CSharp" = "csharp", "Dart" = "dart", "Elixir" = "elixir", "HEEX" = "heex", "Elm" = "elm", "Erlang" = "erlang", "Gleam" = "gleam", "GLSL" = "glsl", "Haskell" = "haskell", "HTML" = "html", "Lua" = "lua", "OCaml Interface" = "ocaml-interface", "OCaml" = "ocaml", "PHP" = "php", "PHPDoc" = "phpdoc", "Prisma" = "prisma", "PureScript" = "purescript", "Racket" = "racket", "ERB" = "erb", "Ruby" = "ruby", "Scheme" = "scheme", "Svelte" = "svelte", "HCL" = "hcl", "Terraform Vars" = "terraform-vars", "Terraform" = "terraform", "TOML" = "toml", "Uiua" = "uiua", "Vue.js" = "vue", "Zig" = "zig" }

View file

@ -1,30 +1,64 @@
#!/bin/bash
fetch_files() {
local repo_owner=$1
local repo_name=$2
curl -s "https://api.github.com/repos/$repo_owner/$repo_name/git/trees/main?recursive=1" -H "Authorization: Bearer ${GITHUB_TOKEN}" | jq -c -r '.tree[] | .path'
}
process_language_files() {
local files=$1
local repo_owner=$2
local repo_name=$3
local file_patterns=("${@:4}")
for file in $files; do
local match=false
for pattern in "${file_patterns[@]}"; do
if [[ $file == $pattern ]]; then
match=true
break
fi
done
if ! $match; then
continue
fi
name=$(curl -s "https://raw.githubusercontent.com/$repo_owner/$repo_name/main/${file}" | grep -oP '^name = "\K[^"]*')
id="${file%/config.toml}"
id="${id##*/}"
if [[ $LANGUAGES == *"$name\","* && $LANGUAGE_IDS == *"$name\" = \"$id\","* ]]; then
echo "Skipping language $name with id $id (already added)"
else
echo "Adding language $name with id $id"
LANGUAGES+=" \"$name\",\n"
LANGUAGE_IDS+=" \"$name\" = \"$id\","
fi
done
}
RESPONSE=$(curl -s "https://api.github.com/repos/zed-industries/zed/git/trees/main?recursive=1" -H "Authorization: Bearer ${GITHUB_TOKEN}")
EXTENSIONS_RESPONSE=$(curl -s "https://raw.githubusercontent.com/zed-industries/extensions/main/.gitmodules")
REPOSITORIES=($(echo "$EXTENSIONS_RESPONSE" | grep -oP 'url = \K.*'))
FILES=$(echo "$RESPONSE" | jq -c -r '.tree[] | .path')
LANGUAGES="languages = [\n"
LANGUAGE_IDS="language_ids = {"
for file in $FILES; do
if ! [[ $file == crates/languages/src/**/config.toml || $file == extensions/**/languages/**/config.toml ]]; then
continue
fi
for repository in "${REPOSITORIES[@]}"; do
repo_owner=$(echo "$repository" | cut -d'/' -f4)
repo_name=$(echo "$repository" | cut -d'/' -f5 | sed 's/.git$//')
if [[ $file == extensions/test-extension/* ]]; then
continue
fi
name=$(curl -s "https://raw.githubusercontent.com/zed-industries/zed/main/${file}" | head -n 1 | sed 's/^name = "\(.*\)"$/\1/')
id="${file%/config.toml}"
id="${id##*/}"
echo "Adding language $name with id $id"
LANGUAGES+=" \"$name\",\n"
LANGUAGE_IDS+=" \"$name\" = \"$id\","
echo "Checking $repository ($repo_owner/$repo_name)"
files=$(fetch_files "$repo_owner" "$repo_name")
process_language_files "$files" "$repo_owner" "$repo_name" "languages/**/config.toml"
done
echo "Processing zed-industries/zed"
process_language_files "$FILES" "zed-industries" "zed" "crates/languages/src/**/config.toml" "extensions/**/languages/**/config.toml"
LANGUAGES+="]"
LANGUAGE_IDS+="}"