blob: 64c1bc76c54e13c762217af303b1989d26637579 [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 Moolenaar3b0ef8c2020-02-12 21:03:32 +010039# Comment the following line to create an English-only installer:
Bram Moolenaaraf610b82018-12-21 16:22:50 +010040!define HAVE_MULTI_LANG
41
42# Uncomment the next line if you want to create a 64-bit installer.
43#!define WIN64
44
Bram Moolenaar6c7b4442016-01-02 15:44:32 +010045!include gvim_version.nsh # for version number
Bram Moolenaar071d4272004-06-13 20:20:40 +000046
Bram Moolenaar9d591522019-05-26 20:49:42 +020047# Definition of Patch for Vim
48!ifndef PATCHLEVEL
49 !define PATCHLEVEL 0
50!endif
51
Bram Moolenaar071d4272004-06-13 20:20:40 +000052# ----------- No configurable settings below this line -----------
53
Bram Moolenaaraf610b82018-12-21 16:22:50 +010054!include "Library.nsh" # For DLL install
Bram Moolenaaraf610b82018-12-21 16:22:50 +010055!include "LogicLib.nsh"
56!include "MUI2.nsh"
57!include "nsDialogs.nsh"
58!include "Sections.nsh"
59!include "x64.nsh"
Bram Moolenaar071d4272004-06-13 20:20:40 +000060
Bram Moolenaaraf610b82018-12-21 16:22:50 +010061!define PRODUCT "Vim ${VER_MAJOR}.${VER_MINOR}"
62!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
63!define UNINST_REG_KEY_VIM "${UNINST_REG_KEY}\${PRODUCT}"
64
65!ifdef WIN64
66Name "${PRODUCT} (x64)"
67!else
68Name "${PRODUCT}"
69!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000070OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
71CRCCheck force
Bram Moolenaar286eacd2016-01-16 18:05:50 +010072SetCompressor /SOLID lzma
Bram Moolenaaraf610b82018-12-21 16:22:50 +010073SetCompressorDictSize 64
74ManifestDPIAware true
Bram Moolenaar071d4272004-06-13 20:20:40 +000075SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +020076RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +000077
78!ifdef HAVE_UPX
79 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
80!endif
81
Bram Moolenaaraf610b82018-12-21 16:22:50 +010082!ifdef WIN64
83!define BIT 64
84!else
85!define BIT 32
86!endif
87
88##########################################################
89# MUI2 settings
90
91!define MUI_ABORTWARNING
92!define MUI_UNABORTWARNING
93
94!define MUI_ICON "icons\vim_16c.ico"
95!define MUI_UNICON "icons\vim_uninst_16c.ico"
96
97# Show all languages, despite user's codepage:
98!define MUI_LANGDLL_ALLLANGUAGES
99!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
100!define MUI_LANGDLL_REGISTRY_KEY "Software\Vim"
101!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
102
103!define MUI_WELCOMEFINISHPAGE_BITMAP "icons\welcome.bmp"
104!define MUI_UNWELCOMEFINISHPAGE_BITMAP "icons\uninstall.bmp"
105!define MUI_HEADERIMAGE
106!define MUI_HEADERIMAGE_BITMAP "icons\header.bmp"
107!define MUI_HEADERIMAGE_UNBITMAP "icons\un_header.bmp"
108
109!define MUI_WELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
110!define MUI_UNWELCOMEFINISHPAGE_BITMAP_STRETCH "AspectFitHeight"
111!define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight"
112!define MUI_HEADERIMAGE_UNBITMAP_STRETCH "AspectFitHeight"
113
114!define MUI_COMPONENTSPAGE_SMALLDESC
115!define MUI_LICENSEPAGE_CHECKBOX
Bram Moolenaar4a228972021-05-01 22:41:39 +0200116!define MUI_FINISHPAGE_RUN
117!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100118!define MUI_FINISHPAGE_RUN_TEXT $(str_show_readme)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100119
120# This adds '\Vim' to the user choice automagically. The actual value is
121# obtained below with CheckOldVim.
122!ifdef WIN64
Christian Brabandt7d603842021-07-24 21:19:42 +0200123 !define DEFAULT_INSTDIR "$PROGRAMFILES64\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100124!else
Christian Brabandt7d603842021-07-24 21:19:42 +0200125 !define DEFAULT_INSTDIR "$PROGRAMFILES\Vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100126!endif
Christian Brabandt7d603842021-07-24 21:19:42 +0200127InstallDir ${DEFAULT_INSTDIR}
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"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200172 !include "lang\russian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100173 !include "lang\simpchinese.nsi"
174 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100175 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100176!endif
177
Bram Moolenaardabfde02019-05-17 12:37:27 +0200178##########################################################
179# Version resources
180
181VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
182VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
183VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
184VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
185VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200186VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
187VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100188
189# Global variables
190Var vim_dialog
191Var vim_nsd_compat
192Var vim_nsd_keymap
193Var vim_nsd_mouse
194Var vim_compat_stat
195Var vim_keymap_stat
196Var vim_mouse_stat
197
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198
Bram Moolenaar5d424742018-02-04 19:11:30 +0100199# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100200ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100201
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202##########################################################
203# Functions
204
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100205# Get parent directory
206# Share this function both on installer and uninstaller
207!macro GetParent un
208Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209 Exch $0 ; old $0 is on top of stack
210 Push $1
211 Push $2
212 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100213 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100215 ${If} $2 == ""
216 ${OrIf} $2 == "\"
217 ${ExitDo}
218 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100220 ${Loop}
221 StrCpy $0 $0 $1
222 Pop $2
223 Pop $1
224 Exch $0 ; put $0 on top of stack, restore $0 to original value
225FunctionEnd
226!macroend
227
228!insertmacro GetParent ""
229!insertmacro GetParent "un."
230
231# Check if Vim is already installed.
232# return: Installed directory. If not found, it will be empty.
233Function CheckOldVim
234 Push $0
235 Push $R0
236 Push $R1
237 Push $R2
238
239 ${If} ${RunningX64}
240 SetRegView 64
241 ${EndIf}
242
243 ClearErrors
244 StrCpy $0 "" # Installed directory
245 StrCpy $R0 0 # Sub-key index
246 StrCpy $R1 "" # Sub-key
247 ${Do}
248 # Eumerate the sub-key:
249 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
250
251 # Stop if no more sub-key:
252 ${If} ${Errors}
253 ${OrIf} $R1 == ""
254 ${ExitDo}
255 ${EndIf}
256
257 # Move to the next sub-key:
258 IntOp $R0 $R0 + 1
259
260 # Check if the key is Vim uninstall key or not:
261 StrCpy $R2 $R1 4
262 ${If} $R2 S!= "Vim "
263 ${Continue}
264 ${EndIf}
265
266 # Verifies required sub-keys:
267 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
268 ${If} ${Errors}
269 ${OrIf} $R2 == ""
270 ${Continue}
271 ${EndIf}
272
273 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
274 ${If} ${Errors}
275 ${OrIf} $R2 == ""
276 ${Continue}
277 ${EndIf}
278
279 # Found
280 Push $R2
281 call GetParent
282 call GetParent
283 Pop $0 # Vim directory
284 ${ExitDo}
285
286 ${Loop}
287
288 ${If} ${RunningX64}
289 SetRegView lastused
290 ${EndIf}
291
292 Pop $R2
293 Pop $R1
294 Pop $R0
295 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000296FunctionEnd
297
Bram Moolenaar4a228972021-05-01 22:41:39 +0200298Function LaunchApplication
299 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200300 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200301FunctionEnd
302
Bram Moolenaar071d4272004-06-13 20:20:40 +0000303##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100304Section "$(str_section_old_ver)" id_section_old_ver
305 SectionIn 1 2 3 RO
306
307 # run the install program to check for already installed versions
308 SetOutPath $TEMP
309 File /oname=install.exe ${VIMSRC}\installw32.exe
310 DetailPrint "$(str_msg_uninstalling)"
311 ${Do}
312 nsExec::Exec "$TEMP\install.exe -uninstall-check"
313 Pop $3
314
315 call CheckOldVim
316 Pop $3
317 ${If} $3 == ""
318 ${ExitDo}
319 ${Else}
320 # It seems that the old version is still remaining.
321 # TODO: Should we show a warning and run the uninstaller again?
322
323 ${ExitDo} # Just ignore for now.
324 ${EndIf}
325 ${Loop}
326 Delete $TEMP\install.exe
327 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
328
329 # We may have been put to the background when uninstall did something.
330 BringToFront
331SectionEnd
332
333##########################################################
334Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200335 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000336
337 # we need also this here if the user changes the instdir
338 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
339
340 SetOutPath $0
341 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200342!if /FileExists "${VIMSRC}\vim${BIT}.dll"
343 File ${VIMSRC}\vim${BIT}.dll
344!endif
Christian Brabandtcf6ad8e2022-02-13 13:11:32 +0000345!if /FileExists "${VIMRT}\libsodium.dll"
346 File ${VIMRT}\libsodium.dll
347!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000348 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200349 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200351 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100353 File ..\vimtutor.bat
354 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200355 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200358 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100359 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200360 File ${VIMTOOLS}\winpty-agent.exe
361
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100363 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364
365 SetOutPath $0\compiler
366 File ${VIMRT}\compiler\*.*
367
368 SetOutPath $0\doc
369 File ${VIMRT}\doc\*.txt
370 File ${VIMRT}\doc\tags
371
372 SetOutPath $0\ftplugin
373 File ${VIMRT}\ftplugin\*.*
374
375 SetOutPath $0\indent
376 File ${VIMRT}\indent\*.*
377
378 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100379 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100381 SetOutPath $0\pack
382 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200383
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384 SetOutPath $0\plugin
385 File ${VIMRT}\plugin\*.*
386
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000387 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100388 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000389
Bram Moolenaar44433da2022-05-06 18:08:52 +0100390 SetOutPath $0\import\dist
391 File ${VIMRT}\import\dist\*.*
392
Christian Brabandt176711f2022-03-11 15:24:11 +0000393 SetOutPath $0\bitmaps
394 File ${VIMSRC}\vim.ico
395
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396 SetOutPath $0\syntax
K.Takata44b9abb2022-08-24 18:08:00 +0100397 File /r ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000398
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000399 SetOutPath $0\spell
400 File ${VIMRT}\spell\*.txt
401 File ${VIMRT}\spell\*.vim
402 File ${VIMRT}\spell\*.spl
403 File ${VIMRT}\spell\*.sug
404
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405 SetOutPath $0\tools
406 File ${VIMRT}\tools\*.*
407
408 SetOutPath $0\tutor
409 File ${VIMRT}\tutor\*.*
410SectionEnd
411
412##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100413Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414 SectionIn 1 3
415
416 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100417 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418 StrCpy $2 "$2 vim view vimdiff"
419SectionEnd
420
421##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100422Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 SectionIn 3
424
425 StrCpy $1 "$1 -create-batfiles $2"
426SectionEnd
427
428##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100429SectionGroup $(str_group_icons) id_group_icons
430 Section "$(str_section_desktop)" id_section_desktop
431 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100433 StrCpy $1 "$1 -install-icons"
434 SectionEnd
435
436 Section "$(str_section_start_menu)" id_section_startmenu
437 SectionIn 1 3
438
439 StrCpy $1 "$1 -add-start-menu"
440 SectionEnd
441SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442
443##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100444Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 SectionIn 1 3
446
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200448
Bram Moolenaar442b4222010-05-24 21:34:22 +0200449 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200450 # Install 64-bit gvimext.dll into the GvimExt64 directory.
451 SetOutPath $0\GvimExt64
452 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100453 !define LIBRARY_SHELL_EXTENSION
454 !define LIBRARY_X64
455 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
456 "${VIMSRC}\GvimExt\gvimext64.dll" \
457 "$0\GvimExt64\gvimext.dll" "$0"
458 !undef LIBRARY_X64
459 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200460 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200461
Bram Moolenaar6199d432017-10-14 19:05:44 +0200462 # Install 32-bit gvimext.dll into the GvimExt32 directory.
463 SetOutPath $0\GvimExt32
464 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100465 !define LIBRARY_SHELL_EXTENSION
466 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
467 "${VIMSRC}\GvimExt\gvimext.dll" \
468 "$0\GvimExt32\gvimext.dll" "$0"
469 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470
471 # We don't have a separate entry for the "Open With..." menu, assume
472 # the user wants either both or none.
473 StrCpy $1 "$1 -install-popup -install-openwith"
474SectionEnd
475
476##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100477Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000478 SectionIn 1 3
479
480 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100481
482 ${If} ${RunningX64}
483 SetRegView 64
484 ${EndIf}
485 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
486 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
487 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
488 ${If} ${RunningX64}
489 SetRegView lastused
490 ${EndIf}
491
492 ${If} $vim_compat_stat == "vi"
493 StrCpy $1 "$1 -vimrc-compat vi"
494 ${ElseIf} $vim_compat_stat == "vim"
495 StrCpy $1 "$1 -vimrc-compat vim"
496 ${ElseIf} $vim_compat_stat == "defaults"
497 StrCpy $1 "$1 -vimrc-compat defaults"
498 ${Else}
499 StrCpy $1 "$1 -vimrc-compat all"
500 ${EndIf}
501
502 ${If} $vim_keymap_stat == "default"
503 StrCpy $1 "$1 -vimrc-remap no"
504 ${Else}
505 StrCpy $1 "$1 -vimrc-remap win"
506 ${EndIf}
507
508 ${If} $vim_mouse_stat == "default"
509 StrCpy $1 "$1 -vimrc-behave default"
510 ${ElseIf} $vim_mouse_stat == "windows"
511 StrCpy $1 "$1 -vimrc-behave mswin"
512 ${Else}
513 StrCpy $1 "$1 -vimrc-behave unix"
514 ${EndIf}
515
Bram Moolenaar071d4272004-06-13 20:20:40 +0000516SectionEnd
517
518##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100519SectionGroup $(str_group_plugin) id_group_plugin
520 Section "$(str_section_plugin_home)" id_section_pluginhome
521 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100523 StrCpy $1 "$1 -create-directories home"
524 SectionEnd
525
526 Section "$(str_section_plugin_vim)" id_section_pluginvim
527 SectionIn 3
528
529 StrCpy $1 "$1 -create-directories vim"
530 SectionEnd
531SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000532
533##########################################################
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100535Section "$(str_section_nls)" id_section_nls
536 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000537
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100538 SetOutPath $0\lang
539 File /r ${VIMRT}\lang\*.*
540 SetOutPath $0\keymap
541 File ${VIMRT}\keymap\README.txt
542 File ${VIMRT}\keymap\*.vim
543 SetOutPath $0
544 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
545 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
546 "$0\libintl-8.dll" "$0"
547 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
548 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
549 "$0\libiconv-2.dll" "$0"
550 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
551 # Install libgcc_s_sjlj-1.dll only if it is needed.
552 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
553 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
554 "$0\libgcc_s_sjlj-1.dll" "$0"
555 !endif
556
557 ${If} ${SectionIsSelected} ${id_section_editwith}
558 ${If} ${RunningX64}
559 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
560 SetOutPath $0\GvimExt64
561 ClearErrors
562 !define LIBRARY_X64
563 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
564 "${GETTEXT}\gettext64\libintl-8.dll" \
565 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
566 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
567 "${GETTEXT}\gettext64\libiconv-2.dll" \
568 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
569 !undef LIBRARY_X64
570 ${EndIf}
571
572 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
573 SetOutPath $0\GvimExt32
574 ClearErrors
575 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
576 "${GETTEXT}\gettext32\libintl-8.dll" \
577 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
578 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
579 "${GETTEXT}\gettext32\libiconv-2.dll" \
580 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
581 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
582 # Install libgcc_s_sjlj-1.dll only if it is needed.
583 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
584 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
585 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
586 !endif
587 ${EndIf}
588SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000589!endif
590
591##########################################################
592Section -call_install_exe
593 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100594 DetailPrint "$(str_msg_registering)"
595 nsExec::Exec "$0\install.exe $1"
596 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597SectionEnd
598
599##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100600!macro SaveSectionSelection section_id reg_value
601 ${If} ${SectionIsSelected} ${section_id}
602 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
603 ${Else}
604 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
605 ${EndIf}
606!macroend
607
Bram Moolenaar071d4272004-06-13 20:20:40 +0000608Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100609
610 # Get estimated install size
611 SectionGetSize ${id_section_exe} $3
612 ${If} ${SectionIsSelected} ${id_section_console}
613 SectionGetSize ${id_section_console} $4
614 IntOp $3 $3 + $4
615 ${EndIf}
616 ${If} ${SectionIsSelected} ${id_section_editwith}
617 SectionGetSize ${id_section_editwith} $4
618 IntOp $3 $3 + $4
619 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100620!ifdef HAVE_NLS
621 ${If} ${SectionIsSelected} ${id_section_nls}
622 SectionGetSize ${id_section_nls} $4
623 IntOp $3 $3 + $4
624 ${EndIf}
625!endif
626
627 # Register EstimatedSize and AllowSilent.
628 # Other information will be set by the install.exe (dosinst.c).
629 ${If} ${RunningX64}
630 SetRegView 64
631 ${EndIf}
632 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
633 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
634 ${If} ${RunningX64}
635 SetRegView lastused
636 ${EndIf}
637
638 # Store the selections to the registry.
639 ${If} ${RunningX64}
640 SetRegView 64
641 ${EndIf}
642 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
643 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
644 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
645 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
646 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
647 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
648 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
649 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100650!ifdef HAVE_NLS
651 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
652!endif
653 ${If} ${RunningX64}
654 SetRegView lastused
655 ${EndIf}
656
Bram Moolenaar071d4272004-06-13 20:20:40 +0000657 BringToFront
658SectionEnd
659
660##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100661!macro LoadSectionSelection section_id reg_value
662 ClearErrors
663 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
664 ${IfNot} ${Errors}
665 ${If} $3 = 1
666 !insertmacro SelectSection ${section_id}
667 ${Else}
668 !insertmacro UnselectSection ${section_id}
669 ${EndIf}
670 ${EndIf}
671!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200672
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200673!macro LoadDefaultVimrc out_var reg_value default_value
674 ClearErrors
675 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
676 ${If} ${Errors}
677 ${OrIf} ${out_var} == ""
678 StrCpy ${out_var} ${default_value}
679 ${EndIf}
680!macroend
681
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100682Function .onInit
683!ifdef HAVE_MULTI_LANG
684 # Select a language (or read from the registry).
685 !insertmacro MUI_LANGDLL_DISPLAY
686!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200687
Christian Brabandt7d603842021-07-24 21:19:42 +0200688 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
689 # Check $VIM
690 ReadEnvStr $3 "VIM"
691 ${If} $3 != ""
692 StrCpy $INSTDIR $3
693 ${EndIf}
694 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100695
696 call CheckOldVim
697 Pop $3
698 ${If} $3 == ""
699 # No old versions of Vim found. Unselect and hide the section.
700 !insertmacro UnselectSection ${id_section_old_ver}
701 SectionSetInstTypes ${id_section_old_ver} 0
702 SectionSetText ${id_section_old_ver} ""
703 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200704 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100705 StrCpy $INSTDIR $3
706 ${EndIf}
707 ${EndIf}
708
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100709 ${If} ${RunningX64}
710 SetRegView 64
711 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200712 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100713 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
714 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
715 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
716 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
717 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
718 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
719 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
720 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100721!ifdef HAVE_NLS
722 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
723!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200724 # Load the default _vimrc settings from the registry (if any).
725 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
726 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
727 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100728 ${If} ${RunningX64}
729 SetRegView lastused
730 ${EndIf}
731
732 # User variables:
733 # $0 - holds the directory the executables are installed to
734 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
735 # registration (since a non-OLE gvim will not complain, and we want to
736 # always register an OLE gvim).
737 # $2 - holds the names to create batch files for
738 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
739 StrCpy $1 "-register-OLE"
740 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200741FunctionEnd
742
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100743Function .onInstSuccess
744 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
745FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200746
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100747Function .onInstFailed
748 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200749FunctionEnd
750
751##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100752Function SetCustom
753 # Display the _vimrc setting dialog using nsDialogs.
754
755 # Check if a _vimrc should be created
756 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
757 Abort
758 ${EndIf}
759
760 !insertmacro MUI_HEADER_TEXT \
761 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
762
763 nsDialogs::Create 1018
764 Pop $vim_dialog
765
766 ${If} $vim_dialog == error
767 Abort
768 ${EndIf}
769
770 ${If} ${RunningX64}
771 SetRegView 64
772 ${EndIf}
773
774 GetFunctionAddress $3 ValidateCustom
775 nsDialogs::OnBack $3
776
777
778 # 1st group - Compatibility
779 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
780 Pop $3
781
782 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
783 Pop $3
784 ${NSD_CreateDropList} 18% 19% 75% 8% ""
785 Pop $vim_nsd_compat
786 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
787 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
788 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
789 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
790
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200791 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100792 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200793 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100794 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200795 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100796 StrCpy $4 0
797 ${Else} # default
798 StrCpy $4 3
799 ${EndIf}
800 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
801
802
803 # 2nd group - Key remapping
804 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
805 Pop $3
806
807 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
808 Pop $3
809 ${NSD_CreateDropList} 38% 54% 55% 8% ""
810 Pop $vim_nsd_keymap
811 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
812 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
813
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200814 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100815 StrCpy $4 1
816 ${Else} # default
817 StrCpy $4 0
818 ${EndIf}
819 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
820
821
822 # 3rd group - Mouse behavior
823 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
824 Pop $3
825
826 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
827 Pop $3
828 ${NSD_CreateDropList} 23% 87% 70% 8% ""
829 Pop $vim_nsd_mouse
830 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
831 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
832 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
833
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200834 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100835 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200836 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100837 StrCpy $4 1
838 ${Else} # default
839 StrCpy $4 0
840 ${EndIf}
841 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
842
843 ${If} ${RunningX64}
844 SetRegView lastused
845 ${EndIf}
846
847 nsDialogs::Show
848FunctionEnd
849
850Function ValidateCustom
851 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
852 ${If} $3 = 0
853 StrCpy $vim_compat_stat "vi"
854 ${ElseIf} $3 = 1
855 StrCpy $vim_compat_stat "vim"
856 ${ElseIf} $3 = 2
857 StrCpy $vim_compat_stat "defaults"
858 ${Else}
859 StrCpy $vim_compat_stat "all"
860 ${EndIf}
861
862 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
863 ${If} $3 = 0
864 StrCpy $vim_keymap_stat "default"
865 ${Else}
866 StrCpy $vim_keymap_stat "windows"
867 ${EndIf}
868
869 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
870 ${If} $3 = 0
871 StrCpy $vim_mouse_stat "default"
872 ${ElseIf} $3 = 1
873 StrCpy $vim_mouse_stat "windows"
874 ${Else}
875 StrCpy $vim_mouse_stat "xterm"
876 ${EndIf}
877FunctionEnd
878
879##########################################################
880# Description for Installer Sections
881
882!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
883 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
884 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
885 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
886 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
887 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
888 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
889 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
890 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
891 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
892 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
893 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
894 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100895!ifdef HAVE_NLS
896 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
897!endif
898!insertmacro MUI_FUNCTION_DESCRIPTION_END
899
900
901##########################################################
902# Uninstaller Functions and Sections
903
904Function un.onInit
905!ifdef HAVE_MULTI_LANG
906 # Get the language from the registry.
907 !insertmacro MUI_UNGETLANGUAGE
908!endif
909FunctionEnd
910
911Section "un.$(str_unsection_register)" id_unsection_register
912 SectionIn RO
913
Bram Moolenaar071d4272004-06-13 20:20:40 +0000914 # Apparently $INSTDIR is set to the directory where the uninstaller is
915 # created. Thus the "vim61" directory is included in it.
916 StrCpy $0 "$INSTDIR"
917
Bram Moolenaar071d4272004-06-13 20:20:40 +0000918 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100919 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200920 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100921 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000922
923 # We may have been put to the background when uninstall did something.
924 BringToFront
925
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100926 # Delete the installer language setting.
927 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
928SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000929
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100930Section "un.$(str_unsection_exe)" id_unsection_exe
931
932 StrCpy $0 "$INSTDIR"
933
934 # Delete gettext and iconv DLLs
935 ${If} ${FileExists} "$0\libiconv-2.dll"
936 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
937 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200938 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100939 ${If} ${FileExists} "$0\libintl-8.dll"
940 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
941 "$0\libintl-8.dll"
942 ${EndIf}
943 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
944 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
945 "$0\libgcc_s_sjlj-1.dll"
946 ${EndIf}
947
948 # Delete other DLLs
949 Delete /REBOOTOK $0\*.dll
950
951 # Delete 64-bit GvimExt
952 ${If} ${RunningX64}
953 !define LIBRARY_X64
954 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
955 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
956 "$0\GvimExt64\gvimext.dll"
957 ${EndIf}
958 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
959 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
960 "$0\GvimExt64\libiconv-2.dll"
961 ${EndIf}
962 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
963 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
964 "$0\GvimExt64\libintl-8.dll"
965 ${EndIf}
966 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
967 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
968 "$0\GvimExt64\libwinpthread-1.dll"
969 ${EndIf}
970 !undef LIBRARY_X64
971 RMDir /r $0\GvimExt64
972 ${EndIf}
973
974 # Delete 32-bit GvimExt
975 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
976 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
977 "$0\GvimExt32\gvimext.dll"
978 ${EndIf}
979 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
980 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
981 "$0\GvimExt32\libiconv-2.dll"
982 ${EndIf}
983 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
984 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
985 "$0\GvimExt32\libintl-8.dll"
986 ${EndIf}
987 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
988 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
989 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
990 ${EndIf}
991 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +0200992
Bram Moolenaar071d4272004-06-13 20:20:40 +0000993 ClearErrors
994 # Remove everything but *.dll files. Avoids that
995 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +0000996 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997 RMDir /r $0\colors
998 RMDir /r $0\compiler
999 RMDir /r $0\doc
1000 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001001 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001002 RMDir /r $0\indent
1003 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001004 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001005 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001006 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007 RMDir /r $0\syntax
1008 RMDir /r $0\tools
1009 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010 RMDir /r $0\lang
1011 RMDir /r $0\keymap
1012 Delete $0\*.exe
1013 Delete $0\*.bat
1014 Delete $0\*.vim
1015 Delete $0\*.txt
1016
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001017 ${If} ${Errors}
1018 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1019 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001020
1021 # No error message if the "vim62" directory can't be removed, the
1022 # gvimext.dll may still be there.
1023 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001024SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001025
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001026# Remove "vimfiles" directory under the specified directory.
1027!macro RemoveVimfiles dir
1028 ${If} ${FileExists} ${dir}\vimfiles
1029 RMDir ${dir}\vimfiles\colors
1030 RMDir ${dir}\vimfiles\compiler
1031 RMDir ${dir}\vimfiles\doc
1032 RMDir ${dir}\vimfiles\ftdetect
1033 RMDir ${dir}\vimfiles\ftplugin
1034 RMDir ${dir}\vimfiles\indent
1035 RMDir ${dir}\vimfiles\keymap
1036 RMDir ${dir}\vimfiles\plugin
1037 RMDir ${dir}\vimfiles\syntax
1038 RMDir ${dir}\vimfiles
1039 ${EndIf}
1040!macroend
1041
1042SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1043 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1044 # get the home dir
1045 ReadEnvStr $0 "HOME"
1046 ${If} $0 == ""
1047 ReadEnvStr $0 "HOMEDRIVE"
1048 ReadEnvStr $1 "HOMEPATH"
1049 StrCpy $0 "$0$1"
1050 ${If} $0 == ""
1051 ReadEnvStr $0 "USERPROFILE"
1052 ${EndIf}
1053 ${EndIf}
1054
1055 ${If} $0 != ""
1056 !insertmacro RemoveVimfiles $0
1057 ${EndIf}
1058 SectionEnd
1059
1060 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1061 # get the parent dir of the installation
1062 Push $INSTDIR
1063 Call un.GetParent
1064 Pop $0
1065
1066 # if a plugin dir was created at installation remove it
1067 !insertmacro RemoveVimfiles $0
1068 SectionEnd
1069SectionGroupEnd
1070
1071Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001072 # get the parent dir of the installation
1073 Push $INSTDIR
1074 Call un.GetParent
1075 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001077 ${IfNot} ${Silent}
1078 Delete $0\_vimrc
1079 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001080 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001081SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001082
1083##########################################################
1084# Description for Uninstaller Sections
1085
1086!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1087 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1088 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1089 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1090 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1091 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1092 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1093!insertmacro MUI_UNFUNCTION_DESCRIPTION_END