blob: 58ed85c5ebbe6f11b823d53ffa563893dc52465f [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
129InstallDir "$PROGRAMFILES64\Vim"
130!else
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131InstallDir "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100132!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133
134# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100135InstType $(str_type_typical)
136InstType $(str_type_minimal)
137InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138
139SilentInstall normal
140
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100141# General custom functions for MUI2:
142#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
143#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
144
145# Installer pages
146!insertmacro MUI_PAGE_WELCOME
147!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
148!insertmacro MUI_PAGE_COMPONENTS
149Page custom SetCustom ValidateCustom
150#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
151!insertmacro MUI_PAGE_DIRECTORY
152!insertmacro MUI_PAGE_INSTFILES
153!define MUI_FINISHPAGE_NOREBOOTSUPPORT
154!insertmacro MUI_PAGE_FINISH
155
156# Uninstaller pages:
157!insertmacro MUI_UNPAGE_CONFIRM
158#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
159!insertmacro MUI_UNPAGE_COMPONENTS
160!insertmacro MUI_UNPAGE_INSTFILES
161!define MUI_FINISHPAGE_NOREBOOTSUPPORT
162!insertmacro MUI_UNPAGE_FINISH
163
164##########################################################
165# Languages Files
166
167!insertmacro MUI_RESERVEFILE_LANGDLL
168!include "lang\english.nsi"
169
170# Include support for other languages:
171!ifdef HAVE_MULTI_LANG
172 !include "lang\danish.nsi"
173 !include "lang\dutch.nsi"
174 !include "lang\german.nsi"
175 !include "lang\italian.nsi"
176 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200177 !include "lang\russian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100178 !include "lang\simpchinese.nsi"
179 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100180 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100181!endif
182
Bram Moolenaardabfde02019-05-17 12:37:27 +0200183##########################################################
184# Version resources
185
186VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
187VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
188VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
189VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
190VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200191VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
192VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100193
194# Global variables
195Var vim_dialog
196Var vim_nsd_compat
197Var vim_nsd_keymap
198Var vim_nsd_mouse
199Var vim_compat_stat
200Var vim_keymap_stat
201Var vim_mouse_stat
202
Bram Moolenaar071d4272004-06-13 20:20:40 +0000203
Bram Moolenaar5d424742018-02-04 19:11:30 +0100204# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100205ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100206
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207##########################################################
208# Functions
209
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100210# Get parent directory
211# Share this function both on installer and uninstaller
212!macro GetParent un
213Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214 Exch $0 ; old $0 is on top of stack
215 Push $1
216 Push $2
217 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100218 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100220 ${If} $2 == ""
221 ${OrIf} $2 == "\"
222 ${ExitDo}
223 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000224 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100225 ${Loop}
226 StrCpy $0 $0 $1
227 Pop $2
228 Pop $1
229 Exch $0 ; put $0 on top of stack, restore $0 to original value
230FunctionEnd
231!macroend
232
233!insertmacro GetParent ""
234!insertmacro GetParent "un."
235
236# Check if Vim is already installed.
237# return: Installed directory. If not found, it will be empty.
238Function CheckOldVim
239 Push $0
240 Push $R0
241 Push $R1
242 Push $R2
243
244 ${If} ${RunningX64}
245 SetRegView 64
246 ${EndIf}
247
248 ClearErrors
249 StrCpy $0 "" # Installed directory
250 StrCpy $R0 0 # Sub-key index
251 StrCpy $R1 "" # Sub-key
252 ${Do}
253 # Eumerate the sub-key:
254 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
255
256 # Stop if no more sub-key:
257 ${If} ${Errors}
258 ${OrIf} $R1 == ""
259 ${ExitDo}
260 ${EndIf}
261
262 # Move to the next sub-key:
263 IntOp $R0 $R0 + 1
264
265 # Check if the key is Vim uninstall key or not:
266 StrCpy $R2 $R1 4
267 ${If} $R2 S!= "Vim "
268 ${Continue}
269 ${EndIf}
270
271 # Verifies required sub-keys:
272 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
273 ${If} ${Errors}
274 ${OrIf} $R2 == ""
275 ${Continue}
276 ${EndIf}
277
278 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
279 ${If} ${Errors}
280 ${OrIf} $R2 == ""
281 ${Continue}
282 ${EndIf}
283
284 # Found
285 Push $R2
286 call GetParent
287 call GetParent
288 Pop $0 # Vim directory
289 ${ExitDo}
290
291 ${Loop}
292
293 ${If} ${RunningX64}
294 SetRegView lastused
295 ${EndIf}
296
297 Pop $R2
298 Pop $R1
299 Pop $R0
300 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301FunctionEnd
302
Bram Moolenaar4a228972021-05-01 22:41:39 +0200303Function LaunchApplication
304 SetOutPath $0
305 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" "-R $"$0\README.txt$""
306FunctionEnd
307
Bram Moolenaar071d4272004-06-13 20:20:40 +0000308##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100309Section "$(str_section_old_ver)" id_section_old_ver
310 SectionIn 1 2 3 RO
311
312 # run the install program to check for already installed versions
313 SetOutPath $TEMP
314 File /oname=install.exe ${VIMSRC}\installw32.exe
315 DetailPrint "$(str_msg_uninstalling)"
316 ${Do}
317 nsExec::Exec "$TEMP\install.exe -uninstall-check"
318 Pop $3
319
320 call CheckOldVim
321 Pop $3
322 ${If} $3 == ""
323 ${ExitDo}
324 ${Else}
325 # It seems that the old version is still remaining.
326 # TODO: Should we show a warning and run the uninstaller again?
327
328 ${ExitDo} # Just ignore for now.
329 ${EndIf}
330 ${Loop}
331 Delete $TEMP\install.exe
332 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
333
334 # We may have been put to the background when uninstall did something.
335 BringToFront
336SectionEnd
337
338##########################################################
339Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200340 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341
342 # we need also this here if the user changes the instdir
343 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
344
345 SetOutPath $0
346 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200347!if /FileExists "${VIMSRC}\vim${BIT}.dll"
348 File ${VIMSRC}\vim${BIT}.dll
349!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200351 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200353 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100355 File ..\vimtutor.bat
356 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200357 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358 File ${VIMRT}\*.vim
359 File ${VIMRT}\rgb.txt
360
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\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369
370 SetOutPath $0\compiler
371 File ${VIMRT}\compiler\*.*
372
373 SetOutPath $0\doc
374 File ${VIMRT}\doc\*.txt
375 File ${VIMRT}\doc\tags
376
377 SetOutPath $0\ftplugin
378 File ${VIMRT}\ftplugin\*.*
379
380 SetOutPath $0\indent
381 File ${VIMRT}\indent\*.*
382
383 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100384 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100386 SetOutPath $0\pack
387 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200388
Bram Moolenaar071d4272004-06-13 20:20:40 +0000389 SetOutPath $0\plugin
390 File ${VIMRT}\plugin\*.*
391
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000392 SetOutPath $0\autoload
393 File ${VIMRT}\autoload\*.*
394
Bram Moolenaard09a2062017-11-11 15:37:45 +0100395 SetOutPath $0\autoload\dist
396 File ${VIMRT}\autoload\dist\*.*
397
Bram Moolenaar18144c82006-04-12 21:52:12 +0000398 SetOutPath $0\autoload\xml
399 File ${VIMRT}\autoload\xml\*.*
400
Bram Moolenaar071d4272004-06-13 20:20:40 +0000401 SetOutPath $0\syntax
402 File ${VIMRT}\syntax\*.*
403
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000404 SetOutPath $0\spell
405 File ${VIMRT}\spell\*.txt
406 File ${VIMRT}\spell\*.vim
407 File ${VIMRT}\spell\*.spl
408 File ${VIMRT}\spell\*.sug
409
Bram Moolenaar071d4272004-06-13 20:20:40 +0000410 SetOutPath $0\tools
411 File ${VIMRT}\tools\*.*
412
413 SetOutPath $0\tutor
414 File ${VIMRT}\tutor\*.*
415SectionEnd
416
417##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100418Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 SectionIn 1 3
420
421 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100422 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 StrCpy $2 "$2 vim view vimdiff"
424SectionEnd
425
426##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100427Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000428 SectionIn 3
429
430 StrCpy $1 "$1 -create-batfiles $2"
431SectionEnd
432
433##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100434SectionGroup $(str_group_icons) id_group_icons
435 Section "$(str_section_desktop)" id_section_desktop
436 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000437
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100438 StrCpy $1 "$1 -install-icons"
439 SectionEnd
440
441 Section "$(str_section_start_menu)" id_section_startmenu
442 SectionIn 1 3
443
444 StrCpy $1 "$1 -add-start-menu"
445 SectionEnd
446SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447
448##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100449Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450 SectionIn 1 3
451
Bram Moolenaar071d4272004-06-13 20:20:40 +0000452 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200453
Bram Moolenaar442b4222010-05-24 21:34:22 +0200454 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200455 # Install 64-bit gvimext.dll into the GvimExt64 directory.
456 SetOutPath $0\GvimExt64
457 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100458 !define LIBRARY_SHELL_EXTENSION
459 !define LIBRARY_X64
460 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
461 "${VIMSRC}\GvimExt\gvimext64.dll" \
462 "$0\GvimExt64\gvimext.dll" "$0"
463 !undef LIBRARY_X64
464 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200465 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200466
Bram Moolenaar6199d432017-10-14 19:05:44 +0200467 # Install 32-bit gvimext.dll into the GvimExt32 directory.
468 SetOutPath $0\GvimExt32
469 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100470 !define LIBRARY_SHELL_EXTENSION
471 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
472 "${VIMSRC}\GvimExt\gvimext.dll" \
473 "$0\GvimExt32\gvimext.dll" "$0"
474 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475
476 # We don't have a separate entry for the "Open With..." menu, assume
477 # the user wants either both or none.
478 StrCpy $1 "$1 -install-popup -install-openwith"
479SectionEnd
480
481##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100482Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000483 SectionIn 1 3
484
485 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100486
487 ${If} ${RunningX64}
488 SetRegView 64
489 ${EndIf}
490 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
491 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
492 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
493 ${If} ${RunningX64}
494 SetRegView lastused
495 ${EndIf}
496
497 ${If} $vim_compat_stat == "vi"
498 StrCpy $1 "$1 -vimrc-compat vi"
499 ${ElseIf} $vim_compat_stat == "vim"
500 StrCpy $1 "$1 -vimrc-compat vim"
501 ${ElseIf} $vim_compat_stat == "defaults"
502 StrCpy $1 "$1 -vimrc-compat defaults"
503 ${Else}
504 StrCpy $1 "$1 -vimrc-compat all"
505 ${EndIf}
506
507 ${If} $vim_keymap_stat == "default"
508 StrCpy $1 "$1 -vimrc-remap no"
509 ${Else}
510 StrCpy $1 "$1 -vimrc-remap win"
511 ${EndIf}
512
513 ${If} $vim_mouse_stat == "default"
514 StrCpy $1 "$1 -vimrc-behave default"
515 ${ElseIf} $vim_mouse_stat == "windows"
516 StrCpy $1 "$1 -vimrc-behave mswin"
517 ${Else}
518 StrCpy $1 "$1 -vimrc-behave unix"
519 ${EndIf}
520
Bram Moolenaar071d4272004-06-13 20:20:40 +0000521SectionEnd
522
523##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100524SectionGroup $(str_group_plugin) id_group_plugin
525 Section "$(str_section_plugin_home)" id_section_pluginhome
526 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000527
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100528 StrCpy $1 "$1 -create-directories home"
529 SectionEnd
530
531 Section "$(str_section_plugin_vim)" id_section_pluginvim
532 SectionIn 3
533
534 StrCpy $1 "$1 -create-directories vim"
535 SectionEnd
536SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000537
538##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100539!ifdef HAVE_VIS_VIM
540Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000541 SectionIn 3
542
543 SetOutPath $0
544 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
545 File ${VIMSRC}\VisVim\README_VisVim.txt
546SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100547!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000548
549##########################################################
550!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100551Section "$(str_section_nls)" id_section_nls
552 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100554 SetOutPath $0\lang
555 File /r ${VIMRT}\lang\*.*
556 SetOutPath $0\keymap
557 File ${VIMRT}\keymap\README.txt
558 File ${VIMRT}\keymap\*.vim
559 SetOutPath $0
560 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
561 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
562 "$0\libintl-8.dll" "$0"
563 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
564 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
565 "$0\libiconv-2.dll" "$0"
566 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
567 # Install libgcc_s_sjlj-1.dll only if it is needed.
568 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
569 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
570 "$0\libgcc_s_sjlj-1.dll" "$0"
571 !endif
572
573 ${If} ${SectionIsSelected} ${id_section_editwith}
574 ${If} ${RunningX64}
575 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
576 SetOutPath $0\GvimExt64
577 ClearErrors
578 !define LIBRARY_X64
579 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
580 "${GETTEXT}\gettext64\libintl-8.dll" \
581 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
582 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
583 "${GETTEXT}\gettext64\libiconv-2.dll" \
584 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
585 !undef LIBRARY_X64
586 ${EndIf}
587
588 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
589 SetOutPath $0\GvimExt32
590 ClearErrors
591 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
592 "${GETTEXT}\gettext32\libintl-8.dll" \
593 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
594 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
595 "${GETTEXT}\gettext32\libiconv-2.dll" \
596 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
597 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
598 # Install libgcc_s_sjlj-1.dll only if it is needed.
599 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
600 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
601 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
602 !endif
603 ${EndIf}
604SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000605!endif
606
607##########################################################
608Section -call_install_exe
609 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100610 DetailPrint "$(str_msg_registering)"
611 nsExec::Exec "$0\install.exe $1"
612 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000613SectionEnd
614
615##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100616!macro SaveSectionSelection section_id reg_value
617 ${If} ${SectionIsSelected} ${section_id}
618 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
619 ${Else}
620 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
621 ${EndIf}
622!macroend
623
Bram Moolenaar071d4272004-06-13 20:20:40 +0000624Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100625
626 # Get estimated install size
627 SectionGetSize ${id_section_exe} $3
628 ${If} ${SectionIsSelected} ${id_section_console}
629 SectionGetSize ${id_section_console} $4
630 IntOp $3 $3 + $4
631 ${EndIf}
632 ${If} ${SectionIsSelected} ${id_section_editwith}
633 SectionGetSize ${id_section_editwith} $4
634 IntOp $3 $3 + $4
635 ${EndIf}
636!ifdef HAVE_VIS_VIM
637 ${If} ${SectionIsSelected} ${id_section_visvim}
638 SectionGetSize ${id_section_visvim} $4
639 IntOp $3 $3 + $4
640 ${EndIf}
641!endif
642!ifdef HAVE_NLS
643 ${If} ${SectionIsSelected} ${id_section_nls}
644 SectionGetSize ${id_section_nls} $4
645 IntOp $3 $3 + $4
646 ${EndIf}
647!endif
648
649 # Register EstimatedSize and AllowSilent.
650 # Other information will be set by the install.exe (dosinst.c).
651 ${If} ${RunningX64}
652 SetRegView 64
653 ${EndIf}
654 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
655 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
656 ${If} ${RunningX64}
657 SetRegView lastused
658 ${EndIf}
659
660 # Store the selections to the registry.
661 ${If} ${RunningX64}
662 SetRegView 64
663 ${EndIf}
664 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
665 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
666 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
667 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
668 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
669 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
670 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
671 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
672!ifdef HAVE_VIS_VIM
673 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
674!endif
675!ifdef HAVE_NLS
676 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
677!endif
678 ${If} ${RunningX64}
679 SetRegView lastused
680 ${EndIf}
681
Bram Moolenaar071d4272004-06-13 20:20:40 +0000682 BringToFront
683SectionEnd
684
685##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100686!macro LoadSectionSelection section_id reg_value
687 ClearErrors
688 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
689 ${IfNot} ${Errors}
690 ${If} $3 = 1
691 !insertmacro SelectSection ${section_id}
692 ${Else}
693 !insertmacro UnselectSection ${section_id}
694 ${EndIf}
695 ${EndIf}
696!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200697
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200698!macro LoadDefaultVimrc out_var reg_value default_value
699 ClearErrors
700 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
701 ${If} ${Errors}
702 ${OrIf} ${out_var} == ""
703 StrCpy ${out_var} ${default_value}
704 ${EndIf}
705!macroend
706
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100707Function .onInit
708!ifdef HAVE_MULTI_LANG
709 # Select a language (or read from the registry).
710 !insertmacro MUI_LANGDLL_DISPLAY
711!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200712
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100713 # Check $VIM
714 ReadEnvStr $INSTDIR "VIM"
715
716 call CheckOldVim
717 Pop $3
718 ${If} $3 == ""
719 # No old versions of Vim found. Unselect and hide the section.
720 !insertmacro UnselectSection ${id_section_old_ver}
721 SectionSetInstTypes ${id_section_old_ver} 0
722 SectionSetText ${id_section_old_ver} ""
723 ${Else}
724 ${If} $INSTDIR == ""
725 StrCpy $INSTDIR $3
726 ${EndIf}
727 ${EndIf}
728
729 # If did not find a path: use the default dir.
730 ${If} $INSTDIR == ""
731!ifdef WIN64
732 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
733!else
734 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
735!endif
736 ${EndIf}
737
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100738 ${If} ${RunningX64}
739 SetRegView 64
740 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200741 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100742 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
743 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
744 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
745 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
746 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
747 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
748 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
749 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
750!ifdef HAVE_VIS_VIM
751 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
752!endif
753!ifdef HAVE_NLS
754 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
755!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200756 # Load the default _vimrc settings from the registry (if any).
757 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
758 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
759 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100760 ${If} ${RunningX64}
761 SetRegView lastused
762 ${EndIf}
763
764 # User variables:
765 # $0 - holds the directory the executables are installed to
766 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
767 # registration (since a non-OLE gvim will not complain, and we want to
768 # always register an OLE gvim).
769 # $2 - holds the names to create batch files for
770 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
771 StrCpy $1 "-register-OLE"
772 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200773FunctionEnd
774
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100775Function .onInstSuccess
776 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
777FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200778
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100779Function .onInstFailed
780 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200781FunctionEnd
782
783##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100784Function SetCustom
785 # Display the _vimrc setting dialog using nsDialogs.
786
787 # Check if a _vimrc should be created
788 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
789 Abort
790 ${EndIf}
791
792 !insertmacro MUI_HEADER_TEXT \
793 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
794
795 nsDialogs::Create 1018
796 Pop $vim_dialog
797
798 ${If} $vim_dialog == error
799 Abort
800 ${EndIf}
801
802 ${If} ${RunningX64}
803 SetRegView 64
804 ${EndIf}
805
806 GetFunctionAddress $3 ValidateCustom
807 nsDialogs::OnBack $3
808
809
810 # 1st group - Compatibility
811 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
812 Pop $3
813
814 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
815 Pop $3
816 ${NSD_CreateDropList} 18% 19% 75% 8% ""
817 Pop $vim_nsd_compat
818 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
819 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
820 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
821 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
822
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200823 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100824 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200825 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100826 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200827 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100828 StrCpy $4 0
829 ${Else} # default
830 StrCpy $4 3
831 ${EndIf}
832 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
833
834
835 # 2nd group - Key remapping
836 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
837 Pop $3
838
839 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
840 Pop $3
841 ${NSD_CreateDropList} 38% 54% 55% 8% ""
842 Pop $vim_nsd_keymap
843 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
844 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
845
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200846 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100847 StrCpy $4 1
848 ${Else} # default
849 StrCpy $4 0
850 ${EndIf}
851 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
852
853
854 # 3rd group - Mouse behavior
855 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
856 Pop $3
857
858 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
859 Pop $3
860 ${NSD_CreateDropList} 23% 87% 70% 8% ""
861 Pop $vim_nsd_mouse
862 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
863 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
864 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
865
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200866 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100867 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200868 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100869 StrCpy $4 1
870 ${Else} # default
871 StrCpy $4 0
872 ${EndIf}
873 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
874
875 ${If} ${RunningX64}
876 SetRegView lastused
877 ${EndIf}
878
879 nsDialogs::Show
880FunctionEnd
881
882Function ValidateCustom
883 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
884 ${If} $3 = 0
885 StrCpy $vim_compat_stat "vi"
886 ${ElseIf} $3 = 1
887 StrCpy $vim_compat_stat "vim"
888 ${ElseIf} $3 = 2
889 StrCpy $vim_compat_stat "defaults"
890 ${Else}
891 StrCpy $vim_compat_stat "all"
892 ${EndIf}
893
894 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
895 ${If} $3 = 0
896 StrCpy $vim_keymap_stat "default"
897 ${Else}
898 StrCpy $vim_keymap_stat "windows"
899 ${EndIf}
900
901 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
902 ${If} $3 = 0
903 StrCpy $vim_mouse_stat "default"
904 ${ElseIf} $3 = 1
905 StrCpy $vim_mouse_stat "windows"
906 ${Else}
907 StrCpy $vim_mouse_stat "xterm"
908 ${EndIf}
909FunctionEnd
910
911##########################################################
912# Description for Installer Sections
913
914!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
925 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
927!ifdef HAVE_VIS_VIM
928 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
929!endif
930!ifdef HAVE_NLS
931 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
932!endif
933!insertmacro MUI_FUNCTION_DESCRIPTION_END
934
935
936##########################################################
937# Uninstaller Functions and Sections
938
939Function un.onInit
940!ifdef HAVE_MULTI_LANG
941 # Get the language from the registry.
942 !insertmacro MUI_UNGETLANGUAGE
943!endif
944FunctionEnd
945
946Section "un.$(str_unsection_register)" id_unsection_register
947 SectionIn RO
948
Bram Moolenaar071d4272004-06-13 20:20:40 +0000949 # Apparently $INSTDIR is set to the directory where the uninstaller is
950 # created. Thus the "vim61" directory is included in it.
951 StrCpy $0 "$INSTDIR"
952
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100953!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000954 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100955 ${If} ${FileExists} "$0\VisVim.dll"
956 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
957 ${EndIf}
958!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959
960 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100961 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200962 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100963 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964
965 # We may have been put to the background when uninstall did something.
966 BringToFront
967
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100968 # Delete the installer language setting.
969 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
970SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000971
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100972Section "un.$(str_unsection_exe)" id_unsection_exe
973
974 StrCpy $0 "$INSTDIR"
975
976 # Delete gettext and iconv DLLs
977 ${If} ${FileExists} "$0\libiconv-2.dll"
978 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
979 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200980 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100981 ${If} ${FileExists} "$0\libintl-8.dll"
982 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
983 "$0\libintl-8.dll"
984 ${EndIf}
985 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
986 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
987 "$0\libgcc_s_sjlj-1.dll"
988 ${EndIf}
989
990 # Delete other DLLs
991 Delete /REBOOTOK $0\*.dll
992
993 # Delete 64-bit GvimExt
994 ${If} ${RunningX64}
995 !define LIBRARY_X64
996 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
997 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
998 "$0\GvimExt64\gvimext.dll"
999 ${EndIf}
1000 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
1001 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1002 "$0\GvimExt64\libiconv-2.dll"
1003 ${EndIf}
1004 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
1005 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1006 "$0\GvimExt64\libintl-8.dll"
1007 ${EndIf}
1008 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1009 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1010 "$0\GvimExt64\libwinpthread-1.dll"
1011 ${EndIf}
1012 !undef LIBRARY_X64
1013 RMDir /r $0\GvimExt64
1014 ${EndIf}
1015
1016 # Delete 32-bit GvimExt
1017 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1018 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1019 "$0\GvimExt32\gvimext.dll"
1020 ${EndIf}
1021 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1022 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1023 "$0\GvimExt32\libiconv-2.dll"
1024 ${EndIf}
1025 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1026 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1027 "$0\GvimExt32\libintl-8.dll"
1028 ${EndIf}
1029 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1030 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1031 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1032 ${EndIf}
1033 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001034
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035 ClearErrors
1036 # Remove everything but *.dll files. Avoids that
1037 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001038 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039 RMDir /r $0\colors
1040 RMDir /r $0\compiler
1041 RMDir /r $0\doc
1042 RMDir /r $0\ftplugin
1043 RMDir /r $0\indent
1044 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001045 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001047 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001048 RMDir /r $0\syntax
1049 RMDir /r $0\tools
1050 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001051!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001053!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001054 RMDir /r $0\lang
1055 RMDir /r $0\keymap
1056 Delete $0\*.exe
1057 Delete $0\*.bat
1058 Delete $0\*.vim
1059 Delete $0\*.txt
1060
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001061 ${If} ${Errors}
1062 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1063 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001064
1065 # No error message if the "vim62" directory can't be removed, the
1066 # gvimext.dll may still be there.
1067 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001068SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001070# Remove "vimfiles" directory under the specified directory.
1071!macro RemoveVimfiles dir
1072 ${If} ${FileExists} ${dir}\vimfiles
1073 RMDir ${dir}\vimfiles\colors
1074 RMDir ${dir}\vimfiles\compiler
1075 RMDir ${dir}\vimfiles\doc
1076 RMDir ${dir}\vimfiles\ftdetect
1077 RMDir ${dir}\vimfiles\ftplugin
1078 RMDir ${dir}\vimfiles\indent
1079 RMDir ${dir}\vimfiles\keymap
1080 RMDir ${dir}\vimfiles\plugin
1081 RMDir ${dir}\vimfiles\syntax
1082 RMDir ${dir}\vimfiles
1083 ${EndIf}
1084!macroend
1085
1086SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1087 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1088 # get the home dir
1089 ReadEnvStr $0 "HOME"
1090 ${If} $0 == ""
1091 ReadEnvStr $0 "HOMEDRIVE"
1092 ReadEnvStr $1 "HOMEPATH"
1093 StrCpy $0 "$0$1"
1094 ${If} $0 == ""
1095 ReadEnvStr $0 "USERPROFILE"
1096 ${EndIf}
1097 ${EndIf}
1098
1099 ${If} $0 != ""
1100 !insertmacro RemoveVimfiles $0
1101 ${EndIf}
1102 SectionEnd
1103
1104 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1105 # get the parent dir of the installation
1106 Push $INSTDIR
1107 Call un.GetParent
1108 Pop $0
1109
1110 # if a plugin dir was created at installation remove it
1111 !insertmacro RemoveVimfiles $0
1112 SectionEnd
1113SectionGroupEnd
1114
1115Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 # get the parent dir of the installation
1117 Push $INSTDIR
1118 Call un.GetParent
1119 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001121 ${IfNot} ${Silent}
1122 Delete $0\_vimrc
1123 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001124 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001126
1127##########################################################
1128# Description for Uninstaller Sections
1129
1130!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1131 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1132 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1133 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1134 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1135 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1136 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1137!insertmacro MUI_UNFUNCTION_DESCRIPTION_END