blob: ed53ab5fab66b71aac993030a0a224e47d7ce4d6 [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
42# Comment the following line to create a multilanguage installer:
43!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"
179!endif
180
Bram Moolenaardabfde02019-05-17 12:37:27 +0200181##########################################################
182# Version resources
183
184VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
185VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
186VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
187VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
188VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200189VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
190VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100191
192# Global variables
193Var vim_dialog
194Var vim_nsd_compat
195Var vim_nsd_keymap
196Var vim_nsd_mouse
197Var vim_compat_stat
198Var vim_keymap_stat
199Var vim_mouse_stat
200
Bram Moolenaar071d4272004-06-13 20:20:40 +0000201
Bram Moolenaar5d424742018-02-04 19:11:30 +0100202# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100203ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100204
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205##########################################################
206# Functions
207
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100208# Get parent directory
209# Share this function both on installer and uninstaller
210!macro GetParent un
211Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000212 Exch $0 ; old $0 is on top of stack
213 Push $1
214 Push $2
215 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100216 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100218 ${If} $2 == ""
219 ${OrIf} $2 == "\"
220 ${ExitDo}
221 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100223 ${Loop}
224 StrCpy $0 $0 $1
225 Pop $2
226 Pop $1
227 Exch $0 ; put $0 on top of stack, restore $0 to original value
228FunctionEnd
229!macroend
230
231!insertmacro GetParent ""
232!insertmacro GetParent "un."
233
234# Check if Vim is already installed.
235# return: Installed directory. If not found, it will be empty.
236Function CheckOldVim
237 Push $0
238 Push $R0
239 Push $R1
240 Push $R2
241
242 ${If} ${RunningX64}
243 SetRegView 64
244 ${EndIf}
245
246 ClearErrors
247 StrCpy $0 "" # Installed directory
248 StrCpy $R0 0 # Sub-key index
249 StrCpy $R1 "" # Sub-key
250 ${Do}
251 # Eumerate the sub-key:
252 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
253
254 # Stop if no more sub-key:
255 ${If} ${Errors}
256 ${OrIf} $R1 == ""
257 ${ExitDo}
258 ${EndIf}
259
260 # Move to the next sub-key:
261 IntOp $R0 $R0 + 1
262
263 # Check if the key is Vim uninstall key or not:
264 StrCpy $R2 $R1 4
265 ${If} $R2 S!= "Vim "
266 ${Continue}
267 ${EndIf}
268
269 # Verifies required sub-keys:
270 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
271 ${If} ${Errors}
272 ${OrIf} $R2 == ""
273 ${Continue}
274 ${EndIf}
275
276 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
277 ${If} ${Errors}
278 ${OrIf} $R2 == ""
279 ${Continue}
280 ${EndIf}
281
282 # Found
283 Push $R2
284 call GetParent
285 call GetParent
286 Pop $0 # Vim directory
287 ${ExitDo}
288
289 ${Loop}
290
291 ${If} ${RunningX64}
292 SetRegView lastused
293 ${EndIf}
294
295 Pop $R2
296 Pop $R1
297 Pop $R0
298 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000299FunctionEnd
300
301##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100302Section "$(str_section_old_ver)" id_section_old_ver
303 SectionIn 1 2 3 RO
304
305 # run the install program to check for already installed versions
306 SetOutPath $TEMP
307 File /oname=install.exe ${VIMSRC}\installw32.exe
308 DetailPrint "$(str_msg_uninstalling)"
309 ${Do}
310 nsExec::Exec "$TEMP\install.exe -uninstall-check"
311 Pop $3
312
313 call CheckOldVim
314 Pop $3
315 ${If} $3 == ""
316 ${ExitDo}
317 ${Else}
318 # It seems that the old version is still remaining.
319 # TODO: Should we show a warning and run the uninstaller again?
320
321 ${ExitDo} # Just ignore for now.
322 ${EndIf}
323 ${Loop}
324 Delete $TEMP\install.exe
325 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
326
327 # We may have been put to the background when uninstall did something.
328 BringToFront
329SectionEnd
330
331##########################################################
332Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200333 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000334
335 # we need also this here if the user changes the instdir
336 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
337
338 SetOutPath $0
339 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200340!if /FileExists "${VIMSRC}\vim${BIT}.dll"
341 File ${VIMSRC}\vim${BIT}.dll
342!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000343 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200344 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000345 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200346 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000347 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100348 File ..\vimtutor.bat
349 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200350 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351 File ${VIMRT}\*.vim
352 File ${VIMRT}\rgb.txt
353
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200354 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100355 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200356 File ${VIMTOOLS}\winpty-agent.exe
357
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358 SetOutPath $0\colors
359 File ${VIMRT}\colors\*.*
360
361 SetOutPath $0\compiler
362 File ${VIMRT}\compiler\*.*
363
364 SetOutPath $0\doc
365 File ${VIMRT}\doc\*.txt
366 File ${VIMRT}\doc\tags
367
368 SetOutPath $0\ftplugin
369 File ${VIMRT}\ftplugin\*.*
370
371 SetOutPath $0\indent
372 File ${VIMRT}\indent\*.*
373
374 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100375 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100377 SetOutPath $0\pack
378 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200379
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380 SetOutPath $0\plugin
381 File ${VIMRT}\plugin\*.*
382
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000383 SetOutPath $0\autoload
384 File ${VIMRT}\autoload\*.*
385
Bram Moolenaard09a2062017-11-11 15:37:45 +0100386 SetOutPath $0\autoload\dist
387 File ${VIMRT}\autoload\dist\*.*
388
Bram Moolenaar18144c82006-04-12 21:52:12 +0000389 SetOutPath $0\autoload\xml
390 File ${VIMRT}\autoload\xml\*.*
391
Bram Moolenaar071d4272004-06-13 20:20:40 +0000392 SetOutPath $0\syntax
393 File ${VIMRT}\syntax\*.*
394
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000395 SetOutPath $0\spell
396 File ${VIMRT}\spell\*.txt
397 File ${VIMRT}\spell\*.vim
398 File ${VIMRT}\spell\*.spl
399 File ${VIMRT}\spell\*.sug
400
Bram Moolenaar071d4272004-06-13 20:20:40 +0000401 SetOutPath $0\tools
402 File ${VIMRT}\tools\*.*
403
404 SetOutPath $0\tutor
405 File ${VIMRT}\tutor\*.*
406SectionEnd
407
408##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100409Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000410 SectionIn 1 3
411
412 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100413 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414 StrCpy $2 "$2 vim view vimdiff"
415SectionEnd
416
417##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100418Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 SectionIn 3
420
421 StrCpy $1 "$1 -create-batfiles $2"
422SectionEnd
423
424##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100425SectionGroup $(str_group_icons) id_group_icons
426 Section "$(str_section_desktop)" id_section_desktop
427 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000428
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100429 StrCpy $1 "$1 -install-icons"
430 SectionEnd
431
432 Section "$(str_section_start_menu)" id_section_startmenu
433 SectionIn 1 3
434
435 StrCpy $1 "$1 -add-start-menu"
436 SectionEnd
437SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438
439##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100440Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000441 SectionIn 1 3
442
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200444
Bram Moolenaar442b4222010-05-24 21:34:22 +0200445 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200446 # Install 64-bit gvimext.dll into the GvimExt64 directory.
447 SetOutPath $0\GvimExt64
448 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100449 !define LIBRARY_SHELL_EXTENSION
450 !define LIBRARY_X64
451 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
452 "${VIMSRC}\GvimExt\gvimext64.dll" \
453 "$0\GvimExt64\gvimext.dll" "$0"
454 !undef LIBRARY_X64
455 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200456 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200457
Bram Moolenaar6199d432017-10-14 19:05:44 +0200458 # Install 32-bit gvimext.dll into the GvimExt32 directory.
459 SetOutPath $0\GvimExt32
460 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100461 !define LIBRARY_SHELL_EXTENSION
462 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
463 "${VIMSRC}\GvimExt\gvimext.dll" \
464 "$0\GvimExt32\gvimext.dll" "$0"
465 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000466
467 # We don't have a separate entry for the "Open With..." menu, assume
468 # the user wants either both or none.
469 StrCpy $1 "$1 -install-popup -install-openwith"
470SectionEnd
471
472##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100473Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000474 SectionIn 1 3
475
476 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100477
478 ${If} ${RunningX64}
479 SetRegView 64
480 ${EndIf}
481 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
482 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
483 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
484 ${If} ${RunningX64}
485 SetRegView lastused
486 ${EndIf}
487
488 ${If} $vim_compat_stat == "vi"
489 StrCpy $1 "$1 -vimrc-compat vi"
490 ${ElseIf} $vim_compat_stat == "vim"
491 StrCpy $1 "$1 -vimrc-compat vim"
492 ${ElseIf} $vim_compat_stat == "defaults"
493 StrCpy $1 "$1 -vimrc-compat defaults"
494 ${Else}
495 StrCpy $1 "$1 -vimrc-compat all"
496 ${EndIf}
497
498 ${If} $vim_keymap_stat == "default"
499 StrCpy $1 "$1 -vimrc-remap no"
500 ${Else}
501 StrCpy $1 "$1 -vimrc-remap win"
502 ${EndIf}
503
504 ${If} $vim_mouse_stat == "default"
505 StrCpy $1 "$1 -vimrc-behave default"
506 ${ElseIf} $vim_mouse_stat == "windows"
507 StrCpy $1 "$1 -vimrc-behave mswin"
508 ${Else}
509 StrCpy $1 "$1 -vimrc-behave unix"
510 ${EndIf}
511
Bram Moolenaar071d4272004-06-13 20:20:40 +0000512SectionEnd
513
514##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100515SectionGroup $(str_group_plugin) id_group_plugin
516 Section "$(str_section_plugin_home)" id_section_pluginhome
517 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100519 StrCpy $1 "$1 -create-directories home"
520 SectionEnd
521
522 Section "$(str_section_plugin_vim)" id_section_pluginvim
523 SectionIn 3
524
525 StrCpy $1 "$1 -create-directories vim"
526 SectionEnd
527SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528
529##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100530!ifdef HAVE_VIS_VIM
531Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000532 SectionIn 3
533
534 SetOutPath $0
535 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
536 File ${VIMSRC}\VisVim\README_VisVim.txt
537SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100538!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539
540##########################################################
541!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100542Section "$(str_section_nls)" id_section_nls
543 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100545 SetOutPath $0\lang
546 File /r ${VIMRT}\lang\*.*
547 SetOutPath $0\keymap
548 File ${VIMRT}\keymap\README.txt
549 File ${VIMRT}\keymap\*.vim
550 SetOutPath $0
551 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
552 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
553 "$0\libintl-8.dll" "$0"
554 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
555 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
556 "$0\libiconv-2.dll" "$0"
557 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
558 # Install libgcc_s_sjlj-1.dll only if it is needed.
559 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
560 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
561 "$0\libgcc_s_sjlj-1.dll" "$0"
562 !endif
563
564 ${If} ${SectionIsSelected} ${id_section_editwith}
565 ${If} ${RunningX64}
566 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
567 SetOutPath $0\GvimExt64
568 ClearErrors
569 !define LIBRARY_X64
570 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
571 "${GETTEXT}\gettext64\libintl-8.dll" \
572 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
573 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
574 "${GETTEXT}\gettext64\libiconv-2.dll" \
575 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
576 !undef LIBRARY_X64
577 ${EndIf}
578
579 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
580 SetOutPath $0\GvimExt32
581 ClearErrors
582 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
583 "${GETTEXT}\gettext32\libintl-8.dll" \
584 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
585 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
586 "${GETTEXT}\gettext32\libiconv-2.dll" \
587 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
588 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
589 # Install libgcc_s_sjlj-1.dll only if it is needed.
590 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
591 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
592 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
593 !endif
594 ${EndIf}
595SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000596!endif
597
598##########################################################
599Section -call_install_exe
600 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100601 DetailPrint "$(str_msg_registering)"
602 nsExec::Exec "$0\install.exe $1"
603 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000604SectionEnd
605
606##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100607!macro SaveSectionSelection section_id reg_value
608 ${If} ${SectionIsSelected} ${section_id}
609 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
610 ${Else}
611 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
612 ${EndIf}
613!macroend
614
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100616
617 # Get estimated install size
618 SectionGetSize ${id_section_exe} $3
619 ${If} ${SectionIsSelected} ${id_section_console}
620 SectionGetSize ${id_section_console} $4
621 IntOp $3 $3 + $4
622 ${EndIf}
623 ${If} ${SectionIsSelected} ${id_section_editwith}
624 SectionGetSize ${id_section_editwith} $4
625 IntOp $3 $3 + $4
626 ${EndIf}
627!ifdef HAVE_VIS_VIM
628 ${If} ${SectionIsSelected} ${id_section_visvim}
629 SectionGetSize ${id_section_visvim} $4
630 IntOp $3 $3 + $4
631 ${EndIf}
632!endif
633!ifdef HAVE_NLS
634 ${If} ${SectionIsSelected} ${id_section_nls}
635 SectionGetSize ${id_section_nls} $4
636 IntOp $3 $3 + $4
637 ${EndIf}
638!endif
639
640 # Register EstimatedSize and AllowSilent.
641 # Other information will be set by the install.exe (dosinst.c).
642 ${If} ${RunningX64}
643 SetRegView 64
644 ${EndIf}
645 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
646 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
647 ${If} ${RunningX64}
648 SetRegView lastused
649 ${EndIf}
650
651 # Store the selections to the registry.
652 ${If} ${RunningX64}
653 SetRegView 64
654 ${EndIf}
655 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
656 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
657 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
658 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
659 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
660 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
661 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
662 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
663!ifdef HAVE_VIS_VIM
664 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
665!endif
666!ifdef HAVE_NLS
667 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
668!endif
669 ${If} ${RunningX64}
670 SetRegView lastused
671 ${EndIf}
672
Bram Moolenaar071d4272004-06-13 20:20:40 +0000673 BringToFront
674SectionEnd
675
676##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100677!macro LoadSectionSelection section_id reg_value
678 ClearErrors
679 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
680 ${IfNot} ${Errors}
681 ${If} $3 = 1
682 !insertmacro SelectSection ${section_id}
683 ${Else}
684 !insertmacro UnselectSection ${section_id}
685 ${EndIf}
686 ${EndIf}
687!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200688
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100689Function .onInit
690!ifdef HAVE_MULTI_LANG
691 # Select a language (or read from the registry).
692 !insertmacro MUI_LANGDLL_DISPLAY
693!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200694
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100695 # Check $VIM
696 ReadEnvStr $INSTDIR "VIM"
697
698 call CheckOldVim
699 Pop $3
700 ${If} $3 == ""
701 # No old versions of Vim found. Unselect and hide the section.
702 !insertmacro UnselectSection ${id_section_old_ver}
703 SectionSetInstTypes ${id_section_old_ver} 0
704 SectionSetText ${id_section_old_ver} ""
705 ${Else}
706 ${If} $INSTDIR == ""
707 StrCpy $INSTDIR $3
708 ${EndIf}
709 ${EndIf}
710
711 # If did not find a path: use the default dir.
712 ${If} $INSTDIR == ""
713!ifdef WIN64
714 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
715!else
716 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
717!endif
718 ${EndIf}
719
720# Load the selections from the registry (if any).
721 ${If} ${RunningX64}
722 SetRegView 64
723 ${EndIf}
724 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
725 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
726 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
727 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
728 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
729 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
730 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
731 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
732!ifdef HAVE_VIS_VIM
733 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
734!endif
735!ifdef HAVE_NLS
736 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
737!endif
738 ${If} ${RunningX64}
739 SetRegView lastused
740 ${EndIf}
741
742 # User variables:
743 # $0 - holds the directory the executables are installed to
744 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
745 # registration (since a non-OLE gvim will not complain, and we want to
746 # always register an OLE gvim).
747 # $2 - holds the names to create batch files for
748 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
749 StrCpy $1 "-register-OLE"
750 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200751FunctionEnd
752
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100753Function .onInstSuccess
754 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
755FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200756
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100757Function .onInstFailed
758 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200759FunctionEnd
760
761##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100762Function SetCustom
763 # Display the _vimrc setting dialog using nsDialogs.
764
765 # Check if a _vimrc should be created
766 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
767 Abort
768 ${EndIf}
769
770 !insertmacro MUI_HEADER_TEXT \
771 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
772
773 nsDialogs::Create 1018
774 Pop $vim_dialog
775
776 ${If} $vim_dialog == error
777 Abort
778 ${EndIf}
779
780 ${If} ${RunningX64}
781 SetRegView 64
782 ${EndIf}
783
784 GetFunctionAddress $3 ValidateCustom
785 nsDialogs::OnBack $3
786
787
788 # 1st group - Compatibility
789 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
790 Pop $3
791
792 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
793 Pop $3
794 ${NSD_CreateDropList} 18% 19% 75% 8% ""
795 Pop $vim_nsd_compat
796 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
797 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
798 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
799 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
800
801 # Default selection
802 ${If} $vim_compat_stat == ""
803 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_compat"
804 ${Else}
805 StrCpy $3 $vim_compat_stat
806 ${EndIf}
807 ${If} $3 == "defaults"
808 StrCpy $4 2
809 ${ElseIf} $3 == "vim"
810 StrCpy $4 1
811 ${ElseIf} $3 == "vi"
812 StrCpy $4 0
813 ${Else} # default
814 StrCpy $4 3
815 ${EndIf}
816 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
817
818
819 # 2nd group - Key remapping
820 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
821 Pop $3
822
823 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
824 Pop $3
825 ${NSD_CreateDropList} 38% 54% 55% 8% ""
826 Pop $vim_nsd_keymap
827 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
828 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
829
830 # Default selection
831 ${If} $vim_keymap_stat == ""
832 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap"
833 ${Else}
834 StrCpy $3 $vim_keymap_stat
835 ${EndIf}
836 ${If} $3 == "windows"
837 StrCpy $4 1
838 ${Else} # default
839 StrCpy $4 0
840 ${EndIf}
841 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
842
843
844 # 3rd group - Mouse behavior
845 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
846 Pop $3
847
848 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
849 Pop $3
850 ${NSD_CreateDropList} 23% 87% 70% 8% ""
851 Pop $vim_nsd_mouse
852 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
853 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
854 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
855
856 # Default selection
857 ${If} $vim_mouse_stat == ""
858 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse"
859 ${Else}
860 StrCpy $3 $vim_mouse_stat
861 ${EndIf}
862 ${If} $3 == "xterm"
863 StrCpy $4 2
864 ${ElseIf} $3 == "windows"
865 StrCpy $4 1
866 ${Else} # default
867 StrCpy $4 0
868 ${EndIf}
869 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
870
871 ${If} ${RunningX64}
872 SetRegView lastused
873 ${EndIf}
874
875 nsDialogs::Show
876FunctionEnd
877
878Function ValidateCustom
879 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
880 ${If} $3 = 0
881 StrCpy $vim_compat_stat "vi"
882 ${ElseIf} $3 = 1
883 StrCpy $vim_compat_stat "vim"
884 ${ElseIf} $3 = 2
885 StrCpy $vim_compat_stat "defaults"
886 ${Else}
887 StrCpy $vim_compat_stat "all"
888 ${EndIf}
889
890 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
891 ${If} $3 = 0
892 StrCpy $vim_keymap_stat "default"
893 ${Else}
894 StrCpy $vim_keymap_stat "windows"
895 ${EndIf}
896
897 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
898 ${If} $3 = 0
899 StrCpy $vim_mouse_stat "default"
900 ${ElseIf} $3 = 1
901 StrCpy $vim_mouse_stat "windows"
902 ${Else}
903 StrCpy $vim_mouse_stat "xterm"
904 ${EndIf}
905FunctionEnd
906
907##########################################################
908# Description for Installer Sections
909
910!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
911 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
923!ifdef HAVE_VIS_VIM
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
925!endif
926!ifdef HAVE_NLS
927 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
928!endif
929!insertmacro MUI_FUNCTION_DESCRIPTION_END
930
931
932##########################################################
933# Uninstaller Functions and Sections
934
935Function un.onInit
936!ifdef HAVE_MULTI_LANG
937 # Get the language from the registry.
938 !insertmacro MUI_UNGETLANGUAGE
939!endif
940FunctionEnd
941
942Section "un.$(str_unsection_register)" id_unsection_register
943 SectionIn RO
944
Bram Moolenaar071d4272004-06-13 20:20:40 +0000945 # Apparently $INSTDIR is set to the directory where the uninstaller is
946 # created. Thus the "vim61" directory is included in it.
947 StrCpy $0 "$INSTDIR"
948
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100949!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000950 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100951 ${If} ${FileExists} "$0\VisVim.dll"
952 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
953 ${EndIf}
954!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955
956 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100957 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200958 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100959 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000960
961 # We may have been put to the background when uninstall did something.
962 BringToFront
963
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100964 # Delete the installer language setting.
965 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
966SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000967
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100968Section "un.$(str_unsection_exe)" id_unsection_exe
969
970 StrCpy $0 "$INSTDIR"
971
972 # Delete gettext and iconv DLLs
973 ${If} ${FileExists} "$0\libiconv-2.dll"
974 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
975 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200976 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100977 ${If} ${FileExists} "$0\libintl-8.dll"
978 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
979 "$0\libintl-8.dll"
980 ${EndIf}
981 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
982 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
983 "$0\libgcc_s_sjlj-1.dll"
984 ${EndIf}
985
986 # Delete other DLLs
987 Delete /REBOOTOK $0\*.dll
988
989 # Delete 64-bit GvimExt
990 ${If} ${RunningX64}
991 !define LIBRARY_X64
992 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
993 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
994 "$0\GvimExt64\gvimext.dll"
995 ${EndIf}
996 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
997 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
998 "$0\GvimExt64\libiconv-2.dll"
999 ${EndIf}
1000 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1001 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1002 "$0\GvimExt64\libintl-8.dll"
1003 ${EndIf}
1004 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1005 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1006 "$0\GvimExt64\libwinpthread-1.dll"
1007 ${EndIf}
1008 !undef LIBRARY_X64
1009 RMDir /r $0\GvimExt64
1010 ${EndIf}
1011
1012 # Delete 32-bit GvimExt
1013 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1014 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1015 "$0\GvimExt32\gvimext.dll"
1016 ${EndIf}
1017 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1018 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1019 "$0\GvimExt32\libiconv-2.dll"
1020 ${EndIf}
1021 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1022 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1023 "$0\GvimExt32\libintl-8.dll"
1024 ${EndIf}
1025 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1026 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1027 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1028 ${EndIf}
1029 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001030
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 ClearErrors
1032 # Remove everything but *.dll files. Avoids that
1033 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001034 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035 RMDir /r $0\colors
1036 RMDir /r $0\compiler
1037 RMDir /r $0\doc
1038 RMDir /r $0\ftplugin
1039 RMDir /r $0\indent
1040 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001041 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001043 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 RMDir /r $0\syntax
1045 RMDir /r $0\tools
1046 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001047!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001048 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001049!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050 RMDir /r $0\lang
1051 RMDir /r $0\keymap
1052 Delete $0\*.exe
1053 Delete $0\*.bat
1054 Delete $0\*.vim
1055 Delete $0\*.txt
1056
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001057 ${If} ${Errors}
1058 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1059 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060
1061 # No error message if the "vim62" directory can't be removed, the
1062 # gvimext.dll may still be there.
1063 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001064SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001066# Remove "vimfiles" directory under the specified directory.
1067!macro RemoveVimfiles dir
1068 ${If} ${FileExists} ${dir}\vimfiles
1069 RMDir ${dir}\vimfiles\colors
1070 RMDir ${dir}\vimfiles\compiler
1071 RMDir ${dir}\vimfiles\doc
1072 RMDir ${dir}\vimfiles\ftdetect
1073 RMDir ${dir}\vimfiles\ftplugin
1074 RMDir ${dir}\vimfiles\indent
1075 RMDir ${dir}\vimfiles\keymap
1076 RMDir ${dir}\vimfiles\plugin
1077 RMDir ${dir}\vimfiles\syntax
1078 RMDir ${dir}\vimfiles
1079 ${EndIf}
1080!macroend
1081
1082SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1083 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1084 # get the home dir
1085 ReadEnvStr $0 "HOME"
1086 ${If} $0 == ""
1087 ReadEnvStr $0 "HOMEDRIVE"
1088 ReadEnvStr $1 "HOMEPATH"
1089 StrCpy $0 "$0$1"
1090 ${If} $0 == ""
1091 ReadEnvStr $0 "USERPROFILE"
1092 ${EndIf}
1093 ${EndIf}
1094
1095 ${If} $0 != ""
1096 !insertmacro RemoveVimfiles $0
1097 ${EndIf}
1098 SectionEnd
1099
1100 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1101 # get the parent dir of the installation
1102 Push $INSTDIR
1103 Call un.GetParent
1104 Pop $0
1105
1106 # if a plugin dir was created at installation remove it
1107 !insertmacro RemoveVimfiles $0
1108 SectionEnd
1109SectionGroupEnd
1110
1111Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112 # get the parent dir of the installation
1113 Push $INSTDIR
1114 Call un.GetParent
1115 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001117 ${IfNot} ${Silent}
1118 Delete $0\_vimrc
1119 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001120 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001122
1123##########################################################
1124# Description for Uninstaller Sections
1125
1126!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1127 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1128 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1129 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1130 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1131 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1132 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1133!insertmacro MUI_UNFUNCTION_DESCRIPTION_END