blob: 04040b4d251653fb52dbe77b3b7f50d84ae607c9 [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.
RestorerZf8770402025-02-24 19:42:36 +01003# Last Change: 2025 Feb 24
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
RestorerZ2730d382025-01-17 14:04:44 +010017 !define VIMRT "..\runtime"
Bram Moolenaar286eacd2016-01-16 18:05:50 +010018!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
RestorerZ2730d382025-01-17 14:04:44 +010022 !define VIMTOOLS "..\.."
Bram Moolenaar286eacd2016-01-16 18:05:50 +010023!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
RestorerZ2730d382025-01-17 14:04:44 +010029 !define GETTEXT ${VIMTOOLS}
Bram Moolenaar6199d432017-10-14 19:05:44 +020030!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
RestorerZ54585fd2025-07-01 21:30:21 +020056# if you want to create the installer for ARM64, use the /DARM64=1 on
57# the command line makensis.exe. This property will be set to 1.
58!ifndef ARM64
59 !define ARM64 0
60!else
61 !if ${ARM64} > 0
62 !if ${WIN64} < 1
63 !define /redef WIN64 1
64 !endif
65 !endif
66!endif
67
K.Takata48f38332024-10-07 20:37:00 +020068# if you don't want to include libgcc_s_sjlj-1.dll in the package, use the
69# switch /DINCLUDE_LIBGCC=0 on the command line makensis.exe.
70!ifndef INCLUDE_LIBGCC
71 !define INCLUDE_LIBGCC 1
72!endif
73
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010074!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000075
Restorer51c94b62024-03-24 09:41:18 +000076# Definition of Patch for Vim.
Bram Moolenaar9d591522019-05-26 20:49:42 +020077!ifndef PATCHLEVEL
78 !define PATCHLEVEL 0
79!endif
80
Bram Moolenaar071d4272004-06-13 20:20:40 +000081# ----------- No configurable settings below this line -----------
82
Restorer51c94b62024-03-24 09:41:18 +000083!include "Library.nsh" # for DLL install
Bram Moolenaaraf610b82018-12-21 16:22:50 +010084!include "LogicLib.nsh"
85!include "MUI2.nsh"
86!include "nsDialogs.nsh"
87!include "Sections.nsh"
88!include "x64.nsh"
RestorerZ2730d382025-01-17 14:04:44 +010089!include "StrFunc.nsh"
90${StrRep}
Bram Moolenaar071d4272004-06-13 20:20:40 +000091
RestorerZ2680a072024-03-20 20:15:51 +010092# See https://nsis.sourceforge.io/LogicLib
93;FileExists is already part of LogicLib, but returns true for directories
94;as well as files
95!macro _FileExists2 _a _b _t _f
96 !insertmacro _LOGICLIB_TEMP
97 StrCpy $_LOGICLIB_TEMP "0"
98;if path is not blank, continue to next check
99 StrCmp `${_b}` `` +4 0
100;if path exists, continue to next check (IfFileExists returns true if this
101;is a directory)
102 IfFileExists `${_b}` `0` +3
103;if path is not a directory, continue to confirm exists
104 IfFileExists `${_b}\*.*` +2 0
105 StrCpy $_LOGICLIB_TEMP "1" ;file exists
106;now we have a definitive value - the file exists or it does not
107 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
108!macroend
109!undef FileExists
110!define FileExists `"" FileExists2`
111!macro _DirExists _a _b _t _f
112 !insertmacro _LOGICLIB_TEMP
113 StrCpy $_LOGICLIB_TEMP "0"
114;if path is not blank, continue to next check
115 StrCmp `${_b}` `` +3 0
116;if directory exists, continue to confirm exists
117 IfFileExists `${_b}\*.*` 0 +2
118 StrCpy $_LOGICLIB_TEMP "1"
119 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
120!macroend
121!define DirExists `"" DirExists`
122
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100123!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
124!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
125!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
126
Restorer51c94b62024-03-24 09:41:18 +0000127!if ${WIN64}
RestorerZ54585fd2025-07-01 21:30:21 +0200128 !if ${ARM64}
129 Name "${PRODUCT} (ARM64)"
130 !else
131 Name "${PRODUCT} (x64)"
132 !endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100133!else
RestorerZ54585fd2025-07-01 21:30:21 +0200134 Name "${PRODUCT}"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100135!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000136OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
137CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +0100138SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100139SetCompressorDictSize 64
140ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +0200142RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143
Restorer51c94b62024-03-24 09:41:18 +0000144!if ${HAVE_UPX}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000145 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
146!endif
147
Restorer51c94b62024-03-24 09:41:18 +0000148!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100149!define BIT 64
150!else
151!define BIT 32
152!endif
153
154##########################################################
155# MUI2 settings
156
157!define MUI_ABORTWARNING
158!define MUI_UNABORTWARNING
159
160!define MUI_ICON "icons\vim_16c.ico"
161!define MUI_UNICON "icons\vim_uninst_16c.ico"
162
163# Show all languages, despite user's codepage:
164!define MUI_LANGDLL_ALLLANGUAGES
Restorer6dcf59b2024-03-25 15:38:37 +0000165# Always show dialog choice language
166#!define MUI_LANGDLL_ALWAYSSHOW
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100167!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
168!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
169!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
170
171!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
172!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
173!define MUI_HEADERIMAGE
174!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
175!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
176
177!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
178!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
179!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
180!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
181
182!define MUI_COMPONENTSPAGE_SMALLDESC
183!define MUI_LICENSEPAGE_CHECKBOX
Restorer74a23312024-03-28 09:19:44 +0000184!define MUI_FINISHPAGE_SHOWREADME
185!define MUI_FINISHPAGE_SHOWREADME_TEXT $(str_show_readme)
186!define MUI_FINISHPAGE_SHOWREADME_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100187
188# This adds '\Vim' to the user choice automagically. The actual value is
189# obtained below with CheckOldVim.
Restorer51c94b62024-03-24 09:41:18 +0000190!if ${WIN64}
Christian Brabandt7d603842021-07-24 21:19:42 +0200191 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100192!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200193 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100194!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200195InstallDir ${DEFAULT_INSTDIR}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196
197# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100198InstType $(str_type_typical)
199InstType $(str_type_minimal)
200InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000201
202SilentInstall normal
203
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100204# General custom functions for MUI2:
205#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
206#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
207
208# Installer pages
209!insertmacro MUI_PAGE_WELCOME
Restorer74a23312024-03-28 09:19:44 +0000210!insertmacro MUI_PAGE_LICENSE $(page_lic_file)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100211!insertmacro MUI_PAGE_COMPONENTS
212Page custom SetCustom ValidateCustom
213#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
214!insertmacro MUI_PAGE_DIRECTORY
215!insertmacro MUI_PAGE_INSTFILES
216!define MUI_FINISHPAGE_NOREBOOTSUPPORT
217!insertmacro MUI_PAGE_FINISH
218
219# Uninstaller pages:
220!insertmacro MUI_UNPAGE_CONFIRM
221#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
222!insertmacro MUI_UNPAGE_COMPONENTS
223!insertmacro MUI_UNPAGE_INSTFILES
224!define MUI_FINISHPAGE_NOREBOOTSUPPORT
225!insertmacro MUI_UNPAGE_FINISH
226
227##########################################################
228# Languages Files
229
230!insertmacro MUI_RESERVEFILE_LANGDLL
231!include "lang\english.nsi"
232
233# Include support for other languages:
Restorer51c94b62024-03-24 09:41:18 +0000234!if ${HAVE_MULTI_LANG}
Rafael Fontenelleb2bd8de2025-02-25 21:05:22 +0100235 !include "lang\portuguesebr.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100236 !include "lang\danish.nsi"
237 !include "lang\dutch.nsi"
238 !include "lang\german.nsi"
Christos Longrosc62dacb2024-03-06 20:53:02 +0100239 !include "lang\greek.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100240 !include "lang\italian.nsi"
241 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200242 !include "lang\russian.nsi"
Ivan Pešiće1051922024-03-05 23:34:00 +0400243 !include "lang\serbian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100244 !include "lang\simpchinese.nsi"
245 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100246 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100247!endif
248
Bram Moolenaardabfde02019-05-17 12:37:27 +0200249##########################################################
250# Version resources
251
252VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
RestorerZec67ee02024-04-25 21:25:19 +0200253VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "The Vim Project"
Bram Moolenaardabfde02019-05-17 12:37:27 +0200254VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
255VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
256VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200257VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
258VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100259
260# Global variables
261Var vim_dialog
262Var vim_nsd_compat
263Var vim_nsd_keymap
264Var vim_nsd_mouse
265Var vim_compat_stat
266Var vim_keymap_stat
267Var vim_mouse_stat
RestorerZ2730d382025-01-17 14:04:44 +0100268!if ${HAVE_NLS}
269Var lng_usr
270!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100271
Bram Moolenaar071d4272004-06-13 20:20:40 +0000272
Bram Moolenaar5d424742018-02-04 19:11:30 +0100273# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100274ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100275
Bram Moolenaar071d4272004-06-13 20:20:40 +0000276##########################################################
277# Functions
278
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100279# Get parent directory
280# Share this function both on installer and uninstaller
281!macro GetParent un
282Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283 Exch $0 ; old $0 is on top of stack
284 Push $1
285 Push $2
286 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100287 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000288 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100289 ${If} $2 == ""
290 ${OrIf} $2 == "\"
291 ${ExitDo}
292 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000293 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100294 ${Loop}
295 StrCpy $0 $0 $1
296 Pop $2
297 Pop $1
298 Exch $0 ; put $0 on top of stack, restore $0 to original value
299FunctionEnd
300!macroend
301
302!insertmacro GetParent ""
303!insertmacro GetParent "un."
304
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000305# Get home directory
306!macro GetHomeDir un
307Function ${un}GetHomeDir
308 Push $0
309 Push $1
310 ReadEnvStr $0 "HOME"
311 ${If} $0 == ""
312 ReadEnvStr $0 "HOMEDRIVE"
313 ReadEnvStr $1 "HOMEPATH"
314 StrCpy $0 "$0$1"
315 ${If} $0 == ""
316 ReadEnvStr $0 "USERPROFILE"
317 ${EndIf}
318 ${EndIf}
319 Pop $1
320 Exch $0 # put $0 on top of stack, restore $0 to original value
321FunctionEnd
322!macroend
323
324!insertmacro GetHomeDir ""
325!insertmacro GetHomeDir "un."
326
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100327# Check if Vim is already installed.
328# return: Installed directory. If not found, it will be empty.
329Function CheckOldVim
330 Push $0
331 Push $R0
332 Push $R1
333 Push $R2
334
335 ${If} ${RunningX64}
336 SetRegView 64
337 ${EndIf}
338
339 ClearErrors
340 StrCpy $0 "" # Installed directory
341 StrCpy $R0 0 # Sub-key index
342 StrCpy $R1 "" # Sub-key
343 ${Do}
344 # Eumerate the sub-key:
345 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
346
347 # Stop if no more sub-key:
348 ${If} ${Errors}
349 ${OrIf} $R1 == ""
350 ${ExitDo}
351 ${EndIf}
352
353 # Move to the next sub-key:
354 IntOp $R0 $R0 + 1
355
356 # Check if the key is Vim uninstall key or not:
357 StrCpy $R2 $R1 4
358 ${If} $R2 S!= "Vim "
359 ${Continue}
360 ${EndIf}
361
362 # Verifies required sub-keys:
363 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
364 ${If} ${Errors}
365 ${OrIf} $R2 == ""
366 ${Continue}
367 ${EndIf}
368
369 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
370 ${If} ${Errors}
371 ${OrIf} $R2 == ""
372 ${Continue}
373 ${EndIf}
374
375 # Found
376 Push $R2
377 call GetParent
378 call GetParent
379 Pop $0 # Vim directory
380 ${ExitDo}
381
382 ${Loop}
383
384 ${If} ${RunningX64}
385 SetRegView lastused
386 ${EndIf}
387
388 Pop $R2
389 Pop $R1
390 Pop $R0
391 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000392FunctionEnd
393
Bram Moolenaar4a228972021-05-01 22:41:39 +0200394Function LaunchApplication
395 SetOutPath $0
Restorer74a23312024-03-28 09:19:44 +0000396 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\$(vim_readme_file)"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200397FunctionEnd
398
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100400Section "$(str_section_old_ver)" id_section_old_ver
401 SectionIn 1 2 3 RO
402
403 # run the install program to check for already installed versions
404 SetOutPath $TEMP
405 File /oname=install.exe ${VIMSRC}\installw32.exe
406 DetailPrint "$(str_msg_uninstalling)"
407 ${Do}
408 nsExec::Exec "$TEMP\install.exe -uninstall-check"
409 Pop $3
410
411 call CheckOldVim
412 Pop $3
413 ${If} $3 == ""
414 ${ExitDo}
415 ${Else}
416 # It seems that the old version is still remaining.
417 # TODO: Should we show a warning and run the uninstaller again?
418
419 ${ExitDo} # Just ignore for now.
420 ${EndIf}
421 ${Loop}
422 Delete $TEMP\install.exe
423 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
424
425 # We may have been put to the background when uninstall did something.
426 BringToFront
427SectionEnd
428
429##########################################################
430Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200431 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432
433 # we need also this here if the user changes the instdir
434 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
435
436 SetOutPath $0
437 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200438!if /FileExists "${VIMSRC}\vim${BIT}.dll"
439 File ${VIMSRC}\vim${BIT}.dll
440!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000441 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200442 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200444 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100446 File ..\vimtutor.bat
447 File ..\README.txt
RestorerZ2730d382025-01-17 14:04:44 +0100448 File /oname=LICENSE.txt ..\LICENSE
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200449 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451
RestorerZ2680a072024-03-20 20:15:51 +0100452!if /FileExists "${VIMTOOLS}\diff.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200453 File ${VIMTOOLS}\diff.exe
RestorerZ2680a072024-03-20 20:15:51 +0100454!endif
455!if /FileExists "${VIMTOOLS}\winpty${BIT}.dll"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100456 File ${VIMTOOLS}\winpty${BIT}.dll
RestorerZ2680a072024-03-20 20:15:51 +0100457!endif
458!if /FileExists "${VIMTOOLS}\winpty-agent.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200459 File ${VIMTOOLS}\winpty-agent.exe
RestorerZ2680a072024-03-20 20:15:51 +0100460!endif
RestorerZ49f1e192024-04-09 23:04:44 +0200461!if /FileExists "${VIMTOOLS}\libsodium.dll"
462 File ${VIMTOOLS}\libsodium.dll
463!endif
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200464
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100466 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
468 SetOutPath $0\compiler
469 File ${VIMRT}\compiler\*.*
470
471 SetOutPath $0\doc
RestorerZ2680a072024-03-20 20:15:51 +0100472 File /x uganda.nsis.txt ${VIMRT}\doc\*.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473 File ${VIMRT}\doc\tags
474
475 SetOutPath $0\ftplugin
476 File ${VIMRT}\ftplugin\*.*
477
478 SetOutPath $0\indent
RestorerZ2680a072024-03-20 20:15:51 +0100479 File ${VIMRT}\indent\README.txt
480 File ${VIMRT}\indent\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481
Ken Takata1a9aba82024-01-16 17:14:29 +0100482 SetOutPath $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +0100483 File ${VIMRT}\keymap\README.txt
484 File ${VIMRT}\keymap\*.vim
Ken Takata1a9aba82024-01-16 17:14:29 +0100485
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486 SetOutPath $0\macros
RestorerZ2680a072024-03-20 20:15:51 +0100487 File /r /x *.info ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000488
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100489 SetOutPath $0\pack
490 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200491
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492 SetOutPath $0\plugin
493 File ${VIMRT}\plugin\*.*
494
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000495 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100496 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000497
Bram Moolenaar44433da2022-05-06 18:08:52 +0100498 SetOutPath $0\import\dist
499 File ${VIMRT}\import\dist\*.*
500
Christian Brabandt176711f2022-03-11 15:24:11 +0000501 SetOutPath $0\bitmaps
502 File ${VIMSRC}\vim.ico
503
Bram Moolenaar071d4272004-06-13 20:20:40 +0000504 SetOutPath $0\syntax
RestorerZ2680a072024-03-20 20:15:51 +0100505 File /r /x testdir /x generator /x Makefile ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000506
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000507 SetOutPath $0\spell
508 File ${VIMRT}\spell\*.txt
509 File ${VIMRT}\spell\*.vim
510 File ${VIMRT}\spell\*.spl
511 File ${VIMRT}\spell\*.sug
512
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513 SetOutPath $0\tools
514 File ${VIMRT}\tools\*.*
515
516 SetOutPath $0\tutor
RestorerZ44a2e3c2025-06-29 16:23:33 +0200517 File /r /x *.info ${VIMRT}\tutor\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518SectionEnd
519
520##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100521Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522 SectionIn 1 3
523
524 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100525 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 StrCpy $2 "$2 vim view vimdiff"
527SectionEnd
528
529##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100530Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531 SectionIn 3
532
533 StrCpy $1 "$1 -create-batfiles $2"
534SectionEnd
535
536##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100537SectionGroup $(str_group_icons) id_group_icons
538 Section "$(str_section_desktop)" id_section_desktop
539 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100541 StrCpy $1 "$1 -install-icons"
542 SectionEnd
543
544 Section "$(str_section_start_menu)" id_section_startmenu
545 SectionIn 1 3
546
547 StrCpy $1 "$1 -add-start-menu"
548 SectionEnd
549SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550
551##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100552Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553 SectionIn 1 3
554
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200556
Bram Moolenaar442b4222010-05-24 21:34:22 +0200557 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200558 # Install 64-bit gvimext.dll into the GvimExt64 directory.
559 SetOutPath $0\GvimExt64
560 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100561 !define LIBRARY_SHELL_EXTENSION
562 !define LIBRARY_X64
563 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
564 "${VIMSRC}\GvimExt\gvimext64.dll" \
565 "$0\GvimExt64\gvimext.dll" "$0"
566 !undef LIBRARY_X64
567 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200568 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200569
Bram Moolenaar6199d432017-10-14 19:05:44 +0200570 # Install 32-bit gvimext.dll into the GvimExt32 directory.
571 SetOutPath $0\GvimExt32
572 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100573 !define LIBRARY_SHELL_EXTENSION
574 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
575 "${VIMSRC}\GvimExt\gvimext.dll" \
576 "$0\GvimExt32\gvimext.dll" "$0"
577 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578
579 # We don't have a separate entry for the "Open With..." menu, assume
580 # the user wants either both or none.
581 StrCpy $1 "$1 -install-popup -install-openwith"
582SectionEnd
583
584##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100585Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 SectionIn 1 3
587
588 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100589
590 ${If} ${RunningX64}
591 SetRegView 64
592 ${EndIf}
593 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
594 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
595 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
596 ${If} ${RunningX64}
597 SetRegView lastused
598 ${EndIf}
599
600 ${If} $vim_compat_stat == "vi"
601 StrCpy $1 "$1 -vimrc-compat vi"
602 ${ElseIf} $vim_compat_stat == "vim"
603 StrCpy $1 "$1 -vimrc-compat vim"
604 ${ElseIf} $vim_compat_stat == "defaults"
605 StrCpy $1 "$1 -vimrc-compat defaults"
606 ${Else}
607 StrCpy $1 "$1 -vimrc-compat all"
608 ${EndIf}
609
610 ${If} $vim_keymap_stat == "default"
611 StrCpy $1 "$1 -vimrc-remap no"
612 ${Else}
613 StrCpy $1 "$1 -vimrc-remap win"
614 ${EndIf}
615
616 ${If} $vim_mouse_stat == "default"
617 StrCpy $1 "$1 -vimrc-behave default"
618 ${ElseIf} $vim_mouse_stat == "windows"
619 StrCpy $1 "$1 -vimrc-behave mswin"
620 ${Else}
621 StrCpy $1 "$1 -vimrc-behave unix"
622 ${EndIf}
623
Bram Moolenaar071d4272004-06-13 20:20:40 +0000624SectionEnd
625
626##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100627SectionGroup $(str_group_plugin) id_group_plugin
628 Section "$(str_section_plugin_home)" id_section_pluginhome
629 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000631 # use ShellExecAsUser below instead
632 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100633 SectionEnd
634
635 Section "$(str_section_plugin_vim)" id_section_pluginvim
636 SectionIn 3
637
638 StrCpy $1 "$1 -create-directories vim"
639 SectionEnd
640SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641
642##########################################################
Restorer51c94b62024-03-24 09:41:18 +0000643!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100644Section "$(str_section_nls)" id_section_nls
645 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000646
RestorerZ2730d382025-01-17 14:04:44 +0100647 SetOutPath $INSTDIR
648!if /FileExists "..\lang\README.*.txt"
649 File ..\lang\README.*.txt
650 CopyFiles /SILENT /FILESONLY $INSTDIR\README.$lng_usr.txt \
651 $INSTDIR\vim${VER_MAJOR}${VER_MINOR}\README.$lng_usr.txt
652 Delete $INSTDIR\README.*.txt
Restorer74a23312024-03-28 09:19:44 +0000653!endif
RestorerZ2730d382025-01-17 14:04:44 +0100654!if /FileExists "..\lang\LICENSE.??.txt"
655 File ..\lang\LICENSE.??.txt
656!if /FileExists "..\lang\LICENSE.??_??.txt"
657 File ..\lang\LICENSE.??_??.txt
Restorer74a23312024-03-28 09:19:44 +0000658!endif
RestorerZ2730d382025-01-17 14:04:44 +0100659 CopyFiles /SILENT /FILESONLY $INSTDIR\LICENSE.$lng_usr.txt \
660 $INSTDIR\vim${VER_MAJOR}${VER_MINOR}\LICENSE.$lng_usr.txt
661 Delete $INSTDIR\LICENSE.*.txt
Restorer74a23312024-03-28 09:19:44 +0000662!endif
RestorerZ2730d382025-01-17 14:04:44 +0100663
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100664 SetOutPath $0\lang
RestorerZ2680a072024-03-20 20:15:51 +0100665 File /r /x Makefile ${VIMRT}\lang\*.*
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100666 SetOutPath $0
667 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
668 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
669 "$0\libintl-8.dll" "$0"
670 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
671 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
672 "$0\libiconv-2.dll" "$0"
K.Takata48f38332024-10-07 20:37:00 +0200673!if ${INCLUDE_LIBGCC}
674!if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
675 # Install libgcc_s_sjlj-1.dll only if it is needed.
676 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
677 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
678 "$0\libgcc_s_sjlj-1.dll" "$0"
679!endif
680!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100681
682 ${If} ${SectionIsSelected} ${id_section_editwith}
683 ${If} ${RunningX64}
684 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
685 SetOutPath $0\GvimExt64
686 ClearErrors
687 !define LIBRARY_X64
688 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
689 "${GETTEXT}\gettext64\libintl-8.dll" \
690 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
691 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
692 "${GETTEXT}\gettext64\libiconv-2.dll" \
693 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
694 !undef LIBRARY_X64
695 ${EndIf}
696
697 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
698 SetOutPath $0\GvimExt32
699 ClearErrors
700 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
701 "${GETTEXT}\gettext32\libintl-8.dll" \
702 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
703 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
704 "${GETTEXT}\gettext32\libiconv-2.dll" \
705 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
K.Takata48f38332024-10-07 20:37:00 +0200706!if ${INCLUDE_LIBGCC}
707!if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
708 # Install libgcc_s_sjlj-1.dll only if it is needed.
709 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
710 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
711 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
712!endif
713!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100714 ${EndIf}
715SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000716!endif
717
718##########################################################
719Section -call_install_exe
720 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100721 DetailPrint "$(str_msg_registering)"
722 nsExec::Exec "$0\install.exe $1"
723 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000724
725 ${If} ${SectionIsSelected} ${id_section_pluginhome}
726 ReadEnvStr $3 "COMSPEC"
727 Call GetHomeDir
728 Pop $4
729 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
730 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000731SectionEnd
732
733##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100734!macro SaveSectionSelection section_id reg_value
735 ${If} ${SectionIsSelected} ${section_id}
736 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
737 ${Else}
738 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
739 ${EndIf}
740!macroend
741
Bram Moolenaar071d4272004-06-13 20:20:40 +0000742Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100743
744 # Get estimated install size
745 SectionGetSize ${id_section_exe} $3
746 ${If} ${SectionIsSelected} ${id_section_console}
747 SectionGetSize ${id_section_console} $4
748 IntOp $3 $3 + $4
749 ${EndIf}
750 ${If} ${SectionIsSelected} ${id_section_editwith}
751 SectionGetSize ${id_section_editwith} $4
752 IntOp $3 $3 + $4
753 ${EndIf}
Restorer51c94b62024-03-24 09:41:18 +0000754!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100755 ${If} ${SectionIsSelected} ${id_section_nls}
756 SectionGetSize ${id_section_nls} $4
757 IntOp $3 $3 + $4
758 ${EndIf}
759!endif
760
761 # Register EstimatedSize and AllowSilent.
762 # Other information will be set by the install.exe (dosinst.c).
763 ${If} ${RunningX64}
764 SetRegView 64
765 ${EndIf}
766 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
767 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
768 ${If} ${RunningX64}
769 SetRegView lastused
770 ${EndIf}
771
772 # Store the selections to the registry.
773 ${If} ${RunningX64}
774 SetRegView 64
775 ${EndIf}
776 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
777 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
778 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
779 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
780 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
781 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
782 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
783 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000784!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100785 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
786!endif
787 ${If} ${RunningX64}
788 SetRegView lastused
789 ${EndIf}
790
Bram Moolenaar071d4272004-06-13 20:20:40 +0000791 BringToFront
792SectionEnd
793
794##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100795!macro LoadSectionSelection section_id reg_value
796 ClearErrors
797 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
798 ${IfNot} ${Errors}
799 ${If} $3 = 1
800 !insertmacro SelectSection ${section_id}
801 ${Else}
802 !insertmacro UnselectSection ${section_id}
803 ${EndIf}
804 ${EndIf}
805!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200806
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200807!macro LoadDefaultVimrc out_var reg_value default_value
808 ClearErrors
809 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
810 ${If} ${Errors}
811 ${OrIf} ${out_var} == ""
812 StrCpy ${out_var} ${default_value}
813 ${EndIf}
814!macroend
815
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100816Function .onInit
Restorer51c94b62024-03-24 09:41:18 +0000817!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100818 # Select a language (or read from the registry).
819 !insertmacro MUI_LANGDLL_DISPLAY
820!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200821
RestorerZ2730d382025-01-17 14:04:44 +0100822!if ${HAVE_NLS}
823 ClearErrors
824 System::Call 'kernel32::GetUserDefaultLocaleName(t.r19, *i${NSIS_MAX_STRLEN})'
825 StrCmp $R9 "zh-cn" coincide 0
RestorerZf8770402025-02-24 19:42:36 +0100826 StrCmp $R9 "zh-tw" coincide 0
827 StrCmp $R9 "pt-br" 0 part
RestorerZ2730d382025-01-17 14:04:44 +0100828 coincide:
829 System::Call 'User32::CharLower(t r19 r19)*i${NSIS_MAX_STRLEN}'
830 ${StrRep} $lng_usr "$R9" "-" "_"
831 Goto done
832 part:
833 StrCpy $lng_usr $R9 2
834 done:
835!endif
836
Christian Brabandt7d603842021-07-24 21:19:42 +0200837 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
838 # Check $VIM
839 ReadEnvStr $3 "VIM"
840 ${If} $3 != ""
841 StrCpy $INSTDIR $3
842 ${EndIf}
843 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100844
845 call CheckOldVim
846 Pop $3
847 ${If} $3 == ""
848 # No old versions of Vim found. Unselect and hide the section.
849 !insertmacro UnselectSection ${id_section_old_ver}
850 SectionSetInstTypes ${id_section_old_ver} 0
851 SectionSetText ${id_section_old_ver} ""
852 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200853 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100854 StrCpy $INSTDIR $3
855 ${EndIf}
856 ${EndIf}
857
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100858 ${If} ${RunningX64}
859 SetRegView 64
860 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200861 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100862 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
863 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
864 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
865 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
866 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
867 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
868 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
869 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000870!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100871 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
872!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200873 # Load the default _vimrc settings from the registry (if any).
874 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
875 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
876 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100877 ${If} ${RunningX64}
878 SetRegView lastused
879 ${EndIf}
880
881 # User variables:
882 # $0 - holds the directory the executables are installed to
883 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
884 # registration (since a non-OLE gvim will not complain, and we want to
885 # always register an OLE gvim).
886 # $2 - holds the names to create batch files for
887 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
888 StrCpy $1 "-register-OLE"
889 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200890FunctionEnd
891
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100892Function .onInstSuccess
893 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
894FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200895
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100896Function .onInstFailed
897 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200898FunctionEnd
899
900##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100901Function SetCustom
902 # Display the _vimrc setting dialog using nsDialogs.
903
904 # Check if a _vimrc should be created
905 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
906 Abort
907 ${EndIf}
908
909 !insertmacro MUI_HEADER_TEXT \
910 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
911
912 nsDialogs::Create 1018
913 Pop $vim_dialog
914
915 ${If} $vim_dialog == error
916 Abort
917 ${EndIf}
918
919 ${If} ${RunningX64}
920 SetRegView 64
921 ${EndIf}
922
923 GetFunctionAddress $3 ValidateCustom
924 nsDialogs::OnBack $3
925
926
927 # 1st group - Compatibility
Restorer6dcf59b2024-03-25 15:38:37 +0000928 ${NSD_CreateGroupBox} 0u 0u 296u 44u $(str_msg_compat_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100929 Pop $3
930
Restorer6dcf59b2024-03-25 15:38:37 +0000931 ${NSD_CreateLabel} 16u 14u 269u 10u $(str_msg_compat_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100932 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000933 ${NSD_CreateDropList} 42u 26u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100934 Pop $vim_nsd_compat
935 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
936 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
937 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
938 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
939
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200940 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100941 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200942 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100943 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200944 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100945 StrCpy $4 0
946 ${Else} # default
947 StrCpy $4 3
948 ${EndIf}
949 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
950
951
952 # 2nd group - Key remapping
Restorer6dcf59b2024-03-25 15:38:37 +0000953 ${NSD_CreateGroupBox} 0u 48u 296u 44u $(str_msg_keymap_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100954 Pop $3
955
Restorer6dcf59b2024-03-25 15:38:37 +0000956 ${NSD_CreateLabel} 16u 62u 269u 10u $(str_msg_keymap_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100957 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000958 ${NSD_CreateDropList} 42u 74u 236u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100959 Pop $vim_nsd_keymap
960 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
961 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
962
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200963 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100964 StrCpy $4 1
965 ${Else} # default
966 StrCpy $4 0
967 ${EndIf}
968 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
969
970
971 # 3rd group - Mouse behavior
Restorer6dcf59b2024-03-25 15:38:37 +0000972 ${NSD_CreateGroupBox} 0u 95u 296u 44u $(str_msg_mouse_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100973 Pop $3
974
Restorer6dcf59b2024-03-25 15:38:37 +0000975 ${NSD_CreateLabel} 16u 108u 269u 10u $(str_msg_mouse_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100976 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000977 ${NSD_CreateDropList} 42u 121u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100978 Pop $vim_nsd_mouse
979 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
980 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
981 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
982
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200983 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100984 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200985 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100986 StrCpy $4 1
987 ${Else} # default
988 StrCpy $4 0
989 ${EndIf}
990 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
991
992 ${If} ${RunningX64}
993 SetRegView lastused
994 ${EndIf}
995
996 nsDialogs::Show
997FunctionEnd
998
999Function ValidateCustom
1000 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
1001 ${If} $3 = 0
1002 StrCpy $vim_compat_stat "vi"
1003 ${ElseIf} $3 = 1
1004 StrCpy $vim_compat_stat "vim"
1005 ${ElseIf} $3 = 2
1006 StrCpy $vim_compat_stat "defaults"
1007 ${Else}
1008 StrCpy $vim_compat_stat "all"
1009 ${EndIf}
1010
1011 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
1012 ${If} $3 = 0
1013 StrCpy $vim_keymap_stat "default"
1014 ${Else}
1015 StrCpy $vim_keymap_stat "windows"
1016 ${EndIf}
1017
1018 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
1019 ${If} $3 = 0
1020 StrCpy $vim_mouse_stat "default"
1021 ${ElseIf} $3 = 1
1022 StrCpy $vim_mouse_stat "windows"
1023 ${Else}
1024 StrCpy $vim_mouse_stat "xterm"
1025 ${EndIf}
1026FunctionEnd
1027
1028##########################################################
1029# Description for Installer Sections
1030
1031!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
1032 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
1033 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
1034 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
1035 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
1036 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
1037 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
1038 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
1039 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
1040 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
1041 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
1042 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
1043 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +00001044!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001045 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
1046!endif
1047!insertmacro MUI_FUNCTION_DESCRIPTION_END
1048
1049
1050##########################################################
1051# Uninstaller Functions and Sections
1052
1053Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +00001054!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001055 # Get the language from the registry.
1056 !insertmacro MUI_UNGETLANGUAGE
1057!endif
1058FunctionEnd
1059
1060Section "un.$(str_unsection_register)" id_unsection_register
1061 SectionIn RO
1062
Bram Moolenaar071d4272004-06-13 20:20:40 +00001063 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +01001064 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065 StrCpy $0 "$INSTDIR"
1066
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001068 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001069 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001070 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071
1072 # We may have been put to the background when uninstall did something.
1073 BringToFront
1074
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001075 # Delete the installer language setting.
1076 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1077SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001079Section "un.$(str_unsection_exe)" id_unsection_exe
1080
1081 StrCpy $0 "$INSTDIR"
1082
1083 # Delete gettext and iconv DLLs
1084 ${If} ${FileExists} "$0\libiconv-2.dll"
1085 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1086 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001087 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001088 ${If} ${FileExists} "$0\libintl-8.dll"
1089 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1090 "$0\libintl-8.dll"
1091 ${EndIf}
1092 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1093 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1094 "$0\libgcc_s_sjlj-1.dll"
1095 ${EndIf}
1096
1097 # Delete other DLLs
1098 Delete /REBOOTOK $0\*.dll
1099
1100 # Delete 64-bit GvimExt
1101 ${If} ${RunningX64}
1102 !define LIBRARY_X64
1103 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1104 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1105 "$0\GvimExt64\gvimext.dll"
1106 ${EndIf}
1107 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1108 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1109 "$0\GvimExt64\libiconv-2.dll"
1110 ${EndIf}
1111 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1112 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1113 "$0\GvimExt64\libintl-8.dll"
1114 ${EndIf}
1115 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1116 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1117 "$0\GvimExt64\libwinpthread-1.dll"
1118 ${EndIf}
1119 !undef LIBRARY_X64
1120 RMDir /r $0\GvimExt64
1121 ${EndIf}
1122
1123 # Delete 32-bit GvimExt
1124 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1125 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1126 "$0\GvimExt32\gvimext.dll"
1127 ${EndIf}
1128 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1129 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1130 "$0\GvimExt32\libiconv-2.dll"
1131 ${EndIf}
1132 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1133 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1134 "$0\GvimExt32\libintl-8.dll"
1135 ${EndIf}
1136 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1137 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1138 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1139 ${EndIf}
1140 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001141
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 ClearErrors
1143 # Remove everything but *.dll files. Avoids that
1144 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001145 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146 RMDir /r $0\colors
1147 RMDir /r $0\compiler
1148 RMDir /r $0\doc
1149 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001150 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001151 RMDir /r $0\indent
1152 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001153 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001155 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156 RMDir /r $0\syntax
1157 RMDir /r $0\tools
1158 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001159 RMDir /r $0\lang
1160 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001161 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001162 Delete $0\*.exe
1163 Delete $0\*.bat
1164 Delete $0\*.vim
1165 Delete $0\*.txt
1166
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001167 ${If} ${Errors}
1168 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1169 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001170
RestorerZ2680a072024-03-20 20:15:51 +01001171 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172 # gvimext.dll may still be there.
1173 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001174SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001176# Remove "vimfiles" directory under the specified directory.
1177!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001178 ${If} ${FileExists} ${dir}\_viminfo
1179 Delete ${dir}\_viminfo
1180 ${EndIf}
1181 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001182 RMDir ${dir}\vimfiles\colors
1183 RMDir ${dir}\vimfiles\compiler
1184 RMDir ${dir}\vimfiles\doc
1185 RMDir ${dir}\vimfiles\ftdetect
1186 RMDir ${dir}\vimfiles\ftplugin
1187 RMDir ${dir}\vimfiles\indent
1188 RMDir ${dir}\vimfiles\keymap
1189 RMDir ${dir}\vimfiles\plugin
1190 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001191 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1192 Delete ${dir}\vimfiles\.netrwhist*
1193 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001194 RMDir ${dir}\vimfiles
1195 ${EndIf}
1196!macroend
1197
1198SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1199 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1200 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001201 Call un.GetHomeDir
1202 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001203
1204 ${If} $0 != ""
1205 !insertmacro RemoveVimfiles $0
1206 ${EndIf}
1207 SectionEnd
1208
1209 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1210 # get the parent dir of the installation
1211 Push $INSTDIR
1212 Call un.GetParent
1213 Pop $0
1214
1215 # if a plugin dir was created at installation remove it
1216 !insertmacro RemoveVimfiles $0
1217 SectionEnd
1218SectionGroupEnd
1219
1220Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001221 # get the parent dir of the installation
1222 Push $INSTDIR
1223 Call un.GetParent
1224 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001225
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001226 ${IfNot} ${Silent}
1227 Delete $0\_vimrc
1228 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001229 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001231
1232##########################################################
1233# Description for Uninstaller Sections
1234
1235!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1236 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1237 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1238 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1239 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1240 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1241 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1242!insertmacro MUI_UNFUNCTION_DESCRIPTION_END