blob: 754e9ca28ea6ca289f71bf1d0a9064847ddeb553 [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.
Restorer51c94b62024-03-24 09:41:18 +00003# Last Change: 2024 Mar 18
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
Restorer51c94b62024-03-24 09:41:18 +000020# Location of extra tools: diff.exe, winpty{32|64}.dll, winpty-agent.exe, etc.
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
Restorer51c94b62024-03-24 09:41:18 +000032# If you have UPX, use the switch /DHAVE_UPX=1 on the command line makensis.exe.
33# This property will be set to 1. Get it at https://upx.github.io/
34!ifndef HAVE_UPX
35 !define HAVE_UPX 0
36!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000037
Restorer51c94b62024-03-24 09:41:18 +000038# If you do not want to add Native Language Support, use the switch /DHAVE_NLS=0
39# in the command line makensis.exe. This property will be set to 0.
40!ifndef HAVE_NLS
41 !define HAVE_NLS 1
42!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Restorer51c94b62024-03-24 09:41:18 +000044# To create an English-only the installer, use the switch /DHAVE_MULTI_LANG=0 on
45# the command line makensis.exe. This property will be set to 0.
46!ifndef HAVE_MULTI_LANG
47 !define HAVE_MULTI_LANG 1
48!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +010049
Restorer51c94b62024-03-24 09:41:18 +000050# if you want to create a 64-bit the installer, use the switch /DWIN64=1 on
51# the command line makensis.exe. This property will be set to 1.
52!ifndef WIN64
53 !define WIN64 0
54!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +010055
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010056!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
Restorer51c94b62024-03-24 09:41:18 +000058# Definition of Patch for Vim.
Bram Moolenaar9d591522019-05-26 20:49:42 +020059!ifndef PATCHLEVEL
60 !define PATCHLEVEL 0
61!endif
62
Bram Moolenaar071d4272004-06-13 20:20:40 +000063# ----------- No configurable settings below this line -----------
64
Restorer51c94b62024-03-24 09:41:18 +000065!include "Library.nsh" # for DLL install
Bram Moolenaaraf610b82018-12-21 16:22:50 +010066!include "LogicLib.nsh"
67!include "MUI2.nsh"
68!include "nsDialogs.nsh"
69!include "Sections.nsh"
70!include "x64.nsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +000071
RestorerZ2680a072024-03-20 20:15:51 +010072# See https://nsis.sourceforge.io/LogicLib
73;FileExists is already part of LogicLib, but returns true for directories
74;as well as files
75!macro _FileExists2 _a _b _t _f
76 !insertmacro _LOGICLIB_TEMP
77 StrCpy $_LOGICLIB_TEMP "0"
78;if path is not blank, continue to next check
79 StrCmp `${_b}` `` +4 0
80;if path exists, continue to next check (IfFileExists returns true if this
81;is a directory)
82 IfFileExists `${_b}` `0` +3
83;if path is not a directory, continue to confirm exists
84 IfFileExists `${_b}\*.*` +2 0
85 StrCpy $_LOGICLIB_TEMP "1" ;file exists
86;now we have a definitive value - the file exists or it does not
87 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
88!macroend
89!undef FileExists
90!define FileExists `"" FileExists2`
91!macro _DirExists _a _b _t _f
92 !insertmacro _LOGICLIB_TEMP
93 StrCpy $_LOGICLIB_TEMP "0"
94;if path is not blank, continue to next check
95 StrCmp `${_b}` `` +3 0
96;if directory exists, continue to confirm exists
97 IfFileExists `${_b}\*.*` 0 +2
98 StrCpy $_LOGICLIB_TEMP "1"
99 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
100!macroend
101!define DirExists `"" DirExists`
102
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100103!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
104!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
105!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
106
Restorer51c94b62024-03-24 09:41:18 +0000107!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100108Name "${PRODUCT} (x64)"
109!else
110Name "${PRODUCT}"
111!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000112OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
113CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +0100114SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100115SetCompressorDictSize 64
116ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +0200118RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119
Restorer51c94b62024-03-24 09:41:18 +0000120!if ${HAVE_UPX}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000121 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
122!endif
123
Restorer51c94b62024-03-24 09:41:18 +0000124!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100125!define BIT 64
126!else
127!define BIT 32
128!endif
129
130##########################################################
131# MUI2 settings
132
133!define MUI_ABORTWARNING
134!define MUI_UNABORTWARNING
135
136!define MUI_ICON "icons\vim_16c.ico"
137!define MUI_UNICON "icons\vim_uninst_16c.ico"
138
139# Show all languages, despite user's codepage:
140!define MUI_LANGDLL_ALLLANGUAGES
Restorer6dcf59b2024-03-25 15:38:37 +0000141# Always show dialog choice language
142#!define MUI_LANGDLL_ALWAYSSHOW
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100143!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
144!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
145!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
146
147!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
148!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
149!define MUI_HEADERIMAGE
150!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
151!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
152
153!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
154!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
155!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
156!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
157
158!define MUI_COMPONENTSPAGE_SMALLDESC
159!define MUI_LICENSEPAGE_CHECKBOX
Bram Moolenaar4a228972021-05-01 22:41:39 +0200160!define MUI_FINISHPAGE_RUN
161!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100162!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100163
164# This adds '\Vim' to the user choice automagically. The actual value is
165# obtained below with CheckOldVim.
Restorer51c94b62024-03-24 09:41:18 +0000166!if ${WIN64}
Christian Brabandt7d603842021-07-24 21:19:42 +0200167 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100168!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200169 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100170!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200171InstallDir ${DEFAULT_INSTDIR}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000172
173# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100174InstType $(str_type_typical)
175InstType $(str_type_minimal)
176InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000177
178SilentInstall normal
179
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100180# General custom functions for MUI2:
181#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
182#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
183
184# Installer pages
185!insertmacro MUI_PAGE_WELCOME
186!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
187!insertmacro MUI_PAGE_COMPONENTS
188Page custom SetCustom ValidateCustom
189#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
190!insertmacro MUI_PAGE_DIRECTORY
191!insertmacro MUI_PAGE_INSTFILES
192!define MUI_FINISHPAGE_NOREBOOTSUPPORT
193!insertmacro MUI_PAGE_FINISH
194
195# Uninstaller pages:
196!insertmacro MUI_UNPAGE_CONFIRM
197#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
198!insertmacro MUI_UNPAGE_COMPONENTS
199!insertmacro MUI_UNPAGE_INSTFILES
200!define MUI_FINISHPAGE_NOREBOOTSUPPORT
201!insertmacro MUI_UNPAGE_FINISH
202
203##########################################################
204# Languages Files
205
206!insertmacro MUI_RESERVEFILE_LANGDLL
207!include "lang\english.nsi"
208
209# Include support for other languages:
Restorer51c94b62024-03-24 09:41:18 +0000210!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100211 !include "lang\danish.nsi"
212 !include "lang\dutch.nsi"
213 !include "lang\german.nsi"
Christos Longrosc62dacb2024-03-06 20:53:02 +0100214 !include "lang\greek.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100215 !include "lang\italian.nsi"
216 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200217 !include "lang\russian.nsi"
Ivan Pešiće1051922024-03-05 23:34:00 +0400218 !include "lang\serbian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100219 !include "lang\simpchinese.nsi"
220 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100221 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100222!endif
223
Bram Moolenaardabfde02019-05-17 12:37:27 +0200224##########################################################
225# Version resources
226
227VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
228VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
229VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
230VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
231VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200232VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
233VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100234
235# Global variables
236Var vim_dialog
237Var vim_nsd_compat
238Var vim_nsd_keymap
239Var vim_nsd_mouse
240Var vim_compat_stat
241Var vim_keymap_stat
242Var vim_mouse_stat
243
Bram Moolenaar071d4272004-06-13 20:20:40 +0000244
Bram Moolenaar5d424742018-02-04 19:11:30 +0100245# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100246ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100247
Bram Moolenaar071d4272004-06-13 20:20:40 +0000248##########################################################
249# Functions
250
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100251# Get parent directory
252# Share this function both on installer and uninstaller
253!macro GetParent un
254Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000255 Exch $0 ; old $0 is on top of stack
256 Push $1
257 Push $2
258 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100259 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000260 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100261 ${If} $2 == ""
262 ${OrIf} $2 == "\"
263 ${ExitDo}
264 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100266 ${Loop}
267 StrCpy $0 $0 $1
268 Pop $2
269 Pop $1
270 Exch $0 ; put $0 on top of stack, restore $0 to original value
271FunctionEnd
272!macroend
273
274!insertmacro GetParent ""
275!insertmacro GetParent "un."
276
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000277# Get home directory
278!macro GetHomeDir un
279Function ${un}GetHomeDir
280 Push $0
281 Push $1
282 ReadEnvStr $0 "HOME"
283 ${If} $0 == ""
284 ReadEnvStr $0 "HOMEDRIVE"
285 ReadEnvStr $1 "HOMEPATH"
286 StrCpy $0 "$0$1"
287 ${If} $0 == ""
288 ReadEnvStr $0 "USERPROFILE"
289 ${EndIf}
290 ${EndIf}
291 Pop $1
292 Exch $0 # put $0 on top of stack, restore $0 to original value
293FunctionEnd
294!macroend
295
296!insertmacro GetHomeDir ""
297!insertmacro GetHomeDir "un."
298
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100299# Check if Vim is already installed.
300# return: Installed directory. If not found, it will be empty.
301Function CheckOldVim
302 Push $0
303 Push $R0
304 Push $R1
305 Push $R2
306
307 ${If} ${RunningX64}
308 SetRegView 64
309 ${EndIf}
310
311 ClearErrors
312 StrCpy $0 "" # Installed directory
313 StrCpy $R0 0 # Sub-key index
314 StrCpy $R1 "" # Sub-key
315 ${Do}
316 # Eumerate the sub-key:
317 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
318
319 # Stop if no more sub-key:
320 ${If} ${Errors}
321 ${OrIf} $R1 == ""
322 ${ExitDo}
323 ${EndIf}
324
325 # Move to the next sub-key:
326 IntOp $R0 $R0 + 1
327
328 # Check if the key is Vim uninstall key or not:
329 StrCpy $R2 $R1 4
330 ${If} $R2 S!= "Vim "
331 ${Continue}
332 ${EndIf}
333
334 # Verifies required sub-keys:
335 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
336 ${If} ${Errors}
337 ${OrIf} $R2 == ""
338 ${Continue}
339 ${EndIf}
340
341 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
342 ${If} ${Errors}
343 ${OrIf} $R2 == ""
344 ${Continue}
345 ${EndIf}
346
347 # Found
348 Push $R2
349 call GetParent
350 call GetParent
351 Pop $0 # Vim directory
352 ${ExitDo}
353
354 ${Loop}
355
356 ${If} ${RunningX64}
357 SetRegView lastused
358 ${EndIf}
359
360 Pop $R2
361 Pop $R1
362 Pop $R0
363 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364FunctionEnd
365
Bram Moolenaar4a228972021-05-01 22:41:39 +0200366Function LaunchApplication
367 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200368 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200369FunctionEnd
370
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100372Section "$(str_section_old_ver)" id_section_old_ver
373 SectionIn 1 2 3 RO
374
375 # run the install program to check for already installed versions
376 SetOutPath $TEMP
377 File /oname=install.exe ${VIMSRC}\installw32.exe
378 DetailPrint "$(str_msg_uninstalling)"
379 ${Do}
380 nsExec::Exec "$TEMP\install.exe -uninstall-check"
381 Pop $3
382
383 call CheckOldVim
384 Pop $3
385 ${If} $3 == ""
386 ${ExitDo}
387 ${Else}
388 # It seems that the old version is still remaining.
389 # TODO: Should we show a warning and run the uninstaller again?
390
391 ${ExitDo} # Just ignore for now.
392 ${EndIf}
393 ${Loop}
394 Delete $TEMP\install.exe
395 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
396
397 # We may have been put to the background when uninstall did something.
398 BringToFront
399SectionEnd
400
401##########################################################
402Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200403 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404
405 # we need also this here if the user changes the instdir
406 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
407
408 SetOutPath $0
409 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200410!if /FileExists "${VIMSRC}\vim${BIT}.dll"
411 File ${VIMSRC}\vim${BIT}.dll
412!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000413 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200414 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000415 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200416 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000417 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100418 File ..\vimtutor.bat
419 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200420 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000422
RestorerZ2680a072024-03-20 20:15:51 +0100423!if /FileExists "${VIMTOOLS}\diff.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200424 File ${VIMTOOLS}\diff.exe
RestorerZ2680a072024-03-20 20:15:51 +0100425!endif
426!if /FileExists "${VIMTOOLS}\winpty${BIT}.dll"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100427 File ${VIMTOOLS}\winpty${BIT}.dll
RestorerZ2680a072024-03-20 20:15:51 +0100428!endif
429!if /FileExists "${VIMTOOLS}\winpty-agent.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200430 File ${VIMTOOLS}\winpty-agent.exe
RestorerZ2680a072024-03-20 20:15:51 +0100431!endif
432!if /FileExists "${VIMTOOLS}\libsodium.dll"
433 File ${VIMTOOLS}\libsodium.dll
434!endif
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200435
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100437 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438
439 SetOutPath $0\compiler
440 File ${VIMRT}\compiler\*.*
441
442 SetOutPath $0\doc
RestorerZ2680a072024-03-20 20:15:51 +0100443 File /x uganda.nsis.txt ${VIMRT}\doc\*.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444 File ${VIMRT}\doc\tags
445
446 SetOutPath $0\ftplugin
447 File ${VIMRT}\ftplugin\*.*
448
449 SetOutPath $0\indent
RestorerZ2680a072024-03-20 20:15:51 +0100450 File ${VIMRT}\indent\README.txt
451 File ${VIMRT}\indent\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000452
Ken Takata1a9aba82024-01-16 17:14:29 +0100453 SetOutPath $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +0100454 File ${VIMRT}\keymap\README.txt
455 File ${VIMRT}\keymap\*.vim
Ken Takata1a9aba82024-01-16 17:14:29 +0100456
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 SetOutPath $0\macros
RestorerZ2680a072024-03-20 20:15:51 +0100458 File /r /x *.info ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100460 SetOutPath $0\pack
461 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200462
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463 SetOutPath $0\plugin
464 File ${VIMRT}\plugin\*.*
465
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000466 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100467 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000468
Bram Moolenaar44433da2022-05-06 18:08:52 +0100469 SetOutPath $0\import\dist
470 File ${VIMRT}\import\dist\*.*
471
Christian Brabandt176711f2022-03-11 15:24:11 +0000472 SetOutPath $0\bitmaps
473 File ${VIMSRC}\vim.ico
474
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475 SetOutPath $0\syntax
RestorerZ2680a072024-03-20 20:15:51 +0100476 File /r /x testdir /x generator /x Makefile ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000477
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000478 SetOutPath $0\spell
479 File ${VIMRT}\spell\*.txt
480 File ${VIMRT}\spell\*.vim
481 File ${VIMRT}\spell\*.spl
482 File ${VIMRT}\spell\*.sug
483
Bram Moolenaar071d4272004-06-13 20:20:40 +0000484 SetOutPath $0\tools
485 File ${VIMRT}\tools\*.*
486
487 SetOutPath $0\tutor
RestorerZ2680a072024-03-20 20:15:51 +0100488 File /x Makefile /x *.info ${VIMRT}\tutor\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000489SectionEnd
490
491##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100492Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000493 SectionIn 1 3
494
495 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100496 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497 StrCpy $2 "$2 vim view vimdiff"
498SectionEnd
499
500##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100501Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000502 SectionIn 3
503
504 StrCpy $1 "$1 -create-batfiles $2"
505SectionEnd
506
507##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100508SectionGroup $(str_group_icons) id_group_icons
509 Section "$(str_section_desktop)" id_section_desktop
510 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000511
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100512 StrCpy $1 "$1 -install-icons"
513 SectionEnd
514
515 Section "$(str_section_start_menu)" id_section_startmenu
516 SectionIn 1 3
517
518 StrCpy $1 "$1 -add-start-menu"
519 SectionEnd
520SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000521
522##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100523Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 SectionIn 1 3
525
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200527
Bram Moolenaar442b4222010-05-24 21:34:22 +0200528 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200529 # Install 64-bit gvimext.dll into the GvimExt64 directory.
530 SetOutPath $0\GvimExt64
531 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100532 !define LIBRARY_SHELL_EXTENSION
533 !define LIBRARY_X64
534 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
535 "${VIMSRC}\GvimExt\gvimext64.dll" \
536 "$0\GvimExt64\gvimext.dll" "$0"
537 !undef LIBRARY_X64
538 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200539 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200540
Bram Moolenaar6199d432017-10-14 19:05:44 +0200541 # Install 32-bit gvimext.dll into the GvimExt32 directory.
542 SetOutPath $0\GvimExt32
543 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100544 !define LIBRARY_SHELL_EXTENSION
545 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
546 "${VIMSRC}\GvimExt\gvimext.dll" \
547 "$0\GvimExt32\gvimext.dll" "$0"
548 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549
550 # We don't have a separate entry for the "Open With..." menu, assume
551 # the user wants either both or none.
552 StrCpy $1 "$1 -install-popup -install-openwith"
553SectionEnd
554
555##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100556Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 SectionIn 1 3
558
559 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100560
561 ${If} ${RunningX64}
562 SetRegView 64
563 ${EndIf}
564 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
565 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
566 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
567 ${If} ${RunningX64}
568 SetRegView lastused
569 ${EndIf}
570
571 ${If} $vim_compat_stat == "vi"
572 StrCpy $1 "$1 -vimrc-compat vi"
573 ${ElseIf} $vim_compat_stat == "vim"
574 StrCpy $1 "$1 -vimrc-compat vim"
575 ${ElseIf} $vim_compat_stat == "defaults"
576 StrCpy $1 "$1 -vimrc-compat defaults"
577 ${Else}
578 StrCpy $1 "$1 -vimrc-compat all"
579 ${EndIf}
580
581 ${If} $vim_keymap_stat == "default"
582 StrCpy $1 "$1 -vimrc-remap no"
583 ${Else}
584 StrCpy $1 "$1 -vimrc-remap win"
585 ${EndIf}
586
587 ${If} $vim_mouse_stat == "default"
588 StrCpy $1 "$1 -vimrc-behave default"
589 ${ElseIf} $vim_mouse_stat == "windows"
590 StrCpy $1 "$1 -vimrc-behave mswin"
591 ${Else}
592 StrCpy $1 "$1 -vimrc-behave unix"
593 ${EndIf}
594
Bram Moolenaar071d4272004-06-13 20:20:40 +0000595SectionEnd
596
597##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100598SectionGroup $(str_group_plugin) id_group_plugin
599 Section "$(str_section_plugin_home)" id_section_pluginhome
600 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000601
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000602 # use ShellExecAsUser below instead
603 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100604 SectionEnd
605
606 Section "$(str_section_plugin_vim)" id_section_pluginvim
607 SectionIn 3
608
609 StrCpy $1 "$1 -create-directories vim"
610 SectionEnd
611SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000612
613##########################################################
Restorer51c94b62024-03-24 09:41:18 +0000614!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100615Section "$(str_section_nls)" id_section_nls
616 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000617
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100618 SetOutPath $0\lang
RestorerZ2680a072024-03-20 20:15:51 +0100619 File /r /x Makefile ${VIMRT}\lang\*.*
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100620 SetOutPath $0
621 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
622 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
623 "$0\libintl-8.dll" "$0"
624 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
625 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
626 "$0\libiconv-2.dll" "$0"
627 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
628 # Install libgcc_s_sjlj-1.dll only if it is needed.
629 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
630 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
631 "$0\libgcc_s_sjlj-1.dll" "$0"
632 !endif
633
634 ${If} ${SectionIsSelected} ${id_section_editwith}
635 ${If} ${RunningX64}
636 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
637 SetOutPath $0\GvimExt64
638 ClearErrors
639 !define LIBRARY_X64
640 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
641 "${GETTEXT}\gettext64\libintl-8.dll" \
642 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
643 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
644 "${GETTEXT}\gettext64\libiconv-2.dll" \
645 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
646 !undef LIBRARY_X64
647 ${EndIf}
648
649 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
650 SetOutPath $0\GvimExt32
651 ClearErrors
652 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
653 "${GETTEXT}\gettext32\libintl-8.dll" \
654 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
655 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
656 "${GETTEXT}\gettext32\libiconv-2.dll" \
657 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
658 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
659 # Install libgcc_s_sjlj-1.dll only if it is needed.
660 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
661 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
662 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
663 !endif
664 ${EndIf}
665SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000666!endif
667
668##########################################################
669Section -call_install_exe
670 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100671 DetailPrint "$(str_msg_registering)"
672 nsExec::Exec "$0\install.exe $1"
673 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000674
675 ${If} ${SectionIsSelected} ${id_section_pluginhome}
676 ReadEnvStr $3 "COMSPEC"
677 Call GetHomeDir
678 Pop $4
679 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
680 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000681SectionEnd
682
683##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100684!macro SaveSectionSelection section_id reg_value
685 ${If} ${SectionIsSelected} ${section_id}
686 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
687 ${Else}
688 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
689 ${EndIf}
690!macroend
691
Bram Moolenaar071d4272004-06-13 20:20:40 +0000692Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100693
694 # Get estimated install size
695 SectionGetSize ${id_section_exe} $3
696 ${If} ${SectionIsSelected} ${id_section_console}
697 SectionGetSize ${id_section_console} $4
698 IntOp $3 $3 + $4
699 ${EndIf}
700 ${If} ${SectionIsSelected} ${id_section_editwith}
701 SectionGetSize ${id_section_editwith} $4
702 IntOp $3 $3 + $4
703 ${EndIf}
Restorer51c94b62024-03-24 09:41:18 +0000704!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100705 ${If} ${SectionIsSelected} ${id_section_nls}
706 SectionGetSize ${id_section_nls} $4
707 IntOp $3 $3 + $4
708 ${EndIf}
709!endif
710
711 # Register EstimatedSize and AllowSilent.
712 # Other information will be set by the install.exe (dosinst.c).
713 ${If} ${RunningX64}
714 SetRegView 64
715 ${EndIf}
716 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
717 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
718 ${If} ${RunningX64}
719 SetRegView lastused
720 ${EndIf}
721
722 # Store the selections to the registry.
723 ${If} ${RunningX64}
724 SetRegView 64
725 ${EndIf}
726 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
727 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
728 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
729 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
730 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
731 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
732 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
733 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000734!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100735 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
736!endif
737 ${If} ${RunningX64}
738 SetRegView lastused
739 ${EndIf}
740
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 BringToFront
742SectionEnd
743
744##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100745!macro LoadSectionSelection section_id reg_value
746 ClearErrors
747 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
748 ${IfNot} ${Errors}
749 ${If} $3 = 1
750 !insertmacro SelectSection ${section_id}
751 ${Else}
752 !insertmacro UnselectSection ${section_id}
753 ${EndIf}
754 ${EndIf}
755!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200756
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200757!macro LoadDefaultVimrc out_var reg_value default_value
758 ClearErrors
759 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
760 ${If} ${Errors}
761 ${OrIf} ${out_var} == ""
762 StrCpy ${out_var} ${default_value}
763 ${EndIf}
764!macroend
765
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100766Function .onInit
Restorer51c94b62024-03-24 09:41:18 +0000767!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100768 # Select a language (or read from the registry).
769 !insertmacro MUI_LANGDLL_DISPLAY
770!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200771
Christian Brabandt7d603842021-07-24 21:19:42 +0200772 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
773 # Check $VIM
774 ReadEnvStr $3 "VIM"
775 ${If} $3 != ""
776 StrCpy $INSTDIR $3
777 ${EndIf}
778 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100779
780 call CheckOldVim
781 Pop $3
782 ${If} $3 == ""
783 # No old versions of Vim found. Unselect and hide the section.
784 !insertmacro UnselectSection ${id_section_old_ver}
785 SectionSetInstTypes ${id_section_old_ver} 0
786 SectionSetText ${id_section_old_ver} ""
787 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200788 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100789 StrCpy $INSTDIR $3
790 ${EndIf}
791 ${EndIf}
792
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100793 ${If} ${RunningX64}
794 SetRegView 64
795 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200796 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100797 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
798 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
799 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
800 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
801 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
802 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
803 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
804 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000805!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100806 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
807!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200808 # Load the default _vimrc settings from the registry (if any).
809 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
810 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
811 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100812 ${If} ${RunningX64}
813 SetRegView lastused
814 ${EndIf}
815
816 # User variables:
817 # $0 - holds the directory the executables are installed to
818 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
819 # registration (since a non-OLE gvim will not complain, and we want to
820 # always register an OLE gvim).
821 # $2 - holds the names to create batch files for
822 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
823 StrCpy $1 "-register-OLE"
824 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200825FunctionEnd
826
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100827Function .onInstSuccess
828 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
829FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200830
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100831Function .onInstFailed
832 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200833FunctionEnd
834
835##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100836Function SetCustom
837 # Display the _vimrc setting dialog using nsDialogs.
838
839 # Check if a _vimrc should be created
840 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
841 Abort
842 ${EndIf}
843
844 !insertmacro MUI_HEADER_TEXT \
845 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
846
847 nsDialogs::Create 1018
848 Pop $vim_dialog
849
850 ${If} $vim_dialog == error
851 Abort
852 ${EndIf}
853
854 ${If} ${RunningX64}
855 SetRegView 64
856 ${EndIf}
857
858 GetFunctionAddress $3 ValidateCustom
859 nsDialogs::OnBack $3
860
861
862 # 1st group - Compatibility
Restorer6dcf59b2024-03-25 15:38:37 +0000863 ${NSD_CreateGroupBox} 0u 0u 296u 44u $(str_msg_compat_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100864 Pop $3
865
Restorer6dcf59b2024-03-25 15:38:37 +0000866 ${NSD_CreateLabel} 16u 14u 269u 10u $(str_msg_compat_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100867 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000868 ${NSD_CreateDropList} 42u 26u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100869 Pop $vim_nsd_compat
870 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
871 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
872 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
873 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
874
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200875 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100876 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200877 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100878 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200879 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100880 StrCpy $4 0
881 ${Else} # default
882 StrCpy $4 3
883 ${EndIf}
884 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
885
886
887 # 2nd group - Key remapping
Restorer6dcf59b2024-03-25 15:38:37 +0000888 ${NSD_CreateGroupBox} 0u 48u 296u 44u $(str_msg_keymap_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100889 Pop $3
890
Restorer6dcf59b2024-03-25 15:38:37 +0000891 ${NSD_CreateLabel} 16u 62u 269u 10u $(str_msg_keymap_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100892 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000893 ${NSD_CreateDropList} 42u 74u 236u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100894 Pop $vim_nsd_keymap
895 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
896 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
897
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200898 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100899 StrCpy $4 1
900 ${Else} # default
901 StrCpy $4 0
902 ${EndIf}
903 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
904
905
906 # 3rd group - Mouse behavior
Restorer6dcf59b2024-03-25 15:38:37 +0000907 ${NSD_CreateGroupBox} 0u 95u 296u 44u $(str_msg_mouse_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100908 Pop $3
909
Restorer6dcf59b2024-03-25 15:38:37 +0000910 ${NSD_CreateLabel} 16u 108u 269u 10u $(str_msg_mouse_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100911 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000912 ${NSD_CreateDropList} 42u 121u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100913 Pop $vim_nsd_mouse
914 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
915 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
916 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
917
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200918 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100919 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200920 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100921 StrCpy $4 1
922 ${Else} # default
923 StrCpy $4 0
924 ${EndIf}
925 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
926
927 ${If} ${RunningX64}
928 SetRegView lastused
929 ${EndIf}
930
931 nsDialogs::Show
932FunctionEnd
933
934Function ValidateCustom
935 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
936 ${If} $3 = 0
937 StrCpy $vim_compat_stat "vi"
938 ${ElseIf} $3 = 1
939 StrCpy $vim_compat_stat "vim"
940 ${ElseIf} $3 = 2
941 StrCpy $vim_compat_stat "defaults"
942 ${Else}
943 StrCpy $vim_compat_stat "all"
944 ${EndIf}
945
946 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
947 ${If} $3 = 0
948 StrCpy $vim_keymap_stat "default"
949 ${Else}
950 StrCpy $vim_keymap_stat "windows"
951 ${EndIf}
952
953 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
954 ${If} $3 = 0
955 StrCpy $vim_mouse_stat "default"
956 ${ElseIf} $3 = 1
957 StrCpy $vim_mouse_stat "windows"
958 ${Else}
959 StrCpy $vim_mouse_stat "xterm"
960 ${EndIf}
961FunctionEnd
962
963##########################################################
964# Description for Installer Sections
965
966!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
967 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
968 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
969 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
970 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
971 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
972 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
973 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
974 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
975 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
976 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
977 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
978 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +0000979!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100980 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
981!endif
982!insertmacro MUI_FUNCTION_DESCRIPTION_END
983
984
985##########################################################
986# Uninstaller Functions and Sections
987
988Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +0000989!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100990 # Get the language from the registry.
991 !insertmacro MUI_UNGETLANGUAGE
992!endif
993FunctionEnd
994
995Section "un.$(str_unsection_register)" id_unsection_register
996 SectionIn RO
997
Bram Moolenaar071d4272004-06-13 20:20:40 +0000998 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +0100999 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001000 StrCpy $0 "$INSTDIR"
1001
Bram Moolenaar071d4272004-06-13 20:20:40 +00001002 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001003 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001004 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001005 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006
1007 # We may have been put to the background when uninstall did something.
1008 BringToFront
1009
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001010 # Delete the installer language setting.
1011 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1012SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001014Section "un.$(str_unsection_exe)" id_unsection_exe
1015
1016 StrCpy $0 "$INSTDIR"
1017
1018 # Delete gettext and iconv DLLs
1019 ${If} ${FileExists} "$0\libiconv-2.dll"
1020 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1021 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001022 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001023 ${If} ${FileExists} "$0\libintl-8.dll"
1024 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1025 "$0\libintl-8.dll"
1026 ${EndIf}
1027 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1028 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1029 "$0\libgcc_s_sjlj-1.dll"
1030 ${EndIf}
1031
1032 # Delete other DLLs
1033 Delete /REBOOTOK $0\*.dll
1034
1035 # Delete 64-bit GvimExt
1036 ${If} ${RunningX64}
1037 !define LIBRARY_X64
1038 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1039 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1040 "$0\GvimExt64\gvimext.dll"
1041 ${EndIf}
1042 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1043 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1044 "$0\GvimExt64\libiconv-2.dll"
1045 ${EndIf}
1046 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1047 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1048 "$0\GvimExt64\libintl-8.dll"
1049 ${EndIf}
1050 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1051 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1052 "$0\GvimExt64\libwinpthread-1.dll"
1053 ${EndIf}
1054 !undef LIBRARY_X64
1055 RMDir /r $0\GvimExt64
1056 ${EndIf}
1057
1058 # Delete 32-bit GvimExt
1059 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1060 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1061 "$0\GvimExt32\gvimext.dll"
1062 ${EndIf}
1063 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1064 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1065 "$0\GvimExt32\libiconv-2.dll"
1066 ${EndIf}
1067 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1068 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1069 "$0\GvimExt32\libintl-8.dll"
1070 ${EndIf}
1071 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1072 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1073 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1074 ${EndIf}
1075 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001076
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 ClearErrors
1078 # Remove everything but *.dll files. Avoids that
1079 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001080 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001081 RMDir /r $0\colors
1082 RMDir /r $0\compiler
1083 RMDir /r $0\doc
1084 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001085 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 RMDir /r $0\indent
1087 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001088 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001090 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091 RMDir /r $0\syntax
1092 RMDir /r $0\tools
1093 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001094 RMDir /r $0\lang
1095 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001096 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001097 Delete $0\*.exe
1098 Delete $0\*.bat
1099 Delete $0\*.vim
1100 Delete $0\*.txt
1101
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001102 ${If} ${Errors}
1103 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1104 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001105
RestorerZ2680a072024-03-20 20:15:51 +01001106 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 # gvimext.dll may still be there.
1108 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001109SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001111# Remove "vimfiles" directory under the specified directory.
1112!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001113 ${If} ${FileExists} ${dir}\_viminfo
1114 Delete ${dir}\_viminfo
1115 ${EndIf}
1116 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001117 RMDir ${dir}\vimfiles\colors
1118 RMDir ${dir}\vimfiles\compiler
1119 RMDir ${dir}\vimfiles\doc
1120 RMDir ${dir}\vimfiles\ftdetect
1121 RMDir ${dir}\vimfiles\ftplugin
1122 RMDir ${dir}\vimfiles\indent
1123 RMDir ${dir}\vimfiles\keymap
1124 RMDir ${dir}\vimfiles\plugin
1125 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001126 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1127 Delete ${dir}\vimfiles\.netrwhist*
1128 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001129 RMDir ${dir}\vimfiles
1130 ${EndIf}
1131!macroend
1132
1133SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1134 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1135 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001136 Call un.GetHomeDir
1137 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001138
1139 ${If} $0 != ""
1140 !insertmacro RemoveVimfiles $0
1141 ${EndIf}
1142 SectionEnd
1143
1144 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1145 # get the parent dir of the installation
1146 Push $INSTDIR
1147 Call un.GetParent
1148 Pop $0
1149
1150 # if a plugin dir was created at installation remove it
1151 !insertmacro RemoveVimfiles $0
1152 SectionEnd
1153SectionGroupEnd
1154
1155Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156 # get the parent dir of the installation
1157 Push $INSTDIR
1158 Call un.GetParent
1159 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001161 ${IfNot} ${Silent}
1162 Delete $0\_vimrc
1163 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001164 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001166
1167##########################################################
1168# Description for Uninstaller Sections
1169
1170!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1171 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1172 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1173 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1174 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1175 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1176 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1177!insertmacro MUI_UNFUNCTION_DESCRIPTION_END