blob: 878867f68f817a25905f24fe23fb27439778d80b [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.
RestorerZ2730d382025-01-17 14:04:44 +01003# Last Change: 2025 Jan 05
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
809 StrCmp $R9 "zh-tw" 0 part
810 coincide:
811 System::Call 'User32::CharLower(t r19 r19)*i${NSIS_MAX_STRLEN}'
812 ${StrRep} $lng_usr "$R9" "-" "_"
813 Goto done
814 part:
815 StrCpy $lng_usr $R9 2
816 done:
817!endif
818
Christian Brabandt7d603842021-07-24 21:19:42 +0200819 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
820 # Check $VIM
821 ReadEnvStr $3 "VIM"
822 ${If} $3 != ""
823 StrCpy $INSTDIR $3
824 ${EndIf}
825 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100826
827 call CheckOldVim
828 Pop $3
829 ${If} $3 == ""
830 # No old versions of Vim found. Unselect and hide the section.
831 !insertmacro UnselectSection ${id_section_old_ver}
832 SectionSetInstTypes ${id_section_old_ver} 0
833 SectionSetText ${id_section_old_ver} ""
834 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200835 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100836 StrCpy $INSTDIR $3
837 ${EndIf}
838 ${EndIf}
839
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100840 ${If} ${RunningX64}
841 SetRegView 64
842 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200843 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100844 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
845 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
846 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
847 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
848 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
849 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
850 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
851 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000852!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100853 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
854!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200855 # Load the default _vimrc settings from the registry (if any).
856 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
857 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
858 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100859 ${If} ${RunningX64}
860 SetRegView lastused
861 ${EndIf}
862
863 # User variables:
864 # $0 - holds the directory the executables are installed to
865 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
866 # registration (since a non-OLE gvim will not complain, and we want to
867 # always register an OLE gvim).
868 # $2 - holds the names to create batch files for
869 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
870 StrCpy $1 "-register-OLE"
871 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200872FunctionEnd
873
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100874Function .onInstSuccess
875 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
876FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200877
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100878Function .onInstFailed
879 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200880FunctionEnd
881
882##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100883Function SetCustom
884 # Display the _vimrc setting dialog using nsDialogs.
885
886 # Check if a _vimrc should be created
887 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
888 Abort
889 ${EndIf}
890
891 !insertmacro MUI_HEADER_TEXT \
892 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
893
894 nsDialogs::Create 1018
895 Pop $vim_dialog
896
897 ${If} $vim_dialog == error
898 Abort
899 ${EndIf}
900
901 ${If} ${RunningX64}
902 SetRegView 64
903 ${EndIf}
904
905 GetFunctionAddress $3 ValidateCustom
906 nsDialogs::OnBack $3
907
908
909 # 1st group - Compatibility
Restorer6dcf59b2024-03-25 15:38:37 +0000910 ${NSD_CreateGroupBox} 0u 0u 296u 44u $(str_msg_compat_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100911 Pop $3
912
Restorer6dcf59b2024-03-25 15:38:37 +0000913 ${NSD_CreateLabel} 16u 14u 269u 10u $(str_msg_compat_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100914 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000915 ${NSD_CreateDropList} 42u 26u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100916 Pop $vim_nsd_compat
917 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
918 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
919 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
920 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
921
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200922 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100923 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200924 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100925 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200926 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100927 StrCpy $4 0
928 ${Else} # default
929 StrCpy $4 3
930 ${EndIf}
931 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
932
933
934 # 2nd group - Key remapping
Restorer6dcf59b2024-03-25 15:38:37 +0000935 ${NSD_CreateGroupBox} 0u 48u 296u 44u $(str_msg_keymap_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100936 Pop $3
937
Restorer6dcf59b2024-03-25 15:38:37 +0000938 ${NSD_CreateLabel} 16u 62u 269u 10u $(str_msg_keymap_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100939 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000940 ${NSD_CreateDropList} 42u 74u 236u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100941 Pop $vim_nsd_keymap
942 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
943 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
944
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200945 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100946 StrCpy $4 1
947 ${Else} # default
948 StrCpy $4 0
949 ${EndIf}
950 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
951
952
953 # 3rd group - Mouse behavior
Restorer6dcf59b2024-03-25 15:38:37 +0000954 ${NSD_CreateGroupBox} 0u 95u 296u 44u $(str_msg_mouse_title)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100955 Pop $3
956
Restorer6dcf59b2024-03-25 15:38:37 +0000957 ${NSD_CreateLabel} 16u 108u 269u 10u $(str_msg_mouse_desc)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100958 Pop $3
Restorer6dcf59b2024-03-25 15:38:37 +0000959 ${NSD_CreateDropList} 42u 121u 237u 13u ""
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960 Pop $vim_nsd_mouse
961 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
962 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
963 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
964
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200965 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100966 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200967 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100968 StrCpy $4 1
969 ${Else} # default
970 StrCpy $4 0
971 ${EndIf}
972 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
973
974 ${If} ${RunningX64}
975 SetRegView lastused
976 ${EndIf}
977
978 nsDialogs::Show
979FunctionEnd
980
981Function ValidateCustom
982 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
983 ${If} $3 = 0
984 StrCpy $vim_compat_stat "vi"
985 ${ElseIf} $3 = 1
986 StrCpy $vim_compat_stat "vim"
987 ${ElseIf} $3 = 2
988 StrCpy $vim_compat_stat "defaults"
989 ${Else}
990 StrCpy $vim_compat_stat "all"
991 ${EndIf}
992
993 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
994 ${If} $3 = 0
995 StrCpy $vim_keymap_stat "default"
996 ${Else}
997 StrCpy $vim_keymap_stat "windows"
998 ${EndIf}
999
1000 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
1001 ${If} $3 = 0
1002 StrCpy $vim_mouse_stat "default"
1003 ${ElseIf} $3 = 1
1004 StrCpy $vim_mouse_stat "windows"
1005 ${Else}
1006 StrCpy $vim_mouse_stat "xterm"
1007 ${EndIf}
1008FunctionEnd
1009
1010##########################################################
1011# Description for Installer Sections
1012
1013!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
1014 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
1015 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
1016 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
1017 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
1018 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
1019 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
1020 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
1021 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
1022 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
1023 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
1024 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
1025 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +00001026!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001027 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
1028!endif
1029!insertmacro MUI_FUNCTION_DESCRIPTION_END
1030
1031
1032##########################################################
1033# Uninstaller Functions and Sections
1034
1035Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +00001036!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001037 # Get the language from the registry.
1038 !insertmacro MUI_UNGETLANGUAGE
1039!endif
1040FunctionEnd
1041
1042Section "un.$(str_unsection_register)" id_unsection_register
1043 SectionIn RO
1044
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +01001046 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 StrCpy $0 "$INSTDIR"
1048
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001050 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001051 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001052 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053
1054 # We may have been put to the background when uninstall did something.
1055 BringToFront
1056
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001057 # Delete the installer language setting.
1058 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1059SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001061Section "un.$(str_unsection_exe)" id_unsection_exe
1062
1063 StrCpy $0 "$INSTDIR"
1064
1065 # Delete gettext and iconv DLLs
1066 ${If} ${FileExists} "$0\libiconv-2.dll"
1067 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1068 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001069 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001070 ${If} ${FileExists} "$0\libintl-8.dll"
1071 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1072 "$0\libintl-8.dll"
1073 ${EndIf}
1074 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1075 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1076 "$0\libgcc_s_sjlj-1.dll"
1077 ${EndIf}
1078
1079 # Delete other DLLs
1080 Delete /REBOOTOK $0\*.dll
1081
1082 # Delete 64-bit GvimExt
1083 ${If} ${RunningX64}
1084 !define LIBRARY_X64
1085 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1086 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1087 "$0\GvimExt64\gvimext.dll"
1088 ${EndIf}
1089 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1090 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1091 "$0\GvimExt64\libiconv-2.dll"
1092 ${EndIf}
1093 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1094 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1095 "$0\GvimExt64\libintl-8.dll"
1096 ${EndIf}
1097 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1098 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1099 "$0\GvimExt64\libwinpthread-1.dll"
1100 ${EndIf}
1101 !undef LIBRARY_X64
1102 RMDir /r $0\GvimExt64
1103 ${EndIf}
1104
1105 # Delete 32-bit GvimExt
1106 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1107 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1108 "$0\GvimExt32\gvimext.dll"
1109 ${EndIf}
1110 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1111 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1112 "$0\GvimExt32\libiconv-2.dll"
1113 ${EndIf}
1114 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1115 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1116 "$0\GvimExt32\libintl-8.dll"
1117 ${EndIf}
1118 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1119 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1120 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1121 ${EndIf}
1122 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001123
Bram Moolenaar071d4272004-06-13 20:20:40 +00001124 ClearErrors
1125 # Remove everything but *.dll files. Avoids that
1126 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001127 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001128 RMDir /r $0\colors
1129 RMDir /r $0\compiler
1130 RMDir /r $0\doc
1131 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001132 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133 RMDir /r $0\indent
1134 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001135 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001137 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 RMDir /r $0\syntax
1139 RMDir /r $0\tools
1140 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 RMDir /r $0\lang
1142 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001143 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 Delete $0\*.exe
1145 Delete $0\*.bat
1146 Delete $0\*.vim
1147 Delete $0\*.txt
1148
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001149 ${If} ${Errors}
1150 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1151 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001152
RestorerZ2680a072024-03-20 20:15:51 +01001153 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154 # gvimext.dll may still be there.
1155 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001156SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001157
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001158# Remove "vimfiles" directory under the specified directory.
1159!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001160 ${If} ${FileExists} ${dir}\_viminfo
1161 Delete ${dir}\_viminfo
1162 ${EndIf}
1163 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001164 RMDir ${dir}\vimfiles\colors
1165 RMDir ${dir}\vimfiles\compiler
1166 RMDir ${dir}\vimfiles\doc
1167 RMDir ${dir}\vimfiles\ftdetect
1168 RMDir ${dir}\vimfiles\ftplugin
1169 RMDir ${dir}\vimfiles\indent
1170 RMDir ${dir}\vimfiles\keymap
1171 RMDir ${dir}\vimfiles\plugin
1172 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001173 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1174 Delete ${dir}\vimfiles\.netrwhist*
1175 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001176 RMDir ${dir}\vimfiles
1177 ${EndIf}
1178!macroend
1179
1180SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1181 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1182 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001183 Call un.GetHomeDir
1184 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001185
1186 ${If} $0 != ""
1187 !insertmacro RemoveVimfiles $0
1188 ${EndIf}
1189 SectionEnd
1190
1191 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1192 # get the parent dir of the installation
1193 Push $INSTDIR
1194 Call un.GetParent
1195 Pop $0
1196
1197 # if a plugin dir was created at installation remove it
1198 !insertmacro RemoveVimfiles $0
1199 SectionEnd
1200SectionGroupEnd
1201
1202Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203 # get the parent dir of the installation
1204 Push $INSTDIR
1205 Call un.GetParent
1206 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001207
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001208 ${IfNot} ${Silent}
1209 Delete $0\_vimrc
1210 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001211 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001213
1214##########################################################
1215# Description for Uninstaller Sections
1216
1217!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1218 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1219 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1220 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1221 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1222 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1223 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1224!insertmacro MUI_UNFUNCTION_DESCRIPTION_END