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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
# NSIS file to create a self-installing exe for Vim.
# It requires NSIS version 2.0 or later.
# Last Change: 2014 Nov 5
# WARNING: if you make changes to this script, look out for $0 to be valid,
# because uninstall deletes most files in $0.
# Location of gvim_ole.exe, vimw32.exe, GvimExt/*, etc.
!ifndef VIMSRC
!define VIMSRC "..\src"
!endif
# Location of runtime files
!ifndef VIMRT
!define VIMRT ".."
!endif
# Location of extra tools: diff.exe
!ifndef VIMTOOLS
!define VIMTOOLS ..\..
!endif
# Comment the next line if you don't have UPX.
# Get it at http://upx.sourceforge.net
!define HAVE_UPX
# comment the next line if you do not want to add Native Language Support
!define HAVE_NLS
!include gvim_version.nsh # for version number
# ----------- No configurable settings below this line -----------
!include UpgradeDLL.nsh # for VisVim.dll
!include LogicLib.nsh
!include x64.nsh
Name "Vim ${VER_MAJOR}.${VER_MINOR}"
OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
CRCCheck force
SetCompressor /SOLID lzma
SetDatablockOptimize on
RequestExecutionLevel highest
XPStyle on
ComponentText "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer."
DirText "Choose a directory to install Vim (should contain 'vim')"
Icon icons\vim_16c.ico
# NSIS2 uses a different strategy with six different images in a strip...
#EnabledBitmap icons\enabled.bmp
#DisabledBitmap icons\disabled.bmp
UninstallText "This will uninstall Vim ${VER_MAJOR}.${VER_MINOR} from your system."
UninstallIcon icons\vim_uninst_16c.ico
# On NSIS 2 using the BGGradient causes trouble on Windows 98, in combination
# with the BringToFront.
# BGGradient 004000 008200 FFFFFF
LicenseText "You should read the following before installing:"
LicenseData ${VIMRT}\doc\uganda.nsis.txt
!ifdef HAVE_UPX
!packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
!endif
# This adds '\vim' to the user choice automagically. The actual value is
# obtained below with ReadINIStr.
InstallDir "$PROGRAMFILES\Vim"
# Types of installs we can perform:
InstType Typical
InstType Minimal
InstType Full
SilentInstall normal
# These are the pages we use
Page license
Page components
Page directory "" "" CheckInstallDir
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
##########################################################
# Functions
Function .onInit
MessageBox MB_YESNO|MB_ICONQUESTION \
"This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer.$\n Continue?" \
/SD IDYES \
IDYES NoAbort
Abort ; causes installer to quit.
NoAbort:
# run the install program to check for already installed versions
SetOutPath $TEMP
File /oname=install.exe ${VIMSRC}\installw32.exe
ExecWait "$TEMP\install.exe -uninstall-check"
Delete $TEMP\install.exe
# We may have been put to the background when uninstall did something.
BringToFront
# Install will have created a file for us that contains the directory where
# we should install. This is $VIM if it's set. This appears to be the only
# way to get the value of $VIM here!?
ReadINIStr $INSTDIR $TEMP\vimini.ini vimini dir
Delete $TEMP\vimini.ini
# If ReadINIStr failed or did not find a path: use the default dir.
StrCmp $INSTDIR "" 0 IniOK
StrCpy $INSTDIR "$PROGRAMFILES\Vim"
IniOK:
# Should check for the value of $VIM and use it. Unfortunately I don't know
# how to obtain the value of $VIM
# IfFileExists "$VIM" 0 No_Vim
# StrCpy $INSTDIR "$VIM"
# No_Vim:
# User variables:
# $0 - holds the directory the executables are installed to
# $1 - holds the parameters to be passed to install.exe. Starts with OLE
# registration (since a non-OLE gvim will not complain, and we want to
# always register an OLE gvim).
# $2 - holds the names to create batch files for
StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
StrCpy $1 "-register-OLE"
StrCpy $2 "gvim evim gview gvimdiff vimtutor"
FunctionEnd
Function .onUserAbort
MessageBox MB_YESNO|MB_ICONQUESTION "Abort install?" IDYES NoCancelAbort
Abort ; causes installer to not quit.
NoCancelAbort:
FunctionEnd
# We only accept the directory if it ends in "vim". Using .onVerifyInstDir has
# the disadvantage that the browse dialog is difficult to use.
Function CheckInstallDir
FunctionEnd
Function .onInstSuccess
WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
MessageBox MB_YESNO|MB_ICONQUESTION \
"The installation process has been successful. Happy Vimming! \
$\n$\n Do you want to see the README file now?" IDNO NoReadme
Exec '$0\gvim.exe -R "$0\README.txt"'
NoReadme:
FunctionEnd
Function .onInstFailed
MessageBox MB_OK|MB_ICONEXCLAMATION "Installation failed. Better luck next time."
FunctionEnd
Function un.onUnInstSuccess
MessageBox MB_OK|MB_ICONINFORMATION \
"Vim ${VER_MAJOR}.${VER_MINOR} has been (partly) removed from your system"
FunctionEnd
Function un.GetParent
Exch $0 ; old $0 is on top of stack
Push $1
Push $2
StrCpy $1 -1
loop:
StrCpy $2 $0 1 $1
StrCmp $2 "" exit
StrCmp $2 "\" exit
IntOp $1 $1 - 1
Goto loop
exit:
StrCpy $0 $0 $1
Pop $2
Pop $1
Exch $0 ; put $0 on top of stack, restore $0 to original value
FunctionEnd
##########################################################
Section "Vim executables and runtime files"
SectionIn 1 2 3
# we need also this here if the user changes the instdir
StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
SetOutPath $0
File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
File /oname=install.exe ${VIMSRC}\installw32.exe
File /oname=uninstal.exe ${VIMSRC}\uninstalw32.exe
File ${VIMSRC}\vimrun.exe
File /oname=tee.exe ${VIMSRC}\teew32.exe
File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
File ${VIMRT}\vimtutor.bat
File ${VIMRT}\README.txt
File ..\uninstal.txt
File ${VIMRT}\*.vim
File ${VIMRT}\rgb.txt
File ${VIMTOOLS}\diff.exe
File ${VIMTOOLS}\winpty32.dll
File ${VIMTOOLS}\winpty-agent.exe
SetOutPath $0\colors
File ${VIMRT}\colors\*.*
SetOutPath $0\compiler
File ${VIMRT}\compiler\*.*
SetOutPath $0\doc
File ${VIMRT}\doc\*.txt
File ${VIMRT}\doc\tags
SetOutPath $0\ftplugin
File ${VIMRT}\ftplugin\*.*
SetOutPath $0\indent
File ${VIMRT}\indent\*.*
SetOutPath $0\macros
File ${VIMRT}\macros\*.*
SetOutPath $0\macros\hanoi
File ${VIMRT}\macros\hanoi\*.*
SetOutPath $0\macros\life
File ${VIMRT}\macros\life\*.*
SetOutPath $0\macros\maze
File ${VIMRT}\macros\maze\*.*
SetOutPath $0\macros\urm
File ${VIMRT}\macros\urm\*.*
SetOutPath $0\pack\dist\opt\dvorak\dvorak
File ${VIMRT}\pack\dist\opt\dvorak\dvorak\*.*
SetOutPath $0\pack\dist\opt\dvorak\plugin
File ${VIMRT}\pack\dist\opt\dvorak\plugin\*.*
SetOutPath $0\pack\dist\opt\editexisting\plugin
File ${VIMRT}\pack\dist\opt\editexisting\plugin\*.*
SetOutPath $0\pack\dist\opt\justify\plugin
File ${VIMRT}\pack\dist\opt\justify\plugin\*.*
SetOutPath $0\pack\dist\opt\matchit\doc
File ${VIMRT}\pack\dist\opt\matchit\doc\*.*
SetOutPath $0\pack\dist\opt\matchit\plugin
File ${VIMRT}\pack\dist\opt\matchit\plugin\*.*
SetOutPath $0\pack\dist\opt\shellmenu\plugin
File ${VIMRT}\pack\dist\opt\shellmenu\plugin\*.*
SetOutPath $0\pack\dist\opt\swapmouse\plugin
File ${VIMRT}\pack\dist\opt\swapmouse\plugin\*.*
SetOutPath $0\plugin
File ${VIMRT}\plugin\*.*
SetOutPath $0\autoload
File ${VIMRT}\autoload\*.*
SetOutPath $0\autoload\xml
File ${VIMRT}\autoload\xml\*.*
SetOutPath $0\syntax
File ${VIMRT}\syntax\*.*
SetOutPath $0\spell
File ${VIMRT}\spell\*.txt
File ${VIMRT}\spell\*.vim
File ${VIMRT}\spell\*.spl
File ${VIMRT}\spell\*.sug
SetOutPath $0\tools
File ${VIMRT}\tools\*.*
SetOutPath $0\tutor
File ${VIMRT}\tutor\*.*
SectionEnd
##########################################################
Section "Vim console program (vim.exe)"
SectionIn 1 3
SetOutPath $0
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors 0 lbl_winnt
# Windows 95/98/ME: not supported
Goto lbl_done
lbl_winnt:
# Windows NT/2000/XP and later
File /oname=vim.exe ${VIMSRC}\vimw32.exe
lbl_done:
StrCpy $2 "$2 vim view vimdiff"
SectionEnd
##########################################################
Section "Create .bat files for command line use"
SectionIn 3
StrCpy $1 "$1 -create-batfiles $2"
SectionEnd
##########################################################
Section "Create icons on the Desktop"
SectionIn 1 3
StrCpy $1 "$1 -install-icons"
SectionEnd
##########################################################
Section "Add Vim to the Start Menu"
SectionIn 1 3
StrCpy $1 "$1 -add-start-menu"
SectionEnd
##########################################################
Section "Add an Edit-with-Vim context menu entry"
SectionIn 1 3
# Be aware of this sequence of events:
# - user uninstalls Vim, gvimext.dll can't be removed (it's in use) and
# is scheduled to be removed at next reboot.
# - user installs Vim in same directory, gvimext.dll still exists.
# If we now skip installing gvimext.dll, it will disappear at the next
# reboot. Thus when copying gvimext.dll fails always schedule it to be
# installed at the next reboot. Can't use UpgradeDLL!
# We don't ask the user to reboot, the old dll will keep on working.
SetOutPath $0
ClearErrors
SetOverwrite try
${If} ${RunningX64}
File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext64.dll
${Else}
File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll
${EndIf}
IfErrors 0 GvimExtDone
# Can't copy gvimext.dll, create it under another name and rename it on
# next reboot.
GetTempFileName $3 $0
${If} ${RunningX64}
File /oname=$3 ${VIMSRC}\GvimExt\gvimext64.dll
${Else}
File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll
${EndIf}
Rename /REBOOTOK $3 $0\gvimext.dll
GvimExtDone:
SetOverwrite lastused
# We don't have a separate entry for the "Open With..." menu, assume
# the user wants either both or none.
StrCpy $1 "$1 -install-popup -install-openwith"
SectionEnd
##########################################################
Section "Create a _vimrc if it doesn't exist"
SectionIn 1 3
StrCpy $1 "$1 -create-vimrc"
SectionEnd
##########################################################
Section "Create plugin directories in HOME or VIM"
SectionIn 1 3
StrCpy $1 "
|