-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetlsp.sh
More file actions
executable file
·44 lines (30 loc) · 929 Bytes
/
getlsp.sh
File metadata and controls
executable file
·44 lines (30 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
GHAPI="https://api.github.com"
REPO="neovim/nvim-lspconfig"
API_URL="$GHAPI/repos/$REPO/contents/lsp"
TMP_JSON="/tmp/nvim_lspconfig_lsp_files.json"
curl -s "$API_URL" -o "$TMP_JSON"
if [ ! -s "$TMP_JSON" ]; then
echo "Failed to fetch file from api."
exit 1
fi
NAMES=$(jq -r '.[] | select(.type == "file") | .name' "$TMP_JSON")
SELECTED=$(echo "$NAMES" | fzf --prompt="Select LSP config: " --height=~80% --layout=reverse --border --exit-0)
if [ -z "$SELECTED" ]; then
echo "No client selected."
exit 0
fi
# Get download_url from JSON
URL=$(jq -r --arg name "$SELECTED" '.[] | select(.name == $name) | .download_url' "$TMP_JSON")
if [ -z "$URL" ]; then
echo "Failed to find download URL for $SELECTED"
exit 1
fi
echo "Downloading $SELECTED..."
curl -fSL "$URL" -o "lsp/$SELECTED"
if [ $? -eq 0 ]; then
echo "Saved as $SELECTED"
else
echo "Failed to download $SELECTED"
exit 1
fi