blob: 649c6950dde640be026d13d2fa61884c0069b23e [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.
Bram Moolenaar04344822014-11-05 18:18:17 +01003# Last Change: 2014 Nov 5
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
20# Location of extra tools: diff.exe
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
Bram Moolenaar071d4272004-06-13 20:20:40 +000032# Comment the next line if you don't have UPX.
Bram Moolenaar6199d432017-10-14 19:05:44 +020033# Get it at https://upx.github.io/
Bram Moolenaar071d4272004-06-13 20:20:40 +000034!define HAVE_UPX
35
Bram Moolenaaraf610b82018-12-21 16:22:50 +010036# Comment the next line if you do not want to add Native Language Support
Bram Moolenaar071d4272004-06-13 20:20:40 +000037!define HAVE_NLS
38
Bram Moolenaaraf610b82018-12-21 16:22:50 +010039# Uncomment the next line if you want to include VisVim extension:
40#!define HAVE_VIS_VIM
41
Bram Moolenaar3b0ef8c2020-02-12 21:03:32 +010042# Comment the following line to create an English-only installer:
Bram Moolenaaraf610b82018-12-21 16:22:50 +010043!define HAVE_MULTI_LANG
44
45# Uncomment the next line if you want to create a 64-bit installer.
46#!define WIN64
47
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010048!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000049
Bram Moolenaar9d591522019-05-26 20:49:42 +020050# Definition of Patch for Vim
51!ifndef PATCHLEVEL
52 !define PATCHLEVEL 0
53!endif
54
Bram Moolenaar071d4272004-06-13 20:20:40 +000055# ----------- No configurable settings below this line -----------
56
Bram Moolenaaraf610b82018-12-21 16:22:50 +010057!include "Library.nsh" # For DLL install
58!ifdef HAVE_VIS_VIM
59 !include "UpgradeDLL.nsh" # for VisVim.dll
60!endif
61!include "LogicLib.nsh"
62!include "MUI2.nsh"
63!include "nsDialogs.nsh"
64!include "Sections.nsh"
65!include "x64.nsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +000066
Bram Moolenaaraf610b82018-12-21 16:22:50 +010067!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
68!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
69!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
70
71!ifdef WIN64
72Name "${PRODUCT} (x64)"
73!else
74Name "${PRODUCT}"
75!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000076OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
77CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +010078SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +010079SetCompressorDictSize 64
80ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +000081SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +020082RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +000083
84!ifdef HAVE_UPX
85 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
86!endif
87
Bram Moolenaaraf610b82018-12-21 16:22:50 +010088!ifdef WIN64
89!define BIT 64
90!else
91!define BIT 32
92!endif
93
94##########################################################
95# MUI2 settings
96
97!define MUI_ABORTWARNING
98!define MUI_UNABORTWARNING
99
100!define MUI_ICON "icons\vim_16c.ico"
101!define MUI_UNICON "icons\vim_uninst_16c.ico"
102
103# Show all languages, despite user's codepage:
104!define MUI_LANGDLL_ALLLANGUAGES
105!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
106!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
107!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
108
109!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
110!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
111!define MUI_HEADERIMAGE
112!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
113!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
114
115!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
116!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
117!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
118!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
119
120!define MUI_COMPONENTSPAGE_SMALLDESC
121!define MUI_LICENSEPAGE_CHECKBOX
Bram Moolenaar4a228972021-05-01 22:41:39 +0200122!define MUI_FINISHPAGE_RUN
123!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100124!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100125
126# This adds '\Vim' to the user choice automagically. The actual value is
127# obtained below with CheckOldVim.
128!ifdef WIN64
Christian Brabandt7d603842021-07-24 21:19:42 +0200129 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100130!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200131 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100132!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200133InstallDir ${DEFAULT_INSTDIR}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134
135# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100136InstType $(str_type_typical)
137InstType $(str_type_minimal)
138InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
140SilentInstall normal
141
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100142# General custom functions for MUI2:
143#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
144#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
145
146# Installer pages
147!insertmacro MUI_PAGE_WELCOME
148!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
149!insertmacro MUI_PAGE_COMPONENTS
150Page custom SetCustom ValidateCustom
151#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
152!insertmacro MUI_PAGE_DIRECTORY
153!insertmacro MUI_PAGE_INSTFILES
154!define MUI_FINISHPAGE_NOREBOOTSUPPORT
155!insertmacro MUI_PAGE_FINISH
156
157# Uninstaller pages:
158!insertmacro MUI_UNPAGE_CONFIRM
159#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
160!insertmacro MUI_UNPAGE_COMPONENTS
161!insertmacro MUI_UNPAGE_INSTFILES
162!define MUI_FINISHPAGE_NOREBOOTSUPPORT
163!insertmacro MUI_UNPAGE_FINISH
164
165##########################################################
166# Languages Files
167
168!insertmacro MUI_RESERVEFILE_LANGDLL
169!include "lang\english.nsi"
170
171# Include support for other languages:
172!ifdef HAVE_MULTI_LANG
173 !include "lang\danish.nsi"
174 !include "lang\dutch.nsi"
175 !include "lang\german.nsi"
176 !include "lang\italian.nsi"
177 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200178 !include "lang\russian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100179 !include "lang\simpchinese.nsi"
180 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100181 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100182!endif
183
Bram Moolenaardabfde02019-05-17 12:37:27 +0200184##########################################################
185# Version resources
186
187VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
188VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
189VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
190VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
191VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200192VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
193VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100194
195# Global variables
196Var vim_dialog
197Var vim_nsd_compat
198Var vim_nsd_keymap
199Var vim_nsd_mouse
200Var vim_compat_stat
201Var vim_keymap_stat
202Var vim_mouse_stat
203
Bram Moolenaar071d4272004-06-13 20:20:40 +0000204
Bram Moolenaar5d424742018-02-04 19:11:30 +0100205# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100206ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100207
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208##########################################################
209# Functions
210
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100211# Get parent directory
212# Share this function both on installer and uninstaller
213!macro GetParent un
214Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000215 Exch $0 ; old $0 is on top of stack
216 Push $1
217 Push $2
218 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100219 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000220 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100221 ${If} $2 == ""
222 ${OrIf} $2 == "\"
223 ${ExitDo}
224 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000225 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100226 ${Loop}
227 StrCpy $0 $0 $1
228 Pop $2
229 Pop $1
230 Exch $0 ; put $0 on top of stack, restore $0 to original value
231FunctionEnd
232!macroend
233
234!insertmacro GetParent ""
235!insertmacro GetParent "un."
236
237# Check if Vim is already installed.
238# return: Installed directory. If not found, it will be empty.
239Function CheckOldVim
240 Push $0
241 Push $R0
242 Push $R1
243 Push $R2
244
245 ${If} ${RunningX64}
246 SetRegView 64
247 ${EndIf}
248
249 ClearErrors
250 StrCpy $0 "" # Installed directory
251 StrCpy $R0 0 # Sub-key index
252 StrCpy $R1 "" # Sub-key
253 ${Do}
254 # Eumerate the sub-key:
255 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
256
257 # Stop if no more sub-key:
258 ${If} ${Errors}
259 ${OrIf} $R1 == ""
260 ${ExitDo}
261 ${EndIf}
262
263 # Move to the next sub-key:
264 IntOp $R0 $R0 + 1
265
266 # Check if the key is Vim uninstall key or not:
267 StrCpy $R2 $R1 4
268 ${If} $R2 S!= "Vim "
269 ${Continue}
270 ${EndIf}
271
272 # Verifies required sub-keys:
273 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
274 ${If} ${Errors}
275 ${OrIf} $R2 == ""
276 ${Continue}
277 ${EndIf}
278
279 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
280 ${If} ${Errors}
281 ${OrIf} $R2 == ""
282 ${Continue}
283 ${EndIf}
284
285 # Found
286 Push $R2
287 call GetParent
288 call GetParent
289 Pop $0 # Vim directory
290 ${ExitDo}
291
292 ${Loop}
293
294 ${If} ${RunningX64}
295 SetRegView lastused
296 ${EndIf}
297
298 Pop $R2
299 Pop $R1
300 Pop $R0
301 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302FunctionEnd
303
Bram Moolenaar4a228972021-05-01 22:41:39 +0200304Function LaunchApplication
305 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200306 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200307FunctionEnd
308
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100310Section "$(str_section_old_ver)" id_section_old_ver
311 SectionIn 1 2 3 RO
312
313 # run the install program to check for already installed versions
314 SetOutPath $TEMP
315 File /oname=install.exe ${VIMSRC}\installw32.exe
316 DetailPrint "$(str_msg_uninstalling)"
317 ${Do}
318 nsExec::Exec "$TEMP\install.exe -uninstall-check"
319 Pop $3
320
321 call CheckOldVim
322 Pop $3
323 ${If} $3 == ""
324 ${ExitDo}
325 ${Else}
326 # It seems that the old version is still remaining.
327 # TODO: Should we show a warning and run the uninstaller again?
328
329 ${ExitDo} # Just ignore for now.
330 ${EndIf}
331 ${Loop}
332 Delete $TEMP\install.exe
333 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
334
335 # We may have been put to the background when uninstall did something.
336 BringToFront
337SectionEnd
338
339##########################################################
340Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200341 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000342
343 # we need also this here if the user changes the instdir
344 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
345
346 SetOutPath $0
347 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200348!if /FileExists "${VIMSRC}\vim${BIT}.dll"
349 File ${VIMSRC}\vim${BIT}.dll
350!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200352 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000353 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200354 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100356 File ..\vimtutor.bat
357 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200358 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000359 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200361 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100362 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200363 File ${VIMTOOLS}\winpty-agent.exe
364
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365 SetOutPath $0\colors
366 File ${VIMRT}\colors\*.*
Bram Moolenaard0bce502021-02-26 20:25:35 +0100367 SetOutPath $0\colors\tools
368 File ${VIMRT}\colors\tools\*.*
Drew Vogele30d1022021-10-24 20:35:07 +0100369 SetOutPath $0\colors\lists
370 File ${VIMRT}\colors\lists\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371
372 SetOutPath $0\compiler
373 File ${VIMRT}\compiler\*.*
374
375 SetOutPath $0\doc
376 File ${VIMRT}\doc\*.txt
377 File ${VIMRT}\doc\tags
378
379 SetOutPath $0\ftplugin
380 File ${VIMRT}\ftplugin\*.*
381
382 SetOutPath $0\indent
383 File ${VIMRT}\indent\*.*
384
385 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100386 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000387
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100388 SetOutPath $0\pack
389 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200390
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391 SetOutPath $0\plugin
392 File ${VIMRT}\plugin\*.*
393
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000394 SetOutPath $0\autoload
395 File ${VIMRT}\autoload\*.*
396
Bram Moolenaard09a2062017-11-11 15:37:45 +0100397 SetOutPath $0\autoload\dist
398 File ${VIMRT}\autoload\dist\*.*
399
Bram Moolenaar18144c82006-04-12 21:52:12 +0000400 SetOutPath $0\autoload\xml
401 File ${VIMRT}\autoload\xml\*.*
402
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403 SetOutPath $0\syntax
404 File ${VIMRT}\syntax\*.*
405
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000406 SetOutPath $0\spell
407 File ${VIMRT}\spell\*.txt
408 File ${VIMRT}\spell\*.vim
409 File ${VIMRT}\spell\*.spl
410 File ${VIMRT}\spell\*.sug
411
Bram Moolenaar071d4272004-06-13 20:20:40 +0000412 SetOutPath $0\tools
413 File ${VIMRT}\tools\*.*
414
415 SetOutPath $0\tutor
416 File ${VIMRT}\tutor\*.*
417SectionEnd
418
419##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100420Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421 SectionIn 1 3
422
423 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100424 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425 StrCpy $2 "$2 vim view vimdiff"
426SectionEnd
427
428##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100429Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430 SectionIn 3
431
432 StrCpy $1 "$1 -create-batfiles $2"
433SectionEnd
434
435##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100436SectionGroup $(str_group_icons) id_group_icons
437 Section "$(str_section_desktop)" id_section_desktop
438 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000439
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100440 StrCpy $1 "$1 -install-icons"
441 SectionEnd
442
443 Section "$(str_section_start_menu)" id_section_startmenu
444 SectionIn 1 3
445
446 StrCpy $1 "$1 -add-start-menu"
447 SectionEnd
448SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449
450##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100451Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000452 SectionIn 1 3
453
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200455
Bram Moolenaar442b4222010-05-24 21:34:22 +0200456 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200457 # Install 64-bit gvimext.dll into the GvimExt64 directory.
458 SetOutPath $0\GvimExt64
459 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100460 !define LIBRARY_SHELL_EXTENSION
461 !define LIBRARY_X64
462 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
463 "${VIMSRC}\GvimExt\gvimext64.dll" \
464 "$0\GvimExt64\gvimext.dll" "$0"
465 !undef LIBRARY_X64
466 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200467 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200468
Bram Moolenaar6199d432017-10-14 19:05:44 +0200469 # Install 32-bit gvimext.dll into the GvimExt32 directory.
470 SetOutPath $0\GvimExt32
471 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100472 !define LIBRARY_SHELL_EXTENSION
473 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
474 "${VIMSRC}\GvimExt\gvimext.dll" \
475 "$0\GvimExt32\gvimext.dll" "$0"
476 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000477
478 # We don't have a separate entry for the "Open With..." menu, assume
479 # the user wants either both or none.
480 StrCpy $1 "$1 -install-popup -install-openwith"
481SectionEnd
482
483##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100484Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000485 SectionIn 1 3
486
487 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100488
489 ${If} ${RunningX64}
490 SetRegView 64
491 ${EndIf}
492 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
493 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
494 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
495 ${If} ${RunningX64}
496 SetRegView lastused
497 ${EndIf}
498
499 ${If} $vim_compat_stat == "vi"
500 StrCpy $1 "$1 -vimrc-compat vi"
501 ${ElseIf} $vim_compat_stat == "vim"
502 StrCpy $1 "$1 -vimrc-compat vim"
503 ${ElseIf} $vim_compat_stat == "defaults"
504 StrCpy $1 "$1 -vimrc-compat defaults"
505 ${Else}
506 StrCpy $1 "$1 -vimrc-compat all"
507 ${EndIf}
508
509 ${If} $vim_keymap_stat == "default"
510 StrCpy $1 "$1 -vimrc-remap no"
511 ${Else}
512 StrCpy $1 "$1 -vimrc-remap win"
513 ${EndIf}
514
515 ${If} $vim_mouse_stat == "default"
516 StrCpy $1 "$1 -vimrc-behave default"
517 ${ElseIf} $vim_mouse_stat == "windows"
518 StrCpy $1 "$1 -vimrc-behave mswin"
519 ${Else}
520 StrCpy $1 "$1 -vimrc-behave unix"
521 ${EndIf}
522
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523SectionEnd
524
525##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100526SectionGroup $(str_group_plugin) id_group_plugin
527 Section "$(str_section_plugin_home)" id_section_pluginhome
528 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000529
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100530 StrCpy $1 "$1 -create-directories home"
531 SectionEnd
532
533 Section "$(str_section_plugin_vim)" id_section_pluginvim
534 SectionIn 3
535
536 StrCpy $1 "$1 -create-directories vim"
537 SectionEnd
538SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539
540##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100541!ifdef HAVE_VIS_VIM
542Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543 SectionIn 3
544
545 SetOutPath $0
546 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
547 File ${VIMSRC}\VisVim\README_VisVim.txt
548SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100549!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550
551##########################################################
552!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100553Section "$(str_section_nls)" id_section_nls
554 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100556 SetOutPath $0\lang
557 File /r ${VIMRT}\lang\*.*
558 SetOutPath $0\keymap
559 File ${VIMRT}\keymap\README.txt
560 File ${VIMRT}\keymap\*.vim
561 SetOutPath $0
562 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
563 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
564 "$0\libintl-8.dll" "$0"
565 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
566 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
567 "$0\libiconv-2.dll" "$0"
568 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
569 # Install libgcc_s_sjlj-1.dll only if it is needed.
570 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
571 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
572 "$0\libgcc_s_sjlj-1.dll" "$0"
573 !endif
574
575 ${If} ${SectionIsSelected} ${id_section_editwith}
576 ${If} ${RunningX64}
577 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
578 SetOutPath $0\GvimExt64
579 ClearErrors
580 !define LIBRARY_X64
581 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
582 "${GETTEXT}\gettext64\libintl-8.dll" \
583 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
584 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
585 "${GETTEXT}\gettext64\libiconv-2.dll" \
586 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
587 !undef LIBRARY_X64
588 ${EndIf}
589
590 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
591 SetOutPath $0\GvimExt32
592 ClearErrors
593 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
594 "${GETTEXT}\gettext32\libintl-8.dll" \
595 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
596 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
597 "${GETTEXT}\gettext32\libiconv-2.dll" \
598 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
599 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
600 # Install libgcc_s_sjlj-1.dll only if it is needed.
601 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
602 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
603 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
604 !endif
605 ${EndIf}
606SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000607!endif
608
609##########################################################
610Section -call_install_exe
611 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100612 DetailPrint "$(str_msg_registering)"
613 nsExec::Exec "$0\install.exe $1"
614 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615SectionEnd
616
617##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100618!macro SaveSectionSelection section_id reg_value
619 ${If} ${SectionIsSelected} ${section_id}
620 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
621 ${Else}
622 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
623 ${EndIf}
624!macroend
625
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100627
628 # Get estimated install size
629 SectionGetSize ${id_section_exe} $3
630 ${If} ${SectionIsSelected} ${id_section_console}
631 SectionGetSize ${id_section_console} $4
632 IntOp $3 $3 + $4
633 ${EndIf}
634 ${If} ${SectionIsSelected} ${id_section_editwith}
635 SectionGetSize ${id_section_editwith} $4
636 IntOp $3 $3 + $4
637 ${EndIf}
638!ifdef HAVE_VIS_VIM
639 ${If} ${SectionIsSelected} ${id_section_visvim}
640 SectionGetSize ${id_section_visvim} $4
641 IntOp $3 $3 + $4
642 ${EndIf}
643!endif
644!ifdef HAVE_NLS
645 ${If} ${SectionIsSelected} ${id_section_nls}
646 SectionGetSize ${id_section_nls} $4
647 IntOp $3 $3 + $4
648 ${EndIf}
649!endif
650
651 # Register EstimatedSize and AllowSilent.
652 # Other information will be set by the install.exe (dosinst.c).
653 ${If} ${RunningX64}
654 SetRegView 64
655 ${EndIf}
656 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
657 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
658 ${If} ${RunningX64}
659 SetRegView lastused
660 ${EndIf}
661
662 # Store the selections to the registry.
663 ${If} ${RunningX64}
664 SetRegView 64
665 ${EndIf}
666 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
667 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
668 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
669 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
670 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
671 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
672 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
673 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
674!ifdef HAVE_VIS_VIM
675 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
676!endif
677!ifdef HAVE_NLS
678 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
679!endif
680 ${If} ${RunningX64}
681 SetRegView lastused
682 ${EndIf}
683
Bram Moolenaar071d4272004-06-13 20:20:40 +0000684 BringToFront
685SectionEnd
686
687##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100688!macro LoadSectionSelection section_id reg_value
689 ClearErrors
690 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
691 ${IfNot} ${Errors}
692 ${If} $3 = 1
693 !insertmacro SelectSection ${section_id}
694 ${Else}
695 !insertmacro UnselectSection ${section_id}
696 ${EndIf}
697 ${EndIf}
698!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200699
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200700!macro LoadDefaultVimrc out_var reg_value default_value
701 ClearErrors
702 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
703 ${If} ${Errors}
704 ${OrIf} ${out_var} == ""
705 StrCpy ${out_var} ${default_value}
706 ${EndIf}
707!macroend
708
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100709Function .onInit
710!ifdef HAVE_MULTI_LANG
711 # Select a language (or read from the registry).
712 !insertmacro MUI_LANGDLL_DISPLAY
713!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200714
Christian Brabandt7d603842021-07-24 21:19:42 +0200715 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
716 # Check $VIM
717 ReadEnvStr $3 "VIM"
718 ${If} $3 != ""
719 StrCpy $INSTDIR $3
720 ${EndIf}
721 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100722
723 call CheckOldVim
724 Pop $3
725 ${If} $3 == ""
726 # No old versions of Vim found. Unselect and hide the section.
727 !insertmacro UnselectSection ${id_section_old_ver}
728 SectionSetInstTypes ${id_section_old_ver} 0
729 SectionSetText ${id_section_old_ver} ""
730 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200731 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100732 StrCpy $INSTDIR $3
733 ${EndIf}
734 ${EndIf}
735
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100736 ${If} ${RunningX64}
737 SetRegView 64
738 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200739 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100740 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
741 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
742 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
743 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
744 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
745 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
746 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
747 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
748!ifdef HAVE_VIS_VIM
749 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
750!endif
751!ifdef HAVE_NLS
752 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
753!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200754 # Load the default _vimrc settings from the registry (if any).
755 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
756 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
757 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100758 ${If} ${RunningX64}
759 SetRegView lastused
760 ${EndIf}
761
762 # User variables:
763 # $0 - holds the directory the executables are installed to
764 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
765 # registration (since a non-OLE gvim will not complain, and we want to
766 # always register an OLE gvim).
767 # $2 - holds the names to create batch files for
768 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
769 StrCpy $1 "-register-OLE"
770 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200771FunctionEnd
772
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100773Function .onInstSuccess
774 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
775FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200776
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100777Function .onInstFailed
778 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200779FunctionEnd
780
781##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100782Function SetCustom
783 # Display the _vimrc setting dialog using nsDialogs.
784
785 # Check if a _vimrc should be created
786 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
787 Abort
788 ${EndIf}
789
790 !insertmacro MUI_HEADER_TEXT \
791 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
792
793 nsDialogs::Create 1018
794 Pop $vim_dialog
795
796 ${If} $vim_dialog == error
797 Abort
798 ${EndIf}
799
800 ${If} ${RunningX64}
801 SetRegView 64
802 ${EndIf}
803
804 GetFunctionAddress $3 ValidateCustom
805 nsDialogs::OnBack $3
806
807
808 # 1st group - Compatibility
809 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
810 Pop $3
811
812 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
813 Pop $3
814 ${NSD_CreateDropList} 18% 19% 75% 8% ""
815 Pop $vim_nsd_compat
816 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
817 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
818 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
819 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
820
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200821 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100822 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200823 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100824 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200825 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100826 StrCpy $4 0
827 ${Else} # default
828 StrCpy $4 3
829 ${EndIf}
830 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
831
832
833 # 2nd group - Key remapping
834 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
835 Pop $3
836
837 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
838 Pop $3
839 ${NSD_CreateDropList} 38% 54% 55% 8% ""
840 Pop $vim_nsd_keymap
841 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
842 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
843
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200844 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100845 StrCpy $4 1
846 ${Else} # default
847 StrCpy $4 0
848 ${EndIf}
849 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
850
851
852 # 3rd group - Mouse behavior
853 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
854 Pop $3
855
856 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
857 Pop $3
858 ${NSD_CreateDropList} 23% 87% 70% 8% ""
859 Pop $vim_nsd_mouse
860 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
861 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
862 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
863
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200864 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100865 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200866 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100867 StrCpy $4 1
868 ${Else} # default
869 StrCpy $4 0
870 ${EndIf}
871 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
872
873 ${If} ${RunningX64}
874 SetRegView lastused
875 ${EndIf}
876
877 nsDialogs::Show
878FunctionEnd
879
880Function ValidateCustom
881 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
882 ${If} $3 = 0
883 StrCpy $vim_compat_stat "vi"
884 ${ElseIf} $3 = 1
885 StrCpy $vim_compat_stat "vim"
886 ${ElseIf} $3 = 2
887 StrCpy $vim_compat_stat "defaults"
888 ${Else}
889 StrCpy $vim_compat_stat "all"
890 ${EndIf}
891
892 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
893 ${If} $3 = 0
894 StrCpy $vim_keymap_stat "default"
895 ${Else}
896 StrCpy $vim_keymap_stat "windows"
897 ${EndIf}
898
899 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
900 ${If} $3 = 0
901 StrCpy $vim_mouse_stat "default"
902 ${ElseIf} $3 = 1
903 StrCpy $vim_mouse_stat "windows"
904 ${Else}
905 StrCpy $vim_mouse_stat "xterm"
906 ${EndIf}
907FunctionEnd
908
909##########################################################
910# Description for Installer Sections
911
912!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
925!ifdef HAVE_VIS_VIM
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
927!endif
928!ifdef HAVE_NLS
929 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
930!endif
931!insertmacro MUI_FUNCTION_DESCRIPTION_END
932
933
934##########################################################
935# Uninstaller Functions and Sections
936
937Function un.onInit
938!ifdef HAVE_MULTI_LANG
939 # Get the language from the registry.
940 !insertmacro MUI_UNGETLANGUAGE
941!endif
942FunctionEnd
943
944Section "un.$(str_unsection_register)" id_unsection_register
945 SectionIn RO
946
Bram Moolenaar071d4272004-06-13 20:20:40 +0000947 # Apparently $INSTDIR is set to the directory where the uninstaller is
948 # created. Thus the "vim61" directory is included in it.
949 StrCpy $0 "$INSTDIR"
950
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100951!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000952 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100953 ${If} ${FileExists} "$0\VisVim.dll"
954 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
955 ${EndIf}
956!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000957
958 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100959 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200960 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100961 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962
963 # We may have been put to the background when uninstall did something.
964 BringToFront
965
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100966 # Delete the installer language setting.
967 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
968SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000969
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100970Section "un.$(str_unsection_exe)" id_unsection_exe
971
972 StrCpy $0 "$INSTDIR"
973
974 # Delete gettext and iconv DLLs
975 ${If} ${FileExists} "$0\libiconv-2.dll"
976 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
977 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200978 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100979 ${If} ${FileExists} "$0\libintl-8.dll"
980 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
981 "$0\libintl-8.dll"
982 ${EndIf}
983 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
984 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
985 "$0\libgcc_s_sjlj-1.dll"
986 ${EndIf}
987
988 # Delete other DLLs
989 Delete /REBOOTOK $0\*.dll
990
991 # Delete 64-bit GvimExt
992 ${If} ${RunningX64}
993 !define LIBRARY_X64
994 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
995 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
996 "$0\GvimExt64\gvimext.dll"
997 ${EndIf}
998 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
999 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1000 "$0\GvimExt64\libiconv-2.dll"
1001 ${EndIf}
1002 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1003 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1004 "$0\GvimExt64\libintl-8.dll"
1005 ${EndIf}
1006 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1007 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1008 "$0\GvimExt64\libwinpthread-1.dll"
1009 ${EndIf}
1010 !undef LIBRARY_X64
1011 RMDir /r $0\GvimExt64
1012 ${EndIf}
1013
1014 # Delete 32-bit GvimExt
1015 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1016 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1017 "$0\GvimExt32\gvimext.dll"
1018 ${EndIf}
1019 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1020 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1021 "$0\GvimExt32\libiconv-2.dll"
1022 ${EndIf}
1023 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1024 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1025 "$0\GvimExt32\libintl-8.dll"
1026 ${EndIf}
1027 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1028 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1029 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1030 ${EndIf}
1031 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001032
Bram Moolenaar071d4272004-06-13 20:20:40 +00001033 ClearErrors
1034 # Remove everything but *.dll files. Avoids that
1035 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001036 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 RMDir /r $0\colors
1038 RMDir /r $0\compiler
1039 RMDir /r $0\doc
1040 RMDir /r $0\ftplugin
1041 RMDir /r $0\indent
1042 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001043 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001045 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 RMDir /r $0\syntax
1047 RMDir /r $0\tools
1048 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001049!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001051!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 RMDir /r $0\lang
1053 RMDir /r $0\keymap
1054 Delete $0\*.exe
1055 Delete $0\*.bat
1056 Delete $0\*.vim
1057 Delete $0\*.txt
1058
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001059 ${If} ${Errors}
1060 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1061 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062
1063 # No error message if the "vim62" directory can't be removed, the
1064 # gvimext.dll may still be there.
1065 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001066SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001068# Remove "vimfiles" directory under the specified directory.
1069!macro RemoveVimfiles dir
1070 ${If} ${FileExists} ${dir}\vimfiles
1071 RMDir ${dir}\vimfiles\colors
1072 RMDir ${dir}\vimfiles\compiler
1073 RMDir ${dir}\vimfiles\doc
1074 RMDir ${dir}\vimfiles\ftdetect
1075 RMDir ${dir}\vimfiles\ftplugin
1076 RMDir ${dir}\vimfiles\indent
1077 RMDir ${dir}\vimfiles\keymap
1078 RMDir ${dir}\vimfiles\plugin
1079 RMDir ${dir}\vimfiles\syntax
1080 RMDir ${dir}\vimfiles
1081 ${EndIf}
1082!macroend
1083
1084SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1085 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1086 # get the home dir
1087 ReadEnvStr $0 "HOME"
1088 ${If} $0 == ""
1089 ReadEnvStr $0 "HOMEDRIVE"
1090 ReadEnvStr $1 "HOMEPATH"
1091 StrCpy $0 "$0$1"
1092 ${If} $0 == ""
1093 ReadEnvStr $0 "USERPROFILE"
1094 ${EndIf}
1095 ${EndIf}
1096
1097 ${If} $0 != ""
1098 !insertmacro RemoveVimfiles $0
1099 ${EndIf}
1100 SectionEnd
1101
1102 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1103 # get the parent dir of the installation
1104 Push $INSTDIR
1105 Call un.GetParent
1106 Pop $0
1107
1108 # if a plugin dir was created at installation remove it
1109 !insertmacro RemoveVimfiles $0
1110 SectionEnd
1111SectionGroupEnd
1112
1113Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 # get the parent dir of the installation
1115 Push $INSTDIR
1116 Call un.GetParent
1117 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001119 ${IfNot} ${Silent}
1120 Delete $0\_vimrc
1121 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001122 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001124
1125##########################################################
1126# Description for Uninstaller Sections
1127
1128!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1129 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1130 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1131 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1132 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1133 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1134 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1135!insertmacro MUI_UNFUNCTION_DESCRIPTION_END