-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsp_installer.hl
More file actions
74 lines (64 loc) · 2.4 KB
/
Copy pathlsp_installer.hl
File metadata and controls
74 lines (64 loc) · 2.4 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { dir_exists, file_chmod, symlink_create } from "std/fs"
import { file_download } from "std/http"
import { is_root } from "std/env"
if !is_root() {
throw "This script requires root permissions!"
}
fn get_download_path(repo: str, position: num) -> str {
return $(curl -sL "https://api.github.com/repos/$repo/releases" | jq -r ".[0].assets.[$position].browser_download_url")
}
fn move_to_bin(download_url: str, binary: str) {
if silent file_download(download_url, binary) {
try {
mv binary "/usr/local/bin"
} catch {
throw "Move $binary to /usr/local/bin failed!"
}
file_chmod("/usr/local/bin/$binary", "+x")
} else {
throw "Download for $binary at $download_url failed"
}
}
fn download_to_bin(download_url: str, binary: str, packed_file: str) {
if file_download(download_url, packed_file) {
if "tar.gz".contains(packed_file) {
tar -zxvf "./$packed_file" -C ./ > null $stderr>$stdout
mv "./$binary" "/usr/local/bin"
} else {
gunzip -c - > "/usr/local/bin/$binary"
}
rm "./$packed_file"
file_chmod("/usr/local/bin/$binary", "+x")
} else {
throw "Download for $binary at $download_url failed"
}
}
cd "/tmp"
echo "Install Typos LSP"
download_to_bin(get_download_path("tekumara/typos-lsp", 6), "typos-lsp", "typos.tar.gz")
echo "Install Rust LSP"
download_to_bin("https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz", "rust-analyzer", "rust-analyzer-x86_64-unknown-linux-gnu.gz")
echo "Install Lua LSP"
if ! dir_exists("/opt/lua-language-server") {
cd "/opt/"
git clone "https://github.com/LuaLS/lua-language-server"
} else {
cd "/opt/lua-language-server"
}
silent trust {
cd "lua-language-server"
git pull
& c"./make.sh"
}
symlink_create("/opt/lua-language-server/bin/lua-language-server", "/usr/local/bin/lua-language-server")
cd "/tmp"
let npm_lsp = ["vscode-langservers-extracted", "@tailwindcss/language-server", "@olrtg/emmet-language-server", "intelephense", "bash-language-server"]
let npm_lsp_name = ["CSS, HTML, JSON LSP", "Tailwind LSP", "Emmet LSP", "Intelephense LSP", "Bash LSP"]
loop (index: num, lsp: str) in npm_lsp {
echo "Install ${npm_lsp_name[$index]}"
try {
npm i -g $lsp
} catch (err: Error) {
echo "Error! Exit code: ${err.code}"
}
}