diff options
Diffstat (limited to 'bootstrap-win')
| -rw-r--r-- | bootstrap-win/neovim-dict.ps1 | 58 | ||||
| -rw-r--r-- | bootstrap-win/neovim.ps1 | 199 |
2 files changed, 257 insertions, 0 deletions
diff --git a/bootstrap-win/neovim-dict.ps1 b/bootstrap-win/neovim-dict.ps1 new file mode 100644 index 0000000..5aeb117 --- /dev/null +++ b/bootstrap-win/neovim-dict.ps1 | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | #Requires -Version 5.1 | ||
| 2 | <# | ||
| 3 | Windows-natives Pendant zu bootstrap/neovim-dict.sh. | ||
| 4 | Laedt die deutschen Rechtschreib-Woerterbuecher fuer Neovim herunter. | ||
| 5 | |||
| 6 | Aufruf: | ||
| 7 | .\bootstrap-win\neovim-dict.ps1 | ||
| 8 | #> | ||
| 9 | |||
| 10 | $ErrorActionPreference = "Stop" | ||
| 11 | |||
| 12 | function Write-Ok($msg) { | ||
| 13 | Write-Host "OK $msg" -ForegroundColor Green | ||
| 14 | } | ||
| 15 | |||
| 16 | function Write-Step($msg) { | ||
| 17 | Write-Host "==> $msg" -ForegroundColor Cyan | ||
| 18 | } | ||
| 19 | |||
| 20 | function Write-SkipMsg($msg) { | ||
| 21 | Write-Host "- $msg bereits vorhanden" -ForegroundColor DarkGray | ||
| 22 | } | ||
| 23 | |||
| 24 | $SpellDir = Join-Path $env:LOCALAPPDATA "nvim-data\site\spell" | ||
| 25 | |||
| 26 | $Urls = @( | ||
| 27 | "https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.spl", | ||
| 28 | "https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.sug" | ||
| 29 | ) | ||
| 30 | |||
| 31 | function Get-SpellFile([string]$Url) { | ||
| 32 | $fileName = Split-Path -Leaf $Url | ||
| 33 | $dest = Join-Path $SpellDir $fileName | ||
| 34 | |||
| 35 | if (Test-Path $dest) { | ||
| 36 | Write-SkipMsg $fileName | ||
| 37 | return | ||
| 38 | } | ||
| 39 | |||
| 40 | Write-Step "Lade $fileName herunter" | ||
| 41 | Invoke-WebRequest -Uri $Url -OutFile $dest | ||
| 42 | Write-Ok $fileName | ||
| 43 | } | ||
| 44 | |||
| 45 | function Main { | ||
| 46 | if (-not (Test-Path $SpellDir)) { | ||
| 47 | New-Item -ItemType Directory -Path $SpellDir -Force | Out-Null | ||
| 48 | } | ||
| 49 | |||
| 50 | foreach ($url in $Urls) { | ||
| 51 | Get-SpellFile $url | ||
| 52 | } | ||
| 53 | |||
| 54 | Write-Host "" | ||
| 55 | Write-Host "Woerterbuecher fuer Neovim installiert!" -ForegroundColor Green | ||
| 56 | } | ||
| 57 | |||
| 58 | Main | ||
diff --git a/bootstrap-win/neovim.ps1 b/bootstrap-win/neovim.ps1 new file mode 100644 index 0000000..32e2db7 --- /dev/null +++ b/bootstrap-win/neovim.ps1 | |||
| @@ -0,0 +1,199 @@ | |||
| 1 | #Requires -Version 5.1 | ||
| 2 | <# | ||
| 3 | Windows-natives Pendant zu bootstrap/neovim.sh - nutzt winget/npm statt | ||
| 4 | brew/pkg, daher eigenstaendiges Skript ohne Git-Bash-/WSL-Abhaengigkeit. | ||
| 5 | |||
| 6 | Aufruf (keine Admin-Rechte noetig): | ||
| 7 | .\bootstrap-win\neovim.ps1 | ||
| 8 | |||
| 9 | yamlfmt, gawk und xmllint sind bewusst nicht enthalten (siehe | ||
| 10 | neovim-windows-setup.md). Fehlgeschlagene Installationen werden als | ||
| 11 | Warnung gemeldet, das Skript bricht nicht ab. | ||
| 12 | #> | ||
| 13 | |||
| 14 | $ErrorActionPreference = "Stop" | ||
| 15 | $script:Failures = @() | ||
| 16 | |||
| 17 | function Write-Ok($msg) { | ||
| 18 | Write-Host "OK $msg" -ForegroundColor Green | ||
| 19 | } | ||
| 20 | |||
| 21 | function Write-Step($msg) { | ||
| 22 | Write-Host "==> $msg" -ForegroundColor Cyan | ||
| 23 | } | ||
| 24 | |||
| 25 | function Write-Skip($msg) { | ||
| 26 | Write-Host "- $msg bereits vorhanden" -ForegroundColor DarkGray | ||
| 27 | } | ||
| 28 | |||
| 29 | function Write-Warn($msg) { | ||
| 30 | Write-Host "! $msg" -ForegroundColor Yellow | ||
| 31 | $script:Failures += $msg | ||
| 32 | } | ||
| 33 | |||
| 34 | function Test-CommandExists([string]$Name) { | ||
| 35 | return [bool](Get-Command $Name -ErrorAction SilentlyContinue) | ||
| 36 | } | ||
| 37 | |||
| 38 | function Find-BinaryDirectory([string]$Binary) { | ||
| 39 | # Deckt den Fall ab, dass winget (v.a. --silent) korrekt installiert, | ||
| 40 | # aber die PATH-Registrierung ausgelassen hat (beobachtet bei LLVM.LLVM). | ||
| 41 | $searchRoots = @( | ||
| 42 | $env:ProgramFiles, | ||
| 43 | ${env:ProgramFiles(x86)}, | ||
| 44 | (Join-Path $env:LOCALAPPDATA "Programs") | ||
| 45 | ) | Where-Object { $_ -and (Test-Path $_) } | ||
| 46 | |||
| 47 | foreach ($root in $searchRoots) { | ||
| 48 | $found = Get-ChildItem -Path $root -Recurse -Depth 4 -Filter "$Binary.exe" -File -ErrorAction SilentlyContinue | Select-Object -First 1 | ||
| 49 | if ($found) { | ||
| 50 | return $found.DirectoryName | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | return $null | ||
| 55 | } | ||
| 56 | |||
| 57 | function Add-ToUserPath([string]$Dir) { | ||
| 58 | $userPath = [Environment]::GetEnvironmentVariable("PATH", "User") | ||
| 59 | $entries = $userPath -split ";" | ||
| 60 | |||
| 61 | if ($entries -contains $Dir) { | ||
| 62 | return $false | ||
| 63 | } | ||
| 64 | |||
| 65 | [Environment]::SetEnvironmentVariable("PATH", "$userPath;$Dir", "User") | ||
| 66 | $env:PATH = "$env:PATH;$Dir" | ||
| 67 | return $true | ||
| 68 | } | ||
| 69 | |||
| 70 | function Install-WingetPackage([string]$Binary, [string]$Id) { | ||
| 71 | if (Test-CommandExists $Binary) { | ||
| 72 | Write-Skip $Binary | ||
| 73 | return | ||
| 74 | } | ||
| 75 | |||
| 76 | Write-Step "winget install $Id" | ||
| 77 | $output = winget install --id $Id -e --source winget --accept-package-agreements --accept-source-agreements --silent 2>&1 | ||
| 78 | |||
| 79 | if ($LASTEXITCODE -ne 0) { | ||
| 80 | $text = $output -join " " | ||
| 81 | $lastLine = ($output | Select-Object -Last 3) -join " / " | ||
| 82 | |||
| 83 | if ($text -match "bereits ein vorhandenes Paket|already installed|No applicable update") { | ||
| 84 | # Installiert, aber nicht im PATH - Binary suchen und PATH ergaenzen. | ||
| 85 | $dir = Find-BinaryDirectory $Binary | ||
| 86 | |||
| 87 | if ($dir) { | ||
| 88 | Add-ToUserPath $dir | Out-Null | ||
| 89 | if (Test-CommandExists $Binary) { | ||
| 90 | Write-Ok "$Id ('$Binary' in $dir gefunden, User-PATH ergaenzt)" | ||
| 91 | } else { | ||
| 92 | Write-Warn "${Id}: $dir zum User-PATH hinzugefuegt, aber '$Binary' laesst sich immer noch nicht ausfuehren - manuell pruefen." | ||
| 93 | } | ||
| 94 | } else { | ||
| 95 | Write-Warn "$Id ist laut winget bereits installiert, aber '$Binary' wurde nicht gefunden und konnte auch nicht automatisch lokalisiert werden (durchsucht: Program Files, Program Files (x86), $env:LOCALAPPDATA\Programs). Installationsordner manuell suchen und zum PATH hinzufuegen." | ||
| 96 | } | ||
| 97 | } else { | ||
| 98 | Write-Warn "winget install $Id fehlgeschlagen (Binary '$Binary' nicht gefunden): $lastLine -- Pruefen mit: winget search $Id" | ||
| 99 | } | ||
| 100 | return | ||
| 101 | } | ||
| 102 | |||
| 103 | Write-Ok $Id | ||
| 104 | } | ||
| 105 | |||
| 106 | function Install-NpmPackage([string]$Binary, [string]$Package) { | ||
| 107 | if (Test-CommandExists $Binary) { | ||
| 108 | Write-Skip $Binary | ||
| 109 | return | ||
| 110 | } | ||
| 111 | |||
| 112 | if (-not (Test-CommandExists "npm")) { | ||
| 113 | Write-Warn "npm wurde nicht gefunden - kann '$Package' nicht installieren." | ||
| 114 | return | ||
| 115 | } | ||
| 116 | |||
| 117 | Write-Step "npm install -g $Package" | ||
| 118 | npm install -g $Package | Out-Null | ||
| 119 | |||
| 120 | if ($LASTEXITCODE -ne 0) { | ||
| 121 | Write-Warn "npm install -g $Package fehlgeschlagen." | ||
| 122 | return | ||
| 123 | } | ||
| 124 | |||
| 125 | Write-Ok $Package | ||
| 126 | } | ||
| 127 | |||
| 128 | function Test-Prerequisites { | ||
| 129 | if (-not (Test-CommandExists "winget")) { | ||
| 130 | Write-Host "Fehler: winget wurde nicht gefunden. 'App Installer' aus dem Microsoft Store installieren." -ForegroundColor Red | ||
| 131 | exit 1 | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | function Update-SessionPath { | ||
| 136 | # Registry-PATH-Aenderungen durch winget/npm wirken erst nach diesem Refresh. | ||
| 137 | $machine = [Environment]::GetEnvironmentVariable("PATH", "Machine") | ||
| 138 | $user = [Environment]::GetEnvironmentVariable("PATH", "User") | ||
| 139 | $env:PATH = "$machine;$user" | ||
| 140 | } | ||
| 141 | |||
| 142 | function Install-Prerequisites { | ||
| 143 | Install-WingetPackage -Binary "git" -Id "Git.Git" | ||
| 144 | Install-WingetPackage -Binary "node" -Id "OpenJS.NodeJS.LTS" | ||
| 145 | Update-SessionPath | ||
| 146 | } | ||
| 147 | |||
| 148 | function Install-Formatters { | ||
| 149 | Install-WingetPackage -Binary "jq" -Id "jqlang.jq" | ||
| 150 | Install-NpmPackage -Binary "prettier" -Package "prettier" | ||
| 151 | Install-WingetPackage -Binary "ruff" -Id "astral-sh.ruff" | ||
| 152 | Install-WingetPackage -Binary "shfmt" -Id "mvdan.shfmt" | ||
| 153 | Install-WingetPackage -Binary "stylua" -Id "JohnnyMorganz.StyLua" | ||
| 154 | |||
| 155 | # yamlfmt, gawk, xmllint: kein winget-Paket gefunden, siehe neovim-windows-setup.md. | ||
| 156 | } | ||
| 157 | |||
| 158 | function Install-Tools { | ||
| 159 | Install-WingetPackage -Binary "rg" -Id "BurntSushi.ripgrep.MSVC" | ||
| 160 | Install-WingetPackage -Binary "fd" -Id "sharkdp.fd" | ||
| 161 | Install-NpmPackage -Binary "tree-sitter" -Package "tree-sitter-cli" | ||
| 162 | |||
| 163 | # MSVC (cl.exe) ist bereits vorhanden, kein winget-Paket noetig - Neovim | ||
| 164 | # dafuer aber aus einer "Developer PowerShell for VS" starten. | ||
| 165 | Install-WingetPackage -Binary "make" -Id "ezwinports.make" | ||
| 166 | } | ||
| 167 | |||
| 168 | function Install-Lsp { | ||
| 169 | Install-NpmPackage -Binary "basedpyright-langserver" -Package "basedpyright" | ||
| 170 | Install-NpmPackage -Binary "bash-language-server" -Package "bash-language-server" | ||
| 171 | Install-WingetPackage -Binary "clangd" -Id "LLVM.LLVM" | ||
| 172 | Install-WingetPackage -Binary "shellcheck" -Id "koalaman.shellcheck" | ||
| 173 | Install-NpmPackage -Binary "vscode-html-language-server" -Package "vscode-langservers-extracted" | ||
| 174 | Install-NpmPackage -Binary "vscode-json-language-server" -Package "vscode-langservers-extracted" | ||
| 175 | Install-WingetPackage -Binary "lua-language-server" -Id "LuaLS.lua-language-server" | ||
| 176 | Install-NpmPackage -Binary "prisma-language-server" -Package "@prisma/language-server" | ||
| 177 | Install-NpmPackage -Binary "vtsls" -Package "@vtsls/language-server" | ||
| 178 | } | ||
| 179 | |||
| 180 | function Main { | ||
| 181 | Test-Prerequisites | ||
| 182 | |||
| 183 | Install-Prerequisites | ||
| 184 | Install-Formatters | ||
| 185 | Install-Tools | ||
| 186 | Install-Lsp | ||
| 187 | |||
| 188 | Write-Host "" | ||
| 189 | if ($script:Failures.Count -eq 0) { | ||
| 190 | Write-Host "Bootstrap abgeschlossen." -ForegroundColor Green | ||
| 191 | } else { | ||
| 192 | Write-Host "Bootstrap abgeschlossen, mit $($script:Failures.Count) Warnung(en):" -ForegroundColor Yellow | ||
| 193 | foreach ($f in $script:Failures) { | ||
| 194 | Write-Host " - $f" -ForegroundColor Yellow | ||
| 195 | } | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
| 199 | Main | ||
