-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
105 lines (90 loc) · 2.22 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
param
(
[string] $Install,
[switch] $Uninstall
)
$CurrentDir = Get-Location
function Uninstall
{
# TODO
Write-Host "Uninstall c-vim ..."
}
function Install-Item
{
param (
[String] $Name,
[String] $Type,
[String] $Dir,
[String] $Target
)
$Path = "$Dir\$Name"
$BackupPath = "$Path.old"
if (Test-Path -Path $Path) {
if (Test-Path -Path $BackupPath) {
if ($Type -eq "Junction") {
[IO.Directory]::Delete($BackupPath)
}
else {
Remove-Item $BackupPath
}
}
Rename-Item -Path $Path -NewName "$Name.old"
Write-Host "backup $Name to $Name.old"
}
New-Item -ItemType $Type -Path $Path -Target $Target
}
function Install-Neovim
{
Write-Host "Install c-vim for neovim ..."
$Dir = "$Home\AppData\Local"
Install-Item -Name nvim -Type Junction -Dir $Dir -Target $CurrentDir
Install-Item -Name "nvim-data" -Type Junction -Dir $Dir -Target $CurrentDir
Write-Host "Installed c-vim for neovim" -ForegroundColor Green
if (-Not (Test-Path -Path "$CurrentDir\plugged")) {
nvim +PlugInstall! +PlugClean! +qall
Write-Host "Installed plugins" -ForegroundColor Green
}
}
function Install-Vim
{
Write-Host "Install c-vim for vim ..."
Install-Item -Name _vimrc -Type SymbolicLink -Dir $HOME -Target $CurrentDir\vimrc
Install-Item -Name vimfiles -Type Junction -Dir $HOME -Target $CurrentDir
Install-Item -Name .vimrc -Type SymbolicLink -Dir $HOME -Target $CurrentDir\vimrc
Install-Item -Name .vim -Type Junction -Dir $HOME -Target $CurrentDir
Write-Host "Installed c-vim for vim" -ForegroundColor Green
if (-Not (Test-Path -Path "$CurrentDir\plugged")) {
vim +PlugInstall! +PlugClean! +qall
Write-Host "Installed plugins" -ForegroundColor Green
}
}
function UseDefaultSettings
{
if (!(Test-Path "$PSScriptRoot\coc-settings.json"))
{
Install-Item -Name "coc-settings.json" -Type SymbolicLink -Dir $PSScriptRoot -Target "$PSScriptRoot\settings\coc-default-settings.json"
}
}
if ($Uninstall)
{
Uninstall
return
}
if ($Install -eq "neovim")
{
Install-Neovim
}
elseif ($Install -eq "vim")
{
Install-Vim
}
elseif ($Install -eq "")
{
Install-Neovim
Install-Vim
}
else
{
Write-Error "Unknown: $Install"
}
UseDefaultSettings