aboutsummaryrefslogtreecommitdiff
path: root/bootstrap-win/neovim-dict.ps1
blob: 7909ffa8da06c84f34e483ac5b35c74cb58a58e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#Requires -Version 5.1
<#
  Windows-natives Pendant zu bootstrap/neovim-dict.sh.
  Laedt die deutschen Rechtschreib-Woerterbuecher fuer Neovim herunter.
  bootstrap/neovim-dict.sh bleibt unveraendert.

  Aufruf:
    .\bootstrap-win\neovim-dict.ps1

  Falls die Ausfuehrung durch die Execution Policy blockiert wird:
    powershell -ExecutionPolicy Bypass -File .\bootstrap-win\neovim-dict.ps1
#>

$ErrorActionPreference = "Stop"

function Write-Ok($msg) {
  Write-Host "OK   $msg" -ForegroundColor Green
}

function Write-Step($msg) {
  Write-Host "==> $msg" -ForegroundColor Cyan
}

function Write-SkipMsg($msg) {
  Write-Host "-    $msg bereits vorhanden" -ForegroundColor DarkGray
}

# Nativer Windows-Datenpfad von Neovim (kein XDG_DATA_HOME gesetzt):
# $env:LOCALAPPDATA\nvim-data\site\spell
$SpellDir = Join-Path $env:LOCALAPPDATA "nvim-data\site\spell"

$Urls = @(
  "https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.spl",
  "https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.sug"
)

function Get-SpellFile([string]$Url) {
  $fileName = Split-Path -Leaf $Url
  $dest = Join-Path $SpellDir $fileName

  if (Test-Path $dest) {
    Write-SkipMsg $fileName
    return
  }

  Write-Step "Lade $fileName herunter"
  Invoke-WebRequest -Uri $Url -OutFile $dest
  Write-Ok $fileName
}

function Main {
  if (-not (Test-Path $SpellDir)) {
    New-Item -ItemType Directory -Path $SpellDir -Force | Out-Null
  }

  foreach ($url in $Urls) {
    Get-SpellFile $url
  }

  Write-Host ""
  Write-Host "Woerterbuecher fuer Neovim installiert!" -ForegroundColor Green
}

Main