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] [language_servers.discord_presence]
name = "Discord Presence LSP" 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 = [ languages = [
"Astro", "Shell Script",
"Clojure", "C",
"C", "C++",
"C++", "CSS",
"C#", "Go",
"Dart", "Go Mod",
"Dockerfile", "Go Work",
"Elixir", "JavaScript",
"Elm", "JSDoc",
"ERB", "JSON",
"Erlang", "JSONC",
"Gleam", "Markdown",
"GLSL", "proto",
"Go", "Python",
"Haskell", "Regex",
"HCL", "Rust",
"HEEX", "TSX",
"HTML", "TypeScript",
"JavaScript", "YAML",
"JSDoc", "Astro",
"JSON", "Clojure",
"Lua", "CSharp",
"Markdown", "Dart",
"OCaml", "Elixir",
"PHP", "HEEX",
"Python", "Elm",
"Prisma", "Erlang",
"PureScript", "Gleam",
"Racket", "GLSL",
"Ruby", "Haskell",
"Rust", "HTML",
"Scheme", "Lua",
"Shell Script", "OCaml Interface",
"Svelte", "OCaml",
"Terraform", "PHP",
"TOML", "PHPDoc",
"TypeScript", "Prisma",
"TSX", "PureScript",
"Uiua", "Racket",
"Vue.js", "ERB",
"Zig", "Ruby",
"LOG", "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