blob: 799f8fff64bc6766871730e2149bbd27ab1aa744 [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.
Restorer51c94b62024-03-24 09:41:18 +00003# Last Change: 2024 Mar 18
Bram Moolenaar071d4272004-06-13 20:20:40 +00004
Bram Moolenaaraf610b82018-12-21 16:22:50 +01005Unicode true
6
Bram Moolenaar071d4272004-06-13 20:20:40 +00007# WARNING: if you make changes to this script, look out for $0 to be valid,
8# because uninstall deletes most files in $0.
9
Bram Moolenaarba460752013-07-04 22:35:01 +020010# Location of gvim_ole.exe, vimw32.exe, GvimExt/*, etc.
Bram Moolenaar286eacd2016-01-16 18:05:50 +010011!ifndef VIMSRC
12 !define VIMSRC "..\src"
13!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000014
15# Location of runtime files
Bram Moolenaar286eacd2016-01-16 18:05:50 +010016!ifndef VIMRT
17 !define VIMRT ".."
18!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
Restorer51c94b62024-03-24 09:41:18 +000020# Location of extra tools: diff.exe, winpty{32|64}.dll, winpty-agent.exe, etc.
Bram Moolenaar286eacd2016-01-16 18:05:50 +010021!ifndef VIMTOOLS
22 !define VIMTOOLS ..\..
23!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000024
Bram Moolenaar6199d432017-10-14 19:05:44 +020025# Location of gettext.
26# It must contain two directories: gettext32 and gettext64.
27# See README.txt for detail.
28!ifndef GETTEXT
29 !define GETTEXT ${VIMRT}
30!endif
31
Restorer51c94b62024-03-24 09:41:18 +000032# If you have UPX, use the switch /DHAVE_UPX=1 on the command line makensis.exe.
33# This property will be set to 1. Get it at https://upx.github.io/
34!ifndef HAVE_UPX
35 !define HAVE_UPX 0
36!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000037
Restorer51c94b62024-03-24 09:41:18 +000038# If you do not want to add Native Language Support, use the switch /DHAVE_NLS=0
39# in the command line makensis.exe. This property will be set to 0.
40!ifndef HAVE_NLS
41 !define HAVE_NLS 1
42!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Restorer51c94b62024-03-24 09:41:18 +000044# To create an English-only the installer, use the switch /DHAVE_MULTI_LANG=0 on
45# the command line makensis.exe. This property will be set to 0.
46!ifndef HAVE_MULTI_LANG
47 !define HAVE_MULTI_LANG 1
48!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +010049
Restorer51c94b62024-03-24 09:41:18 +000050# if you want to create a 64-bit the installer, use the switch /DWIN64=1 on
51# the command line makensis.exe. This property will be set to 1.
52!ifndef WIN64
53 !define WIN64 0
54!endif
Bram Moolenaaraf610b82018-12-21 16:22:50 +010055
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010056!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
Restorer51c94b62024-03-24 09:41:18 +000058# Definition of Patch for Vim.
Bram Moolenaar9d591522019-05-26 20:49:42 +020059!ifndef PATCHLEVEL
60 !define PATCHLEVEL 0
61!endif
62
Bram Moolenaar071d4272004-06-13 20:20:40 +000063# ----------- No configurable settings below this line -----------
64
Restorer51c94b62024-03-24 09:41:18 +000065!include "Library.nsh" # for DLL install
Bram Moolenaaraf610b82018-12-21 16:22:50 +010066!include "LogicLib.nsh"
67!include "MUI2.nsh"
68!include "nsDialogs.nsh"
69!include "Sections.nsh"
70!include "x64.nsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +000071
RestorerZ2680a072024-03-20 20:15:51 +010072# See https://nsis.sourceforge.io/LogicLib
73;FileExists is already part of LogicLib, but returns true for directories
74;as well as files
75!macro _FileExists2 _a _b _t _f
76 !insertmacro _LOGICLIB_TEMP
77 StrCpy $_LOGICLIB_TEMP "0"
78;if path is not blank, continue to next check
79 StrCmp `${_b}` `` +4 0
80;if path exists, continue to next check (IfFileExists returns true if this
81;is a directory)
82 IfFileExists `${_b}` `0` +3
83;if path is not a directory, continue to confirm exists
84 IfFileExists `${_b}\*.*` +2 0
85 StrCpy $_LOGICLIB_TEMP "1" ;file exists
86;now we have a definitive value - the file exists or it does not
87 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
88!macroend
89!undef FileExists
90!define FileExists `"" FileExists2`
91!macro _DirExists _a _b _t _f
92 !insertmacro _LOGICLIB_TEMP
93 StrCpy $_LOGICLIB_TEMP "0"
94;if path is not blank, continue to next check
95 StrCmp `${_b}` `` +3 0
96;if directory exists, continue to confirm exists
97 IfFileExists `${_b}\*.*` 0 +2
98 StrCpy $_LOGICLIB_TEMP "1"
99 StrCmp $_LOGICLIB_TEMP "1" `${_t}` `${_f}`
100!macroend
101!define DirExists `"" DirExists`
102
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100103!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
104!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
105!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
106
Restorer51c94b62024-03-24 09:41:18 +0000107!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100108Name "${PRODUCT} (x64)"
109!else
110Name "${PRODUCT}"
111!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000112OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
113CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +0100114SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100115SetCompressorDictSize 64
116ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +0200118RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119
Restorer51c94b62024-03-24 09:41:18 +0000120!if ${HAVE_UPX}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000121 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
122!endif
123
Restorer51c94b62024-03-24 09:41:18 +0000124!if ${WIN64}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100125!define BIT 64
126!else
127!define BIT 32
128!endif
129
130##########################################################
131# MUI2 settings
132
133!define MUI_ABORTWARNING
134!define MUI_UNABORTWARNING
135
136!define MUI_ICON "icons\vim_16c.ico"
137!define MUI_UNICON "icons\vim_uninst_16c.ico"
138
139# Show all languages, despite user's codepage:
140!define MUI_LANGDLL_ALLLANGUAGES
141!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
142!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
143!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
144
145!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
146!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
147!define MUI_HEADERIMAGE
148!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
149!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
150
151!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
152!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
153!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
154!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
155
156!define MUI_COMPONENTSPAGE_SMALLDESC
157!define MUI_LICENSEPAGE_CHECKBOX
Bram Moolenaar4a228972021-05-01 22:41:39 +0200158!define MUI_FINISHPAGE_RUN
159!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100160!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100161
162# This adds '\Vim' to the user choice automagically. The actual value is
163# obtained below with CheckOldVim.
Restorer51c94b62024-03-24 09:41:18 +0000164!if ${WIN64}
Christian Brabandt7d603842021-07-24 21:19:42 +0200165 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100166!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200167 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100168!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200169InstallDir ${DEFAULT_INSTDIR}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000170
171# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100172InstType $(str_type_typical)
173InstType $(str_type_minimal)
174InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175
176SilentInstall normal
177
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100178# General custom functions for MUI2:
179#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
180#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
181
182# Installer pages
183!insertmacro MUI_PAGE_WELCOME
184!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
185!insertmacro MUI_PAGE_COMPONENTS
186Page custom SetCustom ValidateCustom
187#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
188!insertmacro MUI_PAGE_DIRECTORY
189!insertmacro MUI_PAGE_INSTFILES
190!define MUI_FINISHPAGE_NOREBOOTSUPPORT
191!insertmacro MUI_PAGE_FINISH
192
193# Uninstaller pages:
194!insertmacro MUI_UNPAGE_CONFIRM
195#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
196!insertmacro MUI_UNPAGE_COMPONENTS
197!insertmacro MUI_UNPAGE_INSTFILES
198!define MUI_FINISHPAGE_NOREBOOTSUPPORT
199!insertmacro MUI_UNPAGE_FINISH
200
201##########################################################
202# Languages Files
203
204!insertmacro MUI_RESERVEFILE_LANGDLL
205!include "lang\english.nsi"
206
207# Include support for other languages:
Restorer51c94b62024-03-24 09:41:18 +0000208!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100209 !include "lang\danish.nsi"
210 !include "lang\dutch.nsi"
211 !include "lang\german.nsi"
Christos Longrosc62dacb2024-03-06 20:53:02 +0100212 !include "lang\greek.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100213 !include "lang\italian.nsi"
214 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200215 !include "lang\russian.nsi"
Ivan Pešiće1051922024-03-05 23:34:00 +0400216 !include "lang\serbian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100217 !include "lang\simpchinese.nsi"
218 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100219 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100220!endif
221
Bram Moolenaardabfde02019-05-17 12:37:27 +0200222##########################################################
223# Version resources
224
225VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
226VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
227VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
228VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
229VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200230VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
231VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100232
233# Global variables
234Var vim_dialog
235Var vim_nsd_compat
236Var vim_nsd_keymap
237Var vim_nsd_mouse
238Var vim_compat_stat
239Var vim_keymap_stat
240Var vim_mouse_stat
241
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242
Bram Moolenaar5d424742018-02-04 19:11:30 +0100243# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100244ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100245
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246##########################################################
247# Functions
248
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100249# Get parent directory
250# Share this function both on installer and uninstaller
251!macro GetParent un
252Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000253 Exch $0 ; old $0 is on top of stack
254 Push $1
255 Push $2
256 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100257 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100259 ${If} $2 == ""
260 ${OrIf} $2 == "\"
261 ${ExitDo}
262 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000263 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100264 ${Loop}
265 StrCpy $0 $0 $1
266 Pop $2
267 Pop $1
268 Exch $0 ; put $0 on top of stack, restore $0 to original value
269FunctionEnd
270!macroend
271
272!insertmacro GetParent ""
273!insertmacro GetParent "un."
274
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000275# Get home directory
276!macro GetHomeDir un
277Function ${un}GetHomeDir
278 Push $0
279 Push $1
280 ReadEnvStr $0 "HOME"
281 ${If} $0 == ""
282 ReadEnvStr $0 "HOMEDRIVE"
283 ReadEnvStr $1 "HOMEPATH"
284 StrCpy $0 "$0$1"
285 ${If} $0 == ""
286 ReadEnvStr $0 "USERPROFILE"
287 ${EndIf}
288 ${EndIf}
289 Pop $1
290 Exch $0 # put $0 on top of stack, restore $0 to original value
291FunctionEnd
292!macroend
293
294!insertmacro GetHomeDir ""
295!insertmacro GetHomeDir "un."
296
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100297# Check if Vim is already installed.
298# return: Installed directory. If not found, it will be empty.
299Function CheckOldVim
300 Push $0
301 Push $R0
302 Push $R1
303 Push $R2
304
305 ${If} ${RunningX64}
306 SetRegView 64
307 ${EndIf}
308
309 ClearErrors
310 StrCpy $0 "" # Installed directory
311 StrCpy $R0 0 # Sub-key index
312 StrCpy $R1 "" # Sub-key
313 ${Do}
314 # Eumerate the sub-key:
315 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
316
317 # Stop if no more sub-key:
318 ${If} ${Errors}
319 ${OrIf} $R1 == ""
320 ${ExitDo}
321 ${EndIf}
322
323 # Move to the next sub-key:
324 IntOp $R0 $R0 + 1
325
326 # Check if the key is Vim uninstall key or not:
327 StrCpy $R2 $R1 4
328 ${If} $R2 S!= "Vim "
329 ${Continue}
330 ${EndIf}
331
332 # Verifies required sub-keys:
333 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
334 ${If} ${Errors}
335 ${OrIf} $R2 == ""
336 ${Continue}
337 ${EndIf}
338
339 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
340 ${If} ${Errors}
341 ${OrIf} $R2 == ""
342 ${Continue}
343 ${EndIf}
344
345 # Found
346 Push $R2
347 call GetParent
348 call GetParent
349 Pop $0 # Vim directory
350 ${ExitDo}
351
352 ${Loop}
353
354 ${If} ${RunningX64}
355 SetRegView lastused
356 ${EndIf}
357
358 Pop $R2
359 Pop $R1
360 Pop $R0
361 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362FunctionEnd
363
Bram Moolenaar4a228972021-05-01 22:41:39 +0200364Function LaunchApplication
365 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200366 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200367FunctionEnd
368
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100370Section "$(str_section_old_ver)" id_section_old_ver
371 SectionIn 1 2 3 RO
372
373 # run the install program to check for already installed versions
374 SetOutPath $TEMP
375 File /oname=install.exe ${VIMSRC}\installw32.exe
376 DetailPrint "$(str_msg_uninstalling)"
377 ${Do}
378 nsExec::Exec "$TEMP\install.exe -uninstall-check"
379 Pop $3
380
381 call CheckOldVim
382 Pop $3
383 ${If} $3 == ""
384 ${ExitDo}
385 ${Else}
386 # It seems that the old version is still remaining.
387 # TODO: Should we show a warning and run the uninstaller again?
388
389 ${ExitDo} # Just ignore for now.
390 ${EndIf}
391 ${Loop}
392 Delete $TEMP\install.exe
393 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
394
395 # We may have been put to the background when uninstall did something.
396 BringToFront
397SectionEnd
398
399##########################################################
400Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200401 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402
403 # we need also this here if the user changes the instdir
404 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
405
406 SetOutPath $0
407 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200408!if /FileExists "${VIMSRC}\vim${BIT}.dll"
409 File ${VIMSRC}\vim${BIT}.dll
410!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200412 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000413 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200414 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000415 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100416 File ..\vimtutor.bat
417 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200418 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420
RestorerZ2680a072024-03-20 20:15:51 +0100421!if /FileExists "${VIMTOOLS}\diff.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200422 File ${VIMTOOLS}\diff.exe
RestorerZ2680a072024-03-20 20:15:51 +0100423!endif
424!if /FileExists "${VIMTOOLS}\winpty${BIT}.dll"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100425 File ${VIMTOOLS}\winpty${BIT}.dll
RestorerZ2680a072024-03-20 20:15:51 +0100426!endif
427!if /FileExists "${VIMTOOLS}\winpty-agent.exe"
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200428 File ${VIMTOOLS}\winpty-agent.exe
RestorerZ2680a072024-03-20 20:15:51 +0100429!endif
430!if /FileExists "${VIMTOOLS}\libsodium.dll"
431 File ${VIMTOOLS}\libsodium.dll
432!endif
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200433
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100435 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436
437 SetOutPath $0\compiler
438 File ${VIMRT}\compiler\*.*
439
440 SetOutPath $0\doc
RestorerZ2680a072024-03-20 20:15:51 +0100441 File /x uganda.nsis.txt ${VIMRT}\doc\*.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442 File ${VIMRT}\doc\tags
443
444 SetOutPath $0\ftplugin
445 File ${VIMRT}\ftplugin\*.*
446
447 SetOutPath $0\indent
RestorerZ2680a072024-03-20 20:15:51 +0100448 File ${VIMRT}\indent\README.txt
449 File ${VIMRT}\indent\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450
Ken Takata1a9aba82024-01-16 17:14:29 +0100451 SetOutPath $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +0100452 File ${VIMRT}\keymap\README.txt
453 File ${VIMRT}\keymap\*.vim
Ken Takata1a9aba82024-01-16 17:14:29 +0100454
Bram Moolenaar071d4272004-06-13 20:20:40 +0000455 SetOutPath $0\macros
RestorerZ2680a072024-03-20 20:15:51 +0100456 File /r /x *.info ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100458 SetOutPath $0\pack
459 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200460
Bram Moolenaar071d4272004-06-13 20:20:40 +0000461 SetOutPath $0\plugin
462 File ${VIMRT}\plugin\*.*
463
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000464 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100465 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000466
Bram Moolenaar44433da2022-05-06 18:08:52 +0100467 SetOutPath $0\import\dist
468 File ${VIMRT}\import\dist\*.*
469
Christian Brabandt176711f2022-03-11 15:24:11 +0000470 SetOutPath $0\bitmaps
471 File ${VIMSRC}\vim.ico
472
Bram Moolenaar071d4272004-06-13 20:20:40 +0000473 SetOutPath $0\syntax
RestorerZ2680a072024-03-20 20:15:51 +0100474 File /r /x testdir /x generator /x Makefile ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000476 SetOutPath $0\spell
477 File ${VIMRT}\spell\*.txt
478 File ${VIMRT}\spell\*.vim
479 File ${VIMRT}\spell\*.spl
480 File ${VIMRT}\spell\*.sug
481
Bram Moolenaar071d4272004-06-13 20:20:40 +0000482 SetOutPath $0\tools
483 File ${VIMRT}\tools\*.*
484
485 SetOutPath $0\tutor
RestorerZ2680a072024-03-20 20:15:51 +0100486 File /x Makefile /x *.info ${VIMRT}\tutor\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000487SectionEnd
488
489##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100490Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000491 SectionIn 1 3
492
493 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100494 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000495 StrCpy $2 "$2 vim view vimdiff"
496SectionEnd
497
498##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100499Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500 SectionIn 3
501
502 StrCpy $1 "$1 -create-batfiles $2"
503SectionEnd
504
505##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100506SectionGroup $(str_group_icons) id_group_icons
507 Section "$(str_section_desktop)" id_section_desktop
508 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000509
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100510 StrCpy $1 "$1 -install-icons"
511 SectionEnd
512
513 Section "$(str_section_start_menu)" id_section_startmenu
514 SectionIn 1 3
515
516 StrCpy $1 "$1 -add-start-menu"
517 SectionEnd
518SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519
520##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100521Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522 SectionIn 1 3
523
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200525
Bram Moolenaar442b4222010-05-24 21:34:22 +0200526 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200527 # Install 64-bit gvimext.dll into the GvimExt64 directory.
528 SetOutPath $0\GvimExt64
529 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100530 !define LIBRARY_SHELL_EXTENSION
531 !define LIBRARY_X64
532 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
533 "${VIMSRC}\GvimExt\gvimext64.dll" \
534 "$0\GvimExt64\gvimext.dll" "$0"
535 !undef LIBRARY_X64
536 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200537 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200538
Bram Moolenaar6199d432017-10-14 19:05:44 +0200539 # Install 32-bit gvimext.dll into the GvimExt32 directory.
540 SetOutPath $0\GvimExt32
541 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100542 !define LIBRARY_SHELL_EXTENSION
543 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
544 "${VIMSRC}\GvimExt\gvimext.dll" \
545 "$0\GvimExt32\gvimext.dll" "$0"
546 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000547
548 # We don't have a separate entry for the "Open With..." menu, assume
549 # the user wants either both or none.
550 StrCpy $1 "$1 -install-popup -install-openwith"
551SectionEnd
552
553##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100554Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 SectionIn 1 3
556
557 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100558
559 ${If} ${RunningX64}
560 SetRegView 64
561 ${EndIf}
562 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
563 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
564 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
565 ${If} ${RunningX64}
566 SetRegView lastused
567 ${EndIf}
568
569 ${If} $vim_compat_stat == "vi"
570 StrCpy $1 "$1 -vimrc-compat vi"
571 ${ElseIf} $vim_compat_stat == "vim"
572 StrCpy $1 "$1 -vimrc-compat vim"
573 ${ElseIf} $vim_compat_stat == "defaults"
574 StrCpy $1 "$1 -vimrc-compat defaults"
575 ${Else}
576 StrCpy $1 "$1 -vimrc-compat all"
577 ${EndIf}
578
579 ${If} $vim_keymap_stat == "default"
580 StrCpy $1 "$1 -vimrc-remap no"
581 ${Else}
582 StrCpy $1 "$1 -vimrc-remap win"
583 ${EndIf}
584
585 ${If} $vim_mouse_stat == "default"
586 StrCpy $1 "$1 -vimrc-behave default"
587 ${ElseIf} $vim_mouse_stat == "windows"
588 StrCpy $1 "$1 -vimrc-behave mswin"
589 ${Else}
590 StrCpy $1 "$1 -vimrc-behave unix"
591 ${EndIf}
592
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593SectionEnd
594
595##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100596SectionGroup $(str_group_plugin) id_group_plugin
597 Section "$(str_section_plugin_home)" id_section_pluginhome
598 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000600 # use ShellExecAsUser below instead
601 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100602 SectionEnd
603
604 Section "$(str_section_plugin_vim)" id_section_pluginvim
605 SectionIn 3
606
607 StrCpy $1 "$1 -create-directories vim"
608 SectionEnd
609SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000610
611##########################################################
Restorer51c94b62024-03-24 09:41:18 +0000612!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100613Section "$(str_section_nls)" id_section_nls
614 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100616 SetOutPath $0\lang
RestorerZ2680a072024-03-20 20:15:51 +0100617 File /r /x Makefile ${VIMRT}\lang\*.*
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100618 SetOutPath $0
619 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
620 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
621 "$0\libintl-8.dll" "$0"
622 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
623 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
624 "$0\libiconv-2.dll" "$0"
625 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
626 # Install libgcc_s_sjlj-1.dll only if it is needed.
627 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
628 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
629 "$0\libgcc_s_sjlj-1.dll" "$0"
630 !endif
631
632 ${If} ${SectionIsSelected} ${id_section_editwith}
633 ${If} ${RunningX64}
634 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
635 SetOutPath $0\GvimExt64
636 ClearErrors
637 !define LIBRARY_X64
638 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
639 "${GETTEXT}\gettext64\libintl-8.dll" \
640 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
641 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
642 "${GETTEXT}\gettext64\libiconv-2.dll" \
643 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
644 !undef LIBRARY_X64
645 ${EndIf}
646
647 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
648 SetOutPath $0\GvimExt32
649 ClearErrors
650 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
651 "${GETTEXT}\gettext32\libintl-8.dll" \
652 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
653 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
654 "${GETTEXT}\gettext32\libiconv-2.dll" \
655 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
656 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
657 # Install libgcc_s_sjlj-1.dll only if it is needed.
658 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
659 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
660 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
661 !endif
662 ${EndIf}
663SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000664!endif
665
666##########################################################
667Section -call_install_exe
668 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100669 DetailPrint "$(str_msg_registering)"
670 nsExec::Exec "$0\install.exe $1"
671 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000672
673 ${If} ${SectionIsSelected} ${id_section_pluginhome}
674 ReadEnvStr $3 "COMSPEC"
675 Call GetHomeDir
676 Pop $4
677 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
678 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000679SectionEnd
680
681##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100682!macro SaveSectionSelection section_id reg_value
683 ${If} ${SectionIsSelected} ${section_id}
684 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
685 ${Else}
686 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
687 ${EndIf}
688!macroend
689
Bram Moolenaar071d4272004-06-13 20:20:40 +0000690Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100691
692 # Get estimated install size
693 SectionGetSize ${id_section_exe} $3
694 ${If} ${SectionIsSelected} ${id_section_console}
695 SectionGetSize ${id_section_console} $4
696 IntOp $3 $3 + $4
697 ${EndIf}
698 ${If} ${SectionIsSelected} ${id_section_editwith}
699 SectionGetSize ${id_section_editwith} $4
700 IntOp $3 $3 + $4
701 ${EndIf}
Restorer51c94b62024-03-24 09:41:18 +0000702!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100703 ${If} ${SectionIsSelected} ${id_section_nls}
704 SectionGetSize ${id_section_nls} $4
705 IntOp $3 $3 + $4
706 ${EndIf}
707!endif
708
709 # Register EstimatedSize and AllowSilent.
710 # Other information will be set by the install.exe (dosinst.c).
711 ${If} ${RunningX64}
712 SetRegView 64
713 ${EndIf}
714 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
715 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
716 ${If} ${RunningX64}
717 SetRegView lastused
718 ${EndIf}
719
720 # Store the selections to the registry.
721 ${If} ${RunningX64}
722 SetRegView 64
723 ${EndIf}
724 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
725 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
726 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
727 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
728 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
729 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
730 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
731 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000732!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100733 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
734!endif
735 ${If} ${RunningX64}
736 SetRegView lastused
737 ${EndIf}
738
Bram Moolenaar071d4272004-06-13 20:20:40 +0000739 BringToFront
740SectionEnd
741
742##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100743!macro LoadSectionSelection section_id reg_value
744 ClearErrors
745 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
746 ${IfNot} ${Errors}
747 ${If} $3 = 1
748 !insertmacro SelectSection ${section_id}
749 ${Else}
750 !insertmacro UnselectSection ${section_id}
751 ${EndIf}
752 ${EndIf}
753!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200754
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200755!macro LoadDefaultVimrc out_var reg_value default_value
756 ClearErrors
757 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
758 ${If} ${Errors}
759 ${OrIf} ${out_var} == ""
760 StrCpy ${out_var} ${default_value}
761 ${EndIf}
762!macroend
763
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100764Function .onInit
Restorer51c94b62024-03-24 09:41:18 +0000765!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100766 # Select a language (or read from the registry).
767 !insertmacro MUI_LANGDLL_DISPLAY
768!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200769
Christian Brabandt7d603842021-07-24 21:19:42 +0200770 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
771 # Check $VIM
772 ReadEnvStr $3 "VIM"
773 ${If} $3 != ""
774 StrCpy $INSTDIR $3
775 ${EndIf}
776 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100777
778 call CheckOldVim
779 Pop $3
780 ${If} $3 == ""
781 # No old versions of Vim found. Unselect and hide the section.
782 !insertmacro UnselectSection ${id_section_old_ver}
783 SectionSetInstTypes ${id_section_old_ver} 0
784 SectionSetText ${id_section_old_ver} ""
785 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200786 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100787 StrCpy $INSTDIR $3
788 ${EndIf}
789 ${EndIf}
790
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100791 ${If} ${RunningX64}
792 SetRegView 64
793 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200794 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100795 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
796 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
797 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
798 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
799 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
800 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
801 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
802 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Restorer51c94b62024-03-24 09:41:18 +0000803!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100804 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
805!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200806 # Load the default _vimrc settings from the registry (if any).
807 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
808 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
809 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100810 ${If} ${RunningX64}
811 SetRegView lastused
812 ${EndIf}
813
814 # User variables:
815 # $0 - holds the directory the executables are installed to
816 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
817 # registration (since a non-OLE gvim will not complain, and we want to
818 # always register an OLE gvim).
819 # $2 - holds the names to create batch files for
820 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
821 StrCpy $1 "-register-OLE"
822 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200823FunctionEnd
824
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100825Function .onInstSuccess
826 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
827FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200828
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100829Function .onInstFailed
830 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200831FunctionEnd
832
833##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100834Function SetCustom
835 # Display the _vimrc setting dialog using nsDialogs.
836
837 # Check if a _vimrc should be created
838 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
839 Abort
840 ${EndIf}
841
842 !insertmacro MUI_HEADER_TEXT \
843 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
844
845 nsDialogs::Create 1018
846 Pop $vim_dialog
847
848 ${If} $vim_dialog == error
849 Abort
850 ${EndIf}
851
852 ${If} ${RunningX64}
853 SetRegView 64
854 ${EndIf}
855
856 GetFunctionAddress $3 ValidateCustom
857 nsDialogs::OnBack $3
858
859
860 # 1st group - Compatibility
861 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
862 Pop $3
863
864 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
865 Pop $3
866 ${NSD_CreateDropList} 18% 19% 75% 8% ""
867 Pop $vim_nsd_compat
868 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
869 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
870 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
871 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
872
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200873 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100874 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200875 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100876 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200877 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100878 StrCpy $4 0
879 ${Else} # default
880 StrCpy $4 3
881 ${EndIf}
882 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
883
884
885 # 2nd group - Key remapping
886 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
887 Pop $3
888
889 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
890 Pop $3
891 ${NSD_CreateDropList} 38% 54% 55% 8% ""
892 Pop $vim_nsd_keymap
893 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
894 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
895
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200896 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100897 StrCpy $4 1
898 ${Else} # default
899 StrCpy $4 0
900 ${EndIf}
901 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
902
903
904 # 3rd group - Mouse behavior
905 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
906 Pop $3
907
908 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
909 Pop $3
910 ${NSD_CreateDropList} 23% 87% 70% 8% ""
911 Pop $vim_nsd_mouse
912 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
913 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
914 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
915
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200916 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100917 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200918 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100919 StrCpy $4 1
920 ${Else} # default
921 StrCpy $4 0
922 ${EndIf}
923 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
924
925 ${If} ${RunningX64}
926 SetRegView lastused
927 ${EndIf}
928
929 nsDialogs::Show
930FunctionEnd
931
932Function ValidateCustom
933 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
934 ${If} $3 = 0
935 StrCpy $vim_compat_stat "vi"
936 ${ElseIf} $3 = 1
937 StrCpy $vim_compat_stat "vim"
938 ${ElseIf} $3 = 2
939 StrCpy $vim_compat_stat "defaults"
940 ${Else}
941 StrCpy $vim_compat_stat "all"
942 ${EndIf}
943
944 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
945 ${If} $3 = 0
946 StrCpy $vim_keymap_stat "default"
947 ${Else}
948 StrCpy $vim_keymap_stat "windows"
949 ${EndIf}
950
951 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
952 ${If} $3 = 0
953 StrCpy $vim_mouse_stat "default"
954 ${ElseIf} $3 = 1
955 StrCpy $vim_mouse_stat "windows"
956 ${Else}
957 StrCpy $vim_mouse_stat "xterm"
958 ${EndIf}
959FunctionEnd
960
961##########################################################
962# Description for Installer Sections
963
964!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
965 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
966 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
967 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
968 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
969 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
970 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
971 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
972 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
973 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
974 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
975 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
976 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Restorer51c94b62024-03-24 09:41:18 +0000977!if ${HAVE_NLS}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100978 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
979!endif
980!insertmacro MUI_FUNCTION_DESCRIPTION_END
981
982
983##########################################################
984# Uninstaller Functions and Sections
985
986Function un.onInit
Restorer51c94b62024-03-24 09:41:18 +0000987!if ${HAVE_MULTI_LANG}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100988 # Get the language from the registry.
989 !insertmacro MUI_UNGETLANGUAGE
990!endif
991FunctionEnd
992
993Section "un.$(str_unsection_register)" id_unsection_register
994 SectionIn RO
995
Bram Moolenaar071d4272004-06-13 20:20:40 +0000996 # Apparently $INSTDIR is set to the directory where the uninstaller is
RestorerZ2680a072024-03-20 20:15:51 +0100997 # created. Thus the "vim91" directory is included in it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000998 StrCpy $0 "$INSTDIR"
999
Bram Moolenaar071d4272004-06-13 20:20:40 +00001000 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001001 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +02001002 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001003 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +00001004
1005 # We may have been put to the background when uninstall did something.
1006 BringToFront
1007
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001008 # Delete the installer language setting.
1009 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
1010SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001011
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001012Section "un.$(str_unsection_exe)" id_unsection_exe
1013
1014 StrCpy $0 "$INSTDIR"
1015
1016 # Delete gettext and iconv DLLs
1017 ${If} ${FileExists} "$0\libiconv-2.dll"
1018 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1019 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +02001020 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001021 ${If} ${FileExists} "$0\libintl-8.dll"
1022 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1023 "$0\libintl-8.dll"
1024 ${EndIf}
1025 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
1026 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1027 "$0\libgcc_s_sjlj-1.dll"
1028 ${EndIf}
1029
1030 # Delete other DLLs
1031 Delete /REBOOTOK $0\*.dll
1032
1033 # Delete 64-bit GvimExt
1034 ${If} ${RunningX64}
1035 !define LIBRARY_X64
1036 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
1037 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1038 "$0\GvimExt64\gvimext.dll"
1039 ${EndIf}
1040 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1041 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1042 "$0\GvimExt64\libiconv-2.dll"
1043 ${EndIf}
1044 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1045 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1046 "$0\GvimExt64\libintl-8.dll"
1047 ${EndIf}
1048 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1049 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1050 "$0\GvimExt64\libwinpthread-1.dll"
1051 ${EndIf}
1052 !undef LIBRARY_X64
1053 RMDir /r $0\GvimExt64
1054 ${EndIf}
1055
1056 # Delete 32-bit GvimExt
1057 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1058 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1059 "$0\GvimExt32\gvimext.dll"
1060 ${EndIf}
1061 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1062 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1063 "$0\GvimExt32\libiconv-2.dll"
1064 ${EndIf}
1065 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1066 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1067 "$0\GvimExt32\libintl-8.dll"
1068 ${EndIf}
1069 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1070 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1071 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1072 ${EndIf}
1073 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001074
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075 ClearErrors
1076 # Remove everything but *.dll files. Avoids that
1077 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001078 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 RMDir /r $0\colors
1080 RMDir /r $0\compiler
1081 RMDir /r $0\doc
1082 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001083 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 RMDir /r $0\indent
1085 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001086 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001087 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001088 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 RMDir /r $0\syntax
1090 RMDir /r $0\tools
1091 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001092 RMDir /r $0\lang
1093 RMDir /r $0\keymap
RestorerZ2680a072024-03-20 20:15:51 +01001094 RMDir /r $0\bitmaps
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095 Delete $0\*.exe
1096 Delete $0\*.bat
1097 Delete $0\*.vim
1098 Delete $0\*.txt
1099
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001100 ${If} ${Errors}
1101 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1102 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103
RestorerZ2680a072024-03-20 20:15:51 +01001104 # No error message if the "vim91" directory can't be removed, the
Bram Moolenaar071d4272004-06-13 20:20:40 +00001105 # gvimext.dll may still be there.
1106 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001107SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001109# Remove "vimfiles" directory under the specified directory.
1110!macro RemoveVimfiles dir
RestorerZ2680a072024-03-20 20:15:51 +01001111 ${If} ${FileExists} ${dir}\_viminfo
1112 Delete ${dir}\_viminfo
1113 ${EndIf}
1114 ${If} ${DirExists} ${dir}\vimfiles
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001115 RMDir ${dir}\vimfiles\colors
1116 RMDir ${dir}\vimfiles\compiler
1117 RMDir ${dir}\vimfiles\doc
1118 RMDir ${dir}\vimfiles\ftdetect
1119 RMDir ${dir}\vimfiles\ftplugin
1120 RMDir ${dir}\vimfiles\indent
1121 RMDir ${dir}\vimfiles\keymap
1122 RMDir ${dir}\vimfiles\plugin
1123 RMDir ${dir}\vimfiles\syntax
RestorerZ2680a072024-03-20 20:15:51 +01001124 ${If} ${FileExists} ${dir}\vimfiles\.netrwhist*
1125 Delete ${dir}\vimfiles\.netrwhist*
1126 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001127 RMDir ${dir}\vimfiles
1128 ${EndIf}
1129!macroend
1130
1131SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1132 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1133 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001134 Call un.GetHomeDir
1135 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001136
1137 ${If} $0 != ""
1138 !insertmacro RemoveVimfiles $0
1139 ${EndIf}
1140 SectionEnd
1141
1142 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1143 # get the parent dir of the installation
1144 Push $INSTDIR
1145 Call un.GetParent
1146 Pop $0
1147
1148 # if a plugin dir was created at installation remove it
1149 !insertmacro RemoveVimfiles $0
1150 SectionEnd
1151SectionGroupEnd
1152
1153Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154 # get the parent dir of the installation
1155 Push $INSTDIR
1156 Call un.GetParent
1157 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001159 ${IfNot} ${Silent}
1160 Delete $0\_vimrc
1161 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001162 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001163SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001164
1165##########################################################
1166# Description for Uninstaller Sections
1167
1168!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1169 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1170 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1171 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1172 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1173 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1174 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1175!insertmacro MUI_UNFUNCTION_DESCRIPTION_END