blob: 498d98dc8485fb34860ce80791c80b8ccefb0040 [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"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200177 !include "lang\russian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100178 !include "lang\simpchinese.nsi"
179 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100180 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100181!endif
182
Bram Moolenaardabfde02019-05-17 12:37:27 +0200183##########################################################
184# Version resources
185
186VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
187VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
188VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
189VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
190VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200191VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
192VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100193
194# Global variables
195Var vim_dialog
196Var vim_nsd_compat
197Var vim_nsd_keymap
198Var vim_nsd_mouse
199Var vim_compat_stat
200Var vim_keymap_stat
201Var vim_mouse_stat
202
Bram Moolenaar071d4272004-06-13 20:20:40 +0000203
Bram Moolenaar5d424742018-02-04 19:11:30 +0100204# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100205ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100206
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207##########################################################
208# Functions
209
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100210# Get parent directory
211# Share this function both on installer and uninstaller
212!macro GetParent un
213Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214 Exch $0 ; old $0 is on top of stack
215 Push $1
216 Push $2
217 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100218 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100220 ${If} $2 == ""
221 ${OrIf} $2 == "\"
222 ${ExitDo}
223 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000224 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100225 ${Loop}
226 StrCpy $0 $0 $1
227 Pop $2
228 Pop $1
229 Exch $0 ; put $0 on top of stack, restore $0 to original value
230FunctionEnd
231!macroend
232
233!insertmacro GetParent ""
234!insertmacro GetParent "un."
235
236# Check if Vim is already installed.
237# return: Installed directory. If not found, it will be empty.
238Function CheckOldVim
239 Push $0
240 Push $R0
241 Push $R1
242 Push $R2
243
244 ${If} ${RunningX64}
245 SetRegView 64
246 ${EndIf}
247
248 ClearErrors
249 StrCpy $0 "" # Installed directory
250 StrCpy $R0 0 # Sub-key index
251 StrCpy $R1 "" # Sub-key
252 ${Do}
253 # Eumerate the sub-key:
254 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
255
256 # Stop if no more sub-key:
257 ${If} ${Errors}
258 ${OrIf} $R1 == ""
259 ${ExitDo}
260 ${EndIf}
261
262 # Move to the next sub-key:
263 IntOp $R0 $R0 + 1
264
265 # Check if the key is Vim uninstall key or not:
266 StrCpy $R2 $R1 4
267 ${If} $R2 S!= "Vim "
268 ${Continue}
269 ${EndIf}
270
271 # Verifies required sub-keys:
272 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
273 ${If} ${Errors}
274 ${OrIf} $R2 == ""
275 ${Continue}
276 ${EndIf}
277
278 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
279 ${If} ${Errors}
280 ${OrIf} $R2 == ""
281 ${Continue}
282 ${EndIf}
283
284 # Found
285 Push $R2
286 call GetParent
287 call GetParent
288 Pop $0 # Vim directory
289 ${ExitDo}
290
291 ${Loop}
292
293 ${If} ${RunningX64}
294 SetRegView lastused
295 ${EndIf}
296
297 Pop $R2
298 Pop $R1
299 Pop $R0
300 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301FunctionEnd
302
303##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100304Section "$(str_section_old_ver)" id_section_old_ver
305 SectionIn 1 2 3 RO
306
307 # run the install program to check for already installed versions
308 SetOutPath $TEMP
309 File /oname=install.exe ${VIMSRC}\installw32.exe
310 DetailPrint "$(str_msg_uninstalling)"
311 ${Do}
312 nsExec::Exec "$TEMP\install.exe -uninstall-check"
313 Pop $3
314
315 call CheckOldVim
316 Pop $3
317 ${If} $3 == ""
318 ${ExitDo}
319 ${Else}
320 # It seems that the old version is still remaining.
321 # TODO: Should we show a warning and run the uninstaller again?
322
323 ${ExitDo} # Just ignore for now.
324 ${EndIf}
325 ${Loop}
326 Delete $TEMP\install.exe
327 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
328
329 # We may have been put to the background when uninstall did something.
330 BringToFront
331SectionEnd
332
333##########################################################
334Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200335 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000336
337 # we need also this here if the user changes the instdir
338 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
339
340 SetOutPath $0
341 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200342!if /FileExists "${VIMSRC}\vim${BIT}.dll"
343 File ${VIMSRC}\vim${BIT}.dll
344!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000345 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200346 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000347 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200348 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100350 File ..\vimtutor.bat
351 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200352 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000353 File ${VIMRT}\*.vim
354 File ${VIMRT}\rgb.txt
355
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200356 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100357 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200358 File ${VIMTOOLS}\winpty-agent.exe
359
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360 SetOutPath $0\colors
361 File ${VIMRT}\colors\*.*
Bram Moolenaard0bce502021-02-26 20:25:35 +0100362 SetOutPath $0\colors\tools
363 File ${VIMRT}\colors\tools\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364
365 SetOutPath $0\compiler
366 File ${VIMRT}\compiler\*.*
367
368 SetOutPath $0\doc
369 File ${VIMRT}\doc\*.txt
370 File ${VIMRT}\doc\tags
371
372 SetOutPath $0\ftplugin
373 File ${VIMRT}\ftplugin\*.*
374
375 SetOutPath $0\indent
376 File ${VIMRT}\indent\*.*
377
378 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100379 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100381 SetOutPath $0\pack
382 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200383
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384 SetOutPath $0\plugin
385 File ${VIMRT}\plugin\*.*
386
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000387 SetOutPath $0\autoload
388 File ${VIMRT}\autoload\*.*
389
Bram Moolenaard09a2062017-11-11 15:37:45 +0100390 SetOutPath $0\autoload\dist
391 File ${VIMRT}\autoload\dist\*.*
392
Bram Moolenaar18144c82006-04-12 21:52:12 +0000393 SetOutPath $0\autoload\xml
394 File ${VIMRT}\autoload\xml\*.*
395
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396 SetOutPath $0\syntax
397 File ${VIMRT}\syntax\*.*
398
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000399 SetOutPath $0\spell
400 File ${VIMRT}\spell\*.txt
401 File ${VIMRT}\spell\*.vim
402 File ${VIMRT}\spell\*.spl
403 File ${VIMRT}\spell\*.sug
404
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405 SetOutPath $0\tools
406 File ${VIMRT}\tools\*.*
407
408 SetOutPath $0\tutor
409 File ${VIMRT}\tutor\*.*
410SectionEnd
411
412##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100413Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414 SectionIn 1 3
415
416 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100417 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418 StrCpy $2 "$2 vim view vimdiff"
419SectionEnd
420
421##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100422Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 SectionIn 3
424
425 StrCpy $1 "$1 -create-batfiles $2"
426SectionEnd
427
428##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100429SectionGroup $(str_group_icons) id_group_icons
430 Section "$(str_section_desktop)" id_section_desktop
431 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100433 StrCpy $1 "$1 -install-icons"
434 SectionEnd
435
436 Section "$(str_section_start_menu)" id_section_startmenu
437 SectionIn 1 3
438
439 StrCpy $1 "$1 -add-start-menu"
440 SectionEnd
441SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442
443##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100444Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 SectionIn 1 3
446
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200448
Bram Moolenaar442b4222010-05-24 21:34:22 +0200449 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200450 # Install 64-bit gvimext.dll into the GvimExt64 directory.
451 SetOutPath $0\GvimExt64
452 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100453 !define LIBRARY_SHELL_EXTENSION
454 !define LIBRARY_X64
455 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
456 "${VIMSRC}\GvimExt\gvimext64.dll" \
457 "$0\GvimExt64\gvimext.dll" "$0"
458 !undef LIBRARY_X64
459 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200460 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200461
Bram Moolenaar6199d432017-10-14 19:05:44 +0200462 # Install 32-bit gvimext.dll into the GvimExt32 directory.
463 SetOutPath $0\GvimExt32
464 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100465 !define LIBRARY_SHELL_EXTENSION
466 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
467 "${VIMSRC}\GvimExt\gvimext.dll" \
468 "$0\GvimExt32\gvimext.dll" "$0"
469 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470
471 # We don't have a separate entry for the "Open With..." menu, assume
472 # the user wants either both or none.
473 StrCpy $1 "$1 -install-popup -install-openwith"
474SectionEnd
475
476##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100477Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000478 SectionIn 1 3
479
480 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100481
482 ${If} ${RunningX64}
483 SetRegView 64
484 ${EndIf}
485 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
486 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
487 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
488 ${If} ${RunningX64}
489 SetRegView lastused
490 ${EndIf}
491
492 ${If} $vim_compat_stat == "vi"
493 StrCpy $1 "$1 -vimrc-compat vi"
494 ${ElseIf} $vim_compat_stat == "vim"
495 StrCpy $1 "$1 -vimrc-compat vim"
496 ${ElseIf} $vim_compat_stat == "defaults"
497 StrCpy $1 "$1 -vimrc-compat defaults"
498 ${Else}
499 StrCpy $1 "$1 -vimrc-compat all"
500 ${EndIf}
501
502 ${If} $vim_keymap_stat == "default"
503 StrCpy $1 "$1 -vimrc-remap no"
504 ${Else}
505 StrCpy $1 "$1 -vimrc-remap win"
506 ${EndIf}
507
508 ${If} $vim_mouse_stat == "default"
509 StrCpy $1 "$1 -vimrc-behave default"
510 ${ElseIf} $vim_mouse_stat == "windows"
511 StrCpy $1 "$1 -vimrc-behave mswin"
512 ${Else}
513 StrCpy $1 "$1 -vimrc-behave unix"
514 ${EndIf}
515
Bram Moolenaar071d4272004-06-13 20:20:40 +0000516SectionEnd
517
518##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100519SectionGroup $(str_group_plugin) id_group_plugin
520 Section "$(str_section_plugin_home)" id_section_pluginhome
521 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100523 StrCpy $1 "$1 -create-directories home"
524 SectionEnd
525
526 Section "$(str_section_plugin_vim)" id_section_pluginvim
527 SectionIn 3
528
529 StrCpy $1 "$1 -create-directories vim"
530 SectionEnd
531SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000532
533##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100534!ifdef HAVE_VIS_VIM
535Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000536 SectionIn 3
537
538 SetOutPath $0
539 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
540 File ${VIMSRC}\VisVim\README_VisVim.txt
541SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100542!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543
544##########################################################
545!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100546Section "$(str_section_nls)" id_section_nls
547 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000548
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100549 SetOutPath $0\lang
550 File /r ${VIMRT}\lang\*.*
551 SetOutPath $0\keymap
552 File ${VIMRT}\keymap\README.txt
553 File ${VIMRT}\keymap\*.vim
554 SetOutPath $0
555 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
556 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
557 "$0\libintl-8.dll" "$0"
558 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
559 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
560 "$0\libiconv-2.dll" "$0"
561 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
562 # Install libgcc_s_sjlj-1.dll only if it is needed.
563 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
564 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
565 "$0\libgcc_s_sjlj-1.dll" "$0"
566 !endif
567
568 ${If} ${SectionIsSelected} ${id_section_editwith}
569 ${If} ${RunningX64}
570 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
571 SetOutPath $0\GvimExt64
572 ClearErrors
573 !define LIBRARY_X64
574 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
575 "${GETTEXT}\gettext64\libintl-8.dll" \
576 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
577 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
578 "${GETTEXT}\gettext64\libiconv-2.dll" \
579 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
580 !undef LIBRARY_X64
581 ${EndIf}
582
583 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
584 SetOutPath $0\GvimExt32
585 ClearErrors
586 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
587 "${GETTEXT}\gettext32\libintl-8.dll" \
588 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
589 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
590 "${GETTEXT}\gettext32\libiconv-2.dll" \
591 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
592 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
593 # Install libgcc_s_sjlj-1.dll only if it is needed.
594 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
595 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
596 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
597 !endif
598 ${EndIf}
599SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000600!endif
601
602##########################################################
603Section -call_install_exe
604 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100605 DetailPrint "$(str_msg_registering)"
606 nsExec::Exec "$0\install.exe $1"
607 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000608SectionEnd
609
610##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100611!macro SaveSectionSelection section_id reg_value
612 ${If} ${SectionIsSelected} ${section_id}
613 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
614 ${Else}
615 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
616 ${EndIf}
617!macroend
618
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100620
621 # Get estimated install size
622 SectionGetSize ${id_section_exe} $3
623 ${If} ${SectionIsSelected} ${id_section_console}
624 SectionGetSize ${id_section_console} $4
625 IntOp $3 $3 + $4
626 ${EndIf}
627 ${If} ${SectionIsSelected} ${id_section_editwith}
628 SectionGetSize ${id_section_editwith} $4
629 IntOp $3 $3 + $4
630 ${EndIf}
631!ifdef HAVE_VIS_VIM
632 ${If} ${SectionIsSelected} ${id_section_visvim}
633 SectionGetSize ${id_section_visvim} $4
634 IntOp $3 $3 + $4
635 ${EndIf}
636!endif
637!ifdef HAVE_NLS
638 ${If} ${SectionIsSelected} ${id_section_nls}
639 SectionGetSize ${id_section_nls} $4
640 IntOp $3 $3 + $4
641 ${EndIf}
642!endif
643
644 # Register EstimatedSize and AllowSilent.
645 # Other information will be set by the install.exe (dosinst.c).
646 ${If} ${RunningX64}
647 SetRegView 64
648 ${EndIf}
649 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
650 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
651 ${If} ${RunningX64}
652 SetRegView lastused
653 ${EndIf}
654
655 # Store the selections to the registry.
656 ${If} ${RunningX64}
657 SetRegView 64
658 ${EndIf}
659 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
660 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
661 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
662 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
663 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
664 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
665 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
666 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
667!ifdef HAVE_VIS_VIM
668 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
669!endif
670!ifdef HAVE_NLS
671 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
672!endif
673 ${If} ${RunningX64}
674 SetRegView lastused
675 ${EndIf}
676
Bram Moolenaar071d4272004-06-13 20:20:40 +0000677 BringToFront
678SectionEnd
679
680##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100681!macro LoadSectionSelection section_id reg_value
682 ClearErrors
683 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
684 ${IfNot} ${Errors}
685 ${If} $3 = 1
686 !insertmacro SelectSection ${section_id}
687 ${Else}
688 !insertmacro UnselectSection ${section_id}
689 ${EndIf}
690 ${EndIf}
691!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200692
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200693!macro LoadDefaultVimrc out_var reg_value default_value
694 ClearErrors
695 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
696 ${If} ${Errors}
697 ${OrIf} ${out_var} == ""
698 StrCpy ${out_var} ${default_value}
699 ${EndIf}
700!macroend
701
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100702Function .onInit
703!ifdef HAVE_MULTI_LANG
704 # Select a language (or read from the registry).
705 !insertmacro MUI_LANGDLL_DISPLAY
706!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200707
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100708 # Check $VIM
709 ReadEnvStr $INSTDIR "VIM"
710
711 call CheckOldVim
712 Pop $3
713 ${If} $3 == ""
714 # No old versions of Vim found. Unselect and hide the section.
715 !insertmacro UnselectSection ${id_section_old_ver}
716 SectionSetInstTypes ${id_section_old_ver} 0
717 SectionSetText ${id_section_old_ver} ""
718 ${Else}
719 ${If} $INSTDIR == ""
720 StrCpy $INSTDIR $3
721 ${EndIf}
722 ${EndIf}
723
724 # If did not find a path: use the default dir.
725 ${If} $INSTDIR == ""
726!ifdef WIN64
727 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
728!else
729 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
730!endif
731 ${EndIf}
732
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100733 ${If} ${RunningX64}
734 SetRegView 64
735 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200736 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100737 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
738 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
739 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
740 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
741 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
742 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
743 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
744 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
745!ifdef HAVE_VIS_VIM
746 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
747!endif
748!ifdef HAVE_NLS
749 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
750!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200751 # Load the default _vimrc settings from the registry (if any).
752 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
753 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
754 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100755 ${If} ${RunningX64}
756 SetRegView lastused
757 ${EndIf}
758
759 # User variables:
760 # $0 - holds the directory the executables are installed to
761 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
762 # registration (since a non-OLE gvim will not complain, and we want to
763 # always register an OLE gvim).
764 # $2 - holds the names to create batch files for
765 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
766 StrCpy $1 "-register-OLE"
767 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200768FunctionEnd
769
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100770Function .onInstSuccess
771 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
772FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200773
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100774Function .onInstFailed
775 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200776FunctionEnd
777
778##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100779Function SetCustom
780 # Display the _vimrc setting dialog using nsDialogs.
781
782 # Check if a _vimrc should be created
783 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
784 Abort
785 ${EndIf}
786
787 !insertmacro MUI_HEADER_TEXT \
788 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
789
790 nsDialogs::Create 1018
791 Pop $vim_dialog
792
793 ${If} $vim_dialog == error
794 Abort
795 ${EndIf}
796
797 ${If} ${RunningX64}
798 SetRegView 64
799 ${EndIf}
800
801 GetFunctionAddress $3 ValidateCustom
802 nsDialogs::OnBack $3
803
804
805 # 1st group - Compatibility
806 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
807 Pop $3
808
809 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
810 Pop $3
811 ${NSD_CreateDropList} 18% 19% 75% 8% ""
812 Pop $vim_nsd_compat
813 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
814 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
815 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
816 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
817
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200818 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100819 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200820 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100821 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200822 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100823 StrCpy $4 0
824 ${Else} # default
825 StrCpy $4 3
826 ${EndIf}
827 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
828
829
830 # 2nd group - Key remapping
831 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
832 Pop $3
833
834 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
835 Pop $3
836 ${NSD_CreateDropList} 38% 54% 55% 8% ""
837 Pop $vim_nsd_keymap
838 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
839 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
840
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200841 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100842 StrCpy $4 1
843 ${Else} # default
844 StrCpy $4 0
845 ${EndIf}
846 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
847
848
849 # 3rd group - Mouse behavior
850 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
851 Pop $3
852
853 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
854 Pop $3
855 ${NSD_CreateDropList} 23% 87% 70% 8% ""
856 Pop $vim_nsd_mouse
857 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
858 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
859 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
860
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200861 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100862 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200863 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100864 StrCpy $4 1
865 ${Else} # default
866 StrCpy $4 0
867 ${EndIf}
868 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
869
870 ${If} ${RunningX64}
871 SetRegView lastused
872 ${EndIf}
873
874 nsDialogs::Show
875FunctionEnd
876
877Function ValidateCustom
878 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
879 ${If} $3 = 0
880 StrCpy $vim_compat_stat "vi"
881 ${ElseIf} $3 = 1
882 StrCpy $vim_compat_stat "vim"
883 ${ElseIf} $3 = 2
884 StrCpy $vim_compat_stat "defaults"
885 ${Else}
886 StrCpy $vim_compat_stat "all"
887 ${EndIf}
888
889 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
890 ${If} $3 = 0
891 StrCpy $vim_keymap_stat "default"
892 ${Else}
893 StrCpy $vim_keymap_stat "windows"
894 ${EndIf}
895
896 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
897 ${If} $3 = 0
898 StrCpy $vim_mouse_stat "default"
899 ${ElseIf} $3 = 1
900 StrCpy $vim_mouse_stat "windows"
901 ${Else}
902 StrCpy $vim_mouse_stat "xterm"
903 ${EndIf}
904FunctionEnd
905
906##########################################################
907# Description for Installer Sections
908
909!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
910 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
911 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
922!ifdef HAVE_VIS_VIM
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
924!endif
925!ifdef HAVE_NLS
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
927!endif
928!insertmacro MUI_FUNCTION_DESCRIPTION_END
929
930
931##########################################################
932# Uninstaller Functions and Sections
933
934Function un.onInit
935!ifdef HAVE_MULTI_LANG
936 # Get the language from the registry.
937 !insertmacro MUI_UNGETLANGUAGE
938!endif
939FunctionEnd
940
941Section "un.$(str_unsection_register)" id_unsection_register
942 SectionIn RO
943
Bram Moolenaar071d4272004-06-13 20:20:40 +0000944 # Apparently $INSTDIR is set to the directory where the uninstaller is
945 # created. Thus the "vim61" directory is included in it.
946 StrCpy $0 "$INSTDIR"
947
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100948!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000949 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100950 ${If} ${FileExists} "$0\VisVim.dll"
951 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
952 ${EndIf}
953!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000954
955 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100956 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200957 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100958 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959
960 # We may have been put to the background when uninstall did something.
961 BringToFront
962
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100963 # Delete the installer language setting.
964 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
965SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000966
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100967Section "un.$(str_unsection_exe)" id_unsection_exe
968
969 StrCpy $0 "$INSTDIR"
970
971 # Delete gettext and iconv DLLs
972 ${If} ${FileExists} "$0\libiconv-2.dll"
973 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
974 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200975 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100976 ${If} ${FileExists} "$0\libintl-8.dll"
977 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
978 "$0\libintl-8.dll"
979 ${EndIf}
980 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
981 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
982 "$0\libgcc_s_sjlj-1.dll"
983 ${EndIf}
984
985 # Delete other DLLs
986 Delete /REBOOTOK $0\*.dll
987
988 # Delete 64-bit GvimExt
989 ${If} ${RunningX64}
990 !define LIBRARY_X64
991 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
992 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
993 "$0\GvimExt64\gvimext.dll"
994 ${EndIf}
995 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
996 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
997 "$0\GvimExt64\libiconv-2.dll"
998 ${EndIf}
999 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1000 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1001 "$0\GvimExt64\libintl-8.dll"
1002 ${EndIf}
1003 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1004 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1005 "$0\GvimExt64\libwinpthread-1.dll"
1006 ${EndIf}
1007 !undef LIBRARY_X64
1008 RMDir /r $0\GvimExt64
1009 ${EndIf}
1010
1011 # Delete 32-bit GvimExt
1012 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1013 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1014 "$0\GvimExt32\gvimext.dll"
1015 ${EndIf}
1016 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1017 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1018 "$0\GvimExt32\libiconv-2.dll"
1019 ${EndIf}
1020 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1021 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1022 "$0\GvimExt32\libintl-8.dll"
1023 ${EndIf}
1024 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1025 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1026 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1027 ${EndIf}
1028 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001029
Bram Moolenaar071d4272004-06-13 20:20:40 +00001030 ClearErrors
1031 # Remove everything but *.dll files. Avoids that
1032 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001033 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034 RMDir /r $0\colors
1035 RMDir /r $0\compiler
1036 RMDir /r $0\doc
1037 RMDir /r $0\ftplugin
1038 RMDir /r $0\indent
1039 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001040 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001042 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 RMDir /r $0\syntax
1044 RMDir /r $0\tools
1045 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001046!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001048!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 RMDir /r $0\lang
1050 RMDir /r $0\keymap
1051 Delete $0\*.exe
1052 Delete $0\*.bat
1053 Delete $0\*.vim
1054 Delete $0\*.txt
1055
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001056 ${If} ${Errors}
1057 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1058 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001059
1060 # No error message if the "vim62" directory can't be removed, the
1061 # gvimext.dll may still be there.
1062 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001063SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001064
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001065# Remove "vimfiles" directory under the specified directory.
1066!macro RemoveVimfiles dir
1067 ${If} ${FileExists} ${dir}\vimfiles
1068 RMDir ${dir}\vimfiles\colors
1069 RMDir ${dir}\vimfiles\compiler
1070 RMDir ${dir}\vimfiles\doc
1071 RMDir ${dir}\vimfiles\ftdetect
1072 RMDir ${dir}\vimfiles\ftplugin
1073 RMDir ${dir}\vimfiles\indent
1074 RMDir ${dir}\vimfiles\keymap
1075 RMDir ${dir}\vimfiles\plugin
1076 RMDir ${dir}\vimfiles\syntax
1077 RMDir ${dir}\vimfiles
1078 ${EndIf}
1079!macroend
1080
1081SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1082 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1083 # get the home dir
1084 ReadEnvStr $0 "HOME"
1085 ${If} $0 == ""
1086 ReadEnvStr $0 "HOMEDRIVE"
1087 ReadEnvStr $1 "HOMEPATH"
1088 StrCpy $0 "$0$1"
1089 ${If} $0 == ""
1090 ReadEnvStr $0 "USERPROFILE"
1091 ${EndIf}
1092 ${EndIf}
1093
1094 ${If} $0 != ""
1095 !insertmacro RemoveVimfiles $0
1096 ${EndIf}
1097 SectionEnd
1098
1099 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1100 # get the parent dir of the installation
1101 Push $INSTDIR
1102 Call un.GetParent
1103 Pop $0
1104
1105 # if a plugin dir was created at installation remove it
1106 !insertmacro RemoveVimfiles $0
1107 SectionEnd
1108SectionGroupEnd
1109
1110Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001111 # get the parent dir of the installation
1112 Push $INSTDIR
1113 Call un.GetParent
1114 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001116 ${IfNot} ${Silent}
1117 Delete $0\_vimrc
1118 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001119 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001121
1122##########################################################
1123# Description for Uninstaller Sections
1124
1125!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1126 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1127 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1128 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1129 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1130 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1131 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1132!insertmacro MUI_UNFUNCTION_DESCRIPTION_END