blob: b8ef079dba9275d5318cbf3b3ab86ae27d7b5d34 [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.
Restorer74a23312024-03-28 09:19:44 +00003# Last Change: 2024 Mar 20
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
Restorer74a23312024-03-28 09:19:44 +0000160!define MUI_FINISHPAGE_SHOWREADME
161!define MUI_FINISHPAGE_SHOWREADME_TEXT $(str_show_readme)
162!define MUI_FINISHPAGE_SHOWREADME_FUNCTION LaunchApplication
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
Restorer74a23312024-03-28 09:19:44 +0000186!insertmacro MUI_PAGE_LICENSE $(page_lic_file)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100187!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
Restorer74a23312024-03-28 09:19:44 +0000368 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\$(vim_readme_file)"'
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
RestorerZ49f1e192024-04-09 23:04:44 +0200432!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
Restorer74a23312024-03-28 09:19:44 +0000618#; FIXME: When adding new translations, do not forget to make changes here.
619 SetOutPath $0
620!if /FileExists ..\README.dax.txt
621 ${If} $Language = ${LANG_DANISH}
622 File ..\README.dax.txt
623 ${EndIf}
624!endif
625!if /FileExists ..\README.nlx.txt
626 ${If} $Language = ${LANG_DUTCH}
627 File ..\README.nlx.txt
628 ${EndIf}
629!endif
630!if /FileExists ..\README.dex.txt
631 ${If} $Language = ${LANG_GERMAN}
632 File ..\README.dex.txt
633 ${EndIf}
634!endif
635!if /FileExists ..\README.itx.txt
636 ${If} $Language = ${LANG_ITALIAN}
637 File ..\README.itx.txt
638 ${EndIf}
639!endif
640!if /FileExists ..\README.jax.txt
641 ${If} $Language = ${LANG_JAPANESE}
642 File ..\README.jax.txt
643 ${EndIf}
644!endif
645!if /FileExists ..\README.rux.txt
646 ${If} $Language = ${LANG_RUSSIAN}
647 File ..\README.rux.txt
648 ${EndIf}
649!endif
650!if /FileExists ..\README.srx.txt
651 ${If} $Language = ${LANG_SERBIAN}
652 File ..\README.srx.txt
653 ${EndIf}
654!endif
655!if /FileExists ..\README.cnx.txt
656 ${If} $Language = ${LANG_SIMPCHINESE}
657 File ..\README.cnx.txt
658 ${EndIf}
659!endif
660!if /FileExists ..\README.twx.txt
661 ${If} $Language = ${LANG_TRADCHINESE}
662 File ..\README.twx.txt
663 ${EndIf}
664!endif
665!if /FileExists ..\README.trx.txt
666 ${OrIf} $Language = ${LANG_TURKISH}
667 File ..\README.trx.txt
668 ${EndIf}
669!endif
670#; FIXME: When adding new translations, do not forget to make changes here.
671 SetOutPath $0\doc
672!if /FileExists "${VIMRT}\doc\uganda.dax"
673 ${If} $Language = ${LANG_DANISH}
674 File ${VIMRT}\doc\uganda.dax
675 ${EndIf}
676!endif
677!if /FileExists "${VIMRT}\doc\uganda.nlx"
678 ${If} $Language = ${LANG_DUTCH}
679 File ${VIMRT}\doc\uganda.nlx
680 ${EndIf}
681!endif
682!if /FileExists "${VIMRT}\doc\uganda.dex"
683 ${If} $Language = ${LANG_GERMAN}
684 File ${VIMRT}\doc\uganda.dex
685 ${EndIf}
686!endif
687!if /FileExists "${VIMRT}\doc\uganda.itx"
688 ${If} $Language = ${LANG_ITALIAN}
689 File ${VIMRT}\doc\uganda.itx
690 ${EndIf}
691!endif
692!if /FileExists "${VIMRT}\doc\uganda.jax"
693 ${If} $Language = ${LANG_JAPANESE}
694 File ${VIMRT}\doc\uganda.jax
695 ${EndIf}
696!endif
697!if /FileExists "${VIMRT}\doc\uganda.rux"
698 ${If} $Language = ${LANG_RUSSIAN}
699 File ${VIMRT}\doc\uganda.rux
700 ${EndIf}
701!endif
702!if /FileExists "${VIMRT}\doc\uganda.srx"
703 ${If} $Language = ${LANG_SERBIAN}
704 File ${VIMRT}\doc\uganda.srx
705 ${EndIf}
706!endif
707!if /FileExists "${VIMRT}\doc\uganda.cnx"
708 ${If} $Language = ${LANG_SIMPCHINESE}
709 File ${VIMRT}\doc\uganda.cnx
710 ${EndIf}
711!endif
712!if /FileExists "${VIMRT}\doc\uganda.twx"
713 ${If} $Language = ${LANG_TRADCHINESE}
714 File ${VIMRT}\doc\uganda.twx
715 ${EndIf}
716!endif
717!if /FileExists "${VIMRT}\doc\uganda.trx"
718 ${If} $Language = ${LANG_TURKISH}
719 File ${VIMRT}\doc\uganda.trx
720 ${EndIf}
721!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100722 SetOutPath $0\lang
RestorerZ2680a072024-03-20 20:15:51 +0100723 File /r /x Makefile ${VIMRT}\lang\*.*
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100724 SetOutPath $0
725 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
726 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
727 "$0\libintl-8.dll" "$0"
728 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
729 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
730 "$0\libiconv-2.dll" "$0"
RestorerZ49f1e192024-04-09 23:04:44 +0200731# Install libgcc_s_sjlj-1.dll only if it is needed.
732# !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
733# !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
734# "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
735# "$0\libgcc_s_sjlj-1.dll" "$0"
736# !endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100737
738 ${If} ${SectionIsSelected} ${id_section_editwith}
739 ${If} ${RunningX64}
740 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
741 SetOutPath $0\GvimExt64
742 ClearErrors
743 !define LIBRARY_X64
744 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
745 "${GETTEXT}\gettext64\libintl-8.dll" \
746 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
747 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
748 "${GETTEXT}\gettext64\libiconv-2.dll" \
749 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
750 !undef LIBRARY_X64
751 ${EndIf}
752
753 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
754 SetOutPath $0\GvimExt32
755 ClearErrors
756 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
757 "${GETTEXT}\gettext32\libintl-8.dll" \
758 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
759 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
760 "${GETTEXT}\gettext32\libiconv-2.dll" \
761 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
RestorerZ49f1e192024-04-09 23:04:44 +0200762# Install libgcc_s_sjlj-1.dll only if it is needed.
763# !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
764# !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
765# "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
766# "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
767# !endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100768 ${EndIf}
769SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000770!endif
771
772##########################################################
773Section -call_install_exe
774 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100775 DetailPrint "$(str_msg_registering)"
776 nsExec::Exec "$0\install.exe $1"
777 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000778
779 ${If} ${SectionIsSelected} ${id_section_pluginhome}
780 ReadEnvStr $3 "COMSPEC"
781 Call GetHomeDir
782 Pop $4
783 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
784 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000785SectionEnd
786
787##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100788!macro SaveSectionSelection section_id reg_value
789 ${If} ${SectionIsSelected} ${section_id}
790 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
791 ${Else}
792 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
793 ${EndIf}
794!macroend
795
Bram Moolenaar071d4272004-06-13 20:20:40 +0000796Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100797
798 # Get estimated install size
799 SectionGetSize ${id_section_exe} $3
800 ${If} ${SectionIsSelected} ${id_section_console}
801 SectionGetSize ${id_section_console} $4
802 IntOp $3 $3 + $4
803 ${EndIf}
804 ${If} ${SectionIsSelected} ${id_section_editwith}
805 SectionGetSize ${id_section_editwith} $4
806 IntOp $3 $3 + $4
807 ${EndIf}
Restorer51c94b62024-03-24 09:41:18 +0000808!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100809 ${If} ${SectionIsSelected} ${id_section_nls}
810 SectionGetSize ${id_section_nls} $4
811 IntOp $3 $3 + $4
812 ${EndIf}
813!endif
814
815 # Register EstimatedSize and AllowSilent.
816 # Other information will be set by the install.exe (dosinst.c).
817 ${If} ${RunningX64}
818 SetRegView 64
819 ${EndIf}
820 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
821 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
822 ${If} ${RunningX64}
823 SetRegView lastused
824 ${EndIf}
825
826 # Store the selections to the registry.
827 ${If} ${RunningX64}
828 SetRegView 64
829 ${EndIf}
830 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
831 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
832 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
833 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
834 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
835 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
836 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
837 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000838!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100839 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
840!endif
841 ${If} ${RunningX64}
842 SetRegView lastused
843 ${EndIf}
844
Bram Moolenaar071d4272004-06-13 20:20:40 +0000845 BringToFront
846SectionEnd
847
848##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100849!macro LoadSectionSelection section_id reg_value
850 ClearErrors
851 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
852 ${IfNot} ${Errors}
853 ${If} $3 = 1
854 !insertmacro SelectSection ${section_id}
855 ${Else}
856 !insertmacro UnselectSection ${section_id}
857 ${EndIf}
858 ${EndIf}
859!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200860
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200861!macro LoadDefaultVimrc out_var reg_value default_value
862 ClearErrors
863 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
864 ${If} ${Errors}
865 ${OrIf} ${out_var} == ""
866 StrCpy ${out_var} ${default_value}
867 ${EndIf}
868!macroend
869
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100870Function .onInit
Restorer51c94b62024-03-24 09:41:18 +0000871!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100872 # Select a language (or read from the registry).
873 !insertmacro MUI_LANGDLL_DISPLAY
874!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200875
Christian Brabandt7d603842021-07-24 21:19:42 +0200876 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
877 # Check $VIM
878 ReadEnvStr $3 "VIM"
879 ${If} $3 != ""
880 StrCpy $INSTDIR $3
881 ${EndIf}
882 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100883
884 call CheckOldVim
885 Pop $3
886 ${If} $3 == ""
887 # No old versions of Vim found. Unselect and hide the section.
888 !insertmacro UnselectSection ${id_section_old_ver}
889 SectionSetInstTypes ${id_section_old_ver} 0
890 SectionSetText ${id_section_old_ver} ""
891 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200892 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100893 StrCpy $INSTDIR $3
894 ${EndIf}
895 ${EndIf}
896
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100897 ${If} ${RunningX64}
898 SetRegView 64
899 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200900 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100901 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
902 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
903 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
904 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
905 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
906 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
907 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
908 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000909!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100910 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
911!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200912 # Load the default _vimrc settings from the registry (if any).
913 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
914 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
915 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100916 ${If} ${RunningX64}
917 SetRegView lastused
918 ${EndIf}
919
920 # User variables:
921 # $0 - holds the directory the executables are installed to
922 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
923 # registration (since a non-OLE gvim will not complain, and we want to
924 # always register an OLE gvim).
925 # $2 - holds the names to create batch files for
926 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
927 StrCpy $1 "-register-OLE"
928 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200929FunctionEnd
930
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100931Function .onInstSuccess
932 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
933FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200934
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100935Function .onInstFailed
936 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200937FunctionEnd
938
939##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100940Function SetCustom
941 # Display the _vimrc setting dialog using nsDialogs.
942
943 # Check if a _vimrc should be created
944 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
945 Abort
946 ${EndIf}
947
948 !insertmacro MUI_HEADER_TEXT \
949 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
950
951 nsDialogs::Create 1018
952 Pop $vim_dialog
953
954 ${If} $vim_dialog == error
955 Abort
956 ${EndIf}
957
958 ${If} ${RunningX64}
959 SetRegView 64
960 ${EndIf}
961
962 GetFunctionAddress $3 ValidateCustom
963 nsDialogs::OnBack $3
964
965
966 # 1st group - Compatibility
Restorer6dcf59b2024-03-25 15:38:37 +0000967 ${NSD_CreateGroupBox} 0u 0u 296u 44u $(str_msg_compat_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100968 Pop $3
969
Restorer6dcf59b2024-03-25 15:38:37 +0000970 ${NSD_CreateLabel} 16u 14u 269u 10u $(str_msg_compat_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100971 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000972 ${NSD_CreateDropList} 42u 26u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100973 Pop $vim_nsd_compat
974 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
975 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
976 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
977 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
978
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200979 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100980 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200981 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100982 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200983 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100984 StrCpy $4 0
985 ${Else} # default
986 StrCpy $4 3
987 ${EndIf}
988 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
989
990
991 # 2nd group - Key remapping
Restorer6dcf59b2024-03-25 15:38:37 +0000992 ${NSD_CreateGroupBox} 0u 48u 296u 44u $(str_msg_keymap_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100993 Pop $3
994
Restorer6dcf59b2024-03-25 15:38:37 +0000995 ${NSD_CreateLabel} 16u 62u 269u 10u $(str_msg_keymap_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100996 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000997 ${NSD_CreateDropList} 42u 74u 236u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100998 Pop $vim_nsd_keymap
999 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
1000 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
1001
Bram Moolenaarceb56dd2020-07-14 22:24:40 +02001002 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001003 StrCpy $4 1
1004 ${Else} # default
1005 StrCpy $4 0
1006 ${EndIf}
1007 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
1008
1009
1010 # 3rd group - Mouse behavior
Restorer6dcf59b2024-03-25 15:38:37 +00001011 ${NSD_CreateGroupBox} 0u 95u 296u 44u $(str_msg_mouse_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001012 Pop $3
1013
Restorer6dcf59b2024-03-25 15:38:37 +00001014 ${NSD_CreateLabel} 16u 108u 269u 10u $(str_msg_mouse_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001015 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +00001016 ${NSD_CreateDropList} 42u 121u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001017 Pop $vim_nsd_mouse
1018 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
1019 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
1020 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
1021
Bram Moolenaarceb56dd2020-07-14 22:24:40 +02001022 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001023 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +02001024 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001025 StrCpy $4 1
1026 ${Else} # default
1027 StrCpy $4 0
1028 ${EndIf}
1029 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
1030
1031 ${If} ${RunningX64}
1032 SetRegView lastused
1033 ${EndIf}
1034
1035 nsDialogs::Show
1036FunctionEnd
1037
1038Function ValidateCustom
1039 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
1040 ${If} $3 = 0
1041 StrCpy $vim_compat_stat "vi"
1042 ${ElseIf} $3 = 1
1043 StrCpy $vim_compat_stat "vim"
1044 ${ElseIf} $3 = 2
1045 StrCpy $vim_compat_stat "defaults"
1046 ${Else}
1047 StrCpy $vim_compat_stat "all"
1048 ${EndIf}
1049
1050 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
1051 ${If} $3 = 0
1052 StrCpy $vim_keymap_stat "default"
1053 ${Else}
1054 StrCpy $vim_keymap_stat "windows"
1055 ${EndIf}
1056
1057 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
1058 ${If} $3 = 0
1059 StrCpy $vim_mouse_stat "default"
1060 ${ElseIf} $3 = 1
1061 StrCpy $vim_mouse_stat "windows"
1062 ${Else}
1063 StrCpy $vim_mouse_stat "xterm"
1064 ${EndIf}
1065FunctionEnd
1066
1067##########################################################
1068# Description for Installer Sections
1069
1070!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
1071 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
1072 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
1073 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
1074 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
1075 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
1076 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
1077 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
1078 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
1079 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
1080 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
1081 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
1082 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +00001083!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001084 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
1085!endif
1086!insertmacro MUI_FUNCTION_DESCRIPTION_END
1087
1088
1089##########################################################
1090# Uninstaller Functions and Sections
1091
1092Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +00001093!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001094 # Get the language from the registry.
1095 !insertmacro MUI_UNGETLANGUAGE
1096!endif
1097FunctionEnd
1098
1099Section "un.$(str_unsection_register)" id_unsection_register
1100 SectionIn RO
1101
Bram Moolenaar071d4272004-06-13 20:20:40 +00001102 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +01001103 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 StrCpy $0 "$INSTDIR"
1105
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001107 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001108 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001109 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110
1111 # We may have been put to the background when uninstall did something.
1112 BringToFront
1113
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001114 # Delete the installer language setting.
1115 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1116SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001118Section "un.$(str_unsection_exe)" id_unsection_exe
1119
1120 StrCpy $0 "$INSTDIR"
1121
1122 # Delete gettext and iconv DLLs
1123 ${If} ${FileExists} "$0\libiconv-2.dll"
1124 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1125 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001126 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001127 ${If} ${FileExists} "$0\libintl-8.dll"
1128 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1129 "$0\libintl-8.dll"
1130 ${EndIf}
1131 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1132 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1133 "$0\libgcc_s_sjlj-1.dll"
1134 ${EndIf}
1135
1136 # Delete other DLLs
1137 Delete /REBOOTOK $0\*.dll
1138
1139 # Delete 64-bit GvimExt
1140 ${If} ${RunningX64}
1141 !define LIBRARY_X64
1142 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1143 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1144 "$0\GvimExt64\gvimext.dll"
1145 ${EndIf}
1146 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1147 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1148 "$0\GvimExt64\libiconv-2.dll"
1149 ${EndIf}
1150 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1151 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1152 "$0\GvimExt64\libintl-8.dll"
1153 ${EndIf}
1154 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1155 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1156 "$0\GvimExt64\libwinpthread-1.dll"
1157 ${EndIf}
1158 !undef LIBRARY_X64
1159 RMDir /r $0\GvimExt64
1160 ${EndIf}
1161
1162 # Delete 32-bit GvimExt
1163 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1164 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1165 "$0\GvimExt32\gvimext.dll"
1166 ${EndIf}
1167 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1168 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1169 "$0\GvimExt32\libiconv-2.dll"
1170 ${EndIf}
1171 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1172 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1173 "$0\GvimExt32\libintl-8.dll"
1174 ${EndIf}
1175 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1176 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1177 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1178 ${EndIf}
1179 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001180
Bram Moolenaar071d4272004-06-13 20:20:40 +00001181 ClearErrors
1182 # Remove everything but *.dll files. Avoids that
1183 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001184 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001185 RMDir /r $0\colors
1186 RMDir /r $0\compiler
1187 RMDir /r $0\doc
1188 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001189 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 RMDir /r $0\indent
1191 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001192 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001194 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001195 RMDir /r $0\syntax
1196 RMDir /r $0\tools
1197 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001198 RMDir /r $0\lang
1199 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001200 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001201 Delete $0\*.exe
1202 Delete $0\*.bat
1203 Delete $0\*.vim
1204 Delete $0\*.txt
1205
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001206 ${If} ${Errors}
1207 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1208 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209
RestorerZ2680a072024-03-20 20:15:51 +01001210 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 # gvimext.dll may still be there.
1212 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001213SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001214
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001215# Remove "vimfiles" directory under the specified directory.
1216!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001217 ${If} ${FileExists} ${dir}\_viminfo
1218 Delete ${dir}\_viminfo
1219 ${EndIf}
1220 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001221 RMDir ${dir}\vimfiles\colors
1222 RMDir ${dir}\vimfiles\compiler
1223 RMDir ${dir}\vimfiles\doc
1224 RMDir ${dir}\vimfiles\ftdetect
1225 RMDir ${dir}\vimfiles\ftplugin
1226 RMDir ${dir}\vimfiles\indent
1227 RMDir ${dir}\vimfiles\keymap
1228 RMDir ${dir}\vimfiles\plugin
1229 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001230 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1231 Delete ${dir}\vimfiles\.netrwhist*
1232 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001233 RMDir ${dir}\vimfiles
1234 ${EndIf}
1235!macroend
1236
1237SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1238 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1239 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001240 Call un.GetHomeDir
1241 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001242
1243 ${If} $0 != ""
1244 !insertmacro RemoveVimfiles $0
1245 ${EndIf}
1246 SectionEnd
1247
1248 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1249 # get the parent dir of the installation
1250 Push $INSTDIR
1251 Call un.GetParent
1252 Pop $0
1253
1254 # if a plugin dir was created at installation remove it
1255 !insertmacro RemoveVimfiles $0
1256 SectionEnd
1257SectionGroupEnd
1258
1259Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260 # get the parent dir of the installation
1261 Push $INSTDIR
1262 Call un.GetParent
1263 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001264
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001265 ${IfNot} ${Silent}
1266 Delete $0\_vimrc
1267 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001268 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001270
1271##########################################################
1272# Description for Uninstaller Sections
1273
1274!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1275 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1276 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1277 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1278 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1279 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1280 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1281!insertmacro MUI_UNFUNCTION_DESCRIPTION_END