blob: 72252527c7dd115c019baab04e4a6325c486e728 [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
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000231# Get home directory
232!macro GetHomeDir un
233Function ${un}GetHomeDir
234 Push $0
235 Push $1
236 ReadEnvStr $0 "HOME"
237 ${If} $0 == ""
238 ReadEnvStr $0 "HOMEDRIVE"
239 ReadEnvStr $1 "HOMEPATH"
240 StrCpy $0 "$0$1"
241 ${If} $0 == ""
242 ReadEnvStr $0 "USERPROFILE"
243 ${EndIf}
244 ${EndIf}
245 Pop $1
246 Exch $0 # put $0 on top of stack, restore $0 to original value
247FunctionEnd
248!macroend
249
250!insertmacro GetHomeDir ""
251!insertmacro GetHomeDir "un."
252
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100253# Check if Vim is already installed.
254# return: Installed directory. If not found, it will be empty.
255Function CheckOldVim
256 Push $0
257 Push $R0
258 Push $R1
259 Push $R2
260
261 ${If} ${RunningX64}
262 SetRegView 64
263 ${EndIf}
264
265 ClearErrors
266 StrCpy $0 "" # Installed directory
267 StrCpy $R0 0 # Sub-key index
268 StrCpy $R1 "" # Sub-key
269 ${Do}
270 # Eumerate the sub-key:
271 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
272
273 # Stop if no more sub-key:
274 ${If} ${Errors}
275 ${OrIf} $R1 == ""
276 ${ExitDo}
277 ${EndIf}
278
279 # Move to the next sub-key:
280 IntOp $R0 $R0 + 1
281
282 # Check if the key is Vim uninstall key or not:
283 StrCpy $R2 $R1 4
284 ${If} $R2 S!= "Vim "
285 ${Continue}
286 ${EndIf}
287
288 # Verifies required sub-keys:
289 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
290 ${If} ${Errors}
291 ${OrIf} $R2 == ""
292 ${Continue}
293 ${EndIf}
294
295 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
296 ${If} ${Errors}
297 ${OrIf} $R2 == ""
298 ${Continue}
299 ${EndIf}
300
301 # Found
302 Push $R2
303 call GetParent
304 call GetParent
305 Pop $0 # Vim directory
306 ${ExitDo}
307
308 ${Loop}
309
310 ${If} ${RunningX64}
311 SetRegView lastused
312 ${EndIf}
313
314 Pop $R2
315 Pop $R1
316 Pop $R0
317 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318FunctionEnd
319
Bram Moolenaar4a228972021-05-01 22:41:39 +0200320Function LaunchApplication
321 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200322 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200323FunctionEnd
324
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100326Section "$(str_section_old_ver)" id_section_old_ver
327 SectionIn 1 2 3 RO
328
329 # run the install program to check for already installed versions
330 SetOutPath $TEMP
331 File /oname=install.exe ${VIMSRC}\installw32.exe
332 DetailPrint "$(str_msg_uninstalling)"
333 ${Do}
334 nsExec::Exec "$TEMP\install.exe -uninstall-check"
335 Pop $3
336
337 call CheckOldVim
338 Pop $3
339 ${If} $3 == ""
340 ${ExitDo}
341 ${Else}
342 # It seems that the old version is still remaining.
343 # TODO: Should we show a warning and run the uninstaller again?
344
345 ${ExitDo} # Just ignore for now.
346 ${EndIf}
347 ${Loop}
348 Delete $TEMP\install.exe
349 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
350
351 # We may have been put to the background when uninstall did something.
352 BringToFront
353SectionEnd
354
355##########################################################
356Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200357 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358
359 # we need also this here if the user changes the instdir
360 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
361
362 SetOutPath $0
363 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200364!if /FileExists "${VIMSRC}\vim${BIT}.dll"
365 File ${VIMSRC}\vim${BIT}.dll
366!endif
Christian Brabandtcf6ad8e2022-02-13 13:11:32 +0000367!if /FileExists "${VIMRT}\libsodium.dll"
368 File ${VIMRT}\libsodium.dll
369!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200371 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000372 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200373 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100375 File ..\vimtutor.bat
376 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200377 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000378 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000379
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200380 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100381 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200382 File ${VIMTOOLS}\winpty-agent.exe
383
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100385 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386
387 SetOutPath $0\compiler
388 File ${VIMRT}\compiler\*.*
389
390 SetOutPath $0\doc
391 File ${VIMRT}\doc\*.txt
392 File ${VIMRT}\doc\tags
393
394 SetOutPath $0\ftplugin
395 File ${VIMRT}\ftplugin\*.*
396
397 SetOutPath $0\indent
398 File ${VIMRT}\indent\*.*
399
Ken Takata1a9aba82024-01-16 17:14:29 +0100400 SetOutPath $0\keymap
401 File ${VIMRT}\keymap\*.*
402
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100404 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100406 SetOutPath $0\pack
407 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200408
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409 SetOutPath $0\plugin
410 File ${VIMRT}\plugin\*.*
411
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000412 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100413 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000414
Bram Moolenaar44433da2022-05-06 18:08:52 +0100415 SetOutPath $0\import\dist
416 File ${VIMRT}\import\dist\*.*
417
Christian Brabandt176711f2022-03-11 15:24:11 +0000418 SetOutPath $0\bitmaps
419 File ${VIMSRC}\vim.ico
420
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421 SetOutPath $0\syntax
Christian Brabandt30994d62024-01-04 22:14:28 +0100422 File /r /x testdir ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000424 SetOutPath $0\spell
425 File ${VIMRT}\spell\*.txt
426 File ${VIMRT}\spell\*.vim
427 File ${VIMRT}\spell\*.spl
428 File ${VIMRT}\spell\*.sug
429
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430 SetOutPath $0\tools
431 File ${VIMRT}\tools\*.*
432
433 SetOutPath $0\tutor
434 File ${VIMRT}\tutor\*.*
435SectionEnd
436
437##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100438Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000439 SectionIn 1 3
440
441 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100442 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443 StrCpy $2 "$2 vim view vimdiff"
444SectionEnd
445
446##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100447Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448 SectionIn 3
449
450 StrCpy $1 "$1 -create-batfiles $2"
451SectionEnd
452
453##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100454SectionGroup $(str_group_icons) id_group_icons
455 Section "$(str_section_desktop)" id_section_desktop
456 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100458 StrCpy $1 "$1 -install-icons"
459 SectionEnd
460
461 Section "$(str_section_start_menu)" id_section_startmenu
462 SectionIn 1 3
463
464 StrCpy $1 "$1 -add-start-menu"
465 SectionEnd
466SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
468##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100469Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470 SectionIn 1 3
471
Bram Moolenaar071d4272004-06-13 20:20:40 +0000472 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200473
Bram Moolenaar442b4222010-05-24 21:34:22 +0200474 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200475 # Install 64-bit gvimext.dll into the GvimExt64 directory.
476 SetOutPath $0\GvimExt64
477 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100478 !define LIBRARY_SHELL_EXTENSION
479 !define LIBRARY_X64
480 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
481 "${VIMSRC}\GvimExt\gvimext64.dll" \
482 "$0\GvimExt64\gvimext.dll" "$0"
483 !undef LIBRARY_X64
484 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200485 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200486
Bram Moolenaar6199d432017-10-14 19:05:44 +0200487 # Install 32-bit gvimext.dll into the GvimExt32 directory.
488 SetOutPath $0\GvimExt32
489 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100490 !define LIBRARY_SHELL_EXTENSION
491 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
492 "${VIMSRC}\GvimExt\gvimext.dll" \
493 "$0\GvimExt32\gvimext.dll" "$0"
494 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000495
496 # We don't have a separate entry for the "Open With..." menu, assume
497 # the user wants either both or none.
498 StrCpy $1 "$1 -install-popup -install-openwith"
499SectionEnd
500
501##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100502Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503 SectionIn 1 3
504
505 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100506
507 ${If} ${RunningX64}
508 SetRegView 64
509 ${EndIf}
510 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
511 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
512 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
513 ${If} ${RunningX64}
514 SetRegView lastused
515 ${EndIf}
516
517 ${If} $vim_compat_stat == "vi"
518 StrCpy $1 "$1 -vimrc-compat vi"
519 ${ElseIf} $vim_compat_stat == "vim"
520 StrCpy $1 "$1 -vimrc-compat vim"
521 ${ElseIf} $vim_compat_stat == "defaults"
522 StrCpy $1 "$1 -vimrc-compat defaults"
523 ${Else}
524 StrCpy $1 "$1 -vimrc-compat all"
525 ${EndIf}
526
527 ${If} $vim_keymap_stat == "default"
528 StrCpy $1 "$1 -vimrc-remap no"
529 ${Else}
530 StrCpy $1 "$1 -vimrc-remap win"
531 ${EndIf}
532
533 ${If} $vim_mouse_stat == "default"
534 StrCpy $1 "$1 -vimrc-behave default"
535 ${ElseIf} $vim_mouse_stat == "windows"
536 StrCpy $1 "$1 -vimrc-behave mswin"
537 ${Else}
538 StrCpy $1 "$1 -vimrc-behave unix"
539 ${EndIf}
540
Bram Moolenaar071d4272004-06-13 20:20:40 +0000541SectionEnd
542
543##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100544SectionGroup $(str_group_plugin) id_group_plugin
545 Section "$(str_section_plugin_home)" id_section_pluginhome
546 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000547
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000548 # use ShellExecAsUser below instead
549 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100550 SectionEnd
551
552 Section "$(str_section_plugin_vim)" id_section_pluginvim
553 SectionIn 3
554
555 StrCpy $1 "$1 -create-directories vim"
556 SectionEnd
557SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558
559##########################################################
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100561Section "$(str_section_nls)" id_section_nls
562 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000563
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100564 SetOutPath $0\lang
565 File /r ${VIMRT}\lang\*.*
566 SetOutPath $0\keymap
567 File ${VIMRT}\keymap\README.txt
568 File ${VIMRT}\keymap\*.vim
569 SetOutPath $0
570 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
571 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
572 "$0\libintl-8.dll" "$0"
573 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
574 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
575 "$0\libiconv-2.dll" "$0"
576 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
577 # Install libgcc_s_sjlj-1.dll only if it is needed.
578 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
579 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
580 "$0\libgcc_s_sjlj-1.dll" "$0"
581 !endif
582
583 ${If} ${SectionIsSelected} ${id_section_editwith}
584 ${If} ${RunningX64}
585 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
586 SetOutPath $0\GvimExt64
587 ClearErrors
588 !define LIBRARY_X64
589 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
590 "${GETTEXT}\gettext64\libintl-8.dll" \
591 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
592 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
593 "${GETTEXT}\gettext64\libiconv-2.dll" \
594 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
595 !undef LIBRARY_X64
596 ${EndIf}
597
598 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
599 SetOutPath $0\GvimExt32
600 ClearErrors
601 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
602 "${GETTEXT}\gettext32\libintl-8.dll" \
603 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
604 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
605 "${GETTEXT}\gettext32\libiconv-2.dll" \
606 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
607 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
608 # Install libgcc_s_sjlj-1.dll only if it is needed.
609 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
610 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
611 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
612 !endif
613 ${EndIf}
614SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615!endif
616
617##########################################################
618Section -call_install_exe
619 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100620 DetailPrint "$(str_msg_registering)"
621 nsExec::Exec "$0\install.exe $1"
622 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000623
624 ${If} ${SectionIsSelected} ${id_section_pluginhome}
625 ReadEnvStr $3 "COMSPEC"
626 Call GetHomeDir
627 Pop $4
628 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
629 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630SectionEnd
631
632##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100633!macro SaveSectionSelection section_id reg_value
634 ${If} ${SectionIsSelected} ${section_id}
635 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
636 ${Else}
637 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
638 ${EndIf}
639!macroend
640
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100642
643 # Get estimated install size
644 SectionGetSize ${id_section_exe} $3
645 ${If} ${SectionIsSelected} ${id_section_console}
646 SectionGetSize ${id_section_console} $4
647 IntOp $3 $3 + $4
648 ${EndIf}
649 ${If} ${SectionIsSelected} ${id_section_editwith}
650 SectionGetSize ${id_section_editwith} $4
651 IntOp $3 $3 + $4
652 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100653!ifdef HAVE_NLS
654 ${If} ${SectionIsSelected} ${id_section_nls}
655 SectionGetSize ${id_section_nls} $4
656 IntOp $3 $3 + $4
657 ${EndIf}
658!endif
659
660 # Register EstimatedSize and AllowSilent.
661 # Other information will be set by the install.exe (dosinst.c).
662 ${If} ${RunningX64}
663 SetRegView 64
664 ${EndIf}
665 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
666 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
667 ${If} ${RunningX64}
668 SetRegView lastused
669 ${EndIf}
670
671 # Store the selections to the registry.
672 ${If} ${RunningX64}
673 SetRegView 64
674 ${EndIf}
675 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
676 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
677 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
678 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
679 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
680 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
681 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
682 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100683!ifdef HAVE_NLS
684 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
685!endif
686 ${If} ${RunningX64}
687 SetRegView lastused
688 ${EndIf}
689
Bram Moolenaar071d4272004-06-13 20:20:40 +0000690 BringToFront
691SectionEnd
692
693##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100694!macro LoadSectionSelection section_id reg_value
695 ClearErrors
696 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
697 ${IfNot} ${Errors}
698 ${If} $3 = 1
699 !insertmacro SelectSection ${section_id}
700 ${Else}
701 !insertmacro UnselectSection ${section_id}
702 ${EndIf}
703 ${EndIf}
704!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200705
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200706!macro LoadDefaultVimrc out_var reg_value default_value
707 ClearErrors
708 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
709 ${If} ${Errors}
710 ${OrIf} ${out_var} == ""
711 StrCpy ${out_var} ${default_value}
712 ${EndIf}
713!macroend
714
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100715Function .onInit
716!ifdef HAVE_MULTI_LANG
717 # Select a language (or read from the registry).
718 !insertmacro MUI_LANGDLL_DISPLAY
719!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200720
Christian Brabandt7d603842021-07-24 21:19:42 +0200721 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
722 # Check $VIM
723 ReadEnvStr $3 "VIM"
724 ${If} $3 != ""
725 StrCpy $INSTDIR $3
726 ${EndIf}
727 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100728
729 call CheckOldVim
730 Pop $3
731 ${If} $3 == ""
732 # No old versions of Vim found. Unselect and hide the section.
733 !insertmacro UnselectSection ${id_section_old_ver}
734 SectionSetInstTypes ${id_section_old_ver} 0
735 SectionSetText ${id_section_old_ver} ""
736 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200737 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100738 StrCpy $INSTDIR $3
739 ${EndIf}
740 ${EndIf}
741
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100742 ${If} ${RunningX64}
743 SetRegView 64
744 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200745 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100746 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
747 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
748 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
749 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
750 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
751 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
752 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
753 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100754!ifdef HAVE_NLS
755 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
756!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200757 # Load the default _vimrc settings from the registry (if any).
758 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
759 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
760 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100761 ${If} ${RunningX64}
762 SetRegView lastused
763 ${EndIf}
764
765 # User variables:
766 # $0 - holds the directory the executables are installed to
767 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
768 # registration (since a non-OLE gvim will not complain, and we want to
769 # always register an OLE gvim).
770 # $2 - holds the names to create batch files for
771 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
772 StrCpy $1 "-register-OLE"
773 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200774FunctionEnd
775
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100776Function .onInstSuccess
777 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
778FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200779
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100780Function .onInstFailed
781 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200782FunctionEnd
783
784##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100785Function SetCustom
786 # Display the _vimrc setting dialog using nsDialogs.
787
788 # Check if a _vimrc should be created
789 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
790 Abort
791 ${EndIf}
792
793 !insertmacro MUI_HEADER_TEXT \
794 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
795
796 nsDialogs::Create 1018
797 Pop $vim_dialog
798
799 ${If} $vim_dialog == error
800 Abort
801 ${EndIf}
802
803 ${If} ${RunningX64}
804 SetRegView 64
805 ${EndIf}
806
807 GetFunctionAddress $3 ValidateCustom
808 nsDialogs::OnBack $3
809
810
811 # 1st group - Compatibility
812 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
813 Pop $3
814
815 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
816 Pop $3
817 ${NSD_CreateDropList} 18% 19% 75% 8% ""
818 Pop $vim_nsd_compat
819 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
820 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
821 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
822 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
823
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200824 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100825 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200826 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100827 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200828 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100829 StrCpy $4 0
830 ${Else} # default
831 StrCpy $4 3
832 ${EndIf}
833 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
834
835
836 # 2nd group - Key remapping
837 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
838 Pop $3
839
840 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
841 Pop $3
842 ${NSD_CreateDropList} 38% 54% 55% 8% ""
843 Pop $vim_nsd_keymap
844 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
845 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
846
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200847 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100848 StrCpy $4 1
849 ${Else} # default
850 StrCpy $4 0
851 ${EndIf}
852 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
853
854
855 # 3rd group - Mouse behavior
856 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
857 Pop $3
858
859 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
860 Pop $3
861 ${NSD_CreateDropList} 23% 87% 70% 8% ""
862 Pop $vim_nsd_mouse
863 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
864 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
865 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
866
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200867 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100868 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200869 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100870 StrCpy $4 1
871 ${Else} # default
872 StrCpy $4 0
873 ${EndIf}
874 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
875
876 ${If} ${RunningX64}
877 SetRegView lastused
878 ${EndIf}
879
880 nsDialogs::Show
881FunctionEnd
882
883Function ValidateCustom
884 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
885 ${If} $3 = 0
886 StrCpy $vim_compat_stat "vi"
887 ${ElseIf} $3 = 1
888 StrCpy $vim_compat_stat "vim"
889 ${ElseIf} $3 = 2
890 StrCpy $vim_compat_stat "defaults"
891 ${Else}
892 StrCpy $vim_compat_stat "all"
893 ${EndIf}
894
895 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
896 ${If} $3 = 0
897 StrCpy $vim_keymap_stat "default"
898 ${Else}
899 StrCpy $vim_keymap_stat "windows"
900 ${EndIf}
901
902 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
903 ${If} $3 = 0
904 StrCpy $vim_mouse_stat "default"
905 ${ElseIf} $3 = 1
906 StrCpy $vim_mouse_stat "windows"
907 ${Else}
908 StrCpy $vim_mouse_stat "xterm"
909 ${EndIf}
910FunctionEnd
911
912##########################################################
913# Description for Installer Sections
914
915!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
925 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
927 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100928!ifdef HAVE_NLS
929 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
930!endif
931!insertmacro MUI_FUNCTION_DESCRIPTION_END
932
933
934##########################################################
935# Uninstaller Functions and Sections
936
937Function un.onInit
938!ifdef HAVE_MULTI_LANG
939 # Get the language from the registry.
940 !insertmacro MUI_UNGETLANGUAGE
941!endif
942FunctionEnd
943
944Section "un.$(str_unsection_register)" id_unsection_register
945 SectionIn RO
946
Bram Moolenaar071d4272004-06-13 20:20:40 +0000947 # Apparently $INSTDIR is set to the directory where the uninstaller is
948 # created. Thus the "vim61" directory is included in it.
949 StrCpy $0 "$INSTDIR"
950
Bram Moolenaar071d4272004-06-13 20:20:40 +0000951 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100952 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200953 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100954 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955
956 # We may have been put to the background when uninstall did something.
957 BringToFront
958
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100959 # Delete the installer language setting.
960 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
961SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100963Section "un.$(str_unsection_exe)" id_unsection_exe
964
965 StrCpy $0 "$INSTDIR"
966
967 # Delete gettext and iconv DLLs
968 ${If} ${FileExists} "$0\libiconv-2.dll"
969 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
970 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200971 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100972 ${If} ${FileExists} "$0\libintl-8.dll"
973 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
974 "$0\libintl-8.dll"
975 ${EndIf}
976 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
977 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
978 "$0\libgcc_s_sjlj-1.dll"
979 ${EndIf}
980
981 # Delete other DLLs
982 Delete /REBOOTOK $0\*.dll
983
984 # Delete 64-bit GvimExt
985 ${If} ${RunningX64}
986 !define LIBRARY_X64
987 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
988 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
989 "$0\GvimExt64\gvimext.dll"
990 ${EndIf}
991 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
992 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
993 "$0\GvimExt64\libiconv-2.dll"
994 ${EndIf}
995 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
996 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
997 "$0\GvimExt64\libintl-8.dll"
998 ${EndIf}
999 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1000 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1001 "$0\GvimExt64\libwinpthread-1.dll"
1002 ${EndIf}
1003 !undef LIBRARY_X64
1004 RMDir /r $0\GvimExt64
1005 ${EndIf}
1006
1007 # Delete 32-bit GvimExt
1008 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1009 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1010 "$0\GvimExt32\gvimext.dll"
1011 ${EndIf}
1012 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1013 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1014 "$0\GvimExt32\libiconv-2.dll"
1015 ${EndIf}
1016 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1017 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1018 "$0\GvimExt32\libintl-8.dll"
1019 ${EndIf}
1020 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1021 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1022 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1023 ${EndIf}
1024 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001025
Bram Moolenaar071d4272004-06-13 20:20:40 +00001026 ClearErrors
1027 # Remove everything but *.dll files. Avoids that
1028 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001029 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001030 RMDir /r $0\colors
1031 RMDir /r $0\compiler
1032 RMDir /r $0\doc
1033 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001034 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035 RMDir /r $0\indent
1036 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001037 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001039 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 RMDir /r $0\syntax
1041 RMDir /r $0\tools
1042 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 RMDir /r $0\lang
1044 RMDir /r $0\keymap
1045 Delete $0\*.exe
1046 Delete $0\*.bat
1047 Delete $0\*.vim
1048 Delete $0\*.txt
1049
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001050 ${If} ${Errors}
1051 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1052 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053
1054 # No error message if the "vim62" directory can't be removed, the
1055 # gvimext.dll may still be there.
1056 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001057SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001058
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001059# Remove "vimfiles" directory under the specified directory.
1060!macro RemoveVimfiles dir
1061 ${If} ${FileExists} ${dir}\vimfiles
1062 RMDir ${dir}\vimfiles\colors
1063 RMDir ${dir}\vimfiles\compiler
1064 RMDir ${dir}\vimfiles\doc
1065 RMDir ${dir}\vimfiles\ftdetect
1066 RMDir ${dir}\vimfiles\ftplugin
1067 RMDir ${dir}\vimfiles\indent
1068 RMDir ${dir}\vimfiles\keymap
1069 RMDir ${dir}\vimfiles\plugin
1070 RMDir ${dir}\vimfiles\syntax
1071 RMDir ${dir}\vimfiles
1072 ${EndIf}
1073!macroend
1074
1075SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1076 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1077 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001078 Call un.GetHomeDir
1079 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001080
1081 ${If} $0 != ""
1082 !insertmacro RemoveVimfiles $0
1083 ${EndIf}
1084 SectionEnd
1085
1086 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1087 # get the parent dir of the installation
1088 Push $INSTDIR
1089 Call un.GetParent
1090 Pop $0
1091
1092 # if a plugin dir was created at installation remove it
1093 !insertmacro RemoveVimfiles $0
1094 SectionEnd
1095SectionGroupEnd
1096
1097Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098 # get the parent dir of the installation
1099 Push $INSTDIR
1100 Call un.GetParent
1101 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001102
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001103 ${IfNot} ${Silent}
1104 Delete $0\_vimrc
1105 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001106 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001108
1109##########################################################
1110# Description for Uninstaller Sections
1111
1112!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1113 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1114 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1115 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1116 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1117 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1118 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1119!insertmacro MUI_UNFUNCTION_DESCRIPTION_END