From 18daae3825935ef0ea11d967cc4955a4d5df5335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Sat, 20 Jul 2024 14:10:02 +0200 Subject: [PATCH] feat: support more languages --- extension.toml | 96 ++++++++++++++++++++++------------------ scripts/get_languages.sh | 32 ++++++++++++++ 2 files changed, 84 insertions(+), 44 deletions(-) create mode 100755 scripts/get_languages.sh diff --git a/extension.toml b/extension.toml index 6dd2c63..ecd0b62 100644 --- a/extension.toml +++ b/extension.toml @@ -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"} diff --git a/scripts/get_languages.sh b/scripts/get_languages.sh new file mode 100755 index 0000000..5c8a70c --- /dev/null +++ b/scripts/get_languages.sh @@ -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