<commit_before>#!/bin/bash -e

if [[ "-v" == "$1"  ]]; then
  shift
  VERBOSE=1
fi
ASK_VERBOSE="$VERBOSE"

source vendor/ask.sh/lib/ask.sh

if [ -z "$VIM_DIR" ]; then
  die "please define VIM_DIR"
fi

VIM_DIR="$(cd "$VIM_DIR"; pwd)"

function non_dotvim2_dir_warning() {
  red "> Your vim directory $VIM_DIR already exists but doesn't seem to be created by dotvim2"
  bold
  red -e "> Proceed at your own risk!!!\n"
  green -n "Continue? "
  cyan -n "(y/N): "
  local ok
  read ok
  echo
  if ! is_true ok; then
    yellow -e "move or remove the directory and run make again.\n"
    bold
    blue -e "> Note: you can override the default directory by passing VIM_DIR to make: 'VIM_DIR=... make'\n"
    exit 1
  fi

  bold
  yellow -e "> WARNING: installing into non dotvim2 directory!\n\n\n"
}

if [ -d "$VIM_DIR" ]; then
  if [ ! -d "$VIM_DIR/dein" ]; then
    non_dotvim2_dir_warning
  fi
else
  mkdir -pv "$VIM_DIR"
fi

init ${VIM_DIR}/.config

if [ "$VIM_DIR" != "$(cd ~/.vim; pwd)" ]; then

  desc <<-END
Your installation directory is $VIM_DIR
     Make sure you link this directory into ~/.vim

> Note: you can override the default directory by passing VIM_DIR to make: 'VIM_DIR=... make'
END
  ask bool vimdir_warning "I understand" y
fi

source lib/common.sh

load_all plugins/*

finish
bold
info -e "\nDOME"<commit_msg>dotvim2 v0.21: fix initial install vimdir handling<commit_after>#!/bin/bash -e

if [[ "-v" == "$1"  ]]; then
  shift
  VERBOSE=1
fi
ASK_VERBOSE="$VERBOSE"

source vendor/ask.sh/lib/ask.sh

function non_dotvim2_dir()
{
  [ -d "$VIM_DIR" -a ! -d "$VIM_DIR/dein" ]
}

function non_dotvim2_dir_warning()
{
  red "> Your vim directory $VIM_DIR already exists but doesn't seem to be created by dotvim2"
  bold
  red -e "> Proceed at your own risk!!!\n"
  green -n "Continue? "
  cyan -n "(y/N): "
  local ok
  read ok
  echo
  if ! is_true ok; then
    yellow -e "move or remove the directory and run make again.\n"
    bold
    blue -e "> Note: you can override the default directory by passing VIM_DIR to make: 'VIM_DIR=... make'\n"
    exit 1
  fi

  bold
  yellow -e "> WARNING: installing into non dotvim2 directory!\n\n\n"
}

function non_standard_dir()
{
  [ ! -d ~/.vim ] || [ "$VIM_DIR" != "$(cd ~/.vim; pwd)" ]
}

function non_standard_dir_warning()
{
  desc <<-END
Your installation directory is $VIM_DIR
     Make sure you link this directory into ~/.vim

> Note: you can override the default directory by passing VIM_DIR to make: 'VIM_DIR=... make'
END
  ask bool vimdir_warning "I understand" y
}

function init_vimdir()
{
  [ -n "$VIM_DIR" ] || die "please define VIM_DIR"

  if non_dotvim2_dir; then
    non_dotvim2_dir_warning
  else
    mkdir -pv "$VIM_DIR"
  fi

  VIM_DIR="$(cd "$VIM_DIR"; pwd)"

  init ${VIM_DIR}/.config

  if non_standard_dir; then
    non_standard_dir_warning
  fi
}

init_vimdir

source lib/common.sh

load_all plugins/*

finish
bold
info -e "\nDOME"
{'fraction_non_alphanumeric': 0.12898799313893652, 'fraction_numerical': 0.00686106346483705, 'mean_word_length': 3.1836441893830703, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2680809', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1103, 'n_words': 360}