diff options
| -rw-r--r-- | .github/workflows/install.yaml | 12 | ||||
| -rw-r--r-- | lua/lvim/core/log.lua | 28 | ||||
| -rw-r--r-- | lua/lvim/utils/git.lua | 16 | ||||
| -rwxr-xr-x | utils/installer/install-neovim-from-release | 4 | ||||
| -rwxr-xr-x | utils/installer/install.sh | 3 | 
5 files changed, 41 insertions, 22 deletions
| diff --git a/.github/workflows/install.yaml b/.github/workflows/install.yaml index 7829644d..e21607ab 100644 --- a/.github/workflows/install.yaml +++ b/.github/workflows/install.yaml @@ -35,17 +35,19 @@ jobs:      steps:        - uses: actions/checkout@v2 -      - name: Install neovim binary -        uses: rhysd/action-setup-vim@v1 -        with: -          neovim: true -          version: ${{ matrix.neovim }} +      - name: Install neovim binary from release +        env: +          RELEASE_VER: ${{ matrix.neovim }} +        run: | +          echo "$HOME/.local/bin" >> $GITHUB_PATH +          bash ./utils/installer/install-neovim-from-release        - name: Install LunarVim          timeout-minutes: 4          env:            LV_BRANCH: ${{ github.head_ref || github.ref_name }}            LV_REMOTE: ${{ github.event.pull_request.head.repo.full_name || github.repository }} +          LUNARVIM_LOG_LEVEL: "debug"          run: |            export PATH="$HOME/.local/bin:$PATH" diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua index 49c70f83..48891139 100644 --- a/lua/lvim/core/log.lua +++ b/lua/lvim/core/log.lua @@ -12,17 +12,27 @@ vim.tbl_add_reverse_lookup(Log.levels)  local notify_opts = {}  function Log:set_level(level) -  -- package.loaded["lvim.core.log"] = nil -  local log_level = Log.levels[level:upper()] -  local status_ok, logger = pcall(require("structlog").get_logger, "lvim") -  if status_ok then -    for _, s in ipairs(logger.sinks) do -      s.level = log_level +  local logger_ok, _ = xpcall(function() +    local log_level = Log.levels[level:upper()] +    local structlog = require "structlog" +    if structlog then +      local logger = structlog.get_logger "lvim" +      for _, s in ipairs(logger.sinks) do +        s.level = log_level +      end      end +  end, debug.traceback) +  if not logger_ok then +    Log:debug("Unable to set logger's level: " .. debug.traceback())    end -  package.loaded["packer.log"] = nil -  require("packer.log").new { level = lvim.log.level } +  local packer_ok, _ = xpcall(function() +    package.loaded["packer.log"] = nil +    require("packer.log").new { level = lvim.log.level } +  end, debug.traceback) +  if not packer_ok then +    Log:debug("Unable to set packer's log level: " .. debug.traceback()) +  end  end  function Log:init() @@ -36,7 +46,7 @@ function Log:init()      lvim = {        sinks = {          structlog.sinks.Console(log_level, { -          async = false, +          async = true,            processors = {              structlog.processors.Namer(),              structlog.processors.StackWriter({ "line", "file" }, { max_parents = 0, stack_level = 2 }), diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 81b1faf4..62915458 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -32,20 +32,20 @@ local function git_cmd(opts)      Log:debug(stdout)    end -  return ret, stdout +  return ret, stdout, stderr  end  local function safe_deep_fetch() -  local ret, result = git_cmd { args = { "rev-parse", "--is-shallow-repository" } } +  local ret, result, error = git_cmd { args = { "rev-parse", "--is-shallow-repository" } }    if ret ~= 0 then -    Log:error "Git fetch failed! Check the log for further information" +    Log:error(vim.inspect(error))      return    end    -- git fetch --unshallow will cause an error on a a complete clone    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! Check the log for further information" +    Log:error("Git fetch failed! Please pull the changes manually in " .. get_lvim_base_dir())      return    end    return true @@ -55,12 +55,12 @@ end  function M.update_base_lvim()    Log:info "Checking for updates" -  local ret = git_cmd { args = { "fetch" } } -  if ret ~= 0 then -    Log:error "Update failed! Check the log for further information" +  if not safe_deep_fetch() then      return    end +  local ret +    ret = git_cmd { args = { "diff", "--quiet", "@{upstream}" } }    if ret == 0 then      Log:info "LunarVim is already up-to-date" @@ -69,7 +69,7 @@ function M.update_base_lvim()    ret = git_cmd { args = { "merge", "--ff-only", "--progress" } }    if ret ~= 0 then -    Log:error "Update failed! Please pull the changes manually instead." +    Log:error("Update failed! Please pull the changes manually in " .. get_lvim_base_dir())      return    end diff --git a/utils/installer/install-neovim-from-release b/utils/installer/install-neovim-from-release index 08f27149..076ac46d 100755 --- a/utils/installer/install-neovim-from-release +++ b/utils/installer/install-neovim-from-release @@ -72,6 +72,10 @@ function install_neovim() {    pushd "$DOWNLOAD_DIR"    tar -xzf "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz"    popd +  if [ ! -d "$DOWNLOAD_DIR/$RELEASE_NAME" ]; then +    # fallback to archive name +    RELEASE_NAME="$ARCHIVE_NAME" +  fi    # https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00    cp -r "$DOWNLOAD_DIR/$RELEASE_NAME/." "$LV_INSTALL_PREFIX"    echo "Installation complete!" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index ec675e6d..5072bb2f 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -15,6 +15,8 @@ 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 -r LUNARVIM_LOG_LEVEL="${LUNARVIM_LOG_LEVEL:-warn}" +  declare BASEDIR  BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"  BASEDIR="$(dirname -- "$(dirname -- "$BASEDIR")")" @@ -423,6 +425,7 @@ function setup_lvim() {    echo "Preparing Packer setup"    "$INSTALL_PREFIX/bin/lvim" --headless \ +    -c "lua require('lvim.core.log'):set_level([[$LUNARVIM_LOG_LEVEL]])" \      -c 'autocmd User PackerComplete quitall' \      -c 'PackerSync' | 
