uninstall.ps1 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #Requires -Version 7.1
  2. $ErrorActionPreference = "Stop" # exit when command fails
  3. # set script variables
  4. $LV_BRANCH = $LV_BRANCH ?? "rolling"
  5. $LV_REMOTE = $LV_REMOTE ?? "lunarvim/lunarvim.git"
  6. $INSTALL_PREFIX = $INSTALL_PREFIX ?? "$HOME\.local"
  7. $env:XDG_DATA_HOME = $env:XDG_DATA_HOME ?? $env:APPDATA
  8. $env:XDG_CONFIG_HOME = $env:XDG_CONFIG_HOME ?? $env:LOCALAPPDATA
  9. $env:XDG_CACHE_HOME = $env:XDG_CACHE_HOME ?? $env:TEMP
  10. $env:LUNARVIM_RUNTIME_DIR = $env:LUNARVIM_RUNTIME_DIR ?? "$env:XDG_DATA_HOME\lunarvim"
  11. $env:LUNARVIM_CONFIG_DIR = $env:LUNARVIM_CONFIG_DIR ?? "$env:XDG_CONFIG_HOME\lvim"
  12. $env:LUNARVIM_CACHE_DIR = $env:LUNARVIM_CACHE_DIR ?? "$env:XDG_CACHE_HOME\lvim"
  13. $env:LUNARVIM_BASE_DIR = $env:LUNARVIM_BASE_DIR ?? "$env:LUNARVIM_RUNTIME_DIR\lvim"
  14. $__lvim_dirs = (
  15. $env:LUNARVIM_BASE_DIR,
  16. $env:LUNARVIM_RUNTIME_DIR,
  17. $env:LUNARVIM_CONFIG_DIR,
  18. $env:LUNARVIM_CACHE_DIR
  19. )
  20. function main($cliargs) {
  21. Write-Output "Removing LunarVim binary..."
  22. remove_lvim_bin
  23. Write-Output "Removing LunarVim directories..."
  24. $force = $false
  25. if ($cliargs.Contains("--remove-backups")) {
  26. $force = $true
  27. }
  28. remove_lvim_dirs $force
  29. Write-Output "Uninstalled LunarVim!"
  30. }
  31. function remove_lvim_bin(){
  32. $lvim_bin="$INSTALL_PREFIX\bin\lvim"
  33. if (Test-Path $lvim_bin) {
  34. Remove-Item -Force $lvim_bin
  35. }
  36. if (Test-Path alias:lvim) {
  37. Write-Warning "Please make sure to remove the 'lvim' alias from your `$PROFILE`: $PROFILE"
  38. }
  39. }
  40. function remove_lvim_dirs($force) {
  41. foreach ($dir in $__lvim_dirs) {
  42. if (Test-Path $dir) {
  43. Remove-Item -Force -Recurse $dir
  44. }
  45. if ($force -eq $true) {
  46. if (Test-Path "$dir.bak") {
  47. Remove-Item -Force -Recurse "$dir.bak"
  48. }
  49. if (Test-Path "$dir.old") {
  50. Remove-Item -Force -Recurse "$dir.old"
  51. }
  52. }
  53. }
  54. }
  55. main($args)