-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinstall.ps1
55 lines (49 loc) · 1.74 KB
/
install.ps1
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
[CmdletBinding()] param (
[Parameter(Mandatory = $false)]
[string]
$NvimExe = $null
)
$ErrorActionPreference = "Stop"
# Install pynvim; vim-plug requires pynvim
if (Get-Command -Name pip3 -ErrorAction SilentlyContinue) {
pip3 install --user pynvim jedi
}
# Install vim-plug
$VimPlugUrl = `
"https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
New-Item -ItemType Directory -Path nvim\autoload -ErrorAction SilentlyContinue
Invoke-WebRequest $VimPlugUrl -OutFile nvim\autoload\plug.vim
# Download hanja.txt
$HanjaUrl = `
"https://github.com/choehwanjin/libhangul/raw/main/data/hanja/hanja.txt"
Invoke-WebRequest $HanjaUrl -OutFile hanja.txt
# Link neovim configuration to %LOCALAPPDATA%\nvim
$NvimrcName = "init.nvim"
$NvimDirName = "nvim"
$SourceNvimDir = Join-Path $PSScriptRoot $NvimDirName
Write-Debug "SourceNvimDir: $SourceNvimDir"
$SourceNvimrc = Join-Path $SourceNvimDir $NvimrcName
Write-Debug "SourceNvimrc: $SourceNvimrc"
$DestinationNvimDir = Join-Path $env:LocalAppData $NvimDirName
Write-Debug "DestinationNvimDir: $DestinationNvimDir"
$DestinationNvimrc = Join-Path $DestinationNvimDir $NvimrcName
Write-Debug "DestinationNvimrc: $DestinationNvimrc"
if ((Get-Item $DestinationNvimDir -ErrorAction SilentlyContinue).Target -ne `
$SourceNvimDir) {
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue $DestinationNvimrc
New-Item `
-ItemType Directory `
-Path $env:LocalAppData `
-ErrorAction SilentlyContinue
New-Item `
-ItemType SymbolicLink `
-Path $env:LocalAppData `
-Name $NvimDirName `
-Value $SourceNvimDir
}
# Install plugins using vim-plug
if ($NvimExe -eq $null) {
&$NvimExe +PlugInstall +PlugUpdate +PlugClean! +qall
} else {
nvim +PlugInstall +PlugUpdate +PlugClean! +qall
}