blob: 4521fc273058efe1b922266b162f003c5a54d83c [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\*.*
362
363 SetOutPath $0\compiler
364 File ${VIMRT}\compiler\*.*
365
366 SetOutPath $0\doc
367 File ${VIMRT}\doc\*.txt
368 File ${VIMRT}\doc\tags
369
370 SetOutPath $0\ftplugin
371 File ${VIMRT}\ftplugin\*.*
372
373 SetOutPath $0\indent
374 File ${VIMRT}\indent\*.*
375
376 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100377 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000378
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100379 SetOutPath $0\pack
380 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200381
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382 SetOutPath $0\plugin
383 File ${VIMRT}\plugin\*.*
384
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000385 SetOutPath $0\autoload
386 File ${VIMRT}\autoload\*.*
387
Bram Moolenaard09a2062017-11-11 15:37:45 +0100388 SetOutPath $0\autoload\dist
389 File ${VIMRT}\autoload\dist\*.*
390
Bram Moolenaar18144c82006-04-12 21:52:12 +0000391 SetOutPath $0\autoload\xml
392 File ${VIMRT}\autoload\xml\*.*
393
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394 SetOutPath $0\syntax
395 File ${VIMRT}\syntax\*.*
396
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000397 SetOutPath $0\spell
398 File ${VIMRT}\spell\*.txt
399 File ${VIMRT}\spell\*.vim
400 File ${VIMRT}\spell\*.spl
401 File ${VIMRT}\spell\*.sug
402
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403 SetOutPath $0\tools
404 File ${VIMRT}\tools\*.*
405
406 SetOutPath $0\tutor
407 File ${VIMRT}\tutor\*.*
408SectionEnd
409
410##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100411Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000412 SectionIn 1 3
413
414 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100415 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416 StrCpy $2 "$2 vim view vimdiff"
417SectionEnd
418
419##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100420Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421 SectionIn 3
422
423 StrCpy $1 "$1 -create-batfiles $2"
424SectionEnd
425
426##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100427SectionGroup $(str_group_icons) id_group_icons
428 Section "$(str_section_desktop)" id_section_desktop
429 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100431 StrCpy $1 "$1 -install-icons"
432 SectionEnd
433
434 Section "$(str_section_start_menu)" id_section_startmenu
435 SectionIn 1 3
436
437 StrCpy $1 "$1 -add-start-menu"
438 SectionEnd
439SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000440
441##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100442Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443 SectionIn 1 3
444
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200446
Bram Moolenaar442b4222010-05-24 21:34:22 +0200447 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200448 # Install 64-bit gvimext.dll into the GvimExt64 directory.
449 SetOutPath $0\GvimExt64
450 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100451 !define LIBRARY_SHELL_EXTENSION
452 !define LIBRARY_X64
453 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
454 "${VIMSRC}\GvimExt\gvimext64.dll" \
455 "$0\GvimExt64\gvimext.dll" "$0"
456 !undef LIBRARY_X64
457 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200458 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200459
Bram Moolenaar6199d432017-10-14 19:05:44 +0200460 # Install 32-bit gvimext.dll into the GvimExt32 directory.
461 SetOutPath $0\GvimExt32
462 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100463 !define LIBRARY_SHELL_EXTENSION
464 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
465 "${VIMSRC}\GvimExt\gvimext.dll" \
466 "$0\GvimExt32\gvimext.dll" "$0"
467 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000468
469 # We don't have a separate entry for the "Open With..." menu, assume
470 # the user wants either both or none.
471 StrCpy $1 "$1 -install-popup -install-openwith"
472SectionEnd
473
474##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100475Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000476 SectionIn 1 3
477
478 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100479
480 ${If} ${RunningX64}
481 SetRegView 64
482 ${EndIf}
483 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
484 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
485 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
486 ${If} ${RunningX64}
487 SetRegView lastused
488 ${EndIf}
489
490 ${If} $vim_compat_stat == "vi"
491 StrCpy $1 "$1 -vimrc-compat vi"
492 ${ElseIf} $vim_compat_stat == "vim"
493 StrCpy $1 "$1 -vimrc-compat vim"
494 ${ElseIf} $vim_compat_stat == "defaults"
495 StrCpy $1 "$1 -vimrc-compat defaults"
496 ${Else}
497 StrCpy $1 "$1 -vimrc-compat all"
498 ${EndIf}
499
500 ${If} $vim_keymap_stat == "default"
501 StrCpy $1 "$1 -vimrc-remap no"
502 ${Else}
503 StrCpy $1 "$1 -vimrc-remap win"
504 ${EndIf}
505
506 ${If} $vim_mouse_stat == "default"
507 StrCpy $1 "$1 -vimrc-behave default"
508 ${ElseIf} $vim_mouse_stat == "windows"
509 StrCpy $1 "$1 -vimrc-behave mswin"
510 ${Else}
511 StrCpy $1 "$1 -vimrc-behave unix"
512 ${EndIf}
513
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514SectionEnd
515
516##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100517SectionGroup $(str_group_plugin) id_group_plugin
518 Section "$(str_section_plugin_home)" id_section_pluginhome
519 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100521 StrCpy $1 "$1 -create-directories home"
522 SectionEnd
523
524 Section "$(str_section_plugin_vim)" id_section_pluginvim
525 SectionIn 3
526
527 StrCpy $1 "$1 -create-directories vim"
528 SectionEnd
529SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000530
531##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100532!ifdef HAVE_VIS_VIM
533Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534 SectionIn 3
535
536 SetOutPath $0
537 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
538 File ${VIMSRC}\VisVim\README_VisVim.txt
539SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100540!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000541
542##########################################################
543!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100544Section "$(str_section_nls)" id_section_nls
545 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100547 SetOutPath $0\lang
548 File /r ${VIMRT}\lang\*.*
549 SetOutPath $0\keymap
550 File ${VIMRT}\keymap\README.txt
551 File ${VIMRT}\keymap\*.vim
552 SetOutPath $0
553 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
554 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
555 "$0\libintl-8.dll" "$0"
556 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
557 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
558 "$0\libiconv-2.dll" "$0"
559 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
560 # Install libgcc_s_sjlj-1.dll only if it is needed.
561 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
562 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
563 "$0\libgcc_s_sjlj-1.dll" "$0"
564 !endif
565
566 ${If} ${SectionIsSelected} ${id_section_editwith}
567 ${If} ${RunningX64}
568 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
569 SetOutPath $0\GvimExt64
570 ClearErrors
571 !define LIBRARY_X64
572 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
573 "${GETTEXT}\gettext64\libintl-8.dll" \
574 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
575 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
576 "${GETTEXT}\gettext64\libiconv-2.dll" \
577 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
578 !undef LIBRARY_X64
579 ${EndIf}
580
581 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
582 SetOutPath $0\GvimExt32
583 ClearErrors
584 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
585 "${GETTEXT}\gettext32\libintl-8.dll" \
586 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
587 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
588 "${GETTEXT}\gettext32\libiconv-2.dll" \
589 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
590 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
591 # Install libgcc_s_sjlj-1.dll only if it is needed.
592 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
593 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
594 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
595 !endif
596 ${EndIf}
597SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598!endif
599
600##########################################################
601Section -call_install_exe
602 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100603 DetailPrint "$(str_msg_registering)"
604 nsExec::Exec "$0\install.exe $1"
605 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606SectionEnd
607
608##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100609!macro SaveSectionSelection section_id reg_value
610 ${If} ${SectionIsSelected} ${section_id}
611 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
612 ${Else}
613 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
614 ${EndIf}
615!macroend
616
Bram Moolenaar071d4272004-06-13 20:20:40 +0000617Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100618
619 # Get estimated install size
620 SectionGetSize ${id_section_exe} $3
621 ${If} ${SectionIsSelected} ${id_section_console}
622 SectionGetSize ${id_section_console} $4
623 IntOp $3 $3 + $4
624 ${EndIf}
625 ${If} ${SectionIsSelected} ${id_section_editwith}
626 SectionGetSize ${id_section_editwith} $4
627 IntOp $3 $3 + $4
628 ${EndIf}
629!ifdef HAVE_VIS_VIM
630 ${If} ${SectionIsSelected} ${id_section_visvim}
631 SectionGetSize ${id_section_visvim} $4
632 IntOp $3 $3 + $4
633 ${EndIf}
634!endif
635!ifdef HAVE_NLS
636 ${If} ${SectionIsSelected} ${id_section_nls}
637 SectionGetSize ${id_section_nls} $4
638 IntOp $3 $3 + $4
639 ${EndIf}
640!endif
641
642 # Register EstimatedSize and AllowSilent.
643 # Other information will be set by the install.exe (dosinst.c).
644 ${If} ${RunningX64}
645 SetRegView 64
646 ${EndIf}
647 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
648 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
649 ${If} ${RunningX64}
650 SetRegView lastused
651 ${EndIf}
652
653 # Store the selections to the registry.
654 ${If} ${RunningX64}
655 SetRegView 64
656 ${EndIf}
657 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
658 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
659 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
660 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
661 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
662 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
663 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
664 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
665!ifdef HAVE_VIS_VIM
666 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
667!endif
668!ifdef HAVE_NLS
669 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
670!endif
671 ${If} ${RunningX64}
672 SetRegView lastused
673 ${EndIf}
674
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675 BringToFront
676SectionEnd
677
678##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100679!macro LoadSectionSelection section_id reg_value
680 ClearErrors
681 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
682 ${IfNot} ${Errors}
683 ${If} $3 = 1
684 !insertmacro SelectSection ${section_id}
685 ${Else}
686 !insertmacro UnselectSection ${section_id}
687 ${EndIf}
688 ${EndIf}
689!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200690
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200691!macro LoadDefaultVimrc out_var reg_value default_value
692 ClearErrors
693 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
694 ${If} ${Errors}
695 ${OrIf} ${out_var} == ""
696 StrCpy ${out_var} ${default_value}
697 ${EndIf}
698!macroend
699
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100700Function .onInit
701!ifdef HAVE_MULTI_LANG
702 # Select a language (or read from the registry).
703 !insertmacro MUI_LANGDLL_DISPLAY
704!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200705
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100706 # Check $VIM
707 ReadEnvStr $INSTDIR "VIM"
708
709 call CheckOldVim
710 Pop $3
711 ${If} $3 == ""
712 # No old versions of Vim found. Unselect and hide the section.
713 !insertmacro UnselectSection ${id_section_old_ver}
714 SectionSetInstTypes ${id_section_old_ver} 0
715 SectionSetText ${id_section_old_ver} ""
716 ${Else}
717 ${If} $INSTDIR == ""
718 StrCpy $INSTDIR $3
719 ${EndIf}
720 ${EndIf}
721
722 # If did not find a path: use the default dir.
723 ${If} $INSTDIR == ""
724!ifdef WIN64
725 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
726!else
727 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
728!endif
729 ${EndIf}
730
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100731 ${If} ${RunningX64}
732 SetRegView 64
733 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200734 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100735 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
736 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
737 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
738 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
739 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
740 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
741 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
742 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
743!ifdef HAVE_VIS_VIM
744 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
745!endif
746!ifdef HAVE_NLS
747 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
748!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200749 # Load the default _vimrc settings from the registry (if any).
750 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
751 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
752 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100753 ${If} ${RunningX64}
754 SetRegView lastused
755 ${EndIf}
756
757 # User variables:
758 # $0 - holds the directory the executables are installed to
759 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
760 # registration (since a non-OLE gvim will not complain, and we want to
761 # always register an OLE gvim).
762 # $2 - holds the names to create batch files for
763 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
764 StrCpy $1 "-register-OLE"
765 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200766FunctionEnd
767
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100768Function .onInstSuccess
769 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
770FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200771
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100772Function .onInstFailed
773 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200774FunctionEnd
775
776##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100777Function SetCustom
778 # Display the _vimrc setting dialog using nsDialogs.
779
780 # Check if a _vimrc should be created
781 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
782 Abort
783 ${EndIf}
784
785 !insertmacro MUI_HEADER_TEXT \
786 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
787
788 nsDialogs::Create 1018
789 Pop $vim_dialog
790
791 ${If} $vim_dialog == error
792 Abort
793 ${EndIf}
794
795 ${If} ${RunningX64}
796 SetRegView 64
797 ${EndIf}
798
799 GetFunctionAddress $3 ValidateCustom
800 nsDialogs::OnBack $3
801
802
803 # 1st group - Compatibility
804 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
805 Pop $3
806
807 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
808 Pop $3
809 ${NSD_CreateDropList} 18% 19% 75% 8% ""
810 Pop $vim_nsd_compat
811 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
812 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
813 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
814 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
815
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200816 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100817 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200818 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100819 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200820 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100821 StrCpy $4 0
822 ${Else} # default
823 StrCpy $4 3
824 ${EndIf}
825 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
826
827
828 # 2nd group - Key remapping
829 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
830 Pop $3
831
832 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
833 Pop $3
834 ${NSD_CreateDropList} 38% 54% 55% 8% ""
835 Pop $vim_nsd_keymap
836 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
837 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
838
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200839 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100840 StrCpy $4 1
841 ${Else} # default
842 StrCpy $4 0
843 ${EndIf}
844 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
845
846
847 # 3rd group - Mouse behavior
848 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
849 Pop $3
850
851 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
852 Pop $3
853 ${NSD_CreateDropList} 23% 87% 70% 8% ""
854 Pop $vim_nsd_mouse
855 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
856 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
857 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
858
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200859 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100860 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200861 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100862 StrCpy $4 1
863 ${Else} # default
864 StrCpy $4 0
865 ${EndIf}
866 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
867
868 ${If} ${RunningX64}
869 SetRegView lastused
870 ${EndIf}
871
872 nsDialogs::Show
873FunctionEnd
874
875Function ValidateCustom
876 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
877 ${If} $3 = 0
878 StrCpy $vim_compat_stat "vi"
879 ${ElseIf} $3 = 1
880 StrCpy $vim_compat_stat "vim"
881 ${ElseIf} $3 = 2
882 StrCpy $vim_compat_stat "defaults"
883 ${Else}
884 StrCpy $vim_compat_stat "all"
885 ${EndIf}
886
887 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
888 ${If} $3 = 0
889 StrCpy $vim_keymap_stat "default"
890 ${Else}
891 StrCpy $vim_keymap_stat "windows"
892 ${EndIf}
893
894 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
895 ${If} $3 = 0
896 StrCpy $vim_mouse_stat "default"
897 ${ElseIf} $3 = 1
898 StrCpy $vim_mouse_stat "windows"
899 ${Else}
900 StrCpy $vim_mouse_stat "xterm"
901 ${EndIf}
902FunctionEnd
903
904##########################################################
905# Description for Installer Sections
906
907!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
908 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
909 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
910 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
911 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
920!ifdef HAVE_VIS_VIM
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
922!endif
923!ifdef HAVE_NLS
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
925!endif
926!insertmacro MUI_FUNCTION_DESCRIPTION_END
927
928
929##########################################################
930# Uninstaller Functions and Sections
931
932Function un.onInit
933!ifdef HAVE_MULTI_LANG
934 # Get the language from the registry.
935 !insertmacro MUI_UNGETLANGUAGE
936!endif
937FunctionEnd
938
939Section "un.$(str_unsection_register)" id_unsection_register
940 SectionIn RO
941
Bram Moolenaar071d4272004-06-13 20:20:40 +0000942 # Apparently $INSTDIR is set to the directory where the uninstaller is
943 # created. Thus the "vim61" directory is included in it.
944 StrCpy $0 "$INSTDIR"
945
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100946!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000947 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100948 ${If} ${FileExists} "$0\VisVim.dll"
949 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
950 ${EndIf}
951!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000952
953 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100954 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200955 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100956 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000957
958 # We may have been put to the background when uninstall did something.
959 BringToFront
960
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100961 # Delete the installer language setting.
962 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
963SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100965Section "un.$(str_unsection_exe)" id_unsection_exe
966
967 StrCpy $0 "$INSTDIR"
968
969 # Delete gettext and iconv DLLs
970 ${If} ${FileExists} "$0\libiconv-2.dll"
971 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
972 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200973 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100974 ${If} ${FileExists} "$0\libintl-8.dll"
975 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
976 "$0\libintl-8.dll"
977 ${EndIf}
978 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
979 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
980 "$0\libgcc_s_sjlj-1.dll"
981 ${EndIf}
982
983 # Delete other DLLs
984 Delete /REBOOTOK $0\*.dll
985
986 # Delete 64-bit GvimExt
987 ${If} ${RunningX64}
988 !define LIBRARY_X64
989 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
990 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
991 "$0\GvimExt64\gvimext.dll"
992 ${EndIf}
993 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
994 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
995 "$0\GvimExt64\libiconv-2.dll"
996 ${EndIf}
997 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
998 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
999 "$0\GvimExt64\libintl-8.dll"
1000 ${EndIf}
1001 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1002 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1003 "$0\GvimExt64\libwinpthread-1.dll"
1004 ${EndIf}
1005 !undef LIBRARY_X64
1006 RMDir /r $0\GvimExt64
1007 ${EndIf}
1008
1009 # Delete 32-bit GvimExt
1010 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1011 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1012 "$0\GvimExt32\gvimext.dll"
1013 ${EndIf}
1014 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1015 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1016 "$0\GvimExt32\libiconv-2.dll"
1017 ${EndIf}
1018 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1019 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1020 "$0\GvimExt32\libintl-8.dll"
1021 ${EndIf}
1022 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1023 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1024 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1025 ${EndIf}
1026 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001027
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 ClearErrors
1029 # Remove everything but *.dll files. Avoids that
1030 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001031 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 RMDir /r $0\colors
1033 RMDir /r $0\compiler
1034 RMDir /r $0\doc
1035 RMDir /r $0\ftplugin
1036 RMDir /r $0\indent
1037 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001038 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001040 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 RMDir /r $0\syntax
1042 RMDir /r $0\tools
1043 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001044!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001046!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 RMDir /r $0\lang
1048 RMDir /r $0\keymap
1049 Delete $0\*.exe
1050 Delete $0\*.bat
1051 Delete $0\*.vim
1052 Delete $0\*.txt
1053
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001054 ${If} ${Errors}
1055 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1056 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001057
1058 # No error message if the "vim62" directory can't be removed, the
1059 # gvimext.dll may still be there.
1060 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001061SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001063# Remove "vimfiles" directory under the specified directory.
1064!macro RemoveVimfiles dir
1065 ${If} ${FileExists} ${dir}\vimfiles
1066 RMDir ${dir}\vimfiles\colors
1067 RMDir ${dir}\vimfiles\compiler
1068 RMDir ${dir}\vimfiles\doc
1069 RMDir ${dir}\vimfiles\ftdetect
1070 RMDir ${dir}\vimfiles\ftplugin
1071 RMDir ${dir}\vimfiles\indent
1072 RMDir ${dir}\vimfiles\keymap
1073 RMDir ${dir}\vimfiles\plugin
1074 RMDir ${dir}\vimfiles\syntax
1075 RMDir ${dir}\vimfiles
1076 ${EndIf}
1077!macroend
1078
1079SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1080 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1081 # get the home dir
1082 ReadEnvStr $0 "HOME"
1083 ${If} $0 == ""
1084 ReadEnvStr $0 "HOMEDRIVE"
1085 ReadEnvStr $1 "HOMEPATH"
1086 StrCpy $0 "$0$1"
1087 ${If} $0 == ""
1088 ReadEnvStr $0 "USERPROFILE"
1089 ${EndIf}
1090 ${EndIf}
1091
1092 ${If} $0 != ""
1093 !insertmacro RemoveVimfiles $0
1094 ${EndIf}
1095 SectionEnd
1096
1097 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1098 # get the parent dir of the installation
1099 Push $INSTDIR
1100 Call un.GetParent
1101 Pop $0
1102
1103 # if a plugin dir was created at installation remove it
1104 !insertmacro RemoveVimfiles $0
1105 SectionEnd
1106SectionGroupEnd
1107
1108Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001109 # get the parent dir of the installation
1110 Push $INSTDIR
1111 Call un.GetParent
1112 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001114 ${IfNot} ${Silent}
1115 Delete $0\_vimrc
1116 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001117 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001119
1120##########################################################
1121# Description for Uninstaller Sections
1122
1123!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1124 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1125 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1126 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1127 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1128 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1129 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1130!insertmacro MUI_UNFUNCTION_DESCRIPTION_END