feat: support more languages

This commit is contained in:
Jozef Steinhübl 2024-07-20 14:10:02 +02:00
parent 3fe4b20999
commit 18daae3825
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F
2 changed files with 84 additions and 44 deletions

View file

@ -8,49 +8,57 @@ repository = "https://git.sr.ht/~hyro/zed-discord-presence"
[language_servers.discord_presence]
name = "Discord Presence LSP"
# Taken from https://github.com/zed-industries/zed/blob/efc2336be5dd352961765398350fc2fe10f15345/extensions/snippets/extension.toml#L11-L15
# Generated by scripts/get_languages.sh
languages = [
"Astro",
"Clojure",
"C",
"C++",
"C#",
"Dart",
"Dockerfile",
"Elixir",
"Elm",
"ERB",
"Erlang",
"Gleam",
"GLSL",
"Go",
"Haskell",
"HCL",
"HEEX",
"HTML",
"JavaScript",
"JSDoc",
"JSON",
"Lua",
"Markdown",
"OCaml",
"PHP",
"Python",
"Prisma",
"PureScript",
"Racket",
"Ruby",
"Rust",
"Scheme",
"Shell Script",
"Svelte",
"Terraform",
"TOML",
"TypeScript",
"TSX",
"Uiua",
"Vue.js",
"Zig",
"LOG",
"Shell Script",
"C",
"C++",
"CSS",
"Go",
"Go Mod",
"Go Work",
"JavaScript",
"JSDoc",
"JSON",
"JSONC",
"Markdown",
"proto",
"Python",
"Regex",
"Rust",
"TSX",
"TypeScript",
"YAML",
"Astro",
"Clojure",
"CSharp",
"Dart",
"Elixir",
"HEEX",
"Elm",
"Erlang",
"Gleam",
"GLSL",
"Haskell",
"HTML",
"Lua",
"OCaml Interface",
"OCaml",
"PHP",
"PHPDoc",
"Prisma",
"PureScript",
"Racket",
"ERB",
"Ruby",
"Scheme",
"Svelte",
"HCL",
"Terraform Vars",
"Terraform",
"TOML",
"Uiua",
"Vue.js",
"Zig",
]
language_ids = { TypeScript = "typescript", TSX = "typescriptreact", JavaScript = "javascript", "Vue.js" = "vue", Terraform = "terraform", "Terraform Vars" = "terraform-vars", PHP = "php", HTML = "html", CSS = "css", LOG = "log" }
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"}

32
scripts/get_languages.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
RESPONSE=$(curl -s "https://api.github.com/repos/zed-industries/zed/git/trees/main?recursive=1" -H "Authorization: Bearer ${GITHUB_TOKEN}")
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
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\","
done
LANGUAGES+="]"
LANGUAGE_IDS+="}"
echo -e $LANGUAGES
echo -e $LANGUAGE_IDS