blob: 4aa678fbc0f5bbe8d7620a3c09b98da881f7b93a [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}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100219 !include "lang\danish.nsi"
220 !include "lang\dutch.nsi"
221 !include "lang\german.nsi"
Christos Longrosc62dacb2024-03-06 20:53:02 +0100222 !include "lang\greek.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100223 !include "lang\italian.nsi"
224 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200225 !include "lang\russian.nsi"
Ivan Pešiće1051922024-03-05 23:34:00 +0400226 !include "lang\serbian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100227 !include "lang\simpchinese.nsi"
228 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100229 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100230!endif
231
Bram Moolenaardabfde02019-05-17 12:37:27 +0200232##########################################################
233# Version resources
234
235VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
RestorerZec67ee02024-04-25 21:25:19 +0200236VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "The Vim Project"
Bram Moolenaardabfde02019-05-17 12:37:27 +0200237VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
238VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
239VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200240VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
241VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100242
243# Global variables
244Var vim_dialog
245Var vim_nsd_compat
246Var vim_nsd_keymap
247Var vim_nsd_mouse
248Var vim_compat_stat
249Var vim_keymap_stat
250Var vim_mouse_stat
RestorerZ2730d382025-01-17 14:04:44 +0100251!if ${HAVE_NLS}
252Var lng_usr
253!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100254
Bram Moolenaar071d4272004-06-13 20:20:40 +0000255
Bram Moolenaar5d424742018-02-04 19:11:30 +0100256# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100257ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100258
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259##########################################################
260# Functions
261
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100262# Get parent directory
263# Share this function both on installer and uninstaller
264!macro GetParent un
265Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000266 Exch $0 ; old $0 is on top of stack
267 Push $1
268 Push $2
269 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100270 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000271 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100272 ${If} $2 == ""
273 ${OrIf} $2 == "\"
274 ${ExitDo}
275 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000276 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100277 ${Loop}
278 StrCpy $0 $0 $1
279 Pop $2
280 Pop $1
281 Exch $0 ; put $0 on top of stack, restore $0 to original value
282FunctionEnd
283!macroend
284
285!insertmacro GetParent ""
286!insertmacro GetParent "un."
287
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000288# Get home directory
289!macro GetHomeDir un
290Function ${un}GetHomeDir
291 Push $0
292 Push $1
293 ReadEnvStr $0 "HOME"
294 ${If} $0 == ""
295 ReadEnvStr $0 "HOMEDRIVE"
296 ReadEnvStr $1 "HOMEPATH"
297 StrCpy $0 "$0$1"
298 ${If} $0 == ""
299 ReadEnvStr $0 "USERPROFILE"
300 ${EndIf}
301 ${EndIf}
302 Pop $1
303 Exch $0 # put $0 on top of stack, restore $0 to original value
304FunctionEnd
305!macroend
306
307!insertmacro GetHomeDir ""
308!insertmacro GetHomeDir "un."
309
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100310# Check if Vim is already installed.
311# return: Installed directory. If not found, it will be empty.
312Function CheckOldVim
313 Push $0
314 Push $R0
315 Push $R1
316 Push $R2
317
318 ${If} ${RunningX64}
319 SetRegView 64
320 ${EndIf}
321
322 ClearErrors
323 StrCpy $0 "" # Installed directory
324 StrCpy $R0 0 # Sub-key index
325 StrCpy $R1 "" # Sub-key
326 ${Do}
327 # Eumerate the sub-key:
328 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
329
330 # Stop if no more sub-key:
331 ${If} ${Errors}
332 ${OrIf} $R1 == ""
333 ${ExitDo}
334 ${EndIf}
335
336 # Move to the next sub-key:
337 IntOp $R0 $R0 + 1
338
339 # Check if the key is Vim uninstall key or not:
340 StrCpy $R2 $R1 4
341 ${If} $R2 S!= "Vim "
342 ${Continue}
343 ${EndIf}
344
345 # Verifies required sub-keys:
346 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
347 ${If} ${Errors}
348 ${OrIf} $R2 == ""
349 ${Continue}
350 ${EndIf}
351
352 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
353 ${If} ${Errors}
354 ${OrIf} $R2 == ""
355 ${Continue}
356 ${EndIf}
357
358 # Found
359 Push $R2
360 call GetParent
361 call GetParent
362 Pop $0 # Vim directory
363 ${ExitDo}
364
365 ${Loop}
366
367 ${If} ${RunningX64}
368 SetRegView lastused
369 ${EndIf}
370
371 Pop $R2
372 Pop $R1
373 Pop $R0
374 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000375FunctionEnd
376
Bram Moolenaar4a228972021-05-01 22:41:39 +0200377Function LaunchApplication
378 SetOutPath $0
Restorer74a23312024-03-28 09:19:44 +0000379 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\$(vim_readme_file)"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200380FunctionEnd
381
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100383Section "$(str_section_old_ver)" id_section_old_ver
384 SectionIn 1 2 3 RO
385
386 # run the install program to check for already installed versions
387 SetOutPath $TEMP
388 File /oname=install.exe ${VIMSRC}\installw32.exe
389 DetailPrint "$(str_msg_uninstalling)"
390 ${Do}
391 nsExec::Exec "$TEMP\install.exe -uninstall-check"
392 Pop $3
393
394 call CheckOldVim
395 Pop $3
396 ${If} $3 == ""
397 ${ExitDo}
398 ${Else}
399 # It seems that the old version is still remaining.
400 # TODO: Should we show a warning and run the uninstaller again?
401
402 ${ExitDo} # Just ignore for now.
403 ${EndIf}
404 ${Loop}
405 Delete $TEMP\install.exe
406 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
407
408 # We may have been put to the background when uninstall did something.
409 BringToFront
410SectionEnd
411
412##########################################################
413Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200414 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000415
416 # we need also this here if the user changes the instdir
417 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
418
419 SetOutPath $0
420 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200421!if /FileExists "${VIMSRC}\vim${BIT}.dll"
422 File ${VIMSRC}\vim${BIT}.dll
423!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200425 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200427 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000428 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100429 File ..\vimtutor.bat
430 File ..\README.txt
RestorerZ2730d382025-01-17 14:04:44 +0100431 File /oname=LICENSE.txt ..\LICENSE
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200432 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434
RestorerZ2680a072024-03-20 20:15:51 +0100435!if /FileExists "${VIMTOOLS}\diff.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200436 File ${VIMTOOLS}\diff.exe
RestorerZ2680a072024-03-20 20:15:51 +0100437!endif
438!if /FileExists "${VIMTOOLS}\winpty${BIT}.dll"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100439 File ${VIMTOOLS}\winpty${BIT}.dll
RestorerZ2680a072024-03-20 20:15:51 +0100440!endif
441!if /FileExists "${VIMTOOLS}\winpty-agent.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200442 File ${VIMTOOLS}\winpty-agent.exe
RestorerZ2680a072024-03-20 20:15:51 +0100443!endif
RestorerZ49f1e192024-04-09 23:04:44 +0200444!if /FileExists "${VIMTOOLS}\libsodium.dll"
445 File ${VIMTOOLS}\libsodium.dll
446!endif
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200447
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100449 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450
451 SetOutPath $0\compiler
452 File ${VIMRT}\compiler\*.*
453
454 SetOutPath $0\doc
RestorerZ2680a072024-03-20 20:15:51 +0100455 File /x uganda.nsis.txt ${VIMRT}\doc\*.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000456 File ${VIMRT}\doc\tags
457
458 SetOutPath $0\ftplugin
459 File ${VIMRT}\ftplugin\*.*
460
461 SetOutPath $0\indent
RestorerZ2680a072024-03-20 20:15:51 +0100462 File ${VIMRT}\indent\README.txt
463 File ${VIMRT}\indent\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000464
Ken Takata1a9aba82024-01-16 17:14:29 +0100465 SetOutPath $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +0100466 File ${VIMRT}\keymap\README.txt
467 File ${VIMRT}\keymap\*.vim
Ken Takata1a9aba82024-01-16 17:14:29 +0100468
Bram Moolenaar071d4272004-06-13 20:20:40 +0000469 SetOutPath $0\macros
RestorerZ2680a072024-03-20 20:15:51 +0100470 File /r /x *.info ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100472 SetOutPath $0\pack
473 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200474
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475 SetOutPath $0\plugin
476 File ${VIMRT}\plugin\*.*
477
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000478 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100479 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000480
Bram Moolenaar44433da2022-05-06 18:08:52 +0100481 SetOutPath $0\import\dist
482 File ${VIMRT}\import\dist\*.*
483
Christian Brabandt176711f2022-03-11 15:24:11 +0000484 SetOutPath $0\bitmaps
485 File ${VIMSRC}\vim.ico
486
Bram Moolenaar071d4272004-06-13 20:20:40 +0000487 SetOutPath $0\syntax
RestorerZ2680a072024-03-20 20:15:51 +0100488 File /r /x testdir /x generator /x Makefile ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000489
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000490 SetOutPath $0\spell
491 File ${VIMRT}\spell\*.txt
492 File ${VIMRT}\spell\*.vim
493 File ${VIMRT}\spell\*.spl
494 File ${VIMRT}\spell\*.sug
495
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496 SetOutPath $0\tools
497 File ${VIMRT}\tools\*.*
498
499 SetOutPath $0\tutor
RestorerZ2680a072024-03-20 20:15:51 +0100500 File /x Makefile /x *.info ${VIMRT}\tutor\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000501SectionEnd
502
503##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100504Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505 SectionIn 1 3
506
507 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100508 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000509 StrCpy $2 "$2 vim view vimdiff"
510SectionEnd
511
512##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100513Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514 SectionIn 3
515
516 StrCpy $1 "$1 -create-batfiles $2"
517SectionEnd
518
519##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100520SectionGroup $(str_group_icons) id_group_icons
521 Section "$(str_section_desktop)" id_section_desktop
522 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100524 StrCpy $1 "$1 -install-icons"
525 SectionEnd
526
527 Section "$(str_section_start_menu)" id_section_startmenu
528 SectionIn 1 3
529
530 StrCpy $1 "$1 -add-start-menu"
531 SectionEnd
532SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533
534##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100535Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000536 SectionIn 1 3
537
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200539
Bram Moolenaar442b4222010-05-24 21:34:22 +0200540 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200541 # Install 64-bit gvimext.dll into the GvimExt64 directory.
542 SetOutPath $0\GvimExt64
543 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100544 !define LIBRARY_SHELL_EXTENSION
545 !define LIBRARY_X64
546 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
547 "${VIMSRC}\GvimExt\gvimext64.dll" \
548 "$0\GvimExt64\gvimext.dll" "$0"
549 !undef LIBRARY_X64
550 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200551 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200552
Bram Moolenaar6199d432017-10-14 19:05:44 +0200553 # Install 32-bit gvimext.dll into the GvimExt32 directory.
554 SetOutPath $0\GvimExt32
555 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100556 !define LIBRARY_SHELL_EXTENSION
557 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
558 "${VIMSRC}\GvimExt\gvimext.dll" \
559 "$0\GvimExt32\gvimext.dll" "$0"
560 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561
562 # We don't have a separate entry for the "Open With..." menu, assume
563 # the user wants either both or none.
564 StrCpy $1 "$1 -install-popup -install-openwith"
565SectionEnd
566
567##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100568Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569 SectionIn 1 3
570
571 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100572
573 ${If} ${RunningX64}
574 SetRegView 64
575 ${EndIf}
576 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
577 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
578 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
579 ${If} ${RunningX64}
580 SetRegView lastused
581 ${EndIf}
582
583 ${If} $vim_compat_stat == "vi"
584 StrCpy $1 "$1 -vimrc-compat vi"
585 ${ElseIf} $vim_compat_stat == "vim"
586 StrCpy $1 "$1 -vimrc-compat vim"
587 ${ElseIf} $vim_compat_stat == "defaults"
588 StrCpy $1 "$1 -vimrc-compat defaults"
589 ${Else}
590 StrCpy $1 "$1 -vimrc-compat all"
591 ${EndIf}
592
593 ${If} $vim_keymap_stat == "default"
594 StrCpy $1 "$1 -vimrc-remap no"
595 ${Else}
596 StrCpy $1 "$1 -vimrc-remap win"
597 ${EndIf}
598
599 ${If} $vim_mouse_stat == "default"
600 StrCpy $1 "$1 -vimrc-behave default"
601 ${ElseIf} $vim_mouse_stat == "windows"
602 StrCpy $1 "$1 -vimrc-behave mswin"
603 ${Else}
604 StrCpy $1 "$1 -vimrc-behave unix"
605 ${EndIf}
606
Bram Moolenaar071d4272004-06-13 20:20:40 +0000607SectionEnd
608
609##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100610SectionGroup $(str_group_plugin) id_group_plugin
611 Section "$(str_section_plugin_home)" id_section_pluginhome
612 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000613
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000614 # use ShellExecAsUser below instead
615 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100616 SectionEnd
617
618 Section "$(str_section_plugin_vim)" id_section_pluginvim
619 SectionIn 3
620
621 StrCpy $1 "$1 -create-directories vim"
622 SectionEnd
623SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000624
625##########################################################
Restorer51c94b62024-03-24 09:41:18 +0000626!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100627Section "$(str_section_nls)" id_section_nls
628 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000629
RestorerZ2730d382025-01-17 14:04:44 +0100630 SetOutPath $INSTDIR
631!if /FileExists "..\lang\README.*.txt"
632 File ..\lang\README.*.txt
633 CopyFiles /SILENT /FILESONLY $INSTDIR\README.$lng_usr.txt \
634 $INSTDIR\vim${VER_MAJOR}${VER_MINOR}\README.$lng_usr.txt
635 Delete $INSTDIR\README.*.txt
Restorer74a23312024-03-28 09:19:44 +0000636!endif
RestorerZ2730d382025-01-17 14:04:44 +0100637!if /FileExists "..\lang\LICENSE.??.txt"
638 File ..\lang\LICENSE.??.txt
639!if /FileExists "..\lang\LICENSE.??_??.txt"
640 File ..\lang\LICENSE.??_??.txt
Restorer74a23312024-03-28 09:19:44 +0000641!endif
RestorerZ2730d382025-01-17 14:04:44 +0100642 CopyFiles /SILENT /FILESONLY $INSTDIR\LICENSE.$lng_usr.txt \
643 $INSTDIR\vim${VER_MAJOR}${VER_MINOR}\LICENSE.$lng_usr.txt
644 Delete $INSTDIR\LICENSE.*.txt
Restorer74a23312024-03-28 09:19:44 +0000645!endif
RestorerZ2730d382025-01-17 14:04:44 +0100646
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100647 SetOutPath $0\lang
RestorerZ2680a072024-03-20 20:15:51 +0100648 File /r /x Makefile ${VIMRT}\lang\*.*
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100649 SetOutPath $0
650 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
651 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
652 "$0\libintl-8.dll" "$0"
653 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
654 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
655 "$0\libiconv-2.dll" "$0"
K.Takata48f38332024-10-07 20:37:00 +0200656!if ${INCLUDE_LIBGCC}
657!if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
658 # Install libgcc_s_sjlj-1.dll only if it is needed.
659 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
660 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
661 "$0\libgcc_s_sjlj-1.dll" "$0"
662!endif
663!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100664
665 ${If} ${SectionIsSelected} ${id_section_editwith}
666 ${If} ${RunningX64}
667 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
668 SetOutPath $0\GvimExt64
669 ClearErrors
670 !define LIBRARY_X64
671 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
672 "${GETTEXT}\gettext64\libintl-8.dll" \
673 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
674 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
675 "${GETTEXT}\gettext64\libiconv-2.dll" \
676 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
677 !undef LIBRARY_X64
678 ${EndIf}
679
680 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
681 SetOutPath $0\GvimExt32
682 ClearErrors
683 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
684 "${GETTEXT}\gettext32\libintl-8.dll" \
685 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
686 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
687 "${GETTEXT}\gettext32\libiconv-2.dll" \
688 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
K.Takata48f38332024-10-07 20:37:00 +0200689!if ${INCLUDE_LIBGCC}
690!if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
691 # Install libgcc_s_sjlj-1.dll only if it is needed.
692 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
693 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
694 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
695!endif
696!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100697 ${EndIf}
698SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000699!endif
700
701##########################################################
702Section -call_install_exe
703 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100704 DetailPrint "$(str_msg_registering)"
705 nsExec::Exec "$0\install.exe $1"
706 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000707
708 ${If} ${SectionIsSelected} ${id_section_pluginhome}
709 ReadEnvStr $3 "COMSPEC"
710 Call GetHomeDir
711 Pop $4
712 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
713 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000714SectionEnd
715
716##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100717!macro SaveSectionSelection section_id reg_value
718 ${If} ${SectionIsSelected} ${section_id}
719 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
720 ${Else}
721 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
722 ${EndIf}
723!macroend
724
Bram Moolenaar071d4272004-06-13 20:20:40 +0000725Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100726
727 # Get estimated install size
728 SectionGetSize ${id_section_exe} $3
729 ${If} ${SectionIsSelected} ${id_section_console}
730 SectionGetSize ${id_section_console} $4
731 IntOp $3 $3 + $4
732 ${EndIf}
733 ${If} ${SectionIsSelected} ${id_section_editwith}
734 SectionGetSize ${id_section_editwith} $4
735 IntOp $3 $3 + $4
736 ${EndIf}
Restorer51c94b62024-03-24 09:41:18 +0000737!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100738 ${If} ${SectionIsSelected} ${id_section_nls}
739 SectionGetSize ${id_section_nls} $4
740 IntOp $3 $3 + $4
741 ${EndIf}
742!endif
743
744 # Register EstimatedSize and AllowSilent.
745 # Other information will be set by the install.exe (dosinst.c).
746 ${If} ${RunningX64}
747 SetRegView 64
748 ${EndIf}
749 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
750 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
751 ${If} ${RunningX64}
752 SetRegView lastused
753 ${EndIf}
754
755 # Store the selections to the registry.
756 ${If} ${RunningX64}
757 SetRegView 64
758 ${EndIf}
759 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
760 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
761 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
762 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
763 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
764 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
765 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
766 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000767!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100768 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
769!endif
770 ${If} ${RunningX64}
771 SetRegView lastused
772 ${EndIf}
773
Bram Moolenaar071d4272004-06-13 20:20:40 +0000774 BringToFront
775SectionEnd
776
777##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100778!macro LoadSectionSelection section_id reg_value
779 ClearErrors
780 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
781 ${IfNot} ${Errors}
782 ${If} $3 = 1
783 !insertmacro SelectSection ${section_id}
784 ${Else}
785 !insertmacro UnselectSection ${section_id}
786 ${EndIf}
787 ${EndIf}
788!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200789
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200790!macro LoadDefaultVimrc out_var reg_value default_value
791 ClearErrors
792 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
793 ${If} ${Errors}
794 ${OrIf} ${out_var} == ""
795 StrCpy ${out_var} ${default_value}
796 ${EndIf}
797!macroend
798
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100799Function .onInit
Restorer51c94b62024-03-24 09:41:18 +0000800!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100801 # Select a language (or read from the registry).
802 !insertmacro MUI_LANGDLL_DISPLAY
803!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200804
RestorerZ2730d382025-01-17 14:04:44 +0100805!if ${HAVE_NLS}
806 ClearErrors
807 System::Call 'kernel32::GetUserDefaultLocaleName(t.r19, *i${NSIS_MAX_STRLEN})'
808 StrCmp $R9 "zh-cn" coincide 0
RestorerZf8770402025-02-24 19:42:36 +0100809 StrCmp $R9 "zh-tw" coincide 0
810 StrCmp $R9 "pt-br" 0 part
RestorerZ2730d382025-01-17 14:04:44 +0100811 coincide:
812 System::Call 'User32::CharLower(t r19 r19)*i${NSIS_MAX_STRLEN}'
813 ${StrRep} $lng_usr "$R9" "-" "_"
814 Goto done
815 part:
816 StrCpy $lng_usr $R9 2
817 done:
818!endif
819
Christian Brabandt7d603842021-07-24 21:19:42 +0200820 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
821 # Check $VIM
822 ReadEnvStr $3 "VIM"
823 ${If} $3 != ""
824 StrCpy $INSTDIR $3
825 ${EndIf}
826 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100827
828 call CheckOldVim
829 Pop $3
830 ${If} $3 == ""
831 # No old versions of Vim found. Unselect and hide the section.
832 !insertmacro UnselectSection ${id_section_old_ver}
833 SectionSetInstTypes ${id_section_old_ver} 0
834 SectionSetText ${id_section_old_ver} ""
835 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200836 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100837 StrCpy $INSTDIR $3
838 ${EndIf}
839 ${EndIf}
840
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100841 ${If} ${RunningX64}
842 SetRegView 64
843 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200844 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100845 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
846 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
847 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
848 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
849 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
850 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
851 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
852 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000853!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100854 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
855!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200856 # Load the default _vimrc settings from the registry (if any).
857 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
858 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
859 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100860 ${If} ${RunningX64}
861 SetRegView lastused
862 ${EndIf}
863
864 # User variables:
865 # $0 - holds the directory the executables are installed to
866 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
867 # registration (since a non-OLE gvim will not complain, and we want to
868 # always register an OLE gvim).
869 # $2 - holds the names to create batch files for
870 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
871 StrCpy $1 "-register-OLE"
872 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200873FunctionEnd
874
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100875Function .onInstSuccess
876 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
877FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200878
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100879Function .onInstFailed
880 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200881FunctionEnd
882
883##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100884Function SetCustom
885 # Display the _vimrc setting dialog using nsDialogs.
886
887 # Check if a _vimrc should be created
888 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
889 Abort
890 ${EndIf}
891
892 !insertmacro MUI_HEADER_TEXT \
893 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
894
895 nsDialogs::Create 1018
896 Pop $vim_dialog
897
898 ${If} $vim_dialog == error
899 Abort
900 ${EndIf}
901
902 ${If} ${RunningX64}
903 SetRegView 64
904 ${EndIf}
905
906 GetFunctionAddress $3 ValidateCustom
907 nsDialogs::OnBack $3
908
909
910 # 1st group - Compatibility
Restorer6dcf59b2024-03-25 15:38:37 +0000911 ${NSD_CreateGroupBox} 0u 0u 296u 44u $(str_msg_compat_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100912 Pop $3
913
Restorer6dcf59b2024-03-25 15:38:37 +0000914 ${NSD_CreateLabel} 16u 14u 269u 10u $(str_msg_compat_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100915 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000916 ${NSD_CreateDropList} 42u 26u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100917 Pop $vim_nsd_compat
918 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
919 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
920 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
921 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
922
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200923 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100924 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200925 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100926 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200927 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100928 StrCpy $4 0
929 ${Else} # default
930 StrCpy $4 3
931 ${EndIf}
932 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
933
934
935 # 2nd group - Key remapping
Restorer6dcf59b2024-03-25 15:38:37 +0000936 ${NSD_CreateGroupBox} 0u 48u 296u 44u $(str_msg_keymap_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100937 Pop $3
938
Restorer6dcf59b2024-03-25 15:38:37 +0000939 ${NSD_CreateLabel} 16u 62u 269u 10u $(str_msg_keymap_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100940 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000941 ${NSD_CreateDropList} 42u 74u 236u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100942 Pop $vim_nsd_keymap
943 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
944 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
945
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200946 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100947 StrCpy $4 1
948 ${Else} # default
949 StrCpy $4 0
950 ${EndIf}
951 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
952
953
954 # 3rd group - Mouse behavior
Restorer6dcf59b2024-03-25 15:38:37 +0000955 ${NSD_CreateGroupBox} 0u 95u 296u 44u $(str_msg_mouse_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100956 Pop $3
957
Restorer6dcf59b2024-03-25 15:38:37 +0000958 ${NSD_CreateLabel} 16u 108u 269u 10u $(str_msg_mouse_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100959 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000960 ${NSD_CreateDropList} 42u 121u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100961 Pop $vim_nsd_mouse
962 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
963 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
964 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
965
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200966 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100967 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200968 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100969 StrCpy $4 1
970 ${Else} # default
971 StrCpy $4 0
972 ${EndIf}
973 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
974
975 ${If} ${RunningX64}
976 SetRegView lastused
977 ${EndIf}
978
979 nsDialogs::Show
980FunctionEnd
981
982Function ValidateCustom
983 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
984 ${If} $3 = 0
985 StrCpy $vim_compat_stat "vi"
986 ${ElseIf} $3 = 1
987 StrCpy $vim_compat_stat "vim"
988 ${ElseIf} $3 = 2
989 StrCpy $vim_compat_stat "defaults"
990 ${Else}
991 StrCpy $vim_compat_stat "all"
992 ${EndIf}
993
994 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
995 ${If} $3 = 0
996 StrCpy $vim_keymap_stat "default"
997 ${Else}
998 StrCpy $vim_keymap_stat "windows"
999 ${EndIf}
1000
1001 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
1002 ${If} $3 = 0
1003 StrCpy $vim_mouse_stat "default"
1004 ${ElseIf} $3 = 1
1005 StrCpy $vim_mouse_stat "windows"
1006 ${Else}
1007 StrCpy $vim_mouse_stat "xterm"
1008 ${EndIf}
1009FunctionEnd
1010
1011##########################################################
1012# Description for Installer Sections
1013
1014!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
1015 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
1016 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
1017 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
1018 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
1019 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
1020 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
1021 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
1022 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
1023 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
1024 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
1025 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
1026 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +00001027!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001028 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
1029!endif
1030!insertmacro MUI_FUNCTION_DESCRIPTION_END
1031
1032
1033##########################################################
1034# Uninstaller Functions and Sections
1035
1036Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +00001037!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001038 # Get the language from the registry.
1039 !insertmacro MUI_UNGETLANGUAGE
1040!endif
1041FunctionEnd
1042
1043Section "un.$(str_unsection_register)" id_unsection_register
1044 SectionIn RO
1045
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +01001047 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001048 StrCpy $0 "$INSTDIR"
1049
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001051 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001052 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001053 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001054
1055 # We may have been put to the background when uninstall did something.
1056 BringToFront
1057
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001058 # Delete the installer language setting.
1059 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1060SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001062Section "un.$(str_unsection_exe)" id_unsection_exe
1063
1064 StrCpy $0 "$INSTDIR"
1065
1066 # Delete gettext and iconv DLLs
1067 ${If} ${FileExists} "$0\libiconv-2.dll"
1068 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1069 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001070 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001071 ${If} ${FileExists} "$0\libintl-8.dll"
1072 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1073 "$0\libintl-8.dll"
1074 ${EndIf}
1075 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1076 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1077 "$0\libgcc_s_sjlj-1.dll"
1078 ${EndIf}
1079
1080 # Delete other DLLs
1081 Delete /REBOOTOK $0\*.dll
1082
1083 # Delete 64-bit GvimExt
1084 ${If} ${RunningX64}
1085 !define LIBRARY_X64
1086 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1087 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1088 "$0\GvimExt64\gvimext.dll"
1089 ${EndIf}
1090 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1091 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1092 "$0\GvimExt64\libiconv-2.dll"
1093 ${EndIf}
1094 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1095 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1096 "$0\GvimExt64\libintl-8.dll"
1097 ${EndIf}
1098 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1099 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1100 "$0\GvimExt64\libwinpthread-1.dll"
1101 ${EndIf}
1102 !undef LIBRARY_X64
1103 RMDir /r $0\GvimExt64
1104 ${EndIf}
1105
1106 # Delete 32-bit GvimExt
1107 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1108 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1109 "$0\GvimExt32\gvimext.dll"
1110 ${EndIf}
1111 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1112 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1113 "$0\GvimExt32\libiconv-2.dll"
1114 ${EndIf}
1115 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1116 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1117 "$0\GvimExt32\libintl-8.dll"
1118 ${EndIf}
1119 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1120 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1121 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1122 ${EndIf}
1123 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001124
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125 ClearErrors
1126 # Remove everything but *.dll files. Avoids that
1127 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001128 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129 RMDir /r $0\colors
1130 RMDir /r $0\compiler
1131 RMDir /r $0\doc
1132 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001133 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134 RMDir /r $0\indent
1135 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001136 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001138 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001139 RMDir /r $0\syntax
1140 RMDir /r $0\tools
1141 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142 RMDir /r $0\lang
1143 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001144 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145 Delete $0\*.exe
1146 Delete $0\*.bat
1147 Delete $0\*.vim
1148 Delete $0\*.txt
1149
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001150 ${If} ${Errors}
1151 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1152 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001153
RestorerZ2680a072024-03-20 20:15:51 +01001154 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155 # gvimext.dll may still be there.
1156 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001157SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001159# Remove "vimfiles" directory under the specified directory.
1160!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001161 ${If} ${FileExists} ${dir}\_viminfo
1162 Delete ${dir}\_viminfo
1163 ${EndIf}
1164 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001165 RMDir ${dir}\vimfiles\colors
1166 RMDir ${dir}\vimfiles\compiler
1167 RMDir ${dir}\vimfiles\doc
1168 RMDir ${dir}\vimfiles\ftdetect
1169 RMDir ${dir}\vimfiles\ftplugin
1170 RMDir ${dir}\vimfiles\indent
1171 RMDir ${dir}\vimfiles\keymap
1172 RMDir ${dir}\vimfiles\plugin
1173 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001174 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1175 Delete ${dir}\vimfiles\.netrwhist*
1176 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001177 RMDir ${dir}\vimfiles
1178 ${EndIf}
1179!macroend
1180
1181SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1182 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1183 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001184 Call un.GetHomeDir
1185 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001186
1187 ${If} $0 != ""
1188 !insertmacro RemoveVimfiles $0
1189 ${EndIf}
1190 SectionEnd
1191
1192 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1193 # get the parent dir of the installation
1194 Push $INSTDIR
1195 Call un.GetParent
1196 Pop $0
1197
1198 # if a plugin dir was created at installation remove it
1199 !insertmacro RemoveVimfiles $0
1200 SectionEnd
1201SectionGroupEnd
1202
1203Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204 # get the parent dir of the installation
1205 Push $INSTDIR
1206 Call un.GetParent
1207 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001209 ${IfNot} ${Silent}
1210 Delete $0\_vimrc
1211 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001212 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001214
1215##########################################################
1216# Description for Uninstaller Sections
1217
1218!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1219 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1220 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1221 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1222 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1223 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1224 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1225!insertmacro MUI_UNFUNCTION_DESCRIPTION_END