blob: d71cffb8b0252b49990492c6b62848bf5ac51cba [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
Christian Brabandtcf6ad8e2022-02-13 13:11:32 +0000351!if /FileExists "${VIMRT}\libsodium.dll"
352 File ${VIMRT}\libsodium.dll
353!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200355 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200357 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100359 File ..\vimtutor.bat
360 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200361 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200364 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100365 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200366 File ${VIMTOOLS}\winpty-agent.exe
367
Bram Moolenaar071d4272004-06-13 20:20:40 +0000368 SetOutPath $0\colors
369 File ${VIMRT}\colors\*.*
Bram Moolenaard0bce502021-02-26 20:25:35 +0100370 SetOutPath $0\colors\tools
371 File ${VIMRT}\colors\tools\*.*
Drew Vogele30d1022021-10-24 20:35:07 +0100372 SetOutPath $0\colors\lists
373 File ${VIMRT}\colors\lists\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374
375 SetOutPath $0\compiler
376 File ${VIMRT}\compiler\*.*
377
378 SetOutPath $0\doc
379 File ${VIMRT}\doc\*.txt
380 File ${VIMRT}\doc\tags
381
382 SetOutPath $0\ftplugin
383 File ${VIMRT}\ftplugin\*.*
384
385 SetOutPath $0\indent
386 File ${VIMRT}\indent\*.*
387
388 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100389 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100391 SetOutPath $0\pack
392 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200393
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394 SetOutPath $0\plugin
395 File ${VIMRT}\plugin\*.*
396
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000397 SetOutPath $0\autoload
398 File ${VIMRT}\autoload\*.*
399
Bram Moolenaard09a2062017-11-11 15:37:45 +0100400 SetOutPath $0\autoload\dist
401 File ${VIMRT}\autoload\dist\*.*
402
Bram Moolenaar18144c82006-04-12 21:52:12 +0000403 SetOutPath $0\autoload\xml
404 File ${VIMRT}\autoload\xml\*.*
405
Bram Moolenaar44433da2022-05-06 18:08:52 +0100406 SetOutPath $0\import\dist
407 File ${VIMRT}\import\dist\*.*
408
Christian Brabandt176711f2022-03-11 15:24:11 +0000409 SetOutPath $0\bitmaps
410 File ${VIMSRC}\vim.ico
411
Bram Moolenaar071d4272004-06-13 20:20:40 +0000412 SetOutPath $0\syntax
413 File ${VIMRT}\syntax\*.*
414
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000415 SetOutPath $0\spell
416 File ${VIMRT}\spell\*.txt
417 File ${VIMRT}\spell\*.vim
418 File ${VIMRT}\spell\*.spl
419 File ${VIMRT}\spell\*.sug
420
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421 SetOutPath $0\tools
422 File ${VIMRT}\tools\*.*
423
424 SetOutPath $0\tutor
425 File ${VIMRT}\tutor\*.*
426SectionEnd
427
428##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100429Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430 SectionIn 1 3
431
432 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100433 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434 StrCpy $2 "$2 vim view vimdiff"
435SectionEnd
436
437##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100438Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000439 SectionIn 3
440
441 StrCpy $1 "$1 -create-batfiles $2"
442SectionEnd
443
444##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100445SectionGroup $(str_group_icons) id_group_icons
446 Section "$(str_section_desktop)" id_section_desktop
447 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100449 StrCpy $1 "$1 -install-icons"
450 SectionEnd
451
452 Section "$(str_section_start_menu)" id_section_startmenu
453 SectionIn 1 3
454
455 StrCpy $1 "$1 -add-start-menu"
456 SectionEnd
457SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000458
459##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100460Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000461 SectionIn 1 3
462
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200464
Bram Moolenaar442b4222010-05-24 21:34:22 +0200465 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200466 # Install 64-bit gvimext.dll into the GvimExt64 directory.
467 SetOutPath $0\GvimExt64
468 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100469 !define LIBRARY_SHELL_EXTENSION
470 !define LIBRARY_X64
471 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
472 "${VIMSRC}\GvimExt\gvimext64.dll" \
473 "$0\GvimExt64\gvimext.dll" "$0"
474 !undef LIBRARY_X64
475 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200476 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200477
Bram Moolenaar6199d432017-10-14 19:05:44 +0200478 # Install 32-bit gvimext.dll into the GvimExt32 directory.
479 SetOutPath $0\GvimExt32
480 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100481 !define LIBRARY_SHELL_EXTENSION
482 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
483 "${VIMSRC}\GvimExt\gvimext.dll" \
484 "$0\GvimExt32\gvimext.dll" "$0"
485 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486
487 # We don't have a separate entry for the "Open With..." menu, assume
488 # the user wants either both or none.
489 StrCpy $1 "$1 -install-popup -install-openwith"
490SectionEnd
491
492##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100493Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000494 SectionIn 1 3
495
496 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100497
498 ${If} ${RunningX64}
499 SetRegView 64
500 ${EndIf}
501 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
502 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
503 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
504 ${If} ${RunningX64}
505 SetRegView lastused
506 ${EndIf}
507
508 ${If} $vim_compat_stat == "vi"
509 StrCpy $1 "$1 -vimrc-compat vi"
510 ${ElseIf} $vim_compat_stat == "vim"
511 StrCpy $1 "$1 -vimrc-compat vim"
512 ${ElseIf} $vim_compat_stat == "defaults"
513 StrCpy $1 "$1 -vimrc-compat defaults"
514 ${Else}
515 StrCpy $1 "$1 -vimrc-compat all"
516 ${EndIf}
517
518 ${If} $vim_keymap_stat == "default"
519 StrCpy $1 "$1 -vimrc-remap no"
520 ${Else}
521 StrCpy $1 "$1 -vimrc-remap win"
522 ${EndIf}
523
524 ${If} $vim_mouse_stat == "default"
525 StrCpy $1 "$1 -vimrc-behave default"
526 ${ElseIf} $vim_mouse_stat == "windows"
527 StrCpy $1 "$1 -vimrc-behave mswin"
528 ${Else}
529 StrCpy $1 "$1 -vimrc-behave unix"
530 ${EndIf}
531
Bram Moolenaar071d4272004-06-13 20:20:40 +0000532SectionEnd
533
534##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100535SectionGroup $(str_group_plugin) id_group_plugin
536 Section "$(str_section_plugin_home)" id_section_pluginhome
537 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100539 StrCpy $1 "$1 -create-directories home"
540 SectionEnd
541
542 Section "$(str_section_plugin_vim)" id_section_pluginvim
543 SectionIn 3
544
545 StrCpy $1 "$1 -create-directories vim"
546 SectionEnd
547SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000548
549##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100550!ifdef HAVE_VIS_VIM
551Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000552 SectionIn 3
553
554 SetOutPath $0
555 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
556 File ${VIMSRC}\VisVim\README_VisVim.txt
557SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100558!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000559
560##########################################################
561!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100562Section "$(str_section_nls)" id_section_nls
563 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000564
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100565 SetOutPath $0\lang
566 File /r ${VIMRT}\lang\*.*
567 SetOutPath $0\keymap
568 File ${VIMRT}\keymap\README.txt
569 File ${VIMRT}\keymap\*.vim
570 SetOutPath $0
571 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
572 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
573 "$0\libintl-8.dll" "$0"
574 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
575 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
576 "$0\libiconv-2.dll" "$0"
577 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
578 # Install libgcc_s_sjlj-1.dll only if it is needed.
579 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
580 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
581 "$0\libgcc_s_sjlj-1.dll" "$0"
582 !endif
583
584 ${If} ${SectionIsSelected} ${id_section_editwith}
585 ${If} ${RunningX64}
586 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
587 SetOutPath $0\GvimExt64
588 ClearErrors
589 !define LIBRARY_X64
590 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
591 "${GETTEXT}\gettext64\libintl-8.dll" \
592 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
593 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
594 "${GETTEXT}\gettext64\libiconv-2.dll" \
595 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
596 !undef LIBRARY_X64
597 ${EndIf}
598
599 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
600 SetOutPath $0\GvimExt32
601 ClearErrors
602 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
603 "${GETTEXT}\gettext32\libintl-8.dll" \
604 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
605 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
606 "${GETTEXT}\gettext32\libiconv-2.dll" \
607 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
608 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
609 # Install libgcc_s_sjlj-1.dll only if it is needed.
610 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
611 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
612 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
613 !endif
614 ${EndIf}
615SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000616!endif
617
618##########################################################
619Section -call_install_exe
620 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100621 DetailPrint "$(str_msg_registering)"
622 nsExec::Exec "$0\install.exe $1"
623 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000624SectionEnd
625
626##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100627!macro SaveSectionSelection section_id reg_value
628 ${If} ${SectionIsSelected} ${section_id}
629 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
630 ${Else}
631 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
632 ${EndIf}
633!macroend
634
Bram Moolenaar071d4272004-06-13 20:20:40 +0000635Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100636
637 # Get estimated install size
638 SectionGetSize ${id_section_exe} $3
639 ${If} ${SectionIsSelected} ${id_section_console}
640 SectionGetSize ${id_section_console} $4
641 IntOp $3 $3 + $4
642 ${EndIf}
643 ${If} ${SectionIsSelected} ${id_section_editwith}
644 SectionGetSize ${id_section_editwith} $4
645 IntOp $3 $3 + $4
646 ${EndIf}
647!ifdef HAVE_VIS_VIM
648 ${If} ${SectionIsSelected} ${id_section_visvim}
649 SectionGetSize ${id_section_visvim} $4
650 IntOp $3 $3 + $4
651 ${EndIf}
652!endif
653!ifdef HAVE_NLS
654 ${If} ${SectionIsSelected} ${id_section_nls}
655 SectionGetSize ${id_section_nls} $4
656 IntOp $3 $3 + $4
657 ${EndIf}
658!endif
659
660 # Register EstimatedSize and AllowSilent.
661 # Other information will be set by the install.exe (dosinst.c).
662 ${If} ${RunningX64}
663 SetRegView 64
664 ${EndIf}
665 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
666 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
667 ${If} ${RunningX64}
668 SetRegView lastused
669 ${EndIf}
670
671 # Store the selections to the registry.
672 ${If} ${RunningX64}
673 SetRegView 64
674 ${EndIf}
675 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
676 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
677 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
678 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
679 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
680 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
681 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
682 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
683!ifdef HAVE_VIS_VIM
684 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
685!endif
686!ifdef HAVE_NLS
687 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
688!endif
689 ${If} ${RunningX64}
690 SetRegView lastused
691 ${EndIf}
692
Bram Moolenaar071d4272004-06-13 20:20:40 +0000693 BringToFront
694SectionEnd
695
696##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100697!macro LoadSectionSelection section_id reg_value
698 ClearErrors
699 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
700 ${IfNot} ${Errors}
701 ${If} $3 = 1
702 !insertmacro SelectSection ${section_id}
703 ${Else}
704 !insertmacro UnselectSection ${section_id}
705 ${EndIf}
706 ${EndIf}
707!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200708
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200709!macro LoadDefaultVimrc out_var reg_value default_value
710 ClearErrors
711 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
712 ${If} ${Errors}
713 ${OrIf} ${out_var} == ""
714 StrCpy ${out_var} ${default_value}
715 ${EndIf}
716!macroend
717
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100718Function .onInit
719!ifdef HAVE_MULTI_LANG
720 # Select a language (or read from the registry).
721 !insertmacro MUI_LANGDLL_DISPLAY
722!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200723
Christian Brabandt7d603842021-07-24 21:19:42 +0200724 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
725 # Check $VIM
726 ReadEnvStr $3 "VIM"
727 ${If} $3 != ""
728 StrCpy $INSTDIR $3
729 ${EndIf}
730 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100731
732 call CheckOldVim
733 Pop $3
734 ${If} $3 == ""
735 # No old versions of Vim found. Unselect and hide the section.
736 !insertmacro UnselectSection ${id_section_old_ver}
737 SectionSetInstTypes ${id_section_old_ver} 0
738 SectionSetText ${id_section_old_ver} ""
739 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200740 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100741 StrCpy $INSTDIR $3
742 ${EndIf}
743 ${EndIf}
744
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100745 ${If} ${RunningX64}
746 SetRegView 64
747 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200748 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100749 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
750 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
751 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
752 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
753 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
754 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
755 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
756 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
757!ifdef HAVE_VIS_VIM
758 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
759!endif
760!ifdef HAVE_NLS
761 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
762!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200763 # Load the default _vimrc settings from the registry (if any).
764 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
765 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
766 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100767 ${If} ${RunningX64}
768 SetRegView lastused
769 ${EndIf}
770
771 # User variables:
772 # $0 - holds the directory the executables are installed to
773 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
774 # registration (since a non-OLE gvim will not complain, and we want to
775 # always register an OLE gvim).
776 # $2 - holds the names to create batch files for
777 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
778 StrCpy $1 "-register-OLE"
779 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200780FunctionEnd
781
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100782Function .onInstSuccess
783 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
784FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200785
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100786Function .onInstFailed
787 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200788FunctionEnd
789
790##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100791Function SetCustom
792 # Display the _vimrc setting dialog using nsDialogs.
793
794 # Check if a _vimrc should be created
795 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
796 Abort
797 ${EndIf}
798
799 !insertmacro MUI_HEADER_TEXT \
800 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
801
802 nsDialogs::Create 1018
803 Pop $vim_dialog
804
805 ${If} $vim_dialog == error
806 Abort
807 ${EndIf}
808
809 ${If} ${RunningX64}
810 SetRegView 64
811 ${EndIf}
812
813 GetFunctionAddress $3 ValidateCustom
814 nsDialogs::OnBack $3
815
816
817 # 1st group - Compatibility
818 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
819 Pop $3
820
821 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
822 Pop $3
823 ${NSD_CreateDropList} 18% 19% 75% 8% ""
824 Pop $vim_nsd_compat
825 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
826 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
827 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
828 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
829
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200830 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100831 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200832 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100833 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200834 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100835 StrCpy $4 0
836 ${Else} # default
837 StrCpy $4 3
838 ${EndIf}
839 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
840
841
842 # 2nd group - Key remapping
843 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
844 Pop $3
845
846 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
847 Pop $3
848 ${NSD_CreateDropList} 38% 54% 55% 8% ""
849 Pop $vim_nsd_keymap
850 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
851 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
852
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200853 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100854 StrCpy $4 1
855 ${Else} # default
856 StrCpy $4 0
857 ${EndIf}
858 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
859
860
861 # 3rd group - Mouse behavior
862 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
863 Pop $3
864
865 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
866 Pop $3
867 ${NSD_CreateDropList} 23% 87% 70% 8% ""
868 Pop $vim_nsd_mouse
869 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
870 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
871 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
872
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200873 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100874 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200875 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100876 StrCpy $4 1
877 ${Else} # default
878 StrCpy $4 0
879 ${EndIf}
880 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
881
882 ${If} ${RunningX64}
883 SetRegView lastused
884 ${EndIf}
885
886 nsDialogs::Show
887FunctionEnd
888
889Function ValidateCustom
890 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
891 ${If} $3 = 0
892 StrCpy $vim_compat_stat "vi"
893 ${ElseIf} $3 = 1
894 StrCpy $vim_compat_stat "vim"
895 ${ElseIf} $3 = 2
896 StrCpy $vim_compat_stat "defaults"
897 ${Else}
898 StrCpy $vim_compat_stat "all"
899 ${EndIf}
900
901 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
902 ${If} $3 = 0
903 StrCpy $vim_keymap_stat "default"
904 ${Else}
905 StrCpy $vim_keymap_stat "windows"
906 ${EndIf}
907
908 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
909 ${If} $3 = 0
910 StrCpy $vim_mouse_stat "default"
911 ${ElseIf} $3 = 1
912 StrCpy $vim_mouse_stat "windows"
913 ${Else}
914 StrCpy $vim_mouse_stat "xterm"
915 ${EndIf}
916FunctionEnd
917
918##########################################################
919# Description for Installer Sections
920
921!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
925 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
927 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
928 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
929 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
930 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
931 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
932 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
933 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
934!ifdef HAVE_VIS_VIM
935 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
936!endif
937!ifdef HAVE_NLS
938 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
939!endif
940!insertmacro MUI_FUNCTION_DESCRIPTION_END
941
942
943##########################################################
944# Uninstaller Functions and Sections
945
946Function un.onInit
947!ifdef HAVE_MULTI_LANG
948 # Get the language from the registry.
949 !insertmacro MUI_UNGETLANGUAGE
950!endif
951FunctionEnd
952
953Section "un.$(str_unsection_register)" id_unsection_register
954 SectionIn RO
955
Bram Moolenaar071d4272004-06-13 20:20:40 +0000956 # Apparently $INSTDIR is set to the directory where the uninstaller is
957 # created. Thus the "vim61" directory is included in it.
958 StrCpy $0 "$INSTDIR"
959
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000961 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100962 ${If} ${FileExists} "$0\VisVim.dll"
963 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
964 ${EndIf}
965!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000966
967 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100968 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200969 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100970 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000971
972 # We may have been put to the background when uninstall did something.
973 BringToFront
974
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100975 # Delete the installer language setting.
976 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
977SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000978
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100979Section "un.$(str_unsection_exe)" id_unsection_exe
980
981 StrCpy $0 "$INSTDIR"
982
983 # Delete gettext and iconv DLLs
984 ${If} ${FileExists} "$0\libiconv-2.dll"
985 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
986 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200987 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100988 ${If} ${FileExists} "$0\libintl-8.dll"
989 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
990 "$0\libintl-8.dll"
991 ${EndIf}
992 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
993 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
994 "$0\libgcc_s_sjlj-1.dll"
995 ${EndIf}
996
997 # Delete other DLLs
998 Delete /REBOOTOK $0\*.dll
999
1000 # Delete 64-bit GvimExt
1001 ${If} ${RunningX64}
1002 !define LIBRARY_X64
1003 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1004 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1005 "$0\GvimExt64\gvimext.dll"
1006 ${EndIf}
1007 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1008 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1009 "$0\GvimExt64\libiconv-2.dll"
1010 ${EndIf}
1011 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1012 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1013 "$0\GvimExt64\libintl-8.dll"
1014 ${EndIf}
1015 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1016 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1017 "$0\GvimExt64\libwinpthread-1.dll"
1018 ${EndIf}
1019 !undef LIBRARY_X64
1020 RMDir /r $0\GvimExt64
1021 ${EndIf}
1022
1023 # Delete 32-bit GvimExt
1024 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1025 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1026 "$0\GvimExt32\gvimext.dll"
1027 ${EndIf}
1028 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1029 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1030 "$0\GvimExt32\libiconv-2.dll"
1031 ${EndIf}
1032 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1033 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1034 "$0\GvimExt32\libintl-8.dll"
1035 ${EndIf}
1036 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1037 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1038 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1039 ${EndIf}
1040 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001041
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 ClearErrors
1043 # Remove everything but *.dll files. Avoids that
1044 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001045 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 RMDir /r $0\colors
1047 RMDir /r $0\compiler
1048 RMDir /r $0\doc
1049 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001050 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 RMDir /r $0\indent
1052 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001053 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001054 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001055 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056 RMDir /r $0\syntax
1057 RMDir /r $0\tools
1058 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001059!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001061!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062 RMDir /r $0\lang
1063 RMDir /r $0\keymap
1064 Delete $0\*.exe
1065 Delete $0\*.bat
1066 Delete $0\*.vim
1067 Delete $0\*.txt
1068
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001069 ${If} ${Errors}
1070 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1071 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001072
1073 # No error message if the "vim62" directory can't be removed, the
1074 # gvimext.dll may still be there.
1075 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001076SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001078# Remove "vimfiles" directory under the specified directory.
1079!macro RemoveVimfiles dir
1080 ${If} ${FileExists} ${dir}\vimfiles
1081 RMDir ${dir}\vimfiles\colors
1082 RMDir ${dir}\vimfiles\compiler
1083 RMDir ${dir}\vimfiles\doc
1084 RMDir ${dir}\vimfiles\ftdetect
1085 RMDir ${dir}\vimfiles\ftplugin
1086 RMDir ${dir}\vimfiles\indent
1087 RMDir ${dir}\vimfiles\keymap
1088 RMDir ${dir}\vimfiles\plugin
1089 RMDir ${dir}\vimfiles\syntax
1090 RMDir ${dir}\vimfiles
1091 ${EndIf}
1092!macroend
1093
1094SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1095 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1096 # get the home dir
1097 ReadEnvStr $0 "HOME"
1098 ${If} $0 == ""
1099 ReadEnvStr $0 "HOMEDRIVE"
1100 ReadEnvStr $1 "HOMEPATH"
1101 StrCpy $0 "$0$1"
1102 ${If} $0 == ""
1103 ReadEnvStr $0 "USERPROFILE"
1104 ${EndIf}
1105 ${EndIf}
1106
1107 ${If} $0 != ""
1108 !insertmacro RemoveVimfiles $0
1109 ${EndIf}
1110 SectionEnd
1111
1112 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1113 # get the parent dir of the installation
1114 Push $INSTDIR
1115 Call un.GetParent
1116 Pop $0
1117
1118 # if a plugin dir was created at installation remove it
1119 !insertmacro RemoveVimfiles $0
1120 SectionEnd
1121SectionGroupEnd
1122
1123Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001124 # get the parent dir of the installation
1125 Push $INSTDIR
1126 Call un.GetParent
1127 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001128
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001129 ${IfNot} ${Silent}
1130 Delete $0\_vimrc
1131 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001132 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001134
1135##########################################################
1136# Description for Uninstaller Sections
1137
1138!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1139 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1140 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1141 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1142 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1143 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1144 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1145!insertmacro MUI_UNFUNCTION_DESCRIPTION_END