#!/usr/bin/env bash # Usage: # bash <(curl -fsSL ) install mode # wget -qO- | bash install mode # # Assumes Neovim is already installed and functional on the machine. # Wires up: # - telescope.nvim (Ctrl-P fuzzy file finder) # - bufferline.nvim (always-visible buffer tabline) # - lazy.nvim (plugin manager, bootstrapped on first nvim launch) # # Keymaps installed: # find files (telescope) # previous buffer # next buffer # x close current buffer (leader defaults to space) set -e NVIM_MIN_VERSION="0.9.0" # telescope.nvim's stated minimum; also satisfies lazy.nvim/bufferline.nvim # ---- version checks (fail closed) -------------------------------- _version_ge() { # returns 0 if $1 >= $2, for dotted "major.minor.patch" strings local IFS=. local -a v1=($1) v2=($2) local i a b for i in 0 1 2; do a=${v1[i]:-0} b=${v2[i]:-0} if (( a > b )); then return 0; fi if (( a < b )); then return 1; fi done return 0 } if ! command -v nvim >/dev/null 2>&1; then echo "ERROR: nvim not found on PATH. This script assumes Neovim is already installed." >&2 exit 1 fi nvim_version_raw="$(nvim --version | head -n1)" nvim_version="$(printf '%s' "$nvim_version_raw" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)" if [ -z "$nvim_version" ]; then echo "ERROR: could not parse Neovim version from: $nvim_version_raw" >&2 exit 1 fi if ! _version_ge "$nvim_version" "$NVIM_MIN_VERSION"; then echo "ERROR: Neovim >= $NVIM_MIN_VERSION required (found $nvim_version)." >&2 echo " telescope.nvim and bufferline.nvim need a recent Neovim." >&2 exit 1 fi if ! command -v git >/dev/null 2>&1; then echo "ERROR: git not found on PATH. Required by lazy.nvim to install plugins." >&2 exit 1 fi if ! command -v rg >/dev/null 2>&1; then echo "WARNING: ripgrep (rg) not found. File finding will still work but will be slower," >&2 echo " and Telescope live_grep won't work. Install ripgrep for the full experience." >&2 fi # ---- paths --------------------------------------------------------- CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvim" LUA_DIR="$CONFIG_DIR/lua" PLUGIN_FILE="$LUA_DIR/supraa-nvim-setup.lua" _write_plugin_file() { cat > "$PLUGIN_FILE" << 'EOF' -- ------------------------------------------------------------------ -- supraa-nvim-setup.lua — telescope + bufferline, bootstrapped via lazy.nvim -- ------------------------------------------------------------------ if vim.g.mapleader == nil then vim.g.mapleader = " " end vim.opt.termguicolors = true -- bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ { "nvim-telescope/telescope.nvim", tag = "0.1.8", dependencies = { "nvim-lua/plenary.nvim" }, }, { "akinsho/bufferline.nvim", version = "*", dependencies = { "nvim-tree/nvim-web-devicons" }, }, }) require("bufferline").setup({ options = { always_show_bufferline = true, diagnostics = "nvim_lsp", }, }) -- fuzzy file finder: Ctrl-P vim.keymap.set("n", "", require("telescope.builtin").find_files, { desc = "Telescope: find files" }) -- buffer navigation: Shift-H / Shift-L vim.keymap.set("n", "", "BufferLineCyclePrev", { desc = "Previous buffer" }) vim.keymap.set("n", "", "BufferLineCycleNext", { desc = "Next buffer" }) -- close buffer: x (space+x by default) vim.keymap.set("n", "x", "bdelete", { desc = "Close buffer" }) EOF } _hook_init() { local init_lua="$CONFIG_DIR/init.lua" local init_vim="$CONFIG_DIR/init.vim" local marker="supraa-nvim-setup" if [ -f "$init_vim" ] && [ ! -f "$init_lua" ]; then if grep -q "$marker" "$init_vim" 2>/dev/null; then echo " already hooked into $init_vim" else printf '\nlua require("supraa-nvim-setup")\n' >> "$init_vim" echo " hooked into $init_vim" fi return fi touch "$init_lua" if grep -q "$marker" "$init_lua" 2>/dev/null; then echo " already hooked into $init_lua" else printf '\nrequire("supraa-nvim-setup")\n' >> "$init_lua" echo " hooked into $init_lua" fi } # ---- main ---------------------------------------------------------- echo "Installing Neovim setup (telescope + bufferline) ..." mkdir -p "$LUA_DIR" _write_plugin_file echo " written $PLUGIN_FILE" echo "Hooking into Neovim config ..." _hook_init echo "" echo "Done. Open nvim — plugins install automatically on first launch (lazy.nvim bootstrap)." echo "Keymaps: find files | / prev/next buffer | x close buffer (leader = space)"