check / validate (push) Canceled after 0s
- Merge sunbather dark/light into one background-aware color scheme - Fold uninstall.sh into install.sh as a subcommand; drop clone logic - Inline bash_tools/ helpers; remove fct and odict - Remove TPM, tmux-sensible, and tmux-fuzzback; tmux has no plugins now - Remove vim-repeat, vim-fugitive, vim-gitgutter, vim-tmux-navigator, and moonfly; everforest is the default dark theme - Fetch vim-plug via git instead of curl; require git, not curl - Guard termguicolors on Windows consoles without VT support and set nomore before the vimrc loads so headless installs cannot hang - Fall back to sunbather when a color scheme fails to load, without overwriting the saved preference - Append config/vim to runtimepath so netrw stops writing into the repo - Fix .editorconfig Python indent; trim .gitignore; update CI and README Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NBfsAH6iJg9inkNLKq11YC
63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
"""Install the Vim 9 configuration on Windows."""
|
|
|
|
from pathlib import Path
|
|
from shutil import copyfile, which
|
|
import subprocess
|
|
import tempfile
|
|
import time
|
|
|
|
|
|
HOME = Path.home()
|
|
APP_PATH = Path(__file__).resolve().parent
|
|
VIM_PATH = HOME / "vimfiles"
|
|
VIMRC = HOME / "_vimrc"
|
|
|
|
|
|
def run(command, cwd=None):
|
|
subprocess.run(command, cwd=cwd, check=True)
|
|
|
|
|
|
def require(program):
|
|
if which(program) is None:
|
|
raise SystemExit(f"Error: {program} must be installed.")
|
|
|
|
|
|
def check_vim_version():
|
|
result = subprocess.run(
|
|
["vim", "--clean", "-Nu", "NONE", "-n", "-es", "+if v:version < 900 | cquit | endif", "+qall"]
|
|
)
|
|
if result.returncode:
|
|
raise SystemExit("Error: Vim 9 or newer is required.")
|
|
|
|
|
|
def install_vim_plug():
|
|
target = VIM_PATH / "autoload" / "plug.vim"
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
with tempfile.TemporaryDirectory() as temp:
|
|
run(["git", "clone", "--depth", "1", "--quiet", "https://github.com/junegunn/vim-plug", temp])
|
|
copyfile(Path(temp) / "plug.vim", target)
|
|
|
|
|
|
def install_vimrc():
|
|
config_path = (APP_PATH / ".vimrc").as_posix().replace("'", "''")
|
|
source_line = f"execute 'source ' . fnameescape('{config_path}')"
|
|
if VIMRC.exists() and VIMRC.read_text(encoding="utf-8", errors="ignore").strip() != source_line:
|
|
backup = VIMRC.with_name(f"{VIMRC.name}.{int(time.time())}.backup")
|
|
VIMRC.replace(backup)
|
|
print(f"Backed up existing Vim config to {backup}")
|
|
VIMRC.write_text(source_line + "\n", encoding="utf-8")
|
|
|
|
|
|
def main():
|
|
require("git")
|
|
require("vim")
|
|
check_vim_version()
|
|
install_vim_plug()
|
|
install_vimrc()
|
|
run(["vim", "-Nu", str(APP_PATH / ".vimrc"), "-n", "-es", "--cmd", "set nomore", "+PlugInstall --sync", "+qall"])
|
|
print("Vim configuration installed.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|