From b84629bef7218d6bdc36e899eab2b90ddb7efef9 Mon Sep 17 00:00:00 2001 From: nganhkhoa Date: Sun, 11 Jul 2021 11:24:05 +0000 Subject: [PATCH] make plugins installation boostrap from init.lua --- aniseed_env.lua | 109 ------------------------------------------------ bootstrap.lua | 6 --- init.lua | 33 ++++++++++++++- setup.sh | 9 ---- 4 files changed, 32 insertions(+), 125 deletions(-) delete mode 100644 aniseed_env.lua delete mode 100644 bootstrap.lua delete mode 100755 setup.sh diff --git a/aniseed_env.lua b/aniseed_env.lua deleted file mode 100644 index 0f6452d..0000000 --- a/aniseed_env.lua +++ /dev/null @@ -1,109 +0,0 @@ -local _2afile_2a = "fnl/aniseed/env.fnl" -local _0_ -do - local name_0_ = "aniseed.env" - local module_0_ - do - local x_0_ = package.loaded[name_0_] - if ("table" == type(x_0_)) then - module_0_ = x_0_ - else - module_0_ = {} - end - end - module_0_["aniseed/module"] = name_0_ - module_0_["aniseed/locals"] = ((module_0_)["aniseed/locals"] or {}) - do end (module_0_)["aniseed/local-fns"] = ((module_0_)["aniseed/local-fns"] or {}) - do end (package.loaded)[name_0_] = module_0_ - _0_ = module_0_ -end -local autoload -local function _1_(...) - return (require("aniseed.autoload")).autoload(...) -end -autoload = _1_ -local function _2_(...) - local ok_3f_0_, val_0_ = nil, nil - local function _2_() - return {autoload("aniseed.compile"), autoload("aniseed.fennel"), autoload("aniseed.fs"), autoload("aniseed.nvim")} - end - ok_3f_0_, val_0_ = pcall(_2_) - if ok_3f_0_ then - _0_["aniseed/local-fns"] = {autoload = {compile = "aniseed.compile", fennel = "aniseed.fennel", fs = "aniseed.fs", nvim = "aniseed.nvim"}} - return val_0_ - else - return print(val_0_) - end -end -local _local_0_ = _2_(...) -local compile = _local_0_[1] -local fennel = _local_0_[2] -local fs = _local_0_[3] -local nvim = _local_0_[4] -local _2amodule_2a = _0_ -local _2amodule_name_2a = "aniseed.env" -do local _ = ({nil, _0_, nil, {{}, nil, nil, nil}})[2] end -local config_dir -do - local v_0_ = string.gsub(nvim.fn.stdpath("config"), "\\", "/") - local t_0_ = (_0_)["aniseed/locals"] - t_0_["config-dir"] = v_0_ - config_dir = v_0_ -end -local quiet_require -do - local v_0_ - local function quiet_require0(m) - local ok_3f, err = nil, nil - local function _3_() - -- nvim.ex.echoerr("require "..m.." fadjflaksdfjlskadfj") - return require(m) - end - ok_3f, err = pcall(_3_) - if (not ok_3f and not err:find(("module '" .. m .. "' not found"))) then - return nvim.ex.echoerr(err) - end - end - v_0_ = quiet_require0 - local t_0_ = (_0_)["aniseed/locals"] - t_0_["quiet-require"] = v_0_ - quiet_require = v_0_ -end -local init -do - local v_0_ - do - local v_0_0 - local function init0(opts) - local opts0 - if ("table" == type(opts)) then - opts0 = opts - else - opts0 = {} - end - local glob_expr = "**/*.fnl" - local fnl_dir = (opts0.input or (config_dir .. "/fnl")) - local lua_dir = (opts0.output or (config_dir .. "/lua")) - package.path = (package.path .. ";" .. lua_dir .. "/?.lua") - local function _4_(path) - if fs["macro-file-path?"](path) then - return path - else - return string.gsub(path, ".fnl$", ".lua") - end - end - if (((false ~= opts0.compile) or os.getenv("ANISEED_ENV_COMPILE")) and fs["glob-dir-newer?"](fnl_dir, lua_dir, glob_expr, _4_)) then - fennel["add-path"]((fnl_dir .. "/?.fnl")) - compile.glob(glob_expr, fnl_dir, lua_dir, opts0) - end - return quiet_require("plugins") - end - v_0_0 = init0 - _0_["init"] = v_0_0 - v_0_ = v_0_0 - end - local t_0_ = (_0_)["aniseed/locals"] - t_0_["init"] = v_0_ - init = v_0_ -end -return nil diff --git a/bootstrap.lua b/bootstrap.lua deleted file mode 100644 index 56ef119..0000000 --- a/bootstrap.lua +++ /dev/null @@ -1,6 +0,0 @@ -local execute = vim.api.nvim_command - -execute 'packadd packer.nvim' -execute 'packadd aniseed' -require('aniseed.env').init({compile = true}) -execute 'PackerUpdate' diff --git a/init.lua b/init.lua index d020379..daaa8fd 100644 --- a/init.lua +++ b/init.lua @@ -1 +1,32 @@ -vim.g['aniseed#env'] = true +-- Both a bootstraper and stub to call fnl/init.lua + +local fn = vim.fn +local execute = vim.api.nvim_command + +if fn.empty(fn.glob(fn.stdpath('data')..'/site/pack/packer/start/')) > 0 then + local github = 'https://github.com/' + local packer_git = github..'wbthomason/packer.nvim' + local aniseed_git = github..'Olical/aniseed' + + local install_path = fn.stdpath('data')..'/site/pack/packer/start/' + local packer_path = install_path..'packer.nvim' + local aniseed_path = install_path..'aniseed' + + fn.system({'git', 'clone', packer_git, packer_path}) + fn.system({'git', 'clone', aniseed_git, aniseed_path}) + + -- load packer (to install plugins) and aniseed (compile fennel to lua) + execute 'packadd packer.nvim' + execute 'packadd aniseed' + -- load only plugins to install plugins + require('aniseed.env').init({compile = true, module = 'plugins'}) + execute 'PackerUpdate' + + print('Plugins are installed, but config is not fully loaded, please open Neovim again') + +else + +-- call directly from lua, skipping aniseed init +require('aniseed.env').init({compile = true}) + +end diff --git a/setup.sh b/setup.sh deleted file mode 100755 index b6ff80e..0000000 --- a/setup.sh +++ /dev/null @@ -1,9 +0,0 @@ -git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim -git clone https://github.com/Olical/aniseed ~/.local/share/nvim/site/pack/packer/start/aniseed - -mv ~/.local/share/nvim/site/pack/packer/start/aniseed/lua/aniseed/env.lua ./ -cp aniseed_env.lua ~/.local/share/nvim/site/pack/packer/start/aniseed/lua/aniseed/env.lua - -nvim -u bootstrap.lua - -mv env.lua ~/.local/share/nvim/site/pack/packer/start/aniseed/lua/aniseed/env.lua