-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathwin-depend.ps1
More file actions
81 lines (67 loc) · 2.58 KB
/
win-depend.ps1
File metadata and controls
81 lines (67 loc) · 2.58 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Windows dependency repair script (safe to run repeatedly)
$ErrorActionPreference = "Stop"
function Install-WingetPackage {
param (
[Parameter(Mandatory = $true)]
[string]$Id
)
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Warning "winget is not available. Install dependencies manually."
return
}
winget install --id $Id --exact --accept-source-agreements --accept-package-agreements --silent
}
function Ensure-Command {
param (
[Parameter(Mandatory = $true)]
[string]$Command,
[Parameter(Mandatory = $true)]
[string]$WingetId
)
if (-not (Get-Command $Command -ErrorAction SilentlyContinue)) {
Install-WingetPackage -Id $WingetId
}
}
# Core Neovim dependencies used by this config.
Ensure-Command -Command "nvim" -WingetId "Neovim.Neovim"
Ensure-Command -Command "rg" -WingetId "BurntSushi.ripgrep.MSVC"
Ensure-Command -Command "fd" -WingetId "sharkdp.fd"
Ensure-Command -Command "fzf" -WingetId "junegunn.fzf"
Ensure-Command -Command "node" -WingetId "OpenJS.NodeJS.LTS"
# ShellCheck package ID can vary across winget sources, so install best-effort.
if (-not (Get-Command shellcheck -ErrorAction SilentlyContinue)) {
try {
Install-WingetPackage -Id "koalaman.shellcheck"
} catch {
Write-Warning "Could not install shellcheck via winget. Install manually if needed."
}
}
# markdown linting in nvim-lint expects markdownlint-cli2.
if (Get-Command npm -ErrorAction SilentlyContinue) {
if (-not (Get-Command markdownlint-cli2 -ErrorAction SilentlyContinue)) {
npm install -g markdownlint-cli2
}
} else {
Write-Warning "npm not found. Install markdownlint-cli2 manually to enable Markdown linting."
}
$nvimConfigPath = Join-Path $HOME "AppData/Local/nvim"
New-Item -ItemType Directory -Force -Path (Join-Path $HOME ".vim/undodir") | Out-Null
New-Item -ItemType Directory -Force -Path (Join-Path $HOME ".scripts") | Out-Null
$repoPath = (Get-Location).Path
$targetPath = Join-Path $repoPath "titus-kickstart"
if (Test-Path $nvimConfigPath) {
$item = Get-Item $nvimConfigPath -Force
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
$currentTarget = $item.Target
if ($currentTarget -ne $targetPath) {
Remove-Item -Force $nvimConfigPath
New-Item -Path $nvimConfigPath -ItemType SymbolicLink -Target $targetPath | Out-Null
}
} else {
Write-Warning "$nvimConfigPath exists and is not a symlink. Leaving it untouched."
Write-Warning "Remove it manually if you want this script to recreate the symlink."
}
} else {
New-Item -Path $nvimConfigPath -ItemType SymbolicLink -Target $targetPath | Out-Null
}
Write-Host "Dependency check complete."