From 68cdb62f87543d5420e70c241ebd5942ed9c7b0e Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 9 Dec 2021 11:51:37 +0100 Subject: [PATCH] fix(bootstrap): remove hard-coded spellfile option (#2061) --- lua/lvim/bootstrap.lua | 3 -- lua/lvim/config/settings.lua | 1 + utils/installer/install.ps1 | 80 ++++++++++++++++++++---------------- utils/installer/install.sh | 26 ++++++++---- 4 files changed, 62 insertions(+), 48 deletions(-) diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua index 44705a53..702dfae1 100644 --- a/lua/lvim/bootstrap.lua +++ b/lua/lvim/bootstrap.lua @@ -72,11 +72,8 @@ function M:init(base_dir) -- TODO: we need something like this: vim.opt.packpath = vim.opt.rtp vim.cmd [[let &packpath = &runtimepath]] - vim.cmd("set spellfile=" .. join_paths(self.config_dir, "spell", "en.utf-8.add")) end - vim.fn.mkdir(get_cache_dir(), "p") - -- FIXME: currently unreliable in unit-tests if not in_headless then _G.PLENARY_DEBUG = false diff --git a/lua/lvim/config/settings.lua b/lua/lvim/config/settings.lua index 048d4058..d784ce60 100644 --- a/lua/lvim/config/settings.lua +++ b/lua/lvim/config/settings.lua @@ -43,6 +43,7 @@ M.load_options = function() wrap = false, -- display lines as one long line spell = false, spelllang = "en", + spellfile = utils.join_paths(get_config_dir(), "spell", "en.utf-8.add"), scrolloff = 8, -- is one of my fav sidescrolloff = 8, } diff --git a/utils/installer/install.ps1 b/utils/installer/install.ps1 index c46bbfc2..0823032a 100644 --- a/utils/installer/install.ps1 +++ b/utils/installer/install.ps1 @@ -64,20 +64,8 @@ function main($cliargs) { backup_old_config __add_separator "80" - - if ($cliargs.Contains("--overwrite")) { - Write-Output "!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag" - $answer = Read-Host "Would you like to continue? [y]es or [n]o " - if ("$answer" -ne "y" -and "$answer" -ne "Y") { - exit 1 - } - - foreach ($dir in $__lvim_dirs) { - if (Test-Path "$dir") { - Remove-Item -Force -Recurse "$dir" - } - } - } + + verify_lvim_dirs if (Test-Path "$env:LUNARVIM_RUNTIME_DIR\site\pack\packer\start\packer.nvim") { Write-Output "Packer already installed" @@ -153,7 +141,7 @@ function check_system_deps() { function install_nodejs_deps() { try { check_system_dep "node" - Invoke-Command npm install -g neovim tree-sitter-cli -ErrorAction Break + Invoke-Command npm install -g neovim tree-sitter-cli -ErrorAction Break } catch { print_missing_dep_msg "$dep" @@ -211,6 +199,29 @@ function setup_shim() { Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\bin\lvim.ps1" -Destination "$INSTALL_PREFIX\bin\lvim.ps1" -Force } +function verify_lvim_dirs() { + if ($cliargs.Contains("--overwrite")) { + Write-Output "!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag" + $answer = Read-Host "Would you like to continue? [y]es or [n]o " + if ("$answer" -ne "y" -and "$answer" -ne "Y") { + exit 1 + } + + foreach ($dir in $__lvim_dirs) { + if (Test-Path "$dir") { + Remove-Item -Force -Recurse "$dir" + } + } + } + + foreach ($dir in $__lvim_dirs) { + if ((Test-Path "$dir") -eq $false) { + New-Item "$dir" -ItemType Directory + } + } + +} + function setup_lvim() { Write-Output "Installing LunarVim shim" @@ -218,30 +229,26 @@ function setup_lvim() { Write-Output "Preparing Packer setup" - if ((Test-Path "$env:LUNARVIM_CONFIG_DIR") -eq $false) { - New-Item "$env:LUNARVIM_CONFIG_DIR" -ItemType Directory - } - if (Test-Path "$env:LUNARVIM_CONFIG_DIR\config.lua") { Remove-Item -Force "$env:LUNARVIM_CONFIG_DIR\config.lua" } Out-File -FilePath "$env:LUNARVIM_CONFIG_DIR\config.lua" - Write-Output "Packer setup complete" + Write-Output "Packer setup complete" - __add_separator "80" + __add_separator "80" - Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\installer\config.example.lua" "$env:LUNARVIM_CONFIG_DIR\config.lua" + Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\installer\config.example.lua" "$env:LUNARVIM_CONFIG_DIR\config.lua" - $answer = Read-Host $(` - "Would you like to create an alias inside your Powershell profile?`n" +` - "(This enables you to start lvim with the command 'lvim') [y]es or [n]o (default: no)" ) - if ("$answer" -eq "y" -and "$answer" -eq "Y") { - create_alias - } + $answer = Read-Host $(` + "Would you like to create an alias inside your Powershell profile?`n" + ` + "(This enables you to start lvim with the command 'lvim') [y]es or [n]o (default: no)" ) + if ("$answer" -eq "y" -and "$answer" -eq "Y") { + create_alias + } - __add_separator "80" + __add_separator "80" Write-Output "Thank you for installing LunarVim!!" Write-Output "You can start it by running: $INSTALL_PREFIX\bin\lvim.ps1" @@ -267,15 +274,16 @@ function __add_separator($div_width) { } function create_alias { - if($null -eq $(Get-Alias | Select-String "lvim")){ - Add-Content -Path $PROFILE -Value $(-join @('Set-Alias lvim "', "$INSTALL_PREFIX", '\bin\lvim.ps1"')) + if ($null -eq $(Get-Alias | Select-String "lvim")) { + Add-Content -Path $PROFILE -Value $( -join @('Set-Alias lvim "', "$INSTALL_PREFIX", '\bin\lvim.ps1"')) - Write-Output "" - Write-Host 'To use the new alias in this window reload your profile with ". $PROFILE".' -ForegroundColor Yellow + Write-Output "" + Write-Host 'To use the new alias in this window reload your profile with ". $PROFILE".' -ForegroundColor Yellow - }else { - Write-Output "Alias is already set and will not be reset." - } + } + else { + Write-Output "Alias is already set and will not be reset." + } } main "$args" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 88c3e550..722144e3 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -107,11 +107,7 @@ function main() { msg "Backing up old LunarVim configuration" backup_old_config - if [ "$ARGS_OVERWRITE" -eq 1 ]; then - for dir in "${__lvim_dirs[@]}"; do - [ -d "$dir" ] && rm -rf "$dir" - done - fi + verify_lvim_dirs if [ -e "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" ]; then update_lvim @@ -262,11 +258,24 @@ function install_rust_deps() { echo "All Rust dependencies are successfully installed" } +function verify_lvim_dirs() { + if [ "$ARGS_OVERWRITE" -eq 1 ]; then + for dir in "${__lvim_dirs[@]}"; do + [ -d "$dir" ] && rm -rf "$dir" + done + fi + + for dir in "${__lvim_dirs[@]}"; do + mkdir -p "$dir" + done +} + function backup_old_config() { for dir in "${__lvim_dirs[@]}"; do - # we create an empty folder for subsequent commands \ - # that require an existing directory - mkdir -p "$dir" "$dir.bak" + if [ ! -d "$dir" ]; then + continue + fi + mkdir -p "$dir.bak" touch "$dir/ignore" if command -v rsync &>/dev/null; then rsync --archive -hh --partial --progress --cvs-exclude \ @@ -307,7 +316,6 @@ function link_local_lvim() { rm -rf "$LUNARVIM_RUNTIME_DIR/lvim" fi - mkdir -p "$LUNARVIM_RUNTIME_DIR" echo " - $BASEDIR -> $LUNARVIM_RUNTIME_DIR/lvim" ln -s -f "$BASEDIR" "$LUNARVIM_RUNTIME_DIR/lvim" }