blob: 5416a0f886becb56cf382d3bf6f54d56d7a3fb4d [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
42# Comment the following line to create a multilanguage installer:
43!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
50# ----------- No configurable settings below this line -----------
51
Bram Moolenaaraf610b82018-12-21 16:22:50 +010052!include "Library.nsh" # For DLL install
53!ifdef HAVE_VIS_VIM
54 !include "UpgradeDLL.nsh" # for VisVim.dll
55!endif
56!include "LogicLib.nsh"
57!include "MUI2.nsh"
58!include "nsDialogs.nsh"
59!include "Sections.nsh"
60!include "x64.nsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +000061
Bram Moolenaaraf610b82018-12-21 16:22:50 +010062!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
63!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
64!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
65
66!ifdef WIN64
67Name "${PRODUCT} (x64)"
68!else
69Name "${PRODUCT}"
70!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000071OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
72CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +010073SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +010074SetCompressorDictSize 64
75ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +000076SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +020077RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +000078
79!ifdef HAVE_UPX
80 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
81!endif
82
Bram Moolenaaraf610b82018-12-21 16:22:50 +010083!ifdef WIN64
84!define BIT 64
85!else
86!define BIT 32
87!endif
88
89##########################################################
90# MUI2 settings
91
92!define MUI_ABORTWARNING
93!define MUI_UNABORTWARNING
94
95!define MUI_ICON "icons\vim_16c.ico"
96!define MUI_UNICON "icons\vim_uninst_16c.ico"
97
98# Show all languages, despite user's codepage:
99!define MUI_LANGDLL_ALLLANGUAGES
100!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
101!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
102!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
103
104!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
105!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
106!define MUI_HEADERIMAGE
107!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
108!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
109
110!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
111!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
112!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
113!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
114
115!define MUI_COMPONENTSPAGE_SMALLDESC
116!define MUI_LICENSEPAGE_CHECKBOX
117!define MUI_FINISHPAGE_RUN "$0\gvim.exe"
118!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
119!define MUI_FINISHPAGE_RUN_PARAMETERS "-R $\"$0\README.txt$\""
120
121# This adds '\Vim' to the user choice automagically. The actual value is
122# obtained below with CheckOldVim.
123!ifdef WIN64
124InstallDir "$PROGRAMFILES64\Vim"
125!else
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126InstallDir "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100127!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128
129# Types of installs we can perform:
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100130InstType $(str_type_typical)
131InstType $(str_type_minimal)
132InstType $(str_type_full)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133
134SilentInstall normal
135
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100136# General custom functions for MUI2:
137#!define MUI_CUSTOMFUNCTION_ABORT VimOnUserAbort
138#!define MUI_CUSTOMFUNCTION_UNABORT un.VimOnUserAbort
139
140# Installer pages
141!insertmacro MUI_PAGE_WELCOME
142!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
143!insertmacro MUI_PAGE_COMPONENTS
144Page custom SetCustom ValidateCustom
145#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
146!insertmacro MUI_PAGE_DIRECTORY
147!insertmacro MUI_PAGE_INSTFILES
148!define MUI_FINISHPAGE_NOREBOOTSUPPORT
149!insertmacro MUI_PAGE_FINISH
150
151# Uninstaller pages:
152!insertmacro MUI_UNPAGE_CONFIRM
153#!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.VimCheckRunning
154!insertmacro MUI_UNPAGE_COMPONENTS
155!insertmacro MUI_UNPAGE_INSTFILES
156!define MUI_FINISHPAGE_NOREBOOTSUPPORT
157!insertmacro MUI_UNPAGE_FINISH
158
159##########################################################
160# Languages Files
161
162!insertmacro MUI_RESERVEFILE_LANGDLL
163!include "lang\english.nsi"
164
165# Include support for other languages:
166!ifdef HAVE_MULTI_LANG
167 !include "lang\danish.nsi"
168 !include "lang\dutch.nsi"
169 !include "lang\german.nsi"
170 !include "lang\italian.nsi"
171 !include "lang\japanese.nsi"
172 !include "lang\simpchinese.nsi"
173 !include "lang\tradchinese.nsi"
174!endif
175
176
177# Global variables
178Var vim_dialog
179Var vim_nsd_compat
180Var vim_nsd_keymap
181Var vim_nsd_mouse
182Var vim_compat_stat
183Var vim_keymap_stat
184Var vim_mouse_stat
185
Bram Moolenaar071d4272004-06-13 20:20:40 +0000186
Bram Moolenaar5d424742018-02-04 19:11:30 +0100187# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100188ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100189
Bram Moolenaar071d4272004-06-13 20:20:40 +0000190##########################################################
191# Functions
192
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100193# Get parent directory
194# Share this function both on installer and uninstaller
195!macro GetParent un
196Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000197 Exch $0 ; old $0 is on top of stack
198 Push $1
199 Push $2
200 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100201 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100203 ${If} $2 == ""
204 ${OrIf} $2 == "\"
205 ${ExitDo}
206 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100208 ${Loop}
209 StrCpy $0 $0 $1
210 Pop $2
211 Pop $1
212 Exch $0 ; put $0 on top of stack, restore $0 to original value
213FunctionEnd
214!macroend
215
216!insertmacro GetParent ""
217!insertmacro GetParent "un."
218
219# Check if Vim is already installed.
220# return: Installed directory. If not found, it will be empty.
221Function CheckOldVim
222 Push $0
223 Push $R0
224 Push $R1
225 Push $R2
226
227 ${If} ${RunningX64}
228 SetRegView 64
229 ${EndIf}
230
231 ClearErrors
232 StrCpy $0 "" # Installed directory
233 StrCpy $R0 0 # Sub-key index
234 StrCpy $R1 "" # Sub-key
235 ${Do}
236 # Eumerate the sub-key:
237 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
238
239 # Stop if no more sub-key:
240 ${If} ${Errors}
241 ${OrIf} $R1 == ""
242 ${ExitDo}
243 ${EndIf}
244
245 # Move to the next sub-key:
246 IntOp $R0 $R0 + 1
247
248 # Check if the key is Vim uninstall key or not:
249 StrCpy $R2 $R1 4
250 ${If} $R2 S!= "Vim "
251 ${Continue}
252 ${EndIf}
253
254 # Verifies required sub-keys:
255 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
256 ${If} ${Errors}
257 ${OrIf} $R2 == ""
258 ${Continue}
259 ${EndIf}
260
261 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
262 ${If} ${Errors}
263 ${OrIf} $R2 == ""
264 ${Continue}
265 ${EndIf}
266
267 # Found
268 Push $R2
269 call GetParent
270 call GetParent
271 Pop $0 # Vim directory
272 ${ExitDo}
273
274 ${Loop}
275
276 ${If} ${RunningX64}
277 SetRegView lastused
278 ${EndIf}
279
280 Pop $R2
281 Pop $R1
282 Pop $R0
283 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284FunctionEnd
285
286##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100287Section "$(str_section_old_ver)" id_section_old_ver
288 SectionIn 1 2 3 RO
289
290 # run the install program to check for already installed versions
291 SetOutPath $TEMP
292 File /oname=install.exe ${VIMSRC}\installw32.exe
293 DetailPrint "$(str_msg_uninstalling)"
294 ${Do}
295 nsExec::Exec "$TEMP\install.exe -uninstall-check"
296 Pop $3
297
298 call CheckOldVim
299 Pop $3
300 ${If} $3 == ""
301 ${ExitDo}
302 ${Else}
303 # It seems that the old version is still remaining.
304 # TODO: Should we show a warning and run the uninstaller again?
305
306 ${ExitDo} # Just ignore for now.
307 ${EndIf}
308 ${Loop}
309 Delete $TEMP\install.exe
310 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
311
312 # We may have been put to the background when uninstall did something.
313 BringToFront
314SectionEnd
315
316##########################################################
317Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200318 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000319
320 # we need also this here if the user changes the instdir
321 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
322
323 SetOutPath $0
324 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200325!if /FileExists "${VIMSRC}\vim${BIT}.dll"
326 File ${VIMSRC}\vim${BIT}.dll
327!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000328 File /oname=install.exe ${VIMSRC}\installw32.exe
329 File /oname=uninstal.exe ${VIMSRC}\uninstalw32.exe
330 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200331 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000332 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100333 File ..\vimtutor.bat
334 File ..\README.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000335 File ..\uninstal.txt
336 File ${VIMRT}\*.vim
337 File ${VIMRT}\rgb.txt
338
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200339 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100340 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200341 File ${VIMTOOLS}\winpty-agent.exe
342
Bram Moolenaar071d4272004-06-13 20:20:40 +0000343 SetOutPath $0\colors
344 File ${VIMRT}\colors\*.*
345
346 SetOutPath $0\compiler
347 File ${VIMRT}\compiler\*.*
348
349 SetOutPath $0\doc
350 File ${VIMRT}\doc\*.txt
351 File ${VIMRT}\doc\tags
352
353 SetOutPath $0\ftplugin
354 File ${VIMRT}\ftplugin\*.*
355
356 SetOutPath $0\indent
357 File ${VIMRT}\indent\*.*
358
359 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100360 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100362 SetOutPath $0\pack
363 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200364
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365 SetOutPath $0\plugin
366 File ${VIMRT}\plugin\*.*
367
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000368 SetOutPath $0\autoload
369 File ${VIMRT}\autoload\*.*
370
Bram Moolenaard09a2062017-11-11 15:37:45 +0100371 SetOutPath $0\autoload\dist
372 File ${VIMRT}\autoload\dist\*.*
373
Bram Moolenaar18144c82006-04-12 21:52:12 +0000374 SetOutPath $0\autoload\xml
375 File ${VIMRT}\autoload\xml\*.*
376
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377 SetOutPath $0\syntax
378 File ${VIMRT}\syntax\*.*
379
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000380 SetOutPath $0\spell
381 File ${VIMRT}\spell\*.txt
382 File ${VIMRT}\spell\*.vim
383 File ${VIMRT}\spell\*.spl
384 File ${VIMRT}\spell\*.sug
385
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386 SetOutPath $0\tools
387 File ${VIMRT}\tools\*.*
388
389 SetOutPath $0\tutor
390 File ${VIMRT}\tutor\*.*
391SectionEnd
392
393##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100394Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000395 SectionIn 1 3
396
397 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100398 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399 StrCpy $2 "$2 vim view vimdiff"
400SectionEnd
401
402##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100403Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404 SectionIn 3
405
406 StrCpy $1 "$1 -create-batfiles $2"
407SectionEnd
408
409##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100410SectionGroup $(str_group_icons) id_group_icons
411 Section "$(str_section_desktop)" id_section_desktop
412 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000413
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100414 StrCpy $1 "$1 -install-icons"
415 SectionEnd
416
417 Section "$(str_section_start_menu)" id_section_startmenu
418 SectionIn 1 3
419
420 StrCpy $1 "$1 -add-start-menu"
421 SectionEnd
422SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423
424##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100425Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 SectionIn 1 3
427
Bram Moolenaar071d4272004-06-13 20:20:40 +0000428 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200429
Bram Moolenaar442b4222010-05-24 21:34:22 +0200430 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200431 # Install 64-bit gvimext.dll into the GvimExt64 directory.
432 SetOutPath $0\GvimExt64
433 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100434 !define LIBRARY_SHELL_EXTENSION
435 !define LIBRARY_X64
436 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
437 "${VIMSRC}\GvimExt\gvimext64.dll" \
438 "$0\GvimExt64\gvimext.dll" "$0"
439 !undef LIBRARY_X64
440 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200441 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200442
Bram Moolenaar6199d432017-10-14 19:05:44 +0200443 # Install 32-bit gvimext.dll into the GvimExt32 directory.
444 SetOutPath $0\GvimExt32
445 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100446 !define LIBRARY_SHELL_EXTENSION
447 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
448 "${VIMSRC}\GvimExt\gvimext.dll" \
449 "$0\GvimExt32\gvimext.dll" "$0"
450 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451
452 # We don't have a separate entry for the "Open With..." menu, assume
453 # the user wants either both or none.
454 StrCpy $1 "$1 -install-popup -install-openwith"
455SectionEnd
456
457##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100458Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459 SectionIn 1 3
460
461 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100462
463 ${If} ${RunningX64}
464 SetRegView 64
465 ${EndIf}
466 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
467 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
468 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
469 ${If} ${RunningX64}
470 SetRegView lastused
471 ${EndIf}
472
473 ${If} $vim_compat_stat == "vi"
474 StrCpy $1 "$1 -vimrc-compat vi"
475 ${ElseIf} $vim_compat_stat == "vim"
476 StrCpy $1 "$1 -vimrc-compat vim"
477 ${ElseIf} $vim_compat_stat == "defaults"
478 StrCpy $1 "$1 -vimrc-compat defaults"
479 ${Else}
480 StrCpy $1 "$1 -vimrc-compat all"
481 ${EndIf}
482
483 ${If} $vim_keymap_stat == "default"
484 StrCpy $1 "$1 -vimrc-remap no"
485 ${Else}
486 StrCpy $1 "$1 -vimrc-remap win"
487 ${EndIf}
488
489 ${If} $vim_mouse_stat == "default"
490 StrCpy $1 "$1 -vimrc-behave default"
491 ${ElseIf} $vim_mouse_stat == "windows"
492 StrCpy $1 "$1 -vimrc-behave mswin"
493 ${Else}
494 StrCpy $1 "$1 -vimrc-behave unix"
495 ${EndIf}
496
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497SectionEnd
498
499##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100500SectionGroup $(str_group_plugin) id_group_plugin
501 Section "$(str_section_plugin_home)" id_section_pluginhome
502 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100504 StrCpy $1 "$1 -create-directories home"
505 SectionEnd
506
507 Section "$(str_section_plugin_vim)" id_section_pluginvim
508 SectionIn 3
509
510 StrCpy $1 "$1 -create-directories vim"
511 SectionEnd
512SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513
514##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100515!ifdef HAVE_VIS_VIM
516Section "$(str_section_vis_vim)" id_section_visvim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000517 SectionIn 3
518
519 SetOutPath $0
520 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
521 File ${VIMSRC}\VisVim\README_VisVim.txt
522SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100523!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524
525##########################################################
526!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100527Section "$(str_section_nls)" id_section_nls
528 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000529
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100530 SetOutPath $0\lang
531 File /r ${VIMRT}\lang\*.*
532 SetOutPath $0\keymap
533 File ${VIMRT}\keymap\README.txt
534 File ${VIMRT}\keymap\*.vim
535 SetOutPath $0
536 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
537 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
538 "$0\libintl-8.dll" "$0"
539 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
540 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
541 "$0\libiconv-2.dll" "$0"
542 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
543 # Install libgcc_s_sjlj-1.dll only if it is needed.
544 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
545 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
546 "$0\libgcc_s_sjlj-1.dll" "$0"
547 !endif
548
549 ${If} ${SectionIsSelected} ${id_section_editwith}
550 ${If} ${RunningX64}
551 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
552 SetOutPath $0\GvimExt64
553 ClearErrors
554 !define LIBRARY_X64
555 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
556 "${GETTEXT}\gettext64\libintl-8.dll" \
557 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
558 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
559 "${GETTEXT}\gettext64\libiconv-2.dll" \
560 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
561 !undef LIBRARY_X64
562 ${EndIf}
563
564 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
565 SetOutPath $0\GvimExt32
566 ClearErrors
567 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
568 "${GETTEXT}\gettext32\libintl-8.dll" \
569 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
570 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
571 "${GETTEXT}\gettext32\libiconv-2.dll" \
572 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
573 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
574 # Install libgcc_s_sjlj-1.dll only if it is needed.
575 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
576 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
577 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
578 !endif
579 ${EndIf}
580SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581!endif
582
583##########################################################
584Section -call_install_exe
585 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100586 DetailPrint "$(str_msg_registering)"
587 nsExec::Exec "$0\install.exe $1"
588 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000589SectionEnd
590
591##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100592!macro SaveSectionSelection section_id reg_value
593 ${If} ${SectionIsSelected} ${section_id}
594 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
595 ${Else}
596 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
597 ${EndIf}
598!macroend
599
Bram Moolenaar071d4272004-06-13 20:20:40 +0000600Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100601
602 # Get estimated install size
603 SectionGetSize ${id_section_exe} $3
604 ${If} ${SectionIsSelected} ${id_section_console}
605 SectionGetSize ${id_section_console} $4
606 IntOp $3 $3 + $4
607 ${EndIf}
608 ${If} ${SectionIsSelected} ${id_section_editwith}
609 SectionGetSize ${id_section_editwith} $4
610 IntOp $3 $3 + $4
611 ${EndIf}
612!ifdef HAVE_VIS_VIM
613 ${If} ${SectionIsSelected} ${id_section_visvim}
614 SectionGetSize ${id_section_visvim} $4
615 IntOp $3 $3 + $4
616 ${EndIf}
617!endif
618!ifdef HAVE_NLS
619 ${If} ${SectionIsSelected} ${id_section_nls}
620 SectionGetSize ${id_section_nls} $4
621 IntOp $3 $3 + $4
622 ${EndIf}
623!endif
624
625 # Register EstimatedSize and AllowSilent.
626 # Other information will be set by the install.exe (dosinst.c).
627 ${If} ${RunningX64}
628 SetRegView 64
629 ${EndIf}
630 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
631 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
632 ${If} ${RunningX64}
633 SetRegView lastused
634 ${EndIf}
635
636 # Store the selections to the registry.
637 ${If} ${RunningX64}
638 SetRegView 64
639 ${EndIf}
640 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
641 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
642 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
643 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
644 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
645 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
646 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
647 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
648!ifdef HAVE_VIS_VIM
649 !insertmacro SaveSectionSelection ${id_section_visvim} "select_visvim"
650!endif
651!ifdef HAVE_NLS
652 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
653!endif
654 ${If} ${RunningX64}
655 SetRegView lastused
656 ${EndIf}
657
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658 BringToFront
659SectionEnd
660
661##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100662!macro LoadSectionSelection section_id reg_value
663 ClearErrors
664 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
665 ${IfNot} ${Errors}
666 ${If} $3 = 1
667 !insertmacro SelectSection ${section_id}
668 ${Else}
669 !insertmacro UnselectSection ${section_id}
670 ${EndIf}
671 ${EndIf}
672!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200673
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100674Function .onInit
675!ifdef HAVE_MULTI_LANG
676 # Select a language (or read from the registry).
677 !insertmacro MUI_LANGDLL_DISPLAY
678!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200679
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100680 # Check $VIM
681 ReadEnvStr $INSTDIR "VIM"
682
683 call CheckOldVim
684 Pop $3
685 ${If} $3 == ""
686 # No old versions of Vim found. Unselect and hide the section.
687 !insertmacro UnselectSection ${id_section_old_ver}
688 SectionSetInstTypes ${id_section_old_ver} 0
689 SectionSetText ${id_section_old_ver} ""
690 ${Else}
691 ${If} $INSTDIR == ""
692 StrCpy $INSTDIR $3
693 ${EndIf}
694 ${EndIf}
695
696 # If did not find a path: use the default dir.
697 ${If} $INSTDIR == ""
698!ifdef WIN64
699 StrCpy $INSTDIR "$PROGRAMFILES64\Vim"
700!else
701 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
702!endif
703 ${EndIf}
704
705# Load the selections from the registry (if any).
706 ${If} ${RunningX64}
707 SetRegView 64
708 ${EndIf}
709 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
710 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
711 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
712 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
713 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
714 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
715 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
716 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
717!ifdef HAVE_VIS_VIM
718 !insertmacro LoadSectionSelection ${id_section_visvim} "select_visvim"
719!endif
720!ifdef HAVE_NLS
721 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
722!endif
723 ${If} ${RunningX64}
724 SetRegView lastused
725 ${EndIf}
726
727 # User variables:
728 # $0 - holds the directory the executables are installed to
729 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
730 # registration (since a non-OLE gvim will not complain, and we want to
731 # always register an OLE gvim).
732 # $2 - holds the names to create batch files for
733 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
734 StrCpy $1 "-register-OLE"
735 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200736FunctionEnd
737
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100738Function .onInstSuccess
739 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
740FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200741
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100742Function .onInstFailed
743 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200744FunctionEnd
745
746##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100747Function SetCustom
748 # Display the _vimrc setting dialog using nsDialogs.
749
750 # Check if a _vimrc should be created
751 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
752 Abort
753 ${EndIf}
754
755 !insertmacro MUI_HEADER_TEXT \
756 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
757
758 nsDialogs::Create 1018
759 Pop $vim_dialog
760
761 ${If} $vim_dialog == error
762 Abort
763 ${EndIf}
764
765 ${If} ${RunningX64}
766 SetRegView 64
767 ${EndIf}
768
769 GetFunctionAddress $3 ValidateCustom
770 nsDialogs::OnBack $3
771
772
773 # 1st group - Compatibility
774 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
775 Pop $3
776
777 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
778 Pop $3
779 ${NSD_CreateDropList} 18% 19% 75% 8% ""
780 Pop $vim_nsd_compat
781 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
782 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
783 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
784 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
785
786 # Default selection
787 ${If} $vim_compat_stat == ""
788 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_compat"
789 ${Else}
790 StrCpy $3 $vim_compat_stat
791 ${EndIf}
792 ${If} $3 == "defaults"
793 StrCpy $4 2
794 ${ElseIf} $3 == "vim"
795 StrCpy $4 1
796 ${ElseIf} $3 == "vi"
797 StrCpy $4 0
798 ${Else} # default
799 StrCpy $4 3
800 ${EndIf}
801 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
802
803
804 # 2nd group - Key remapping
805 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
806 Pop $3
807
808 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
809 Pop $3
810 ${NSD_CreateDropList} 38% 54% 55% 8% ""
811 Pop $vim_nsd_keymap
812 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
813 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
814
815 # Default selection
816 ${If} $vim_keymap_stat == ""
817 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap"
818 ${Else}
819 StrCpy $3 $vim_keymap_stat
820 ${EndIf}
821 ${If} $3 == "windows"
822 StrCpy $4 1
823 ${Else} # default
824 StrCpy $4 0
825 ${EndIf}
826 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
827
828
829 # 3rd group - Mouse behavior
830 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
831 Pop $3
832
833 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
834 Pop $3
835 ${NSD_CreateDropList} 23% 87% 70% 8% ""
836 Pop $vim_nsd_mouse
837 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
838 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
839 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
840
841 # Default selection
842 ${If} $vim_mouse_stat == ""
843 ReadRegStr $3 HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse"
844 ${Else}
845 StrCpy $3 $vim_mouse_stat
846 ${EndIf}
847 ${If} $3 == "xterm"
848 StrCpy $4 2
849 ${ElseIf} $3 == "windows"
850 StrCpy $4 1
851 ${Else} # default
852 StrCpy $4 0
853 ${EndIf}
854 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
855
856 ${If} ${RunningX64}
857 SetRegView lastused
858 ${EndIf}
859
860 nsDialogs::Show
861FunctionEnd
862
863Function ValidateCustom
864 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
865 ${If} $3 = 0
866 StrCpy $vim_compat_stat "vi"
867 ${ElseIf} $3 = 1
868 StrCpy $vim_compat_stat "vim"
869 ${ElseIf} $3 = 2
870 StrCpy $vim_compat_stat "defaults"
871 ${Else}
872 StrCpy $vim_compat_stat "all"
873 ${EndIf}
874
875 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
876 ${If} $3 = 0
877 StrCpy $vim_keymap_stat "default"
878 ${Else}
879 StrCpy $vim_keymap_stat "windows"
880 ${EndIf}
881
882 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
883 ${If} $3 = 0
884 StrCpy $vim_mouse_stat "default"
885 ${ElseIf} $3 = 1
886 StrCpy $vim_mouse_stat "windows"
887 ${Else}
888 StrCpy $vim_mouse_stat "xterm"
889 ${EndIf}
890FunctionEnd
891
892##########################################################
893# Description for Installer Sections
894
895!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
896 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
897 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
898 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
899 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
900 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
901 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
902 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
903 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
904 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
905 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
906 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
907 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
908!ifdef HAVE_VIS_VIM
909 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_visvim} $(str_desc_vis_vim)
910!endif
911!ifdef HAVE_NLS
912 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
913!endif
914!insertmacro MUI_FUNCTION_DESCRIPTION_END
915
916
917##########################################################
918# Uninstaller Functions and Sections
919
920Function un.onInit
921!ifdef HAVE_MULTI_LANG
922 # Get the language from the registry.
923 !insertmacro MUI_UNGETLANGUAGE
924!endif
925FunctionEnd
926
927Section "un.$(str_unsection_register)" id_unsection_register
928 SectionIn RO
929
Bram Moolenaar071d4272004-06-13 20:20:40 +0000930 # Apparently $INSTDIR is set to the directory where the uninstaller is
931 # created. Thus the "vim61" directory is included in it.
932 StrCpy $0 "$INSTDIR"
933
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100934!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +0000935 # If VisVim was installed, unregister the DLL.
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100936 ${If} ${FileExists} "$0\VisVim.dll"
937 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
938 ${EndIf}
939!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000940
941 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100942 DetailPrint "$(str_msg_unregistering)"
943 nsExec::Exec "$0\uninstal.exe -nsis"
944 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000945
946 # We may have been put to the background when uninstall did something.
947 BringToFront
948
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100949 # Delete the installer language setting.
950 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
951SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000952
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100953Section "un.$(str_unsection_exe)" id_unsection_exe
954
955 StrCpy $0 "$INSTDIR"
956
957 # Delete gettext and iconv DLLs
958 ${If} ${FileExists} "$0\libiconv-2.dll"
959 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
960 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200961 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100962 ${If} ${FileExists} "$0\libintl-8.dll"
963 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
964 "$0\libintl-8.dll"
965 ${EndIf}
966 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
967 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
968 "$0\libgcc_s_sjlj-1.dll"
969 ${EndIf}
970
971 # Delete other DLLs
972 Delete /REBOOTOK $0\*.dll
973
974 # Delete 64-bit GvimExt
975 ${If} ${RunningX64}
976 !define LIBRARY_X64
977 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
978 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
979 "$0\GvimExt64\gvimext.dll"
980 ${EndIf}
981 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
982 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
983 "$0\GvimExt64\libiconv-2.dll"
984 ${EndIf}
985 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
986 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
987 "$0\GvimExt64\libintl-8.dll"
988 ${EndIf}
989 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
990 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
991 "$0\GvimExt64\libwinpthread-1.dll"
992 ${EndIf}
993 !undef LIBRARY_X64
994 RMDir /r $0\GvimExt64
995 ${EndIf}
996
997 # Delete 32-bit GvimExt
998 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
999 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1000 "$0\GvimExt32\gvimext.dll"
1001 ${EndIf}
1002 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1003 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1004 "$0\GvimExt32\libiconv-2.dll"
1005 ${EndIf}
1006 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1007 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1008 "$0\GvimExt32\libintl-8.dll"
1009 ${EndIf}
1010 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1011 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1012 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1013 ${EndIf}
1014 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001015
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 ClearErrors
1017 # Remove everything but *.dll files. Avoids that
1018 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001019 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001020 RMDir /r $0\colors
1021 RMDir /r $0\compiler
1022 RMDir /r $0\doc
1023 RMDir /r $0\ftplugin
1024 RMDir /r $0\indent
1025 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001026 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001028 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001029 RMDir /r $0\syntax
1030 RMDir /r $0\tools
1031 RMDir /r $0\tutor
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001032!ifdef HAVE_VIS_VIM
Bram Moolenaar071d4272004-06-13 20:20:40 +00001033 RMDir /r $0\VisVim
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001034!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035 RMDir /r $0\lang
1036 RMDir /r $0\keymap
1037 Delete $0\*.exe
1038 Delete $0\*.bat
1039 Delete $0\*.vim
1040 Delete $0\*.txt
1041
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001042 ${If} ${Errors}
1043 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1044 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045
1046 # No error message if the "vim62" directory can't be removed, the
1047 # gvimext.dll may still be there.
1048 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001049SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001051# Remove "vimfiles" directory under the specified directory.
1052!macro RemoveVimfiles dir
1053 ${If} ${FileExists} ${dir}\vimfiles
1054 RMDir ${dir}\vimfiles\colors
1055 RMDir ${dir}\vimfiles\compiler
1056 RMDir ${dir}\vimfiles\doc
1057 RMDir ${dir}\vimfiles\ftdetect
1058 RMDir ${dir}\vimfiles\ftplugin
1059 RMDir ${dir}\vimfiles\indent
1060 RMDir ${dir}\vimfiles\keymap
1061 RMDir ${dir}\vimfiles\plugin
1062 RMDir ${dir}\vimfiles\syntax
1063 RMDir ${dir}\vimfiles
1064 ${EndIf}
1065!macroend
1066
1067SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1068 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1069 # get the home dir
1070 ReadEnvStr $0 "HOME"
1071 ${If} $0 == ""
1072 ReadEnvStr $0 "HOMEDRIVE"
1073 ReadEnvStr $1 "HOMEPATH"
1074 StrCpy $0 "$0$1"
1075 ${If} $0 == ""
1076 ReadEnvStr $0 "USERPROFILE"
1077 ${EndIf}
1078 ${EndIf}
1079
1080 ${If} $0 != ""
1081 !insertmacro RemoveVimfiles $0
1082 ${EndIf}
1083 SectionEnd
1084
1085 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1086 # get the parent dir of the installation
1087 Push $INSTDIR
1088 Call un.GetParent
1089 Pop $0
1090
1091 # if a plugin dir was created at installation remove it
1092 !insertmacro RemoveVimfiles $0
1093 SectionEnd
1094SectionGroupEnd
1095
1096Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001097 # get the parent dir of the installation
1098 Push $INSTDIR
1099 Call un.GetParent
1100 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001102 ${IfNot} ${Silent}
1103 Delete $0\_vimrc
1104 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001105 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001107
1108##########################################################
1109# Description for Uninstaller Sections
1110
1111!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1112 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1113 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1114 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1115 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1116 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1117 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1118!insertmacro MUI_UNFUNCTION_DESCRIPTION_END