From 143d0de99399e9d6b4779ebd91a1cbcee5df5dd5 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Thu, 7 Apr 2022 22:46:45 +0200 Subject: feat(bootstrap): convert script to lua --- fnl/bootstrap.fnl | 31 ------------------------------- init.lua | 5 +++-- lua/bootstrap.lua | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 33 deletions(-) delete mode 100644 fnl/bootstrap.fnl create mode 100644 lua/bootstrap.lua diff --git a/fnl/bootstrap.fnl b/fnl/bootstrap.fnl deleted file mode 100644 index 2665550..0000000 --- a/fnl/bootstrap.fnl +++ /dev/null @@ -1,31 +0,0 @@ -;; Bootstraping for fresh install -(module bootstrap - {autoload {util util}}) - -(defn- fmt [s ...] - (string.format s ...)) - -(def- packer-path - (.. (vim.fn.stdpath :data) :site/pack)) - -(def- git-clone-url "!git clone --depth 1 https://github.com/%s/%s %s") - -(defn- execute [cmd] - (vim.api.nvim_command cmd)) - -(defn- ensure-path [packer-path repository] - (fmt "%s/packer/start/%s" packer-path repository)) - -(defn- ensure [user repository] - (let [path (ensure-path packer-path repository)]) - (if (> (vim.fn.empty (vim.fn.glob path) 0)) - (do - (execute (fmt git-clone-url user repository path)) - (execute (fmt "packadd %s" repository))))) - -(ensure :wbthomason :packer.nvim) -(ensure :Olical :aniseed) -(ensure :lewis6991 :impatient.nvim) - -(require :config.packer) -(require :config.impatient) diff --git a/init.lua b/init.lua index 6dfde98..43946ea 100644 --- a/init.lua +++ b/init.lua @@ -1,9 +1,10 @@ -- Loads plugins for Neovim. +-- Bootstap essential plugins +require "bootstrap" + -- Load fennel config vim.g["aniseed#env"] = { module = "init", compile = true, } - --- require "init" diff --git a/lua/bootstrap.lua b/lua/bootstrap.lua new file mode 100644 index 0000000..ab84c17 --- /dev/null +++ b/lua/bootstrap.lua @@ -0,0 +1,29 @@ +-- Bootstrap nvim with essential plugins. + +local fn = vim.fn +local fmt = string.format +local execute = vim.api.nvim_command + +local function ensure(user, repository) + local packer_path = fn.stdpath "data" .. "/site/pack" + local ensure_path = fmt("%s/packer/start/%s", packer_path, repository) + if fn.empty(fn.glob(ensure_path)) > 0 then + execute( + fmt( + "!git clone --depth 1 https://github.com/%s/%s %s", + user, + repository, + ensure_path + ) + ) + execute(fmt("packadd %s", repository)) + end +end + +-- Bootstrap install essential modules if not present +ensure("wbthomason", "packer.nvim") +ensure("Olical", "aniseed") +ensure("lewis6991", "impatient.nvim") + +-- Enable faster loading with impatient +require "impatient" -- cgit v1.2.3-70-g09d2