diff options
| -rw-r--r-- | .github/workflows/format.yaml | 1 | ||||
| -rw-r--r-- | init.lua | 7 | ||||
| -rw-r--r-- | lua/lvim/config/init.lua | 6 | ||||
| -rw-r--r-- | lua/lvim/utils/git.lua | 15 | ||||
| -rw-r--r-- | utils/bin/lvim.ps1 | 2 | ||||
| -rw-r--r-- | utils/bin/lvim.template | 6 | ||||
| -rwxr-xr-x | utils/installer/install.sh | 22 | ||||
| -rwxr-xr-x | utils/installer/install_bin.sh | 3 | 
8 files changed, 43 insertions, 19 deletions
| diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml index 52103a54..27b061ef 100644 --- a/.github/workflows/format.yaml +++ b/.github/workflows/format.yaml @@ -22,6 +22,7 @@ jobs:          with:            token: ${{ secrets.GITHUB_TOKEN }}            # CLI arguments +          version: 0.15.1            args: --check .    shfmt-check: @@ -1,5 +1,8 @@ -local init_path = debug.getinfo(1, "S").source:sub(2) -local base_dir = init_path:match("(.*[/\\])"):sub(1, -2) +local base_dir = vim.env.LUNARVIM_BASE_DIR +  or (function() +    local init_path = debug.getinfo(1, "S").source +    return init_path:sub(2):match("(.*[/\\])"):sub(1, -2) +  end)()  if not vim.tbl_contains(vim.opt.rtp:get(), base_dir) then    vim.opt.rtp:append(base_dir) diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index fae6c518..ea36a9a0 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -118,7 +118,11 @@ function M:load(config_path)      if utils.is_file(user_config_file) then        Log:warn("Invalid configuration: " .. err)      else -      vim.notify_once(string.format("Unable to find configuration file [%s]", config_path), vim.log.levels.WARN) +      vim.notify_once( +        string.format("User-configuration not found. Creating an example configuration in %s", config_path) +      ) +      local example_config = join_paths(get_lvim_base_dir(), "utils", "installer", "config.example.lua") +      vim.loop.fs_copyfile(example_config, config_path)      end    end diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 99c178f3..e1b5ccf2 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -1,6 +1,7 @@  local M = {}  local Log = require "lvim.core.log" +local fmt = string.format  local if_nil = vim.F.if_nil  local function git_cmd(opts) @@ -43,9 +44,16 @@ local function safe_deep_fetch()    local fetch_mode = result[1] == "true" and "--unshallow" or "--all"    ret = git_cmd { args = { "fetch", fetch_mode } }    if ret ~= 0 then -    Log:error("Git fetch failed! Please pull the changes manually in " .. get_lvim_base_dir()) +    Log:error(fmt "Git fetch %s failed! Please pull the changes manually in %s", fetch_mode, get_lvim_base_dir())      return    end +  if fetch_mode == "--unshallow" then +    ret = git_cmd { args = { "remote", "set-branches", "origin", "*" } } +    if ret ~= 0 then +      Log:error(fmt "Git fetch %s failed! Please pull the changes manually in %s", fetch_mode, get_lvim_base_dir()) +      return +    end +  end    return true  end @@ -53,6 +61,11 @@ end  function M.update_base_lvim()    Log:info "Checking for updates" +  if not vim.loop.fs_access(get_lvim_base_dir(), "w") then +    Log:warn(fmt("Lunarvim update aborted! cannot write to %s", get_lvim_base_dir())) +    return +  end +    if not safe_deep_fetch() then      return    end diff --git a/utils/bin/lvim.ps1 b/utils/bin/lvim.ps1 index 32723c18..3ec8125c 100644 --- a/utils/bin/lvim.ps1 +++ b/utils/bin/lvim.ps1 @@ -10,4 +10,4 @@ $env:LUNARVIM_CONFIG_DIR = $env:LUNARVIM_CONFIG_DIR ?? "$env:XDG_CONFIG_HOME\lvi  $env:LUNARVIM_CACHE_DIR = $env:LUNARVIM_CACHE_DIR ?? "$env:XDG_CACHE_HOME\lvim"  $env:LUNARVIM_BASE_DIR = $env:LUNARVIM_BASE_DIR ?? "$env:LUNARVIM_RUNTIME_DIR\lvim" -nvim -u "$env:LUNARVIM_RUNTIME_DIR\lvim\init.lua" @args +nvim -u "$env:LUNARVIM_BASE_DIR\init.lua" @args diff --git a/utils/bin/lvim.template b/utils/bin/lvim.template index 1b18977d..c17d25be 100644 --- a/utils/bin/lvim.template +++ b/utils/bin/lvim.template @@ -1,7 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash  export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-RUNTIME_DIR_VAR}"  export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-CONFIG_DIR_VAR}"  export LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-CACHE_DIR_VAR}" -exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@" +export LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-BASE_DIR_VAR}" + +exec -a lvim nvim -u "$LUNARVIM_BASE_DIR/init.lua" "$@" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index fee0e420..cafd92ad 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -2,20 +2,20 @@  set -eo pipefail  #Set branch to master unless specified by the user -declare LV_BRANCH="${LV_BRANCH:-"master"}" -declare -r LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" -declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" +declare -x LV_BRANCH="${LV_BRANCH:-"master"}" +declare -xr LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" +declare -xr INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" -declare -r XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" -declare -r XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" -declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" +declare -xr XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +declare -xr XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" +declare -xr XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" -declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" -declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" -declare -r LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/lvim"}" -declare -r LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}" +declare -xr LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" +declare -xr LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" +declare -xr LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/lvim"}" +declare -xr LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}" -declare -r LUNARVIM_LOG_LEVEL="${LUNARVIM_LOG_LEVEL:-warn}" +declare -xr LUNARVIM_LOG_LEVEL="${LUNARVIM_LOG_LEVEL:-warn}"  declare BASEDIR  BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" diff --git a/utils/installer/install_bin.sh b/utils/installer/install_bin.sh index c6ad5181..920f2fd5 100755 --- a/utils/installer/install_bin.sh +++ b/utils/installer/install_bin.sh @@ -26,7 +26,8 @@ function setup_shim() {    sed -e s"#RUNTIME_DIR_VAR#\"${LUNARVIM_RUNTIME_DIR}\"#"g \      -e s"#CONFIG_DIR_VAR#\"${LUNARVIM_CONFIG_DIR}\"#"g \ -    -e s"#CACHE_DIR_VAR#\"${LUNARVIM_CACHE_DIR}\"#"g "$src" \ +    -e s"#CACHE_DIR_VAR#\"${LUNARVIM_CACHE_DIR}\"#"g \ +    -e s"#BASE_DIR_VAR#\"${LUNARVIM_BASE_DIR}\"#"g "$src" \      | tee "$dst" >/dev/null    chmod u+x "$dst" | 
