blob: eef8a122277962c8aca3b768b7660b5ebdaca4dc [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
K.Takata48f38332024-10-07 20:37:00 +020056# if you don't want to include libgcc_s_sjlj-1.dll in the package, use the
57# switch /DINCLUDE_LIBGCC=0 on the command line makensis.exe.
58!ifndef INCLUDE_LIBGCC
59 !define INCLUDE_LIBGCC 1
60!endif
61
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010062!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000063
Restorer51c94b62024-03-24 09:41:18 +000064# Definition of Patch for Vim.
Bram Moolenaar9d591522019-05-26 20:49:42 +020065!ifndef PATCHLEVEL
66 !define PATCHLEVEL 0
67!endif
68
Bram Moolenaar071d4272004-06-13 20:20:40 +000069# ----------- No configurable settings below this line -----------
70
Restorer51c94b62024-03-24 09:41:18 +000071!include "Library.nsh" # for DLL install
Bram Moolenaaraf610b82018-12-21 16:22:50 +010072!include "LogicLib.nsh"
73!include "MUI2.nsh"
74!include "nsDialogs.nsh"
75!include "Sections.nsh"
76!include "x64.nsh"
RestorerZ2730d382025-01-17 14:04:44 +010077!include "StrFunc.nsh"
78${StrRep}
Bram Moolenaar071d4272004-06-13 20:20:40 +000079
RestorerZ2680a072024-03-20 20:15:51 +010080# See https://nsis.sourceforge.io/LogicLib
81;FileExists is already part of LogicLib, but returns true for directories
82;as well as files
83!macro _FileExists2 _a _b _t _f
84 !insertmacro _LOGICLIB_TEMP
85 StrCpy $_LOGICLIB_TEMP "0"
86;if path is not blank, continue to next check
87 StrCmp `${_b}` `` +4 0
88;if path exists, continue to next check (IfFileExists returns true if this
89;is a directory)
90 IfFileExists `${_b}` `0` +3
91;if path is not a directory, continue to confirm exists
92 IfFileExists `${_b}\*.*` +2 0
93 StrCpy $_LOGICLIB_TEMP "1" ;file exists
94;now we have a definitive value - the file exists or it does not
95 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
96!macroend
97!undef FileExists
98!define FileExists `"" FileExists2`
99!macro _DirExists _a _b _t _f
100 !insertmacro _LOGICLIB_TEMP
101 StrCpy $_LOGICLIB_TEMP "0"
102;if path is not blank, continue to next check
103 StrCmp `${_b}` `` +3 0
104;if directory exists, continue to confirm exists
105 IfFileExists `${_b}\*.*` 0 +2
106 StrCpy $_LOGICLIB_TEMP "1"
107 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
108!macroend
109!define DirExists `"" DirExists`
110
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100111!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
112!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
113!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
114
Restorer51c94b62024-03-24 09:41:18 +0000115!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100116Name "${PRODUCT} (x64)"
117!else
118Name "${PRODUCT}"
119!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
121CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +0100122SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100123SetCompressorDictSize 64
124ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +0200126RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127
Restorer51c94b62024-03-24 09:41:18 +0000128!if ${HAVE_UPX}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
130!endif
131
Restorer51c94b62024-03-24 09:41:18 +0000132!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100133!define BIT 64
134!else
135!define BIT 32
136!endif
137
138##########################################################
139# MUI2 settings
140
141!define MUI_ABORTWARNING
142!define MUI_UNABORTWARNING
143
144!define MUI_ICON "icons\vim_16c.ico"
145!define MUI_UNICON "icons\vim_uninst_16c.ico"
146
147# Show all languages, despite user's codepage:
148!define MUI_LANGDLL_ALLLANGUAGES
Restorer6dcf59b2024-03-25 15:38:37 +0000149# Always show dialog choice language
150#!define MUI_LANGDLL_ALWAYSSHOW
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100151!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
152!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
153!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
154
155!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
156!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
157!define MUI_HEADERIMAGE
158!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
159!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
160
161!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
162!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
163!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
164!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
165
166!define MUI_COMPONENTSPAGE_SMALLDESC
167!define MUI_LICENSEPAGE_CHECKBOX
Restorer74a23312024-03-28 09:19:44 +0000168!define MUI_FINISHPAGE_SHOWREADME
169!define MUI_FINISHPAGE_SHOWREADME_TEXT $(str_show_readme)
170!define MUI_FINISHPAGE_SHOWREADME_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100171
172# This adds '\Vim' to the user choice automagically. The actual value is
173# obtained below with CheckOldVim.
Restorer51c94b62024-03-24 09:41:18 +0000174!if ${WIN64}
Christian Brabandt7d603842021-07-24 21:19:42 +0200175 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100176!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200177 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100178!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200179InstallDir ${DEFAULT_INSTDIR}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180
181# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100182InstType $(str_type_typical)
183InstType $(str_type_minimal)
184InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185
186SilentInstall normal
187
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100188# General custom functions for MUI2:
189#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
190#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
191
192# Installer pages
193!insertmacro MUI_PAGE_WELCOME
Restorer74a23312024-03-28 09:19:44 +0000194!insertmacro MUI_PAGE_LICENSE $(page_lic_file)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100195!insertmacro MUI_PAGE_COMPONENTS
196Page custom SetCustom ValidateCustom
197#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
198!insertmacro MUI_PAGE_DIRECTORY
199!insertmacro MUI_PAGE_INSTFILES
200!define MUI_FINISHPAGE_NOREBOOTSUPPORT
201!insertmacro MUI_PAGE_FINISH
202
203# Uninstaller pages:
204!insertmacro MUI_UNPAGE_CONFIRM
205#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
206!insertmacro MUI_UNPAGE_COMPONENTS
207!insertmacro MUI_UNPAGE_INSTFILES
208!define MUI_FINISHPAGE_NOREBOOTSUPPORT
209!insertmacro MUI_UNPAGE_FINISH
210
211##########################################################
212# Languages Files
213
214!insertmacro MUI_RESERVEFILE_LANGDLL
215!include "lang\english.nsi"
216
217# Include support for other languages:
Restorer51c94b62024-03-24 09:41:18 +0000218!if ${HAVE_MULTI_LANG}
Rafael Fontenelleb2bd8de2025-02-25 21:05:22 +0100219 !include "lang\portuguesebr.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100220 !include "lang\danish.nsi"
221 !include "lang\dutch.nsi"
222 !include "lang\german.nsi"
Christos Longrosc62dacb2024-03-06 20:53:02 +0100223 !include "lang\greek.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100224 !include "lang\italian.nsi"
225 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200226 !include "lang\russian.nsi"
Ivan Pešiće1051922024-03-05 23:34:00 +0400227 !include "lang\serbian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100228 !include "lang\simpchinese.nsi"
229 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100230 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100231!endif
232
Bram Moolenaardabfde02019-05-17 12:37:27 +0200233##########################################################
234# Version resources
235
236VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
RestorerZec67ee02024-04-25 21:25:19 +0200237VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "The Vim Project"
Bram Moolenaardabfde02019-05-17 12:37:27 +0200238VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
239VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
240VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200241VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
242VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100243
244# Global variables
245Var vim_dialog
246Var vim_nsd_compat
247Var vim_nsd_keymap
248Var vim_nsd_mouse
249Var vim_compat_stat
250Var vim_keymap_stat
251Var vim_mouse_stat
RestorerZ2730d382025-01-17 14:04:44 +0100252!if ${HAVE_NLS}
253Var lng_usr
254!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100255
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256
Bram Moolenaar5d424742018-02-04 19:11:30 +0100257# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100258ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100259
Bram Moolenaar071d4272004-06-13 20:20:40 +0000260##########################################################
261# Functions
262
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100263# Get parent directory
264# Share this function both on installer and uninstaller
265!macro GetParent un
266Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000267 Exch $0 ; old $0 is on top of stack
268 Push $1
269 Push $2
270 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100271 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000272 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100273 ${If} $2 == ""
274 ${OrIf} $2 == "\"
275 ${ExitDo}
276 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000277 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100278 ${Loop}
279 StrCpy $0 $0 $1
280 Pop $2
281 Pop $1
282 Exch $0 ; put $0 on top of stack, restore $0 to original value
283FunctionEnd
284!macroend
285
286!insertmacro GetParent ""
287!insertmacro GetParent "un."
288
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000289# Get home directory
290!macro GetHomeDir un
291Function ${un}GetHomeDir
292 Push $0
293 Push $1
294 ReadEnvStr $0 "HOME"
295 ${If} $0 == ""
296 ReadEnvStr $0 "HOMEDRIVE"
297 ReadEnvStr $1 "HOMEPATH"
298 StrCpy $0 "$0$1"
299 ${If} $0 == ""
300 ReadEnvStr $0 "USERPROFILE"
301 ${EndIf}
302 ${EndIf}
303 Pop $1
304 Exch $0 # put $0 on top of stack, restore $0 to original value
305FunctionEnd
306!macroend
307
308!insertmacro GetHomeDir ""
309!insertmacro GetHomeDir "un."
310
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100311# Check if Vim is already installed.
312# return: Installed directory. If not found, it will be empty.
313Function CheckOldVim
314 Push $0
315 Push $R0
316 Push $R1
317 Push $R2
318
319 ${If} ${RunningX64}
320 SetRegView 64
321 ${EndIf}
322
323 ClearErrors
324 StrCpy $0 "" # Installed directory
325 StrCpy $R0 0 # Sub-key index
326 StrCpy $R1 "" # Sub-key
327 ${Do}
328 # Eumerate the sub-key:
329 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
330
331 # Stop if no more sub-key:
332 ${If} ${Errors}
333 ${OrIf} $R1 == ""
334 ${ExitDo}
335 ${EndIf}
336
337 # Move to the next sub-key:
338 IntOp $R0 $R0 + 1
339
340 # Check if the key is Vim uninstall key or not:
341 StrCpy $R2 $R1 4
342 ${If} $R2 S!= "Vim "
343 ${Continue}
344 ${EndIf}
345
346 # Verifies required sub-keys:
347 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
348 ${If} ${Errors}
349 ${OrIf} $R2 == ""
350 ${Continue}
351 ${EndIf}
352
353 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
354 ${If} ${Errors}
355 ${OrIf} $R2 == ""
356 ${Continue}
357 ${EndIf}
358
359 # Found
360 Push $R2
361 call GetParent
362 call GetParent
363 Pop $0 # Vim directory
364 ${ExitDo}
365
366 ${Loop}
367
368 ${If} ${RunningX64}
369 SetRegView lastused
370 ${EndIf}
371
372 Pop $R2
373 Pop $R1
374 Pop $R0
375 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376FunctionEnd
377
Bram Moolenaar4a228972021-05-01 22:41:39 +0200378Function LaunchApplication
379 SetOutPath $0
Restorer74a23312024-03-28 09:19:44 +0000380 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\$(vim_readme_file)"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200381FunctionEnd
382
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100384Section "$(str_section_old_ver)" id_section_old_ver
385 SectionIn 1 2 3 RO
386
387 # run the install program to check for already installed versions
388 SetOutPath $TEMP
389 File /oname=install.exe ${VIMSRC}\installw32.exe
390 DetailPrint "$(str_msg_uninstalling)"
391 ${Do}
392 nsExec::Exec "$TEMP\install.exe -uninstall-check"
393 Pop $3
394
395 call CheckOldVim
396 Pop $3
397 ${If} $3 == ""
398 ${ExitDo}
399 ${Else}
400 # It seems that the old version is still remaining.
401 # TODO: Should we show a warning and run the uninstaller again?
402
403 ${ExitDo} # Just ignore for now.
404 ${EndIf}
405 ${Loop}
406 Delete $TEMP\install.exe
407 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
408
409 # We may have been put to the background when uninstall did something.
410 BringToFront
411SectionEnd
412
413##########################################################
414Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200415 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416
417 # we need also this here if the user changes the instdir
418 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
419
420 SetOutPath $0
421 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200422!if /FileExists "${VIMSRC}\vim${BIT}.dll"
423 File ${VIMSRC}\vim${BIT}.dll
424!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200426 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200428 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100430 File ..\vimtutor.bat
431 File ..\README.txt
RestorerZ2730d382025-01-17 14:04:44 +0100432 File /oname=LICENSE.txt ..\LICENSE
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200433 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000435
RestorerZ2680a072024-03-20 20:15:51 +0100436!if /FileExists "${VIMTOOLS}\diff.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200437 File ${VIMTOOLS}\diff.exe
RestorerZ2680a072024-03-20 20:15:51 +0100438!endif
439!if /FileExists "${VIMTOOLS}\winpty${BIT}.dll"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100440 File ${VIMTOOLS}\winpty${BIT}.dll
RestorerZ2680a072024-03-20 20:15:51 +0100441!endif
442!if /FileExists "${VIMTOOLS}\winpty-agent.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200443 File ${VIMTOOLS}\winpty-agent.exe
RestorerZ2680a072024-03-20 20:15:51 +0100444!endif
RestorerZ49f1e192024-04-09 23:04:44 +0200445!if /FileExists "${VIMTOOLS}\libsodium.dll"
446 File ${VIMTOOLS}\libsodium.dll
447!endif
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200448
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100450 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451
452 SetOutPath $0\compiler
453 File ${VIMRT}\compiler\*.*
454
455 SetOutPath $0\doc
RestorerZ2680a072024-03-20 20:15:51 +0100456 File /x uganda.nsis.txt ${VIMRT}\doc\*.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 File ${VIMRT}\doc\tags
458
459 SetOutPath $0\ftplugin
460 File ${VIMRT}\ftplugin\*.*
461
462 SetOutPath $0\indent
RestorerZ2680a072024-03-20 20:15:51 +0100463 File ${VIMRT}\indent\README.txt
464 File ${VIMRT}\indent\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465
Ken Takata1a9aba82024-01-16 17:14:29 +0100466 SetOutPath $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +0100467 File ${VIMRT}\keymap\README.txt
468 File ${VIMRT}\keymap\*.vim
Ken Takata1a9aba82024-01-16 17:14:29 +0100469
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470 SetOutPath $0\macros
RestorerZ2680a072024-03-20 20:15:51 +0100471 File /r /x *.info ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000472
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100473 SetOutPath $0\pack
474 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200475
Bram Moolenaar071d4272004-06-13 20:20:40 +0000476 SetOutPath $0\plugin
477 File ${VIMRT}\plugin\*.*
478
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000479 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100480 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000481
Bram Moolenaar44433da2022-05-06 18:08:52 +0100482 SetOutPath $0\import\dist
483 File ${VIMRT}\import\dist\*.*
484
Christian Brabandt176711f2022-03-11 15:24:11 +0000485 SetOutPath $0\bitmaps
486 File ${VIMSRC}\vim.ico
487
Bram Moolenaar071d4272004-06-13 20:20:40 +0000488 SetOutPath $0\syntax
RestorerZ2680a072024-03-20 20:15:51 +0100489 File /r /x testdir /x generator /x Makefile ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000491 SetOutPath $0\spell
492 File ${VIMRT}\spell\*.txt
493 File ${VIMRT}\spell\*.vim
494 File ${VIMRT}\spell\*.spl
495 File ${VIMRT}\spell\*.sug
496
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497 SetOutPath $0\tools
498 File ${VIMRT}\tools\*.*
499
500 SetOutPath $0\tutor
RestorerZ44a2e3c2025-06-29 16:23:33 +0200501 File /r /x *.info ${VIMRT}\tutor\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000502SectionEnd
503
504##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100505Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000506 SectionIn 1 3
507
508 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100509 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000510 StrCpy $2 "$2 vim view vimdiff"
511SectionEnd
512
513##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100514Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000515 SectionIn 3
516
517 StrCpy $1 "$1 -create-batfiles $2"
518SectionEnd
519
520##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100521SectionGroup $(str_group_icons) id_group_icons
522 Section "$(str_section_desktop)" id_section_desktop
523 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100525 StrCpy $1 "$1 -install-icons"
526 SectionEnd
527
528 Section "$(str_section_start_menu)" id_section_startmenu
529 SectionIn 1 3
530
531 StrCpy $1 "$1 -add-start-menu"
532 SectionEnd
533SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534
535##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100536Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000537 SectionIn 1 3
538
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200540
Bram Moolenaar442b4222010-05-24 21:34:22 +0200541 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200542 # Install 64-bit gvimext.dll into the GvimExt64 directory.
543 SetOutPath $0\GvimExt64
544 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100545 !define LIBRARY_SHELL_EXTENSION
546 !define LIBRARY_X64
547 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
548 "${VIMSRC}\GvimExt\gvimext64.dll" \
549 "$0\GvimExt64\gvimext.dll" "$0"
550 !undef LIBRARY_X64
551 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200552 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200553
Bram Moolenaar6199d432017-10-14 19:05:44 +0200554 # Install 32-bit gvimext.dll into the GvimExt32 directory.
555 SetOutPath $0\GvimExt32
556 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100557 !define LIBRARY_SHELL_EXTENSION
558 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
559 "${VIMSRC}\GvimExt\gvimext.dll" \
560 "$0\GvimExt32\gvimext.dll" "$0"
561 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562
563 # We don't have a separate entry for the "Open With..." menu, assume
564 # the user wants either both or none.
565 StrCpy $1 "$1 -install-popup -install-openwith"
566SectionEnd
567
568##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100569Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000570 SectionIn 1 3
571
572 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100573
574 ${If} ${RunningX64}
575 SetRegView 64
576 ${EndIf}
577 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
578 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
579 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
580 ${If} ${RunningX64}
581 SetRegView lastused
582 ${EndIf}
583
584 ${If} $vim_compat_stat == "vi"
585 StrCpy $1 "$1 -vimrc-compat vi"
586 ${ElseIf} $vim_compat_stat == "vim"
587 StrCpy $1 "$1 -vimrc-compat vim"
588 ${ElseIf} $vim_compat_stat == "defaults"
589 StrCpy $1 "$1 -vimrc-compat defaults"
590 ${Else}
591 StrCpy $1 "$1 -vimrc-compat all"
592 ${EndIf}
593
594 ${If} $vim_keymap_stat == "default"
595 StrCpy $1 "$1 -vimrc-remap no"
596 ${Else}
597 StrCpy $1 "$1 -vimrc-remap win"
598 ${EndIf}
599
600 ${If} $vim_mouse_stat == "default"
601 StrCpy $1 "$1 -vimrc-behave default"
602 ${ElseIf} $vim_mouse_stat == "windows"
603 StrCpy $1 "$1 -vimrc-behave mswin"
604 ${Else}
605 StrCpy $1 "$1 -vimrc-behave unix"
606 ${EndIf}
607
Bram Moolenaar071d4272004-06-13 20:20:40 +0000608SectionEnd
609
610##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100611SectionGroup $(str_group_plugin) id_group_plugin
612 Section "$(str_section_plugin_home)" id_section_pluginhome
613 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000615 # use ShellExecAsUser below instead
616 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100617 SectionEnd
618
619 Section "$(str_section_plugin_vim)" id_section_pluginvim
620 SectionIn 3
621
622 StrCpy $1 "$1 -create-directories vim"
623 SectionEnd
624SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000625
626##########################################################
Restorer51c94b62024-03-24 09:41:18 +0000627!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100628Section "$(str_section_nls)" id_section_nls
629 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630
RestorerZ2730d382025-01-17 14:04:44 +0100631 SetOutPath $INSTDIR
632!if /FileExists "..\lang\README.*.txt"
633 File ..\lang\README.*.txt
634 CopyFiles /SILENT /FILESONLY $INSTDIR\README.$lng_usr.txt \
635 $INSTDIR\vim${VER_MAJOR}${VER_MINOR}\README.$lng_usr.txt
636 Delete $INSTDIR\README.*.txt
Restorer74a23312024-03-28 09:19:44 +0000637!endif
RestorerZ2730d382025-01-17 14:04:44 +0100638!if /FileExists "..\lang\LICENSE.??.txt"
639 File ..\lang\LICENSE.??.txt
640!if /FileExists "..\lang\LICENSE.??_??.txt"
641 File ..\lang\LICENSE.??_??.txt
Restorer74a23312024-03-28 09:19:44 +0000642!endif
RestorerZ2730d382025-01-17 14:04:44 +0100643 CopyFiles /SILENT /FILESONLY $INSTDIR\LICENSE.$lng_usr.txt \
644 $INSTDIR\vim${VER_MAJOR}${VER_MINOR}\LICENSE.$lng_usr.txt
645 Delete $INSTDIR\LICENSE.*.txt
Restorer74a23312024-03-28 09:19:44 +0000646!endif
RestorerZ2730d382025-01-17 14:04:44 +0100647
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100648 SetOutPath $0\lang
RestorerZ2680a072024-03-20 20:15:51 +0100649 File /r /x Makefile ${VIMRT}\lang\*.*
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100650 SetOutPath $0
651 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
652 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
653 "$0\libintl-8.dll" "$0"
654 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
655 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
656 "$0\libiconv-2.dll" "$0"
K.Takata48f38332024-10-07 20:37:00 +0200657!if ${INCLUDE_LIBGCC}
658!if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
659 # Install libgcc_s_sjlj-1.dll only if it is needed.
660 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
661 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
662 "$0\libgcc_s_sjlj-1.dll" "$0"
663!endif
664!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100665
666 ${If} ${SectionIsSelected} ${id_section_editwith}
667 ${If} ${RunningX64}
668 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
669 SetOutPath $0\GvimExt64
670 ClearErrors
671 !define LIBRARY_X64
672 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
673 "${GETTEXT}\gettext64\libintl-8.dll" \
674 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
675 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
676 "${GETTEXT}\gettext64\libiconv-2.dll" \
677 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
678 !undef LIBRARY_X64
679 ${EndIf}
680
681 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
682 SetOutPath $0\GvimExt32
683 ClearErrors
684 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
685 "${GETTEXT}\gettext32\libintl-8.dll" \
686 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
687 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
688 "${GETTEXT}\gettext32\libiconv-2.dll" \
689 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
K.Takata48f38332024-10-07 20:37:00 +0200690!if ${INCLUDE_LIBGCC}
691!if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
692 # Install libgcc_s_sjlj-1.dll only if it is needed.
693 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
694 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
695 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
696!endif
697!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100698 ${EndIf}
699SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000700!endif
701
702##########################################################
703Section -call_install_exe
704 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100705 DetailPrint "$(str_msg_registering)"
706 nsExec::Exec "$0\install.exe $1"
707 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000708
709 ${If} ${SectionIsSelected} ${id_section_pluginhome}
710 ReadEnvStr $3 "COMSPEC"
711 Call GetHomeDir
712 Pop $4
713 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
714 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000715SectionEnd
716
717##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100718!macro SaveSectionSelection section_id reg_value
719 ${If} ${SectionIsSelected} ${section_id}
720 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
721 ${Else}
722 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
723 ${EndIf}
724!macroend
725
Bram Moolenaar071d4272004-06-13 20:20:40 +0000726Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100727
728 # Get estimated install size
729 SectionGetSize ${id_section_exe} $3
730 ${If} ${SectionIsSelected} ${id_section_console}
731 SectionGetSize ${id_section_console} $4
732 IntOp $3 $3 + $4
733 ${EndIf}
734 ${If} ${SectionIsSelected} ${id_section_editwith}
735 SectionGetSize ${id_section_editwith} $4
736 IntOp $3 $3 + $4
737 ${EndIf}
Restorer51c94b62024-03-24 09:41:18 +0000738!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100739 ${If} ${SectionIsSelected} ${id_section_nls}
740 SectionGetSize ${id_section_nls} $4
741 IntOp $3 $3 + $4
742 ${EndIf}
743!endif
744
745 # Register EstimatedSize and AllowSilent.
746 # Other information will be set by the install.exe (dosinst.c).
747 ${If} ${RunningX64}
748 SetRegView 64
749 ${EndIf}
750 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
751 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
752 ${If} ${RunningX64}
753 SetRegView lastused
754 ${EndIf}
755
756 # Store the selections to the registry.
757 ${If} ${RunningX64}
758 SetRegView 64
759 ${EndIf}
760 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
761 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
762 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
763 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
764 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
765 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
766 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
767 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000768!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100769 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
770!endif
771 ${If} ${RunningX64}
772 SetRegView lastused
773 ${EndIf}
774
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775 BringToFront
776SectionEnd
777
778##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100779!macro LoadSectionSelection section_id reg_value
780 ClearErrors
781 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
782 ${IfNot} ${Errors}
783 ${If} $3 = 1
784 !insertmacro SelectSection ${section_id}
785 ${Else}
786 !insertmacro UnselectSection ${section_id}
787 ${EndIf}
788 ${EndIf}
789!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200790
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200791!macro LoadDefaultVimrc out_var reg_value default_value
792 ClearErrors
793 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
794 ${If} ${Errors}
795 ${OrIf} ${out_var} == ""
796 StrCpy ${out_var} ${default_value}
797 ${EndIf}
798!macroend
799
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100800Function .onInit
Restorer51c94b62024-03-24 09:41:18 +0000801!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100802 # Select a language (or read from the registry).
803 !insertmacro MUI_LANGDLL_DISPLAY
804!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200805
RestorerZ2730d382025-01-17 14:04:44 +0100806!if ${HAVE_NLS}
807 ClearErrors
808 System::Call 'kernel32::GetUserDefaultLocaleName(t.r19, *i${NSIS_MAX_STRLEN})'
809 StrCmp $R9 "zh-cn" coincide 0
RestorerZf8770402025-02-24 19:42:36 +0100810 StrCmp $R9 "zh-tw" coincide 0
811 StrCmp $R9 "pt-br" 0 part
RestorerZ2730d382025-01-17 14:04:44 +0100812 coincide:
813 System::Call 'User32::CharLower(t r19 r19)*i${NSIS_MAX_STRLEN}'
814 ${StrRep} $lng_usr "$R9" "-" "_"
815 Goto done
816 part:
817 StrCpy $lng_usr $R9 2
818 done:
819!endif
820
Christian Brabandt7d603842021-07-24 21:19:42 +0200821 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
822 # Check $VIM
823 ReadEnvStr $3 "VIM"
824 ${If} $3 != ""
825 StrCpy $INSTDIR $3
826 ${EndIf}
827 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100828
829 call CheckOldVim
830 Pop $3
831 ${If} $3 == ""
832 # No old versions of Vim found. Unselect and hide the section.
833 !insertmacro UnselectSection ${id_section_old_ver}
834 SectionSetInstTypes ${id_section_old_ver} 0
835 SectionSetText ${id_section_old_ver} ""
836 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200837 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100838 StrCpy $INSTDIR $3
839 ${EndIf}
840 ${EndIf}
841
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100842 ${If} ${RunningX64}
843 SetRegView 64
844 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200845 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100846 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
847 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
848 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
849 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
850 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
851 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
852 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
853 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000854!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100855 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
856!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200857 # Load the default _vimrc settings from the registry (if any).
858 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
859 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
860 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100861 ${If} ${RunningX64}
862 SetRegView lastused
863 ${EndIf}
864
865 # User variables:
866 # $0 - holds the directory the executables are installed to
867 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
868 # registration (since a non-OLE gvim will not complain, and we want to
869 # always register an OLE gvim).
870 # $2 - holds the names to create batch files for
871 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
872 StrCpy $1 "-register-OLE"
873 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200874FunctionEnd
875
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100876Function .onInstSuccess
877 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
878FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200879
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100880Function .onInstFailed
881 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200882FunctionEnd
883
884##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100885Function SetCustom
886 # Display the _vimrc setting dialog using nsDialogs.
887
888 # Check if a _vimrc should be created
889 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
890 Abort
891 ${EndIf}
892
893 !insertmacro MUI_HEADER_TEXT \
894 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
895
896 nsDialogs::Create 1018
897 Pop $vim_dialog
898
899 ${If} $vim_dialog == error
900 Abort
901 ${EndIf}
902
903 ${If} ${RunningX64}
904 SetRegView 64
905 ${EndIf}
906
907 GetFunctionAddress $3 ValidateCustom
908 nsDialogs::OnBack $3
909
910
911 # 1st group - Compatibility
Restorer6dcf59b2024-03-25 15:38:37 +0000912 ${NSD_CreateGroupBox} 0u 0u 296u 44u $(str_msg_compat_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100913 Pop $3
914
Restorer6dcf59b2024-03-25 15:38:37 +0000915 ${NSD_CreateLabel} 16u 14u 269u 10u $(str_msg_compat_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100916 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000917 ${NSD_CreateDropList} 42u 26u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100918 Pop $vim_nsd_compat
919 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
920 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
921 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
922 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
923
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200924 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100925 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200926 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100927 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200928 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100929 StrCpy $4 0
930 ${Else} # default
931 StrCpy $4 3
932 ${EndIf}
933 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
934
935
936 # 2nd group - Key remapping
Restorer6dcf59b2024-03-25 15:38:37 +0000937 ${NSD_CreateGroupBox} 0u 48u 296u 44u $(str_msg_keymap_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100938 Pop $3
939
Restorer6dcf59b2024-03-25 15:38:37 +0000940 ${NSD_CreateLabel} 16u 62u 269u 10u $(str_msg_keymap_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100941 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000942 ${NSD_CreateDropList} 42u 74u 236u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100943 Pop $vim_nsd_keymap
944 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
945 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
946
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200947 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100948 StrCpy $4 1
949 ${Else} # default
950 StrCpy $4 0
951 ${EndIf}
952 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
953
954
955 # 3rd group - Mouse behavior
Restorer6dcf59b2024-03-25 15:38:37 +0000956 ${NSD_CreateGroupBox} 0u 95u 296u 44u $(str_msg_mouse_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100957 Pop $3
958
Restorer6dcf59b2024-03-25 15:38:37 +0000959 ${NSD_CreateLabel} 16u 108u 269u 10u $(str_msg_mouse_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000961 ${NSD_CreateDropList} 42u 121u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100962 Pop $vim_nsd_mouse
963 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
964 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
965 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
966
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200967 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100968 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200969 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100970 StrCpy $4 1
971 ${Else} # default
972 StrCpy $4 0
973 ${EndIf}
974 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
975
976 ${If} ${RunningX64}
977 SetRegView lastused
978 ${EndIf}
979
980 nsDialogs::Show
981FunctionEnd
982
983Function ValidateCustom
984 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
985 ${If} $3 = 0
986 StrCpy $vim_compat_stat "vi"
987 ${ElseIf} $3 = 1
988 StrCpy $vim_compat_stat "vim"
989 ${ElseIf} $3 = 2
990 StrCpy $vim_compat_stat "defaults"
991 ${Else}
992 StrCpy $vim_compat_stat "all"
993 ${EndIf}
994
995 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
996 ${If} $3 = 0
997 StrCpy $vim_keymap_stat "default"
998 ${Else}
999 StrCpy $vim_keymap_stat "windows"
1000 ${EndIf}
1001
1002 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
1003 ${If} $3 = 0
1004 StrCpy $vim_mouse_stat "default"
1005 ${ElseIf} $3 = 1
1006 StrCpy $vim_mouse_stat "windows"
1007 ${Else}
1008 StrCpy $vim_mouse_stat "xterm"
1009 ${EndIf}
1010FunctionEnd
1011
1012##########################################################
1013# Description for Installer Sections
1014
1015!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
1016 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
1017 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
1018 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
1019 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
1020 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
1021 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
1022 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
1023 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
1024 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
1025 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
1026 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
1027 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +00001028!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001029 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
1030!endif
1031!insertmacro MUI_FUNCTION_DESCRIPTION_END
1032
1033
1034##########################################################
1035# Uninstaller Functions and Sections
1036
1037Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +00001038!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001039 # Get the language from the registry.
1040 !insertmacro MUI_UNGETLANGUAGE
1041!endif
1042FunctionEnd
1043
1044Section "un.$(str_unsection_register)" id_unsection_register
1045 SectionIn RO
1046
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +01001048 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 StrCpy $0 "$INSTDIR"
1050
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001052 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001053 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001054 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001055
1056 # We may have been put to the background when uninstall did something.
1057 BringToFront
1058
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001059 # Delete the installer language setting.
1060 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1061SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001063Section "un.$(str_unsection_exe)" id_unsection_exe
1064
1065 StrCpy $0 "$INSTDIR"
1066
1067 # Delete gettext and iconv DLLs
1068 ${If} ${FileExists} "$0\libiconv-2.dll"
1069 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1070 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001071 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001072 ${If} ${FileExists} "$0\libintl-8.dll"
1073 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1074 "$0\libintl-8.dll"
1075 ${EndIf}
1076 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1077 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1078 "$0\libgcc_s_sjlj-1.dll"
1079 ${EndIf}
1080
1081 # Delete other DLLs
1082 Delete /REBOOTOK $0\*.dll
1083
1084 # Delete 64-bit GvimExt
1085 ${If} ${RunningX64}
1086 !define LIBRARY_X64
1087 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1088 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1089 "$0\GvimExt64\gvimext.dll"
1090 ${EndIf}
1091 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1092 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1093 "$0\GvimExt64\libiconv-2.dll"
1094 ${EndIf}
1095 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1096 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1097 "$0\GvimExt64\libintl-8.dll"
1098 ${EndIf}
1099 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1100 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1101 "$0\GvimExt64\libwinpthread-1.dll"
1102 ${EndIf}
1103 !undef LIBRARY_X64
1104 RMDir /r $0\GvimExt64
1105 ${EndIf}
1106
1107 # Delete 32-bit GvimExt
1108 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1109 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1110 "$0\GvimExt32\gvimext.dll"
1111 ${EndIf}
1112 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1113 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1114 "$0\GvimExt32\libiconv-2.dll"
1115 ${EndIf}
1116 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1117 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1118 "$0\GvimExt32\libintl-8.dll"
1119 ${EndIf}
1120 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1121 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1122 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1123 ${EndIf}
1124 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001125
Bram Moolenaar071d4272004-06-13 20:20:40 +00001126 ClearErrors
1127 # Remove everything but *.dll files. Avoids that
1128 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001129 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 RMDir /r $0\colors
1131 RMDir /r $0\compiler
1132 RMDir /r $0\doc
1133 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001134 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001135 RMDir /r $0\indent
1136 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001137 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001139 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001140 RMDir /r $0\syntax
1141 RMDir /r $0\tools
1142 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143 RMDir /r $0\lang
1144 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001145 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146 Delete $0\*.exe
1147 Delete $0\*.bat
1148 Delete $0\*.vim
1149 Delete $0\*.txt
1150
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001151 ${If} ${Errors}
1152 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1153 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154
RestorerZ2680a072024-03-20 20:15:51 +01001155 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156 # gvimext.dll may still be there.
1157 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001158SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001159
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001160# Remove "vimfiles" directory under the specified directory.
1161!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001162 ${If} ${FileExists} ${dir}\_viminfo
1163 Delete ${dir}\_viminfo
1164 ${EndIf}
1165 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001166 RMDir ${dir}\vimfiles\colors
1167 RMDir ${dir}\vimfiles\compiler
1168 RMDir ${dir}\vimfiles\doc
1169 RMDir ${dir}\vimfiles\ftdetect
1170 RMDir ${dir}\vimfiles\ftplugin
1171 RMDir ${dir}\vimfiles\indent
1172 RMDir ${dir}\vimfiles\keymap
1173 RMDir ${dir}\vimfiles\plugin
1174 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001175 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1176 Delete ${dir}\vimfiles\.netrwhist*
1177 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001178 RMDir ${dir}\vimfiles
1179 ${EndIf}
1180!macroend
1181
1182SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1183 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1184 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001185 Call un.GetHomeDir
1186 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001187
1188 ${If} $0 != ""
1189 !insertmacro RemoveVimfiles $0
1190 ${EndIf}
1191 SectionEnd
1192
1193 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1194 # get the parent dir of the installation
1195 Push $INSTDIR
1196 Call un.GetParent
1197 Pop $0
1198
1199 # if a plugin dir was created at installation remove it
1200 !insertmacro RemoveVimfiles $0
1201 SectionEnd
1202SectionGroupEnd
1203
1204Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001205 # get the parent dir of the installation
1206 Push $INSTDIR
1207 Call un.GetParent
1208 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001210 ${IfNot} ${Silent}
1211 Delete $0\_vimrc
1212 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001213 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001214SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001215
1216##########################################################
1217# Description for Uninstaller Sections
1218
1219!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1220 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1221 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1222 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1223 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1224 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1225 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1226!insertmacro MUI_UNFUNCTION_DESCRIPTION_END