blob: 871ce673a99635b93a9bebf79a714d2a2af048e6 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001# NSIS file to create a self-installing exe for Vim.
2# It requires NSIS version 2.0 or later.
Bram Moolenaar04344822014-11-05 18:18:17 +01003# Last Change: 2014 Nov 5
Bram Moolenaar071d4272004-06-13 20:20:40 +00004
5# WARNING: if you make changes to this script, look out for $0 to be valid,
6# because uninstall deletes most files in $0.
7
Bram Moolenaarba460752013-07-04 22:35:01 +02008# Location of gvim_ole.exe, vimw32.exe, GvimExt/*, etc.
Bram Moolenaar286eacd2016-01-16 18:05:50 +01009!ifndef VIMSRC
10 !define VIMSRC "..\src"
11!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012
13# Location of runtime files
Bram Moolenaar286eacd2016-01-16 18:05:50 +010014!ifndef VIMRT
15 !define VIMRT ".."
16!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000017
18# Location of extra tools: diff.exe
Bram Moolenaar286eacd2016-01-16 18:05:50 +010019!ifndef VIMTOOLS
20 !define VIMTOOLS ..\..
21!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000022
Bram Moolenaar6199d432017-10-14 19:05:44 +020023# Location of gettext.
24# It must contain two directories: gettext32 and gettext64.
25# See README.txt for detail.
26!ifndef GETTEXT
27 !define GETTEXT ${VIMRT}
28!endif
29
Bram Moolenaar071d4272004-06-13 20:20:40 +000030# Comment the next line if you don't have UPX.
Bram Moolenaar6199d432017-10-14 19:05:44 +020031# Get it at https://upx.github.io/
Bram Moolenaar071d4272004-06-13 20:20:40 +000032!define HAVE_UPX
33
34# comment the next line if you do not want to add Native Language Support
35!define HAVE_NLS
36
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010037!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
39# ----------- No configurable settings below this line -----------
40
41!include UpgradeDLL.nsh # for VisVim.dll
Bram Moolenaar442b4222010-05-24 21:34:22 +020042!include LogicLib.nsh
43!include x64.nsh
Bram Moolenaar071d4272004-06-13 20:20:40 +000044
45Name "Vim ${VER_MAJOR}.${VER_MINOR}"
46OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
47CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +010048SetCompressor /SOLID lzma
Bram Moolenaar071d4272004-06-13 20:20:40 +000049SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +020050RequestExecutionLevel highest
Bram Moolenaar286eacd2016-01-16 18:05:50 +010051XPStyle on
Bram Moolenaar071d4272004-06-13 20:20:40 +000052
53ComponentText "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer."
Bram Moolenaar04344822014-11-05 18:18:17 +010054DirText "Choose a directory to install Vim (should contain 'vim')"
Bram Moolenaar071d4272004-06-13 20:20:40 +000055Icon icons\vim_16c.ico
Bram Moolenaar266411a2013-07-05 20:01:32 +020056# NSIS2 uses a different strategy with six different images in a strip...
Bram Moolenaar071d4272004-06-13 20:20:40 +000057#EnabledBitmap icons\enabled.bmp
58#DisabledBitmap icons\disabled.bmp
59UninstallText "This will uninstall Vim ${VER_MAJOR}.${VER_MINOR} from your system."
60UninstallIcon icons\vim_uninst_16c.ico
61
62# On NSIS 2 using the BGGradient causes trouble on Windows 98, in combination
63# with the BringToFront.
64# BGGradient 004000 008200 FFFFFF
65LicenseText "You should read the following before installing:"
66LicenseData ${VIMRT}\doc\uganda.nsis.txt
67
68!ifdef HAVE_UPX
69 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
70!endif
71
72# This adds '\vim' to the user choice automagically. The actual value is
73# obtained below with ReadINIStr.
74InstallDir "$PROGRAMFILES\Vim"
75
76# Types of installs we can perform:
77InstType Typical
78InstType Minimal
79InstType Full
80
81SilentInstall normal
82
83# These are the pages we use
84Page license
85Page components
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +020086Page custom SetCustom ValidateCustom ": _vimrc setting"
Bram Moolenaar071d4272004-06-13 20:20:40 +000087Page directory "" "" CheckInstallDir
88Page instfiles
89UninstPage uninstConfirm
90UninstPage instfiles
91
92##########################################################
93# Functions
94
95Function .onInit
96 MessageBox MB_YESNO|MB_ICONQUESTION \
97 "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer.$\n Continue?" \
Bram Moolenaara1bd86e2017-06-24 15:11:01 +020098 /SD IDYES \
99 IDYES NoAbort
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100 Abort ; causes installer to quit.
101 NoAbort:
102
103 # run the install program to check for already installed versions
104 SetOutPath $TEMP
105 File /oname=install.exe ${VIMSRC}\installw32.exe
106 ExecWait "$TEMP\install.exe -uninstall-check"
107 Delete $TEMP\install.exe
108
109 # We may have been put to the background when uninstall did something.
110 BringToFront
111
112 # Install will have created a file for us that contains the directory where
113 # we should install. This is $VIM if it's set. This appears to be the only
114 # way to get the value of $VIM here!?
115 ReadINIStr $INSTDIR $TEMP\vimini.ini vimini dir
116 Delete $TEMP\vimini.ini
117
118 # If ReadINIStr failed or did not find a path: use the default dir.
119 StrCmp $INSTDIR "" 0 IniOK
120 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
121 IniOK:
122
123 # Should check for the value of $VIM and use it. Unfortunately I don't know
124 # how to obtain the value of $VIM
125 # IfFileExists "$VIM" 0 No_Vim
126 # StrCpy $INSTDIR "$VIM"
127 # No_Vim:
128
129 # User variables:
130 # $0 - holds the directory the executables are installed to
131 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
132 # registration (since a non-OLE gvim will not complain, and we want to
133 # always register an OLE gvim).
134 # $2 - holds the names to create batch files for
135 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
136 StrCpy $1 "-register-OLE"
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000137 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200139 # Extract InstallOptions files
140 # $PLUGINSDIR will automatically be removed when the installer closes
141 InitPluginsDir
142 File /oname=$PLUGINSDIR\vimrc.ini "vimrc.ini"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143FunctionEnd
144
145Function .onUserAbort
146 MessageBox MB_YESNO|MB_ICONQUESTION "Abort install?" IDYES NoCancelAbort
147 Abort ; causes installer to not quit.
148 NoCancelAbort:
149FunctionEnd
150
151# We only accept the directory if it ends in "vim". Using .onVerifyInstDir has
152# the disadvantage that the browse dialog is difficult to use.
153Function CheckInstallDir
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154FunctionEnd
155
156Function .onInstSuccess
157 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
158 MessageBox MB_YESNO|MB_ICONQUESTION \
Bram Moolenaarf2330482008-06-24 20:19:36 +0000159 "The installation process has been successful. Happy Vimming! \
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160 $\n$\n Do you want to see the README file now?" IDNO NoReadme
161 Exec '$0\gvim.exe -R "$0\README.txt"'
162 NoReadme:
163FunctionEnd
164
165Function .onInstFailed
166 MessageBox MB_OK|MB_ICONEXCLAMATION "Installation failed. Better luck next time."
167FunctionEnd
168
169Function un.onUnInstSuccess
170 MessageBox MB_OK|MB_ICONINFORMATION \
171 "Vim ${VER_MAJOR}.${VER_MINOR} has been (partly) removed from your system"
172FunctionEnd
173
174Function un.GetParent
175 Exch $0 ; old $0 is on top of stack
176 Push $1
177 Push $2
178 StrCpy $1 -1
179 loop:
180 StrCpy $2 $0 1 $1
181 StrCmp $2 "" exit
182 StrCmp $2 "\" exit
183 IntOp $1 $1 - 1
184 Goto loop
185 exit:
186 StrCpy $0 $0 $1
187 Pop $2
188 Pop $1
189 Exch $0 ; put $0 on top of stack, restore $0 to original value
190FunctionEnd
191
192##########################################################
193Section "Vim executables and runtime files"
Bram Moolenaar49150a42017-09-17 21:00:03 +0200194 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195
196 # we need also this here if the user changes the instdir
197 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
198
199 SetOutPath $0
200 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
201 File /oname=install.exe ${VIMSRC}\installw32.exe
202 File /oname=uninstal.exe ${VIMSRC}\uninstalw32.exe
203 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200204 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000206 File ${VIMRT}\vimtutor.bat
207 File ${VIMRT}\README.txt
208 File ..\uninstal.txt
209 File ${VIMRT}\*.vim
210 File ${VIMRT}\rgb.txt
211
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200212 File ${VIMTOOLS}\diff.exe
213 File ${VIMTOOLS}\winpty32.dll
214 File ${VIMTOOLS}\winpty-agent.exe
215
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216 SetOutPath $0\colors
217 File ${VIMRT}\colors\*.*
218
219 SetOutPath $0\compiler
220 File ${VIMRT}\compiler\*.*
221
222 SetOutPath $0\doc
223 File ${VIMRT}\doc\*.txt
224 File ${VIMRT}\doc\tags
225
226 SetOutPath $0\ftplugin
227 File ${VIMRT}\ftplugin\*.*
228
229 SetOutPath $0\indent
230 File ${VIMRT}\indent\*.*
231
232 SetOutPath $0\macros
233 File ${VIMRT}\macros\*.*
Bram Moolenaarc35e4cb2017-09-06 21:43:10 +0200234 SetOutPath $0\macros\hanoi
235 File ${VIMRT}\macros\hanoi\*.*
236 SetOutPath $0\macros\life
237 File ${VIMRT}\macros\life\*.*
238 SetOutPath $0\macros\maze
239 File ${VIMRT}\macros\maze\*.*
240 SetOutPath $0\macros\urm
241 File ${VIMRT}\macros\urm\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242
Bram Moolenaarc7baa432016-04-26 17:34:44 +0200243 SetOutPath $0\pack\dist\opt\dvorak\dvorak
244 File ${VIMRT}\pack\dist\opt\dvorak\dvorak\*.*
245 SetOutPath $0\pack\dist\opt\dvorak\plugin
246 File ${VIMRT}\pack\dist\opt\dvorak\plugin\*.*
247
248 SetOutPath $0\pack\dist\opt\editexisting\plugin
249 File ${VIMRT}\pack\dist\opt\editexisting\plugin\*.*
250
251 SetOutPath $0\pack\dist\opt\justify\plugin
252 File ${VIMRT}\pack\dist\opt\justify\plugin\*.*
253
254 SetOutPath $0\pack\dist\opt\matchit\doc
255 File ${VIMRT}\pack\dist\opt\matchit\doc\*.*
256 SetOutPath $0\pack\dist\opt\matchit\plugin
257 File ${VIMRT}\pack\dist\opt\matchit\plugin\*.*
258
259 SetOutPath $0\pack\dist\opt\shellmenu\plugin
260 File ${VIMRT}\pack\dist\opt\shellmenu\plugin\*.*
261
262 SetOutPath $0\pack\dist\opt\swapmouse\plugin
263 File ${VIMRT}\pack\dist\opt\swapmouse\plugin\*.*
264
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265 SetOutPath $0\plugin
266 File ${VIMRT}\plugin\*.*
267
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000268 SetOutPath $0\autoload
269 File ${VIMRT}\autoload\*.*
270
Bram Moolenaard09a2062017-11-11 15:37:45 +0100271 SetOutPath $0\autoload\dist
272 File ${VIMRT}\autoload\dist\*.*
273
Bram Moolenaar18144c82006-04-12 21:52:12 +0000274 SetOutPath $0\autoload\xml
275 File ${VIMRT}\autoload\xml\*.*
276
Bram Moolenaar071d4272004-06-13 20:20:40 +0000277 SetOutPath $0\syntax
278 File ${VIMRT}\syntax\*.*
279
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000280 SetOutPath $0\spell
281 File ${VIMRT}\spell\*.txt
282 File ${VIMRT}\spell\*.vim
283 File ${VIMRT}\spell\*.spl
284 File ${VIMRT}\spell\*.sug
285
Bram Moolenaar071d4272004-06-13 20:20:40 +0000286 SetOutPath $0\tools
287 File ${VIMRT}\tools\*.*
288
289 SetOutPath $0\tutor
290 File ${VIMRT}\tutor\*.*
291SectionEnd
292
293##########################################################
294Section "Vim console program (vim.exe)"
295 SectionIn 1 3
296
297 SetOutPath $0
298 ReadRegStr $R0 HKLM \
299 "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
300 IfErrors 0 lbl_winnt
Bram Moolenaarba460752013-07-04 22:35:01 +0200301 # Windows 95/98/ME: not supported
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302 Goto lbl_done
303 lbl_winnt:
Bram Moolenaar266411a2013-07-05 20:01:32 +0200304 # Windows NT/2000/XP and later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000305 File /oname=vim.exe ${VIMSRC}\vimw32.exe
306 lbl_done:
307 StrCpy $2 "$2 vim view vimdiff"
308SectionEnd
309
310##########################################################
311Section "Create .bat files for command line use"
312 SectionIn 3
313
314 StrCpy $1 "$1 -create-batfiles $2"
315SectionEnd
316
317##########################################################
318Section "Create icons on the Desktop"
319 SectionIn 1 3
320
321 StrCpy $1 "$1 -install-icons"
322SectionEnd
323
324##########################################################
325Section "Add Vim to the Start Menu"
326 SectionIn 1 3
327
328 StrCpy $1 "$1 -add-start-menu"
329SectionEnd
330
331##########################################################
332Section "Add an Edit-with-Vim context menu entry"
333 SectionIn 1 3
334
335 # Be aware of this sequence of events:
336 # - user uninstalls Vim, gvimext.dll can't be removed (it's in use) and
337 # is scheduled to be removed at next reboot.
338 # - user installs Vim in same directory, gvimext.dll still exists.
339 # If we now skip installing gvimext.dll, it will disappear at the next
340 # reboot. Thus when copying gvimext.dll fails always schedule it to be
341 # installed at the next reboot. Can't use UpgradeDLL!
342 # We don't ask the user to reboot, the old dll will keep on working.
343 SetOutPath $0
344 ClearErrors
345 SetOverwrite try
Bram Moolenaar6199d432017-10-14 19:05:44 +0200346
Bram Moolenaar442b4222010-05-24 21:34:22 +0200347 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200348 # Install 64-bit gvimext.dll into the GvimExt64 directory.
349 SetOutPath $0\GvimExt64
350 ClearErrors
Bram Moolenaar442b4222010-05-24 21:34:22 +0200351 File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext64.dll
Bram Moolenaar6199d432017-10-14 19:05:44 +0200352!ifdef HAVE_NLS
353 File ${GETTEXT}\gettext64\libintl-8.dll
354 File ${GETTEXT}\gettext64\libiconv-2.dll
355!endif
356
357 IfErrors 0 GvimExt64Done
358
359 # Can't copy gvimext.dll, create it under another name and rename it
360 # on next reboot.
361 GetTempFileName $3 $0\GvimExt64
Bram Moolenaar81b07b52017-10-15 21:43:21 +0200362 File /oname=$3 ${VIMSRC}\GvimExt\gvimext64.dll
Bram Moolenaar6199d432017-10-14 19:05:44 +0200363 Rename /REBOOTOK $3 $0\GvimExt64\gvimext.dll
364!ifdef HAVE_NLS
365 GetTempFileName $3 $0\GvimExt64
366 File /oname=$3 ${GETTEXT}\gettext64\libintl-8.dll
367 Rename /REBOOTOK $3 $0\GvimExt64\libintl-8.dll
368 GetTempFileName $3 $0\GvimExt64
369 File /oname=$3 ${GETTEXT}\gettext64\libiconv-2.dll
370 Rename /REBOOTOK $3 $0\GvimExt64\libiconv-2.dll
371!endif
Bram Moolenaar442b4222010-05-24 21:34:22 +0200372 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200373
374 GvimExt64Done:
375
376 # Install 32-bit gvimext.dll into the GvimExt32 directory.
377 SetOutPath $0\GvimExt32
378 ClearErrors
379
380 File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll
381!ifdef HAVE_NLS
382 File ${GETTEXT}\gettext32\libintl-8.dll
383 File ${GETTEXT}\gettext32\libiconv-2.dll
384 File ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll
385!endif
386
387 IfErrors 0 GvimExt32Done
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388
389 # Can't copy gvimext.dll, create it under another name and rename it on
390 # next reboot.
Bram Moolenaar6199d432017-10-14 19:05:44 +0200391 GetTempFileName $3 $0\GvimExt32
392 File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll
393 Rename /REBOOTOK $3 $0\GvimExt32\gvimext.dll
394!ifdef HAVE_NLS
395 GetTempFileName $3 $0\GvimExt32
396 File /oname=$3 ${GETTEXT}\gettext32\libintl-8.dll
397 Rename /REBOOTOK $3 $0\GvimExt32\libintl-8.dll
398 GetTempFileName $3 $0\GvimExt32
399 File /oname=$3 ${GETTEXT}\gettext32\libiconv-2.dll
400 Rename /REBOOTOK $3 $0\GvimExt32\libiconv-2.dll
401 GetTempFileName $3 $0\GvimExt32
402 File /oname=$3 ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll
403 Rename /REBOOTOK $3 $0\GvimExt32\libgcc_s_sjlj-1.dll
404!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405
Bram Moolenaar6199d432017-10-14 19:05:44 +0200406 GvimExt32Done:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407 SetOverwrite lastused
408
409 # We don't have a separate entry for the "Open With..." menu, assume
410 # the user wants either both or none.
411 StrCpy $1 "$1 -install-popup -install-openwith"
412SectionEnd
413
414##########################################################
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200415Section "Create a _vimrc if it doesn't exist" sec_vimrc_id
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416 SectionIn 1 3
417
418 StrCpy $1 "$1 -create-vimrc"
419SectionEnd
420
421##########################################################
422Section "Create plugin directories in HOME or VIM"
423 SectionIn 1 3
424
425 StrCpy $1 "$1 -create-directories home"
426SectionEnd
427
428##########################################################
429Section "Create plugin directories in VIM"
430 SectionIn 3
431
432 StrCpy $1 "$1 -create-directories vim"
433SectionEnd
434
435##########################################################
436Section "VisVim Extension for MS Visual Studio"
437 SectionIn 3
438
439 SetOutPath $0
440 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
441 File ${VIMSRC}\VisVim\README_VisVim.txt
442SectionEnd
443
444##########################################################
445!ifdef HAVE_NLS
446 Section "Native Language Support"
447 SectionIn 1 3
448
449 SetOutPath $0\lang
450 File /r ${VIMRT}\lang\*.*
451 SetOutPath $0\keymap
452 File ${VIMRT}\keymap\README.txt
453 File ${VIMRT}\keymap\*.vim
454 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200455 File ${GETTEXT}\gettext32\libintl-8.dll
456 File ${GETTEXT}\gettext32\libiconv-2.dll
457 #File /nonfatal ${VIMRT}\libwinpthread-1.dll
458 File /nonfatal ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459 SectionEnd
460!endif
461
462##########################################################
463Section -call_install_exe
464 SetOutPath $0
465 ExecWait "$0\install.exe $1"
466SectionEnd
467
468##########################################################
469Section -post
470 BringToFront
471SectionEnd
472
473##########################################################
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200474Function SetCustom
475 # Display the InstallOptions dialog
476
477 # Check if a _vimrc should be created
478 SectionGetFlags ${sec_vimrc_id} $0
479 IntOp $0 $0 & 1
480 StrCmp $0 "1" +2 0
481 Abort
482
483 Push $3
484 InstallOptions::dialog "$PLUGINSDIR\vimrc.ini"
485 Pop $3
486 Pop $3
487FunctionEnd
488
489Function ValidateCustom
490 ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 2" "State"
491 StrCmp $3 "1" 0 +3
492 StrCpy $1 "$1 -vimrc-remap no"
493 Goto behave
494
495 StrCpy $1 "$1 -vimrc-remap win"
496
497 behave:
498 ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 5" "State"
499 StrCmp $3 "1" 0 +3
500 StrCpy $1 "$1 -vimrc-behave unix"
501 Goto done
502
503 ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 6" "State"
504 StrCmp $3 "1" 0 +3
505 StrCpy $1 "$1 -vimrc-behave mswin"
506 Goto done
507
508 StrCpy $1 "$1 -vimrc-behave default"
509 done:
510FunctionEnd
511
512##########################################################
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513Section Uninstall
514 # Apparently $INSTDIR is set to the directory where the uninstaller is
515 # created. Thus the "vim61" directory is included in it.
516 StrCpy $0 "$INSTDIR"
517
518 # If VisVim was installed, unregister the DLL.
519 IfFileExists "$0\VisVim.dll" Has_VisVim No_VisVim
520 Has_VisVim:
521 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
522
523 No_VisVim:
524
525 # delete the context menu entry and batch files
526 ExecWait "$0\uninstal.exe -nsis"
527
528 # We may have been put to the background when uninstall did something.
529 BringToFront
530
531 # ask the user if the Vim version dir must be removed
532 MessageBox MB_YESNO|MB_ICONQUESTION \
533 "Would you like to delete $0?$\n \
534 $\nIt contains the Vim executables and runtime files." IDNO NoRemoveExes
535
536 Delete /REBOOTOK $0\*.dll
Bram Moolenaar6199d432017-10-14 19:05:44 +0200537 Delete /REBOOTOK $0\GvimExt32\*.dll
538 ${If} ${RunningX64}
539 Delete /REBOOTOK $0\GvimExt64\*.dll
540 ${EndIf}
541
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 ClearErrors
543 # Remove everything but *.dll files. Avoids that
544 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +0000545 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546 RMDir /r $0\colors
547 RMDir /r $0\compiler
548 RMDir /r $0\doc
549 RMDir /r $0\ftplugin
550 RMDir /r $0\indent
551 RMDir /r $0\macros
552 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +0000553 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554 RMDir /r $0\syntax
555 RMDir /r $0\tools
556 RMDir /r $0\tutor
557 RMDir /r $0\VisVim
558 RMDir /r $0\lang
559 RMDir /r $0\keymap
560 Delete $0\*.exe
561 Delete $0\*.bat
562 Delete $0\*.vim
563 Delete $0\*.txt
564
565 IfErrors ErrorMess NoErrorMess
566 ErrorMess:
567 MessageBox MB_OK|MB_ICONEXCLAMATION \
568 "Some files in $0 have not been deleted!$\nYou must do it manually."
569 NoErrorMess:
570
571 # No error message if the "vim62" directory can't be removed, the
572 # gvimext.dll may still be there.
573 RMDir $0
574
575 NoRemoveExes:
576 # get the parent dir of the installation
577 Push $INSTDIR
578 Call un.GetParent
579 Pop $0
580 StrCpy $1 $0
581
582 # if a plugin dir was created at installation ask the user to remove it
583 # first look in the root of the installation then in HOME
584 IfFileExists $1\vimfiles AskRemove 0
585 ReadEnvStr $1 "HOME"
586 StrCmp $1 "" NoRemove 0
587
588 IfFileExists $1\vimfiles 0 NoRemove
589
590 AskRemove:
591 MessageBox MB_YESNO|MB_ICONQUESTION \
Bram Moolenaare04abda2010-08-01 22:35:43 +0200592 "Remove all files in your $1\vimfiles directory?$\n \
Bram Moolenaar760d14a2010-07-31 22:03:44 +0200593 $\nCAREFUL: If you have created something there that you want to keep, click No" IDNO Fin
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 RMDir /r $1\vimfiles
595 NoRemove:
596
597 # ask the user if the Vim root dir must be removed
598 MessageBox MB_YESNO|MB_ICONQUESTION \
599 "Would you like to remove $0?$\n \
600 $\nIt contains your Vim configuration files!" IDNO NoDelete
601 RMDir /r $0 ; skipped if no
602 NoDelete:
603
604 Fin:
605 Call un.onUnInstSuccess
606
607SectionEnd