Repository navigation
Expand file tree
/
Copy path2_nvim-setup.sh
More file actions
125 lines (110 loc) · 3.24 KB
/
Copy path2_nvim-setup.sh
File metadata and controls
125 lines (110 loc) · 3.24 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
set -euo pipefail
# Neovim + LazyVim setup script
echo "==> Updating apt..."
sudo apt update && sudo apt upgrade -y
echo "==> Installing dependencies..."
sudo apt install -y git curl jq unzip build-essential \
xclip xsel language-pack-ko \
ripgrep fd-find fzf sd \
python3 python3-pip nodejs npm
# fd-find installs as fdfind, LazyVim expects fd
if ! command -v fd &>/dev/null; then
sudo ln -sf $(which fdfind) /usr/local/bin/fd
fi
RELEASE_JSON="$(curl -fsSL https://api.github.com/repos/neovim/neovim/releases/latest)"
NVIM_LATEST_TAG="$(jq -er '.tag_name' <<<"$RELEASE_JSON")"
CURRENT_VERSION="$(
nvim --version 2>/dev/null |
sed -n '1s/^NVIM //p' ||
true
)"
if [[ "$CURRENT_VERSION" == "$NVIM_LATEST_TAG" ]]; then
echo "Neovim is already installed and up to date ($CURRENT_VERSION). Skipping."
exit 0
fi
echo "==> Installing latest stable Neovim..."
NVIM_URL="$(
jq -er '
.assets[]
| select(.name == "nvim-linux-x86_64.tar.gz")
| .browser_download_url
' <<<"$RELEASE_JSON"
)"
if [[ -z "$NVIM_URL" || "$NVIM_URL" == "null" ]]; then
echo "Error: Failed to fetch the Neovim download URL."
exit 1
fi
TMP_DIR="$(mktemp -d)"
curl -fL "$NVIM_URL" -o "$TMP_DIR/nvim.tar.gz"
tar -xzf "$TMP_DIR/nvim.tar.gz" -C "$TMP_DIR"
sudo rm -rf /opt/nvim
sudo mv "$TMP_DIR/nvim-linux-x86_64" /opt/nvim
sudo ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim
rm -rf "$TMP_DIR"
echo "Neovim $(nvim --version | head -n 1) installed"
echo "==> Registering nvim as system default editor..."
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/nvim 60
sudo update-alternatives --set editor /usr/local/bin/nvim
if ! grep -q "export EDITOR=/usr/local/bin/nvim" ~/.profile 2>/dev/null; then
printf '\nexport EDITOR=/usr/local/bin/nvim' >>~/.profile
fi
if ! grep -q "export VISUAL=/usr/local/bin/nvim" ~/.profile 2>/dev/null; then
printf '\nexport VISUAL=/usr/local/bin/nvim' >>~/.profile
fi
git config --global core.editor "nvim"
sudo git config --global core.editor "nvim"
echo "==> Installing LazyVim..."
# Back up existing config if present
[ -d ~/.config/nvim ] && mv ~/.config/nvim ~/.config/nvim.bak.$(date +%s)
git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git
echo "==> Writing LazyVim plugin configs..."
mkdir -p ~/.config/nvim/lua/plugins
cat >~/.config/nvim/lua/plugins/colorscheme.lua <<'EOF'
return {
{
"LazyVim/LazyVim",
opts = {
colorscheme = "catppuccin-latte",
},
},
}
EOF
cat >~/.config/nvim/lua/plugins/korean.lua <<'EOF'
return {
{
"kiyoon/Korean-IME.nvim",
keys = {
{
"<f12>",
function() require("korean_ime").change_mode() end,
mode = { "i", "n", "x", "s" },
desc = "한/영",
},
},
config = function()
require("korean_ime").setup()
vim.keymap.set("i", "<f9>", function()
require("korean_ime").convert_hanja()
end, { noremap = true, silent = true, desc = "한자" })
end,
},
}
EOF
cat >~/.config/nvim/lua/plugins/vimbegood.lua <<'EOF'
return {
{
"ThePrimeagen/vim-be-good",
lazy = false,
},
}
EOF
echo "==> Creating Windows file opener wrapper..."
cat >~/nvim-open.sh <<'EOF'
#!/bin/bash
nvim "$(wslpath -a "$1")"
EOF
chmod +x ~/nvim-open.sh
echo ""
echo "==> Done!"