blob: fc5713f7903cdcf8147f30880500da24700f4517 [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
Bram Moolenaar4a228972021-05-01 22:41:39 +0200122!define MUI_FINISHPAGE_RUN
123!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100124!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100125
126# This adds '\Vim' to the user choice automagically. The actual value is
127# obtained below with CheckOldVim.
128!ifdef WIN64
Christian Brabandt7d603842021-07-24 21:19:42 +0200129 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100130!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200131 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100132!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200133InstallDir ${DEFAULT_INSTDIR}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134
135# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100136InstType $(str_type_typical)
137InstType $(str_type_minimal)
138InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
140SilentInstall normal
141
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100142# General custom functions for MUI2:
143#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
144#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
145
146# Installer pages
147!insertmacro MUI_PAGE_WELCOME
148!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
149!insertmacro MUI_PAGE_COMPONENTS
150Page custom SetCustom ValidateCustom
151#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
152!insertmacro MUI_PAGE_DIRECTORY
153!insertmacro MUI_PAGE_INSTFILES
154!define MUI_FINISHPAGE_NOREBOOTSUPPORT
155!insertmacro MUI_PAGE_FINISH
156
157# Uninstaller pages:
158!insertmacro MUI_UNPAGE_CONFIRM
159#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
160!insertmacro MUI_UNPAGE_COMPONENTS
161!insertmacro MUI_UNPAGE_INSTFILES
162!define MUI_FINISHPAGE_NOREBOOTSUPPORT
163!insertmacro MUI_UNPAGE_FINISH
164
165##########################################################
166# Languages Files
167
168!insertmacro MUI_RESERVEFILE_LANGDLL
169!include "lang\english.nsi"
170
171# Include support for other languages:
172!ifdef HAVE_MULTI_LANG
173 !include "lang\danish.nsi"
174 !include "lang\dutch.nsi"
175 !include "lang\german.nsi"
176 !include "lang\italian.nsi"
177 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200178 !include "lang\russian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100179 !include "lang\simpchinese.nsi"
180 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100181 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100182!endif
183
Bram Moolenaardabfde02019-05-17 12:37:27 +0200184##########################################################
185# Version resources
186
187VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
188VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
189VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
190VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
191VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200192VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
193VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100194
195# Global variables
196Var vim_dialog
197Var vim_nsd_compat
198Var vim_nsd_keymap
199Var vim_nsd_mouse
200Var vim_compat_stat
201Var vim_keymap_stat
202Var vim_mouse_stat
203
Bram Moolenaar071d4272004-06-13 20:20:40 +0000204
Bram Moolenaar5d424742018-02-04 19:11:30 +0100205# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100206ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100207
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208##########################################################
209# Functions
210
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100211# Get parent directory
212# Share this function both on installer and uninstaller
213!macro GetParent un
214Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000215 Exch $0 ; old $0 is on top of stack
216 Push $1
217 Push $2
218 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100219 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000220 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100221 ${If} $2 == ""
222 ${OrIf} $2 == "\"
223 ${ExitDo}
224 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000225 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100226 ${Loop}
227 StrCpy $0 $0 $1
228 Pop $2
229 Pop $1
230 Exch $0 ; put $0 on top of stack, restore $0 to original value
231FunctionEnd
232!macroend
233
234!insertmacro GetParent ""
235!insertmacro GetParent "un."
236
237# Check if Vim is already installed.
238# return: Installed directory. If not found, it will be empty.
239Function CheckOldVim
240 Push $0
241 Push $R0
242 Push $R1
243 Push $R2
244
245 ${If} ${RunningX64}
246 SetRegView 64
247 ${EndIf}
248
249 ClearErrors
250 StrCpy $0 "" # Installed directory
251 StrCpy $R0 0 # Sub-key index
252 StrCpy $R1 "" # Sub-key
253 ${Do}
254 # Eumerate the sub-key:
255 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
256
257 # Stop if no more sub-key:
258 ${If} ${Errors}
259 ${OrIf} $R1 == ""
260 ${ExitDo}
261 ${EndIf}
262
263 # Move to the next sub-key:
264 IntOp $R0 $R0 + 1
265
266 # Check if the key is Vim uninstall key or not:
267 StrCpy $R2 $R1 4
268 ${If} $R2 S!= "Vim "
269 ${Continue}
270 ${EndIf}
271
272 # Verifies required sub-keys:
273 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
274 ${If} ${Errors}
275 ${OrIf} $R2 == ""
276 ${Continue}
277 ${EndIf}
278
279 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
280 ${If} ${Errors}
281 ${OrIf} $R2 == ""
282 ${Continue}
283 ${EndIf}
284
285 # Found
286 Push $R2
287 call GetParent
288 call GetParent
289 Pop $0 # Vim directory
290 ${ExitDo}
291
292 ${Loop}
293
294 ${If} ${RunningX64}
295 SetRegView lastused
296 ${EndIf}
297
298 Pop $R2
299 Pop $R1
300 Pop $R0
301 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302FunctionEnd
303
Bram Moolenaar4a228972021-05-01 22:41:39 +0200304Function LaunchApplication
305 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200306 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200307FunctionEnd
308
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100310Section "$(str_section_old_ver)" id_section_old_ver
311 SectionIn 1 2 3 RO
312
313 # run the install program to check for already installed versions
314 SetOutPath $TEMP
315 File /oname=install.exe ${VIMSRC}\installw32.exe
316 DetailPrint "$(str_msg_uninstalling)"
317 ${Do}
318 nsExec::Exec "$TEMP\install.exe -uninstall-check"
319 Pop $3
320
321 call CheckOldVim
322 Pop $3
323 ${If} $3 == ""
324 ${ExitDo}
325 ${Else}
326 # It seems that the old version is still remaining.
327 # TODO: Should we show a warning and run the uninstaller again?
328
329 ${ExitDo} # Just ignore for now.
330 ${EndIf}
331 ${Loop}
332 Delete $TEMP\install.exe
333 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
334
335 # We may have been put to the background when uninstall did something.
336 BringToFront
337SectionEnd
338
339##########################################################
340Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200341 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000342
343 # we need also this here if the user changes the instdir
344 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
345
346 SetOutPath $0
347 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200348!if /FileExists "${VIMSRC}\vim${BIT}.dll"
349 File ${VIMSRC}\vim${BIT}.dll
350!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200352 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000353 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200354 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100356 File ..\vimtutor.bat
357 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200358 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000359 File ${VIMRT}\*.vim
360 File ${VIMRT}\rgb.txt
361
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200362 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100363 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200364 File ${VIMTOOLS}\winpty-agent.exe
365
Bram Moolenaar071d4272004-06-13 20:20:40 +0000366 SetOutPath $0\colors
367 File ${VIMRT}\colors\*.*
Bram Moolenaard0bce502021-02-26 20:25:35 +0100368 SetOutPath $0\colors\tools
369 File ${VIMRT}\colors\tools\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370
371 SetOutPath $0\compiler
372 File ${VIMRT}\compiler\*.*
373
374 SetOutPath $0\doc
375 File ${VIMRT}\doc\*.txt
376 File ${VIMRT}\doc\tags
377
378 SetOutPath $0\ftplugin
379 File ${VIMRT}\ftplugin\*.*
380
381 SetOutPath $0\indent
382 File ${VIMRT}\indent\*.*
383
384 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100385 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100387 SetOutPath $0\pack
388 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200389
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390 SetOutPath $0\plugin
391 File ${VIMRT}\plugin\*.*
392
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000393 SetOutPath $0\autoload
394 File ${VIMRT}\autoload\*.*
395
Bram Moolenaard09a2062017-11-11 15:37:45 +0100396 SetOutPath $0\autoload\dist
397 File ${VIMRT}\autoload\dist\*.*
398
Bram Moolenaar18144c82006-04-12 21:52:12 +0000399 SetOutPath $0\autoload\xml
400 File ${VIMRT}\autoload\xml\*.*
401
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402 SetOutPath $0\syntax
403 File ${VIMRT}\syntax\*.*
404
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000405 SetOutPath $0\spell
406 File ${VIMRT}\spell\*.txt
407 File ${VIMRT}\spell\*.vim
408 File ${VIMRT}\spell\*.spl
409 File ${VIMRT}\spell\*.sug
410
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411 SetOutPath $0\tools
412 File ${VIMRT}\tools\*.*
413
414 SetOutPath $0\tutor
415 File ${VIMRT}\tutor\*.*
416SectionEnd
417
418##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100419Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420 SectionIn 1 3
421
422 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100423 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424 StrCpy $2 "$2 vim view vimdiff"
425SectionEnd
426
427##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100428Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429 SectionIn 3
430
431 StrCpy $1 "$1 -create-batfiles $2"
432SectionEnd
433
434##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100435SectionGroup $(str_group_icons) id_group_icons
436 Section "$(str_section_desktop)" id_section_desktop
437 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100439 StrCpy $1 "$1 -install-icons"
440 SectionEnd
441
442 Section "$(str_section_start_menu)" id_section_startmenu
443 SectionIn 1 3
444
445 StrCpy $1 "$1 -add-start-menu"
446 SectionEnd
447SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
449##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100450Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451 SectionIn 1 3
452
Bram Moolenaar071d4272004-06-13 20:20:40 +0000453 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200454
Bram Moolenaar442b4222010-05-24 21:34:22 +0200455 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200456 # Install 64-bit gvimext.dll into the GvimExt64 directory.
457 SetOutPath $0\GvimExt64
458 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100459 !define LIBRARY_SHELL_EXTENSION
460 !define LIBRARY_X64
461 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
462 "${VIMSRC}\GvimExt\gvimext64.dll" \
463 "$0\GvimExt64\gvimext.dll" "$0"
464 !undef LIBRARY_X64
465 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200466 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200467
Bram Moolenaar6199d432017-10-14 19:05:44 +0200468 # Install 32-bit gvimext.dll into the GvimExt32 directory.
469 SetOutPath $0\GvimExt32
470 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100471 !define LIBRARY_SHELL_EXTENSION
472 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
473 "${VIMSRC}\GvimExt\gvimext.dll" \
474 "$0\GvimExt32\gvimext.dll" "$0"
475 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000476
477 # We don't have a separate entry for the "Open With..." menu, assume
478 # the user wants either both or none.
479 StrCpy $1 "$1 -install-popup -install-openwith"
480SectionEnd
481
482##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100483Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000484 SectionIn 1 3
485
486 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100487
488 ${If} ${RunningX64}
489 SetRegView 64
490 ${EndIf}
491 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
492 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
493 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
494 ${If} ${RunningX64}
495 SetRegView lastused
496 ${EndIf}
497
498 ${If} $vim_compat_stat == "vi"
499 StrCpy $1 "$1 -vimrc-compat vi"
500 ${ElseIf} $vim_compat_stat == "vim"
501 StrCpy $1 "$1 -vimrc-compat vim"
502 ${ElseIf} $vim_compat_stat == "defaults"
503 StrCpy $1 "$1 -vimrc-compat defaults"
504 ${Else}
505 StrCpy $1 "$1 -vimrc-compat all"
506 ${EndIf}
507
508 ${If} $vim_keymap_stat == "default"
509 StrCpy $1 "$1 -vimrc-remap no"
510 ${Else}
511 StrCpy $1 "$1 -vimrc-remap win"
512 ${EndIf}
513
514 ${If} $vim_mouse_stat == "default"
515 StrCpy $1 "$1 -vimrc-behave default"
516 ${ElseIf} $vim_mouse_stat == "windows"
517 StrCpy $1 "$1 -vimrc-behave mswin"
518 ${Else}
519 StrCpy $1 "$1 -vimrc-behave unix"
520 ${EndIf}
521
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522SectionEnd
523
524##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100525SectionGroup $(str_group_plugin) id_group_plugin
526 Section "$(str_section_plugin_home)" id_section_pluginhome
527 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100529 StrCpy $1 "$1 -create-directories home"
530 SectionEnd
531
532 Section "$(str_section_plugin_vim)" id_section_pluginvim
533 SectionIn 3
534
535 StrCpy $1 "$1 -create-directories vim"
536 SectionEnd
537SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538
539##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100540!ifdef HAVE_VIS_VIM
541Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 SectionIn 3
543
544 SetOutPath $0
545 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
546 File ${VIMSRC}\VisVim\README_VisVim.txt
547SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100548!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549
550##########################################################
551!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100552Section "$(str_section_nls)" id_section_nls
553 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100555 SetOutPath $0\lang
556 File /r ${VIMRT}\lang\*.*
557 SetOutPath $0\keymap
558 File ${VIMRT}\keymap\README.txt
559 File ${VIMRT}\keymap\*.vim
560 SetOutPath $0
561 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
562 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
563 "$0\libintl-8.dll" "$0"
564 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
565 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
566 "$0\libiconv-2.dll" "$0"
567 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
568 # Install libgcc_s_sjlj-1.dll only if it is needed.
569 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
570 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
571 "$0\libgcc_s_sjlj-1.dll" "$0"
572 !endif
573
574 ${If} ${SectionIsSelected} ${id_section_editwith}
575 ${If} ${RunningX64}
576 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
577 SetOutPath $0\GvimExt64
578 ClearErrors
579 !define LIBRARY_X64
580 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
581 "${GETTEXT}\gettext64\libintl-8.dll" \
582 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
583 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
584 "${GETTEXT}\gettext64\libiconv-2.dll" \
585 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
586 !undef LIBRARY_X64
587 ${EndIf}
588
589 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
590 SetOutPath $0\GvimExt32
591 ClearErrors
592 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
593 "${GETTEXT}\gettext32\libintl-8.dll" \
594 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
595 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
596 "${GETTEXT}\gettext32\libiconv-2.dll" \
597 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
598 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
599 # Install libgcc_s_sjlj-1.dll only if it is needed.
600 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
601 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
602 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
603 !endif
604 ${EndIf}
605SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606!endif
607
608##########################################################
609Section -call_install_exe
610 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100611 DetailPrint "$(str_msg_registering)"
612 nsExec::Exec "$0\install.exe $1"
613 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614SectionEnd
615
616##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100617!macro SaveSectionSelection section_id reg_value
618 ${If} ${SectionIsSelected} ${section_id}
619 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
620 ${Else}
621 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
622 ${EndIf}
623!macroend
624
Bram Moolenaar071d4272004-06-13 20:20:40 +0000625Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100626
627 # Get estimated install size
628 SectionGetSize ${id_section_exe} $3
629 ${If} ${SectionIsSelected} ${id_section_console}
630 SectionGetSize ${id_section_console} $4
631 IntOp $3 $3 + $4
632 ${EndIf}
633 ${If} ${SectionIsSelected} ${id_section_editwith}
634 SectionGetSize ${id_section_editwith} $4
635 IntOp $3 $3 + $4
636 ${EndIf}
637!ifdef HAVE_VIS_VIM
638 ${If} ${SectionIsSelected} ${id_section_visvim}
639 SectionGetSize ${id_section_visvim} $4
640 IntOp $3 $3 + $4
641 ${EndIf}
642!endif
643!ifdef HAVE_NLS
644 ${If} ${SectionIsSelected} ${id_section_nls}
645 SectionGetSize ${id_section_nls} $4
646 IntOp $3 $3 + $4
647 ${EndIf}
648!endif
649
650 # Register EstimatedSize and AllowSilent.
651 # Other information will be set by the install.exe (dosinst.c).
652 ${If} ${RunningX64}
653 SetRegView 64
654 ${EndIf}
655 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
656 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
657 ${If} ${RunningX64}
658 SetRegView lastused
659 ${EndIf}
660
661 # Store the selections to the registry.
662 ${If} ${RunningX64}
663 SetRegView 64
664 ${EndIf}
665 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
666 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
667 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
668 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
669 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
670 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
671 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
672 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
673!ifdef HAVE_VIS_VIM
674 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
675!endif
676!ifdef HAVE_NLS
677 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
678!endif
679 ${If} ${RunningX64}
680 SetRegView lastused
681 ${EndIf}
682
Bram Moolenaar071d4272004-06-13 20:20:40 +0000683 BringToFront
684SectionEnd
685
686##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100687!macro LoadSectionSelection section_id reg_value
688 ClearErrors
689 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
690 ${IfNot} ${Errors}
691 ${If} $3 = 1
692 !insertmacro SelectSection ${section_id}
693 ${Else}
694 !insertmacro UnselectSection ${section_id}
695 ${EndIf}
696 ${EndIf}
697!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200698
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200699!macro LoadDefaultVimrc out_var reg_value default_value
700 ClearErrors
701 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
702 ${If} ${Errors}
703 ${OrIf} ${out_var} == ""
704 StrCpy ${out_var} ${default_value}
705 ${EndIf}
706!macroend
707
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100708Function .onInit
709!ifdef HAVE_MULTI_LANG
710 # Select a language (or read from the registry).
711 !insertmacro MUI_LANGDLL_DISPLAY
712!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200713
Christian Brabandt7d603842021-07-24 21:19:42 +0200714 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
715 # Check $VIM
716 ReadEnvStr $3 "VIM"
717 ${If} $3 != ""
718 StrCpy $INSTDIR $3
719 ${EndIf}
720 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100721
722 call CheckOldVim
723 Pop $3
724 ${If} $3 == ""
725 # No old versions of Vim found. Unselect and hide the section.
726 !insertmacro UnselectSection ${id_section_old_ver}
727 SectionSetInstTypes ${id_section_old_ver} 0
728 SectionSetText ${id_section_old_ver} ""
729 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200730 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100731 StrCpy $INSTDIR $3
732 ${EndIf}
733 ${EndIf}
734
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100735 ${If} ${RunningX64}
736 SetRegView 64
737 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200738 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100739 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
740 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
741 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
742 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
743 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
744 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
745 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
746 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
747!ifdef HAVE_VIS_VIM
748 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
749!endif
750!ifdef HAVE_NLS
751 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
752!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200753 # Load the default _vimrc settings from the registry (if any).
754 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
755 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
756 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100757 ${If} ${RunningX64}
758 SetRegView lastused
759 ${EndIf}
760
761 # User variables:
762 # $0 - holds the directory the executables are installed to
763 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
764 # registration (since a non-OLE gvim will not complain, and we want to
765 # always register an OLE gvim).
766 # $2 - holds the names to create batch files for
767 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
768 StrCpy $1 "-register-OLE"
769 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200770FunctionEnd
771
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100772Function .onInstSuccess
773 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
774FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200775
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100776Function .onInstFailed
777 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200778FunctionEnd
779
780##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100781Function SetCustom
782 # Display the _vimrc setting dialog using nsDialogs.
783
784 # Check if a _vimrc should be created
785 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
786 Abort
787 ${EndIf}
788
789 !insertmacro MUI_HEADER_TEXT \
790 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
791
792 nsDialogs::Create 1018
793 Pop $vim_dialog
794
795 ${If} $vim_dialog == error
796 Abort
797 ${EndIf}
798
799 ${If} ${RunningX64}
800 SetRegView 64
801 ${EndIf}
802
803 GetFunctionAddress $3 ValidateCustom
804 nsDialogs::OnBack $3
805
806
807 # 1st group - Compatibility
808 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
809 Pop $3
810
811 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
812 Pop $3
813 ${NSD_CreateDropList} 18% 19% 75% 8% ""
814 Pop $vim_nsd_compat
815 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
816 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
817 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
818 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
819
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200820 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100821 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200822 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100823 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200824 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100825 StrCpy $4 0
826 ${Else} # default
827 StrCpy $4 3
828 ${EndIf}
829 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
830
831
832 # 2nd group - Key remapping
833 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
834 Pop $3
835
836 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
837 Pop $3
838 ${NSD_CreateDropList} 38% 54% 55% 8% ""
839 Pop $vim_nsd_keymap
840 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
841 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
842
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200843 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100844 StrCpy $4 1
845 ${Else} # default
846 StrCpy $4 0
847 ${EndIf}
848 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
849
850
851 # 3rd group - Mouse behavior
852 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
853 Pop $3
854
855 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
856 Pop $3
857 ${NSD_CreateDropList} 23% 87% 70% 8% ""
858 Pop $vim_nsd_mouse
859 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
860 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
861 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
862
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200863 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100864 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200865 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100866 StrCpy $4 1
867 ${Else} # default
868 StrCpy $4 0
869 ${EndIf}
870 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
871
872 ${If} ${RunningX64}
873 SetRegView lastused
874 ${EndIf}
875
876 nsDialogs::Show
877FunctionEnd
878
879Function ValidateCustom
880 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
881 ${If} $3 = 0
882 StrCpy $vim_compat_stat "vi"
883 ${ElseIf} $3 = 1
884 StrCpy $vim_compat_stat "vim"
885 ${ElseIf} $3 = 2
886 StrCpy $vim_compat_stat "defaults"
887 ${Else}
888 StrCpy $vim_compat_stat "all"
889 ${EndIf}
890
891 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
892 ${If} $3 = 0
893 StrCpy $vim_keymap_stat "default"
894 ${Else}
895 StrCpy $vim_keymap_stat "windows"
896 ${EndIf}
897
898 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
899 ${If} $3 = 0
900 StrCpy $vim_mouse_stat "default"
901 ${ElseIf} $3 = 1
902 StrCpy $vim_mouse_stat "windows"
903 ${Else}
904 StrCpy $vim_mouse_stat "xterm"
905 ${EndIf}
906FunctionEnd
907
908##########################################################
909# Description for Installer Sections
910
911!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
924!ifdef HAVE_VIS_VIM
925 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
926!endif
927!ifdef HAVE_NLS
928 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
929!endif
930!insertmacro MUI_FUNCTION_DESCRIPTION_END
931
932
933##########################################################
934# Uninstaller Functions and Sections
935
936Function un.onInit
937!ifdef HAVE_MULTI_LANG
938 # Get the language from the registry.
939 !insertmacro MUI_UNGETLANGUAGE
940!endif
941FunctionEnd
942
943Section "un.$(str_unsection_register)" id_unsection_register
944 SectionIn RO
945
Bram Moolenaar071d4272004-06-13 20:20:40 +0000946 # Apparently $INSTDIR is set to the directory where the uninstaller is
947 # created. Thus the "vim61" directory is included in it.
948 StrCpy $0 "$INSTDIR"
949
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100950!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000951 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100952 ${If} ${FileExists} "$0\VisVim.dll"
953 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
954 ${EndIf}
955!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000956
957 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100958 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200959 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961
962 # We may have been put to the background when uninstall did something.
963 BringToFront
964
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100965 # Delete the installer language setting.
966 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
967SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000968
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100969Section "un.$(str_unsection_exe)" id_unsection_exe
970
971 StrCpy $0 "$INSTDIR"
972
973 # Delete gettext and iconv DLLs
974 ${If} ${FileExists} "$0\libiconv-2.dll"
975 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
976 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200977 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100978 ${If} ${FileExists} "$0\libintl-8.dll"
979 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
980 "$0\libintl-8.dll"
981 ${EndIf}
982 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
983 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
984 "$0\libgcc_s_sjlj-1.dll"
985 ${EndIf}
986
987 # Delete other DLLs
988 Delete /REBOOTOK $0\*.dll
989
990 # Delete 64-bit GvimExt
991 ${If} ${RunningX64}
992 !define LIBRARY_X64
993 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
994 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
995 "$0\GvimExt64\gvimext.dll"
996 ${EndIf}
997 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
998 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
999 "$0\GvimExt64\libiconv-2.dll"
1000 ${EndIf}
1001 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1002 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1003 "$0\GvimExt64\libintl-8.dll"
1004 ${EndIf}
1005 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1006 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1007 "$0\GvimExt64\libwinpthread-1.dll"
1008 ${EndIf}
1009 !undef LIBRARY_X64
1010 RMDir /r $0\GvimExt64
1011 ${EndIf}
1012
1013 # Delete 32-bit GvimExt
1014 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1015 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1016 "$0\GvimExt32\gvimext.dll"
1017 ${EndIf}
1018 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1019 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1020 "$0\GvimExt32\libiconv-2.dll"
1021 ${EndIf}
1022 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1023 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1024 "$0\GvimExt32\libintl-8.dll"
1025 ${EndIf}
1026 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1027 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1028 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1029 ${EndIf}
1030 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001031
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 ClearErrors
1033 # Remove everything but *.dll files. Avoids that
1034 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001035 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001036 RMDir /r $0\colors
1037 RMDir /r $0\compiler
1038 RMDir /r $0\doc
1039 RMDir /r $0\ftplugin
1040 RMDir /r $0\indent
1041 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001042 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001044 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 RMDir /r $0\syntax
1046 RMDir /r $0\tools
1047 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001048!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001050!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 RMDir /r $0\lang
1052 RMDir /r $0\keymap
1053 Delete $0\*.exe
1054 Delete $0\*.bat
1055 Delete $0\*.vim
1056 Delete $0\*.txt
1057
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001058 ${If} ${Errors}
1059 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1060 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061
1062 # No error message if the "vim62" directory can't be removed, the
1063 # gvimext.dll may still be there.
1064 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001065SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001067# Remove "vimfiles" directory under the specified directory.
1068!macro RemoveVimfiles dir
1069 ${If} ${FileExists} ${dir}\vimfiles
1070 RMDir ${dir}\vimfiles\colors
1071 RMDir ${dir}\vimfiles\compiler
1072 RMDir ${dir}\vimfiles\doc
1073 RMDir ${dir}\vimfiles\ftdetect
1074 RMDir ${dir}\vimfiles\ftplugin
1075 RMDir ${dir}\vimfiles\indent
1076 RMDir ${dir}\vimfiles\keymap
1077 RMDir ${dir}\vimfiles\plugin
1078 RMDir ${dir}\vimfiles\syntax
1079 RMDir ${dir}\vimfiles
1080 ${EndIf}
1081!macroend
1082
1083SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1084 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1085 # get the home dir
1086 ReadEnvStr $0 "HOME"
1087 ${If} $0 == ""
1088 ReadEnvStr $0 "HOMEDRIVE"
1089 ReadEnvStr $1 "HOMEPATH"
1090 StrCpy $0 "$0$1"
1091 ${If} $0 == ""
1092 ReadEnvStr $0 "USERPROFILE"
1093 ${EndIf}
1094 ${EndIf}
1095
1096 ${If} $0 != ""
1097 !insertmacro RemoveVimfiles $0
1098 ${EndIf}
1099 SectionEnd
1100
1101 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1102 # get the parent dir of the installation
1103 Push $INSTDIR
1104 Call un.GetParent
1105 Pop $0
1106
1107 # if a plugin dir was created at installation remove it
1108 !insertmacro RemoveVimfiles $0
1109 SectionEnd
1110SectionGroupEnd
1111
1112Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 # get the parent dir of the installation
1114 Push $INSTDIR
1115 Call un.GetParent
1116 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001118 ${IfNot} ${Silent}
1119 Delete $0\_vimrc
1120 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001121 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001123
1124##########################################################
1125# Description for Uninstaller Sections
1126
1127!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1128 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1129 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1130 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1131 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1132 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1133 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1134!insertmacro MUI_UNFUNCTION_DESCRIPTION_END