blob: 2b40e4b0db6cde83c73cda4d2fc85eaee0136684 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001# NSIS file to create a self-installing exe for Vim.
Bram Moolenaaraf610b82018-12-21 16:22:50 +01002# It requires NSIS version 3.0 or later.
Bram Moolenaar04344822014-11-05 18:18:17 +01003# Last Change: 2014 Nov 5
Bram Moolenaar071d4272004-06-13 20:20:40 +00004
Bram Moolenaaraf610b82018-12-21 16:22:50 +01005Unicode true
6
Bram Moolenaar071d4272004-06-13 20:20:40 +00007# WARNING: if you make changes to this script, look out for $0 to be valid,
8# because uninstall deletes most files in $0.
9
Bram Moolenaarba460752013-07-04 22:35:01 +020010# Location of gvim_ole.exe, vimw32.exe, GvimExt/*, etc.
Bram Moolenaar286eacd2016-01-16 18:05:50 +010011!ifndef VIMSRC
12 !define VIMSRC "..\src"
13!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000014
15# Location of runtime files
Bram Moolenaar286eacd2016-01-16 18:05:50 +010016!ifndef VIMRT
17 !define VIMRT ".."
18!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
20# Location of extra tools: diff.exe
Bram Moolenaar286eacd2016-01-16 18:05:50 +010021!ifndef VIMTOOLS
22 !define VIMTOOLS ..\..
23!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000024
Bram Moolenaar6199d432017-10-14 19:05:44 +020025# Location of gettext.
26# It must contain two directories: gettext32 and gettext64.
27# See README.txt for detail.
28!ifndef GETTEXT
29 !define GETTEXT ${VIMRT}
30!endif
31
Bram Moolenaar071d4272004-06-13 20:20:40 +000032# Comment the next line if you don't have UPX.
Bram Moolenaar6199d432017-10-14 19:05:44 +020033# Get it at https://upx.github.io/
Bram Moolenaar071d4272004-06-13 20:20:40 +000034!define HAVE_UPX
35
Bram Moolenaaraf610b82018-12-21 16:22:50 +010036# Comment the next line if you do not want to add Native Language Support
Bram Moolenaar071d4272004-06-13 20:20:40 +000037!define HAVE_NLS
38
Bram Moolenaaraf610b82018-12-21 16:22:50 +010039# Uncomment the next line if you want to include VisVim extension:
40#!define HAVE_VIS_VIM
41
Bram Moolenaar3b0ef8c2020-02-12 21:03:32 +010042# Comment the following line to create an English-only installer:
Bram Moolenaaraf610b82018-12-21 16:22:50 +010043!define HAVE_MULTI_LANG
44
45# Uncomment the next line if you want to create a 64-bit installer.
46#!define WIN64
47
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010048!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000049
Bram Moolenaar9d591522019-05-26 20:49:42 +020050# Definition of Patch for Vim
51!ifndef PATCHLEVEL
52 !define PATCHLEVEL 0
53!endif
54
Bram Moolenaar071d4272004-06-13 20:20:40 +000055# ----------- No configurable settings below this line -----------
56
Bram Moolenaaraf610b82018-12-21 16:22:50 +010057!include "Library.nsh" # For DLL install
58!ifdef HAVE_VIS_VIM
59 !include "UpgradeDLL.nsh" # for VisVim.dll
60!endif
61!include "LogicLib.nsh"
62!include "MUI2.nsh"
63!include "nsDialogs.nsh"
64!include "Sections.nsh"
65!include "x64.nsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +000066
Bram Moolenaaraf610b82018-12-21 16:22:50 +010067!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
68!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
69!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
70
71!ifdef WIN64
72Name "${PRODUCT} (x64)"
73!else
74Name "${PRODUCT}"
75!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000076OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
77CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +010078SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +010079SetCompressorDictSize 64
80ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +000081SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +020082RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +000083
84!ifdef HAVE_UPX
85 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
86!endif
87
Bram Moolenaaraf610b82018-12-21 16:22:50 +010088!ifdef WIN64
89!define BIT 64
90!else
91!define BIT 32
92!endif
93
94##########################################################
95# MUI2 settings
96
97!define MUI_ABORTWARNING
98!define MUI_UNABORTWARNING
99
100!define MUI_ICON "icons\vim_16c.ico"
101!define MUI_UNICON "icons\vim_uninst_16c.ico"
102
103# Show all languages, despite user's codepage:
104!define MUI_LANGDLL_ALLLANGUAGES
105!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
106!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
107!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
108
109!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
110!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
111!define MUI_HEADERIMAGE
112!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
113!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
114
115!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
116!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
117!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
118!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
119
120!define MUI_COMPONENTSPAGE_SMALLDESC
121!define MUI_LICENSEPAGE_CHECKBOX
122!define MUI_FINISHPAGE_RUN "$0\gvim.exe"
123!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
124!define MUI_FINISHPAGE_RUN_PARAMETERS "-R $\"$0\README.txt$\""
125
126# This adds '\Vim' to the user choice automagically. The actual value is
127# obtained below with CheckOldVim.
128!ifdef WIN64
129InstallDir "$PROGRAMFILES64\Vim"
130!else
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131InstallDir "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100132!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133
134# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100135InstType $(str_type_typical)
136InstType $(str_type_minimal)
137InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138
139SilentInstall normal
140
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100141# General custom functions for MUI2:
142#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
143#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
144
145# Installer pages
146!insertmacro MUI_PAGE_WELCOME
147!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
148!insertmacro MUI_PAGE_COMPONENTS
149Page custom SetCustom ValidateCustom
150#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
151!insertmacro MUI_PAGE_DIRECTORY
152!insertmacro MUI_PAGE_INSTFILES
153!define MUI_FINISHPAGE_NOREBOOTSUPPORT
154!insertmacro MUI_PAGE_FINISH
155
156# Uninstaller pages:
157!insertmacro MUI_UNPAGE_CONFIRM
158#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
159!insertmacro MUI_UNPAGE_COMPONENTS
160!insertmacro MUI_UNPAGE_INSTFILES
161!define MUI_FINISHPAGE_NOREBOOTSUPPORT
162!insertmacro MUI_UNPAGE_FINISH
163
164##########################################################
165# Languages Files
166
167!insertmacro MUI_RESERVEFILE_LANGDLL
168!include "lang\english.nsi"
169
170# Include support for other languages:
171!ifdef HAVE_MULTI_LANG
172 !include "lang\danish.nsi"
173 !include "lang\dutch.nsi"
174 !include "lang\german.nsi"
175 !include "lang\italian.nsi"
176 !include "lang\japanese.nsi"
177 !include "lang\simpchinese.nsi"
178 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100179 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100180!endif
181
Bram Moolenaardabfde02019-05-17 12:37:27 +0200182##########################################################
183# Version resources
184
185VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
186VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
187VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
188VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
189VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200190VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
191VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100192
193# Global variables
194Var vim_dialog
195Var vim_nsd_compat
196Var vim_nsd_keymap
197Var vim_nsd_mouse
198Var vim_compat_stat
199Var vim_keymap_stat
200Var vim_mouse_stat
201
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202
Bram Moolenaar5d424742018-02-04 19:11:30 +0100203# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100204ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100205
Bram Moolenaar071d4272004-06-13 20:20:40 +0000206##########################################################
207# Functions
208
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100209# Get parent directory
210# Share this function both on installer and uninstaller
211!macro GetParent un
212Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213 Exch $0 ; old $0 is on top of stack
214 Push $1
215 Push $2
216 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100217 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000218 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100219 ${If} $2 == ""
220 ${OrIf} $2 == "\"
221 ${ExitDo}
222 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100224 ${Loop}
225 StrCpy $0 $0 $1
226 Pop $2
227 Pop $1
228 Exch $0 ; put $0 on top of stack, restore $0 to original value
229FunctionEnd
230!macroend
231
232!insertmacro GetParent ""
233!insertmacro GetParent "un."
234
235# Check if Vim is already installed.
236# return: Installed directory. If not found, it will be empty.
237Function CheckOldVim
238 Push $0
239 Push $R0
240 Push $R1
241 Push $R2
242
243 ${If} ${RunningX64}
244 SetRegView 64
245 ${EndIf}
246
247 ClearErrors
248 StrCpy $0 "" # Installed directory
249 StrCpy $R0 0 # Sub-key index
250 StrCpy $R1 "" # Sub-key
251 ${Do}
252 # Eumerate the sub-key:
253 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
254
255 # Stop if no more sub-key:
256 ${If} ${Errors}
257 ${OrIf} $R1 == ""
258 ${ExitDo}
259 ${EndIf}
260
261 # Move to the next sub-key:
262 IntOp $R0 $R0 + 1
263
264 # Check if the key is Vim uninstall key or not:
265 StrCpy $R2 $R1 4
266 ${If} $R2 S!= "Vim "
267 ${Continue}
268 ${EndIf}
269
270 # Verifies required sub-keys:
271 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
272 ${If} ${Errors}
273 ${OrIf} $R2 == ""
274 ${Continue}
275 ${EndIf}
276
277 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
278 ${If} ${Errors}
279 ${OrIf} $R2 == ""
280 ${Continue}
281 ${EndIf}
282
283 # Found
284 Push $R2
285 call GetParent
286 call GetParent
287 Pop $0 # Vim directory
288 ${ExitDo}
289
290 ${Loop}
291
292 ${If} ${RunningX64}
293 SetRegView lastused
294 ${EndIf}
295
296 Pop $R2
297 Pop $R1
298 Pop $R0
299 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000300FunctionEnd
301
302##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100303Section "$(str_section_old_ver)" id_section_old_ver
304 SectionIn 1 2 3 RO
305
306 # run the install program to check for already installed versions
307 SetOutPath $TEMP
308 File /oname=install.exe ${VIMSRC}\installw32.exe
309 DetailPrint "$(str_msg_uninstalling)"
310 ${Do}
311 nsExec::Exec "$TEMP\install.exe -uninstall-check"
312 Pop $3
313
314 call CheckOldVim
315 Pop $3
316 ${If} $3 == ""
317 ${ExitDo}
318 ${Else}
319 # It seems that the old version is still remaining.
320 # TODO: Should we show a warning and run the uninstaller again?
321
322 ${ExitDo} # Just ignore for now.
323 ${EndIf}
324 ${Loop}
325 Delete $TEMP\install.exe
326 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
327
328 # We may have been put to the background when uninstall did something.
329 BringToFront
330SectionEnd
331
332##########################################################
333Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200334 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000335
336 # we need also this here if the user changes the instdir
337 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
338
339 SetOutPath $0
340 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200341!if /FileExists "${VIMSRC}\vim${BIT}.dll"
342 File ${VIMSRC}\vim${BIT}.dll
343!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000344 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200345 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200347 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000348 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100349 File ..\vimtutor.bat
350 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200351 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352 File ${VIMRT}\*.vim
353 File ${VIMRT}\rgb.txt
354
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200355 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100356 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200357 File ${VIMTOOLS}\winpty-agent.exe
358
Bram Moolenaar071d4272004-06-13 20:20:40 +0000359 SetOutPath $0\colors
360 File ${VIMRT}\colors\*.*
361
362 SetOutPath $0\compiler
363 File ${VIMRT}\compiler\*.*
364
365 SetOutPath $0\doc
366 File ${VIMRT}\doc\*.txt
367 File ${VIMRT}\doc\tags
368
369 SetOutPath $0\ftplugin
370 File ${VIMRT}\ftplugin\*.*
371
372 SetOutPath $0\indent
373 File ${VIMRT}\indent\*.*
374
375 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100376 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100378 SetOutPath $0\pack
379 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200380
Bram Moolenaar071d4272004-06-13 20:20:40 +0000381 SetOutPath $0\plugin
382 File ${VIMRT}\plugin\*.*
383
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000384 SetOutPath $0\autoload
385 File ${VIMRT}\autoload\*.*
386
Bram Moolenaard09a2062017-11-11 15:37:45 +0100387 SetOutPath $0\autoload\dist
388 File ${VIMRT}\autoload\dist\*.*
389
Bram Moolenaar18144c82006-04-12 21:52:12 +0000390 SetOutPath $0\autoload\xml
391 File ${VIMRT}\autoload\xml\*.*
392
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393 SetOutPath $0\syntax
394 File ${VIMRT}\syntax\*.*
395
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000396 SetOutPath $0\spell
397 File ${VIMRT}\spell\*.txt
398 File ${VIMRT}\spell\*.vim
399 File ${VIMRT}\spell\*.spl
400 File ${VIMRT}\spell\*.sug
401
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402 SetOutPath $0\tools
403 File ${VIMRT}\tools\*.*
404
405 SetOutPath $0\tutor
406 File ${VIMRT}\tutor\*.*
407SectionEnd
408
409##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100410Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411 SectionIn 1 3
412
413 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100414 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000415 StrCpy $2 "$2 vim view vimdiff"
416SectionEnd
417
418##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100419Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420 SectionIn 3
421
422 StrCpy $1 "$1 -create-batfiles $2"
423SectionEnd
424
425##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100426SectionGroup $(str_group_icons) id_group_icons
427 Section "$(str_section_desktop)" id_section_desktop
428 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100430 StrCpy $1 "$1 -install-icons"
431 SectionEnd
432
433 Section "$(str_section_start_menu)" id_section_startmenu
434 SectionIn 1 3
435
436 StrCpy $1 "$1 -add-start-menu"
437 SectionEnd
438SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000439
440##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100441Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442 SectionIn 1 3
443
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200445
Bram Moolenaar442b4222010-05-24 21:34:22 +0200446 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200447 # Install 64-bit gvimext.dll into the GvimExt64 directory.
448 SetOutPath $0\GvimExt64
449 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100450 !define LIBRARY_SHELL_EXTENSION
451 !define LIBRARY_X64
452 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
453 "${VIMSRC}\GvimExt\gvimext64.dll" \
454 "$0\GvimExt64\gvimext.dll" "$0"
455 !undef LIBRARY_X64
456 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200457 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200458
Bram Moolenaar6199d432017-10-14 19:05:44 +0200459 # Install 32-bit gvimext.dll into the GvimExt32 directory.
460 SetOutPath $0\GvimExt32
461 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100462 !define LIBRARY_SHELL_EXTENSION
463 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
464 "${VIMSRC}\GvimExt\gvimext.dll" \
465 "$0\GvimExt32\gvimext.dll" "$0"
466 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
468 # We don't have a separate entry for the "Open With..." menu, assume
469 # the user wants either both or none.
470 StrCpy $1 "$1 -install-popup -install-openwith"
471SectionEnd
472
473##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100474Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475 SectionIn 1 3
476
477 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100478
479 ${If} ${RunningX64}
480 SetRegView 64
481 ${EndIf}
482 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
483 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
484 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
485 ${If} ${RunningX64}
486 SetRegView lastused
487 ${EndIf}
488
489 ${If} $vim_compat_stat == "vi"
490 StrCpy $1 "$1 -vimrc-compat vi"
491 ${ElseIf} $vim_compat_stat == "vim"
492 StrCpy $1 "$1 -vimrc-compat vim"
493 ${ElseIf} $vim_compat_stat == "defaults"
494 StrCpy $1 "$1 -vimrc-compat defaults"
495 ${Else}
496 StrCpy $1 "$1 -vimrc-compat all"
497 ${EndIf}
498
499 ${If} $vim_keymap_stat == "default"
500 StrCpy $1 "$1 -vimrc-remap no"
501 ${Else}
502 StrCpy $1 "$1 -vimrc-remap win"
503 ${EndIf}
504
505 ${If} $vim_mouse_stat == "default"
506 StrCpy $1 "$1 -vimrc-behave default"
507 ${ElseIf} $vim_mouse_stat == "windows"
508 StrCpy $1 "$1 -vimrc-behave mswin"
509 ${Else}
510 StrCpy $1 "$1 -vimrc-behave unix"
511 ${EndIf}
512
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513SectionEnd
514
515##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100516SectionGroup $(str_group_plugin) id_group_plugin
517 Section "$(str_section_plugin_home)" id_section_pluginhome
518 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100520 StrCpy $1 "$1 -create-directories home"
521 SectionEnd
522
523 Section "$(str_section_plugin_vim)" id_section_pluginvim
524 SectionIn 3
525
526 StrCpy $1 "$1 -create-directories vim"
527 SectionEnd
528SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000529
530##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100531!ifdef HAVE_VIS_VIM
532Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533 SectionIn 3
534
535 SetOutPath $0
536 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
537 File ${VIMSRC}\VisVim\README_VisVim.txt
538SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100539!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540
541##########################################################
542!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100543Section "$(str_section_nls)" id_section_nls
544 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000545
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100546 SetOutPath $0\lang
547 File /r ${VIMRT}\lang\*.*
548 SetOutPath $0\keymap
549 File ${VIMRT}\keymap\README.txt
550 File ${VIMRT}\keymap\*.vim
551 SetOutPath $0
552 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
553 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
554 "$0\libintl-8.dll" "$0"
555 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
556 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
557 "$0\libiconv-2.dll" "$0"
558 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
559 # Install libgcc_s_sjlj-1.dll only if it is needed.
560 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
561 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
562 "$0\libgcc_s_sjlj-1.dll" "$0"
563 !endif
564
565 ${If} ${SectionIsSelected} ${id_section_editwith}
566 ${If} ${RunningX64}
567 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
568 SetOutPath $0\GvimExt64
569 ClearErrors
570 !define LIBRARY_X64
571 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
572 "${GETTEXT}\gettext64\libintl-8.dll" \
573 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
574 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
575 "${GETTEXT}\gettext64\libiconv-2.dll" \
576 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
577 !undef LIBRARY_X64
578 ${EndIf}
579
580 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
581 SetOutPath $0\GvimExt32
582 ClearErrors
583 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
584 "${GETTEXT}\gettext32\libintl-8.dll" \
585 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
586 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
587 "${GETTEXT}\gettext32\libiconv-2.dll" \
588 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
589 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
590 # Install libgcc_s_sjlj-1.dll only if it is needed.
591 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
592 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
593 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
594 !endif
595 ${EndIf}
596SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597!endif
598
599##########################################################
600Section -call_install_exe
601 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100602 DetailPrint "$(str_msg_registering)"
603 nsExec::Exec "$0\install.exe $1"
604 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000605SectionEnd
606
607##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100608!macro SaveSectionSelection section_id reg_value
609 ${If} ${SectionIsSelected} ${section_id}
610 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
611 ${Else}
612 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
613 ${EndIf}
614!macroend
615
Bram Moolenaar071d4272004-06-13 20:20:40 +0000616Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100617
618 # Get estimated install size
619 SectionGetSize ${id_section_exe} $3
620 ${If} ${SectionIsSelected} ${id_section_console}
621 SectionGetSize ${id_section_console} $4
622 IntOp $3 $3 + $4
623 ${EndIf}
624 ${If} ${SectionIsSelected} ${id_section_editwith}
625 SectionGetSize ${id_section_editwith} $4
626 IntOp $3 $3 + $4
627 ${EndIf}
628!ifdef HAVE_VIS_VIM
629 ${If} ${SectionIsSelected} ${id_section_visvim}
630 SectionGetSize ${id_section_visvim} $4
631 IntOp $3 $3 + $4
632 ${EndIf}
633!endif
634!ifdef HAVE_NLS
635 ${If} ${SectionIsSelected} ${id_section_nls}
636 SectionGetSize ${id_section_nls} $4
637 IntOp $3 $3 + $4
638 ${EndIf}
639!endif
640
641 # Register EstimatedSize and AllowSilent.
642 # Other information will be set by the install.exe (dosinst.c).
643 ${If} ${RunningX64}
644 SetRegView 64
645 ${EndIf}
646 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
647 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
648 ${If} ${RunningX64}
649 SetRegView lastused
650 ${EndIf}
651
652 # Store the selections to the registry.
653 ${If} ${RunningX64}
654 SetRegView 64
655 ${EndIf}
656 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
657 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
658 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
659 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
660 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
661 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
662 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
663 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
664!ifdef HAVE_VIS_VIM
665 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
666!endif
667!ifdef HAVE_NLS
668 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
669!endif
670 ${If} ${RunningX64}
671 SetRegView lastused
672 ${EndIf}
673
Bram Moolenaar071d4272004-06-13 20:20:40 +0000674 BringToFront
675SectionEnd
676
677##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100678!macro LoadSectionSelection section_id reg_value
679 ClearErrors
680 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
681 ${IfNot} ${Errors}
682 ${If} $3 = 1
683 !insertmacro SelectSection ${section_id}
684 ${Else}
685 !insertmacro UnselectSection ${section_id}
686 ${EndIf}
687 ${EndIf}
688!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200689
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100690Function .onInit
691!ifdef HAVE_MULTI_LANG
692 # Select a language (or read from the registry).
693 !insertmacro MUI_LANGDLL_DISPLAY
694!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200695
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100696 # Check $VIM
697 ReadEnvStr $INSTDIR "VIM"
698
699 call CheckOldVim
700 Pop $3
701 ${If} $3 == ""
702 # No old versions of Vim found. Unselect and hide the section.
703 !insertmacro UnselectSection ${id_section_old_ver}
704 SectionSetInstTypes ${id_section_old_ver} 0
705 SectionSetText ${id_section_old_ver} ""
706 ${Else}
707 ${If} $INSTDIR == ""
708 StrCpy $INSTDIR $3
709 ${EndIf}
710 ${EndIf}
711
712 # If did not find a path: use the default dir.
713 ${If} $INSTDIR == ""
714!ifdef WIN64
715 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
716!else
717 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
718!endif
719 ${EndIf}
720
721# Load the selections from the registry (if any).
722 ${If} ${RunningX64}
723 SetRegView 64
724 ${EndIf}
725 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
726 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
727 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
728 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
729 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
730 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
731 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
732 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
733!ifdef HAVE_VIS_VIM
734 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
735!endif
736!ifdef HAVE_NLS
737 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
738!endif
739 ${If} ${RunningX64}
740 SetRegView lastused
741 ${EndIf}
742
743 # User variables:
744 # $0 - holds the directory the executables are installed to
745 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
746 # registration (since a non-OLE gvim will not complain, and we want to
747 # always register an OLE gvim).
748 # $2 - holds the names to create batch files for
749 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
750 StrCpy $1 "-register-OLE"
751 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200752FunctionEnd
753
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100754Function .onInstSuccess
755 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
756FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200757
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100758Function .onInstFailed
759 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200760FunctionEnd
761
762##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100763Function SetCustom
764 # Display the _vimrc setting dialog using nsDialogs.
765
766 # Check if a _vimrc should be created
767 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
768 Abort
769 ${EndIf}
770
771 !insertmacro MUI_HEADER_TEXT \
772 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
773
774 nsDialogs::Create 1018
775 Pop $vim_dialog
776
777 ${If} $vim_dialog == error
778 Abort
779 ${EndIf}
780
781 ${If} ${RunningX64}
782 SetRegView 64
783 ${EndIf}
784
785 GetFunctionAddress $3 ValidateCustom
786 nsDialogs::OnBack $3
787
788
789 # 1st group - Compatibility
790 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
791 Pop $3
792
793 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
794 Pop $3
795 ${NSD_CreateDropList} 18% 19% 75% 8% ""
796 Pop $vim_nsd_compat
797 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
798 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
799 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
800 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
801
802 # Default selection
803 ${If} $vim_compat_stat == ""
804 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_compat"
805 ${Else}
806 StrCpy $3 $vim_compat_stat
807 ${EndIf}
808 ${If} $3 == "defaults"
809 StrCpy $4 2
810 ${ElseIf} $3 == "vim"
811 StrCpy $4 1
812 ${ElseIf} $3 == "vi"
813 StrCpy $4 0
814 ${Else} # default
815 StrCpy $4 3
816 ${EndIf}
817 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
818
819
820 # 2nd group - Key remapping
821 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
822 Pop $3
823
824 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
825 Pop $3
826 ${NSD_CreateDropList} 38% 54% 55% 8% ""
827 Pop $vim_nsd_keymap
828 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
829 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
830
831 # Default selection
832 ${If} $vim_keymap_stat == ""
833 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap"
834 ${Else}
835 StrCpy $3 $vim_keymap_stat
836 ${EndIf}
837 ${If} $3 == "windows"
838 StrCpy $4 1
839 ${Else} # default
840 StrCpy $4 0
841 ${EndIf}
842 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
843
844
845 # 3rd group - Mouse behavior
846 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
847 Pop $3
848
849 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
850 Pop $3
851 ${NSD_CreateDropList} 23% 87% 70% 8% ""
852 Pop $vim_nsd_mouse
853 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
854 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
855 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
856
857 # Default selection
858 ${If} $vim_mouse_stat == ""
859 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse"
860 ${Else}
861 StrCpy $3 $vim_mouse_stat
862 ${EndIf}
863 ${If} $3 == "xterm"
864 StrCpy $4 2
865 ${ElseIf} $3 == "windows"
866 StrCpy $4 1
867 ${Else} # default
868 StrCpy $4 0
869 ${EndIf}
870 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
871
872 ${If} ${RunningX64}
873 SetRegView lastused
874 ${EndIf}
875
876 nsDialogs::Show
877FunctionEnd
878
879Function ValidateCustom
880 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
881 ${If} $3 = 0
882 StrCpy $vim_compat_stat "vi"
883 ${ElseIf} $3 = 1
884 StrCpy $vim_compat_stat "vim"
885 ${ElseIf} $3 = 2
886 StrCpy $vim_compat_stat "defaults"
887 ${Else}
888 StrCpy $vim_compat_stat "all"
889 ${EndIf}
890
891 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
892 ${If} $3 = 0
893 StrCpy $vim_keymap_stat "default"
894 ${Else}
895 StrCpy $vim_keymap_stat "windows"
896 ${EndIf}
897
898 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
899 ${If} $3 = 0
900 StrCpy $vim_mouse_stat "default"
901 ${ElseIf} $3 = 1
902 StrCpy $vim_mouse_stat "windows"
903 ${Else}
904 StrCpy $vim_mouse_stat "xterm"
905 ${EndIf}
906FunctionEnd
907
908##########################################################
909# Description for Installer Sections
910
911!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
924!ifdef HAVE_VIS_VIM
925 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
926!endif
927!ifdef HAVE_NLS
928 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
929!endif
930!insertmacro MUI_FUNCTION_DESCRIPTION_END
931
932
933##########################################################
934# Uninstaller Functions and Sections
935
936Function un.onInit
937!ifdef HAVE_MULTI_LANG
938 # Get the language from the registry.
939 !insertmacro MUI_UNGETLANGUAGE
940!endif
941FunctionEnd
942
943Section "un.$(str_unsection_register)" id_unsection_register
944 SectionIn RO
945
Bram Moolenaar071d4272004-06-13 20:20:40 +0000946 # Apparently $INSTDIR is set to the directory where the uninstaller is
947 # created. Thus the "vim61" directory is included in it.
948 StrCpy $0 "$INSTDIR"
949
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100950!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000951 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100952 ${If} ${FileExists} "$0\VisVim.dll"
953 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
954 ${EndIf}
955!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000956
957 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100958 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200959 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961
962 # We may have been put to the background when uninstall did something.
963 BringToFront
964
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100965 # Delete the installer language setting.
966 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
967SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000968
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100969Section "un.$(str_unsection_exe)" id_unsection_exe
970
971 StrCpy $0 "$INSTDIR"
972
973 # Delete gettext and iconv DLLs
974 ${If} ${FileExists} "$0\libiconv-2.dll"
975 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
976 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200977 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100978 ${If} ${FileExists} "$0\libintl-8.dll"
979 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
980 "$0\libintl-8.dll"
981 ${EndIf}
982 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
983 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
984 "$0\libgcc_s_sjlj-1.dll"
985 ${EndIf}
986
987 # Delete other DLLs
988 Delete /REBOOTOK $0\*.dll
989
990 # Delete 64-bit GvimExt
991 ${If} ${RunningX64}
992 !define LIBRARY_X64
993 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
994 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
995 "$0\GvimExt64\gvimext.dll"
996 ${EndIf}
997 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
998 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
999 "$0\GvimExt64\libiconv-2.dll"
1000 ${EndIf}
1001 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1002 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1003 "$0\GvimExt64\libintl-8.dll"
1004 ${EndIf}
1005 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1006 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1007 "$0\GvimExt64\libwinpthread-1.dll"
1008 ${EndIf}
1009 !undef LIBRARY_X64
1010 RMDir /r $0\GvimExt64
1011 ${EndIf}
1012
1013 # Delete 32-bit GvimExt
1014 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1015 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1016 "$0\GvimExt32\gvimext.dll"
1017 ${EndIf}
1018 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1019 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1020 "$0\GvimExt32\libiconv-2.dll"
1021 ${EndIf}
1022 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1023 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1024 "$0\GvimExt32\libintl-8.dll"
1025 ${EndIf}
1026 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1027 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1028 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1029 ${EndIf}
1030 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001031
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 ClearErrors
1033 # Remove everything but *.dll files. Avoids that
1034 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001035 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001036 RMDir /r $0\colors
1037 RMDir /r $0\compiler
1038 RMDir /r $0\doc
1039 RMDir /r $0\ftplugin
1040 RMDir /r $0\indent
1041 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001042 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001044 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 RMDir /r $0\syntax
1046 RMDir /r $0\tools
1047 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001048!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001050!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 RMDir /r $0\lang
1052 RMDir /r $0\keymap
1053 Delete $0\*.exe
1054 Delete $0\*.bat
1055 Delete $0\*.vim
1056 Delete $0\*.txt
1057
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001058 ${If} ${Errors}
1059 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1060 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061
1062 # No error message if the "vim62" directory can't be removed, the
1063 # gvimext.dll may still be there.
1064 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001065SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001067# Remove "vimfiles" directory under the specified directory.
1068!macro RemoveVimfiles dir
1069 ${If} ${FileExists} ${dir}\vimfiles
1070 RMDir ${dir}\vimfiles\colors
1071 RMDir ${dir}\vimfiles\compiler
1072 RMDir ${dir}\vimfiles\doc
1073 RMDir ${dir}\vimfiles\ftdetect
1074 RMDir ${dir}\vimfiles\ftplugin
1075 RMDir ${dir}\vimfiles\indent
1076 RMDir ${dir}\vimfiles\keymap
1077 RMDir ${dir}\vimfiles\plugin
1078 RMDir ${dir}\vimfiles\syntax
1079 RMDir ${dir}\vimfiles
1080 ${EndIf}
1081!macroend
1082
1083SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1084 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1085 # get the home dir
1086 ReadEnvStr $0 "HOME"
1087 ${If} $0 == ""
1088 ReadEnvStr $0 "HOMEDRIVE"
1089 ReadEnvStr $1 "HOMEPATH"
1090 StrCpy $0 "$0$1"
1091 ${If} $0 == ""
1092 ReadEnvStr $0 "USERPROFILE"
1093 ${EndIf}
1094 ${EndIf}
1095
1096 ${If} $0 != ""
1097 !insertmacro RemoveVimfiles $0
1098 ${EndIf}
1099 SectionEnd
1100
1101 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1102 # get the parent dir of the installation
1103 Push $INSTDIR
1104 Call un.GetParent
1105 Pop $0
1106
1107 # if a plugin dir was created at installation remove it
1108 !insertmacro RemoveVimfiles $0
1109 SectionEnd
1110SectionGroupEnd
1111
1112Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 # get the parent dir of the installation
1114 Push $INSTDIR
1115 Call un.GetParent
1116 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001118 ${IfNot} ${Silent}
1119 Delete $0\_vimrc
1120 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001121 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001123
1124##########################################################
1125# Description for Uninstaller Sections
1126
1127!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1128 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1129 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1130 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1131 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1132 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1133 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1134!insertmacro MUI_UNFUNCTION_DESCRIPTION_END