blob: 65ac8b11f48bc7c111f3892e3697739441007283 [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 Moolenaarceb56dd2020-07-14 22:24:40 +0200690!macro LoadDefaultVimrc out_var reg_value default_value
691 ClearErrors
692 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
693 ${If} ${Errors}
694 ${OrIf} ${out_var} == ""
695 StrCpy ${out_var} ${default_value}
696 ${EndIf}
697!macroend
698
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100699Function .onInit
700!ifdef HAVE_MULTI_LANG
701 # Select a language (or read from the registry).
702 !insertmacro MUI_LANGDLL_DISPLAY
703!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200704
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100705 # Check $VIM
706 ReadEnvStr $INSTDIR "VIM"
707
708 call CheckOldVim
709 Pop $3
710 ${If} $3 == ""
711 # No old versions of Vim found. Unselect and hide the section.
712 !insertmacro UnselectSection ${id_section_old_ver}
713 SectionSetInstTypes ${id_section_old_ver} 0
714 SectionSetText ${id_section_old_ver} ""
715 ${Else}
716 ${If} $INSTDIR == ""
717 StrCpy $INSTDIR $3
718 ${EndIf}
719 ${EndIf}
720
721 # If did not find a path: use the default dir.
722 ${If} $INSTDIR == ""
723!ifdef WIN64
724 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
725!else
726 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
727!endif
728 ${EndIf}
729
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100730 ${If} ${RunningX64}
731 SetRegView 64
732 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200733 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100734 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
735 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
736 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
737 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
738 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
739 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
740 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
741 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
742!ifdef HAVE_VIS_VIM
743 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
744!endif
745!ifdef HAVE_NLS
746 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
747!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200748 # Load the default _vimrc settings from the registry (if any).
749 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
750 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
751 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100752 ${If} ${RunningX64}
753 SetRegView lastused
754 ${EndIf}
755
756 # User variables:
757 # $0 - holds the directory the executables are installed to
758 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
759 # registration (since a non-OLE gvim will not complain, and we want to
760 # always register an OLE gvim).
761 # $2 - holds the names to create batch files for
762 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
763 StrCpy $1 "-register-OLE"
764 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200765FunctionEnd
766
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100767Function .onInstSuccess
768 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
769FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200770
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100771Function .onInstFailed
772 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200773FunctionEnd
774
775##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100776Function SetCustom
777 # Display the _vimrc setting dialog using nsDialogs.
778
779 # Check if a _vimrc should be created
780 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
781 Abort
782 ${EndIf}
783
784 !insertmacro MUI_HEADER_TEXT \
785 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
786
787 nsDialogs::Create 1018
788 Pop $vim_dialog
789
790 ${If} $vim_dialog == error
791 Abort
792 ${EndIf}
793
794 ${If} ${RunningX64}
795 SetRegView 64
796 ${EndIf}
797
798 GetFunctionAddress $3 ValidateCustom
799 nsDialogs::OnBack $3
800
801
802 # 1st group - Compatibility
803 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
804 Pop $3
805
806 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
807 Pop $3
808 ${NSD_CreateDropList} 18% 19% 75% 8% ""
809 Pop $vim_nsd_compat
810 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
811 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
812 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
813 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
814
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200815 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100816 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200817 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100818 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200819 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100820 StrCpy $4 0
821 ${Else} # default
822 StrCpy $4 3
823 ${EndIf}
824 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
825
826
827 # 2nd group - Key remapping
828 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
829 Pop $3
830
831 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
832 Pop $3
833 ${NSD_CreateDropList} 38% 54% 55% 8% ""
834 Pop $vim_nsd_keymap
835 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
836 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
837
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200838 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100839 StrCpy $4 1
840 ${Else} # default
841 StrCpy $4 0
842 ${EndIf}
843 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
844
845
846 # 3rd group - Mouse behavior
847 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
848 Pop $3
849
850 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
851 Pop $3
852 ${NSD_CreateDropList} 23% 87% 70% 8% ""
853 Pop $vim_nsd_mouse
854 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
855 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
856 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
857
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200858 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100859 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200860 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100861 StrCpy $4 1
862 ${Else} # default
863 StrCpy $4 0
864 ${EndIf}
865 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
866
867 ${If} ${RunningX64}
868 SetRegView lastused
869 ${EndIf}
870
871 nsDialogs::Show
872FunctionEnd
873
874Function ValidateCustom
875 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
876 ${If} $3 = 0
877 StrCpy $vim_compat_stat "vi"
878 ${ElseIf} $3 = 1
879 StrCpy $vim_compat_stat "vim"
880 ${ElseIf} $3 = 2
881 StrCpy $vim_compat_stat "defaults"
882 ${Else}
883 StrCpy $vim_compat_stat "all"
884 ${EndIf}
885
886 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
887 ${If} $3 = 0
888 StrCpy $vim_keymap_stat "default"
889 ${Else}
890 StrCpy $vim_keymap_stat "windows"
891 ${EndIf}
892
893 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
894 ${If} $3 = 0
895 StrCpy $vim_mouse_stat "default"
896 ${ElseIf} $3 = 1
897 StrCpy $vim_mouse_stat "windows"
898 ${Else}
899 StrCpy $vim_mouse_stat "xterm"
900 ${EndIf}
901FunctionEnd
902
903##########################################################
904# Description for Installer Sections
905
906!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
907 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
908 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
909 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
910 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
911 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
919!ifdef HAVE_VIS_VIM
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
921!endif
922!ifdef HAVE_NLS
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
924!endif
925!insertmacro MUI_FUNCTION_DESCRIPTION_END
926
927
928##########################################################
929# Uninstaller Functions and Sections
930
931Function un.onInit
932!ifdef HAVE_MULTI_LANG
933 # Get the language from the registry.
934 !insertmacro MUI_UNGETLANGUAGE
935!endif
936FunctionEnd
937
938Section "un.$(str_unsection_register)" id_unsection_register
939 SectionIn RO
940
Bram Moolenaar071d4272004-06-13 20:20:40 +0000941 # Apparently $INSTDIR is set to the directory where the uninstaller is
942 # created. Thus the "vim61" directory is included in it.
943 StrCpy $0 "$INSTDIR"
944
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100945!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000946 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100947 ${If} ${FileExists} "$0\VisVim.dll"
948 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
949 ${EndIf}
950!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000951
952 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100953 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200954 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100955 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000956
957 # We may have been put to the background when uninstall did something.
958 BringToFront
959
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960 # Delete the installer language setting.
961 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
962SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000963
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100964Section "un.$(str_unsection_exe)" id_unsection_exe
965
966 StrCpy $0 "$INSTDIR"
967
968 # Delete gettext and iconv DLLs
969 ${If} ${FileExists} "$0\libiconv-2.dll"
970 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
971 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200972 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100973 ${If} ${FileExists} "$0\libintl-8.dll"
974 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
975 "$0\libintl-8.dll"
976 ${EndIf}
977 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
978 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
979 "$0\libgcc_s_sjlj-1.dll"
980 ${EndIf}
981
982 # Delete other DLLs
983 Delete /REBOOTOK $0\*.dll
984
985 # Delete 64-bit GvimExt
986 ${If} ${RunningX64}
987 !define LIBRARY_X64
988 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
989 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
990 "$0\GvimExt64\gvimext.dll"
991 ${EndIf}
992 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
993 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
994 "$0\GvimExt64\libiconv-2.dll"
995 ${EndIf}
996 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
997 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
998 "$0\GvimExt64\libintl-8.dll"
999 ${EndIf}
1000 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1001 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1002 "$0\GvimExt64\libwinpthread-1.dll"
1003 ${EndIf}
1004 !undef LIBRARY_X64
1005 RMDir /r $0\GvimExt64
1006 ${EndIf}
1007
1008 # Delete 32-bit GvimExt
1009 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1010 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1011 "$0\GvimExt32\gvimext.dll"
1012 ${EndIf}
1013 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1014 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1015 "$0\GvimExt32\libiconv-2.dll"
1016 ${EndIf}
1017 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1018 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1019 "$0\GvimExt32\libintl-8.dll"
1020 ${EndIf}
1021 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1022 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1023 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1024 ${EndIf}
1025 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001026
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027 ClearErrors
1028 # Remove everything but *.dll files. Avoids that
1029 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001030 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 RMDir /r $0\colors
1032 RMDir /r $0\compiler
1033 RMDir /r $0\doc
1034 RMDir /r $0\ftplugin
1035 RMDir /r $0\indent
1036 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001037 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001039 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 RMDir /r $0\syntax
1041 RMDir /r $0\tools
1042 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001043!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001045!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 RMDir /r $0\lang
1047 RMDir /r $0\keymap
1048 Delete $0\*.exe
1049 Delete $0\*.bat
1050 Delete $0\*.vim
1051 Delete $0\*.txt
1052
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001053 ${If} ${Errors}
1054 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1055 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056
1057 # No error message if the "vim62" directory can't be removed, the
1058 # gvimext.dll may still be there.
1059 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001060SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001062# Remove "vimfiles" directory under the specified directory.
1063!macro RemoveVimfiles dir
1064 ${If} ${FileExists} ${dir}\vimfiles
1065 RMDir ${dir}\vimfiles\colors
1066 RMDir ${dir}\vimfiles\compiler
1067 RMDir ${dir}\vimfiles\doc
1068 RMDir ${dir}\vimfiles\ftdetect
1069 RMDir ${dir}\vimfiles\ftplugin
1070 RMDir ${dir}\vimfiles\indent
1071 RMDir ${dir}\vimfiles\keymap
1072 RMDir ${dir}\vimfiles\plugin
1073 RMDir ${dir}\vimfiles\syntax
1074 RMDir ${dir}\vimfiles
1075 ${EndIf}
1076!macroend
1077
1078SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1079 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1080 # get the home dir
1081 ReadEnvStr $0 "HOME"
1082 ${If} $0 == ""
1083 ReadEnvStr $0 "HOMEDRIVE"
1084 ReadEnvStr $1 "HOMEPATH"
1085 StrCpy $0 "$0$1"
1086 ${If} $0 == ""
1087 ReadEnvStr $0 "USERPROFILE"
1088 ${EndIf}
1089 ${EndIf}
1090
1091 ${If} $0 != ""
1092 !insertmacro RemoveVimfiles $0
1093 ${EndIf}
1094 SectionEnd
1095
1096 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1097 # get the parent dir of the installation
1098 Push $INSTDIR
1099 Call un.GetParent
1100 Pop $0
1101
1102 # if a plugin dir was created at installation remove it
1103 !insertmacro RemoveVimfiles $0
1104 SectionEnd
1105SectionGroupEnd
1106
1107Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108 # get the parent dir of the installation
1109 Push $INSTDIR
1110 Call un.GetParent
1111 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001113 ${IfNot} ${Silent}
1114 Delete $0\_vimrc
1115 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001116 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001118
1119##########################################################
1120# Description for Uninstaller Sections
1121
1122!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1123 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1124 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1125 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1126 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1127 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1128 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1129!insertmacro MUI_UNFUNCTION_DESCRIPTION_END