blob: adb38a4a1120ce33b68857b1a95ee66e825e5c58 [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
400 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100401 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100403 SetOutPath $0\pack
404 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200405
Bram Moolenaar071d4272004-06-13 20:20:40 +0000406 SetOutPath $0\plugin
407 File ${VIMRT}\plugin\*.*
408
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000409 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100410 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000411
Bram Moolenaar44433da2022-05-06 18:08:52 +0100412 SetOutPath $0\import\dist
413 File ${VIMRT}\import\dist\*.*
414
Christian Brabandt176711f2022-03-11 15:24:11 +0000415 SetOutPath $0\bitmaps
416 File ${VIMSRC}\vim.ico
417
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418 SetOutPath $0\syntax
Christian Brabandt30994d62024-01-04 22:14:28 +0100419 File /r /x testdir ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000421 SetOutPath $0\spell
422 File ${VIMRT}\spell\*.txt
423 File ${VIMRT}\spell\*.vim
424 File ${VIMRT}\spell\*.spl
425 File ${VIMRT}\spell\*.sug
426
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427 SetOutPath $0\tools
428 File ${VIMRT}\tools\*.*
429
430 SetOutPath $0\tutor
431 File ${VIMRT}\tutor\*.*
432SectionEnd
433
434##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100435Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436 SectionIn 1 3
437
438 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100439 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000440 StrCpy $2 "$2 vim view vimdiff"
441SectionEnd
442
443##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100444Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 SectionIn 3
446
447 StrCpy $1 "$1 -create-batfiles $2"
448SectionEnd
449
450##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100451SectionGroup $(str_group_icons) id_group_icons
452 Section "$(str_section_desktop)" id_section_desktop
453 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100455 StrCpy $1 "$1 -install-icons"
456 SectionEnd
457
458 Section "$(str_section_start_menu)" id_section_startmenu
459 SectionIn 1 3
460
461 StrCpy $1 "$1 -add-start-menu"
462 SectionEnd
463SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000464
465##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100466Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467 SectionIn 1 3
468
Bram Moolenaar071d4272004-06-13 20:20:40 +0000469 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200470
Bram Moolenaar442b4222010-05-24 21:34:22 +0200471 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200472 # Install 64-bit gvimext.dll into the GvimExt64 directory.
473 SetOutPath $0\GvimExt64
474 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100475 !define LIBRARY_SHELL_EXTENSION
476 !define LIBRARY_X64
477 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
478 "${VIMSRC}\GvimExt\gvimext64.dll" \
479 "$0\GvimExt64\gvimext.dll" "$0"
480 !undef LIBRARY_X64
481 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200482 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200483
Bram Moolenaar6199d432017-10-14 19:05:44 +0200484 # Install 32-bit gvimext.dll into the GvimExt32 directory.
485 SetOutPath $0\GvimExt32
486 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100487 !define LIBRARY_SHELL_EXTENSION
488 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
489 "${VIMSRC}\GvimExt\gvimext.dll" \
490 "$0\GvimExt32\gvimext.dll" "$0"
491 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492
493 # We don't have a separate entry for the "Open With..." menu, assume
494 # the user wants either both or none.
495 StrCpy $1 "$1 -install-popup -install-openwith"
496SectionEnd
497
498##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100499Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500 SectionIn 1 3
501
502 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100503
504 ${If} ${RunningX64}
505 SetRegView 64
506 ${EndIf}
507 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
508 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
509 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
510 ${If} ${RunningX64}
511 SetRegView lastused
512 ${EndIf}
513
514 ${If} $vim_compat_stat == "vi"
515 StrCpy $1 "$1 -vimrc-compat vi"
516 ${ElseIf} $vim_compat_stat == "vim"
517 StrCpy $1 "$1 -vimrc-compat vim"
518 ${ElseIf} $vim_compat_stat == "defaults"
519 StrCpy $1 "$1 -vimrc-compat defaults"
520 ${Else}
521 StrCpy $1 "$1 -vimrc-compat all"
522 ${EndIf}
523
524 ${If} $vim_keymap_stat == "default"
525 StrCpy $1 "$1 -vimrc-remap no"
526 ${Else}
527 StrCpy $1 "$1 -vimrc-remap win"
528 ${EndIf}
529
530 ${If} $vim_mouse_stat == "default"
531 StrCpy $1 "$1 -vimrc-behave default"
532 ${ElseIf} $vim_mouse_stat == "windows"
533 StrCpy $1 "$1 -vimrc-behave mswin"
534 ${Else}
535 StrCpy $1 "$1 -vimrc-behave unix"
536 ${EndIf}
537
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538SectionEnd
539
540##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100541SectionGroup $(str_group_plugin) id_group_plugin
542 Section "$(str_section_plugin_home)" id_section_pluginhome
543 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000545 # use ShellExecAsUser below instead
546 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100547 SectionEnd
548
549 Section "$(str_section_plugin_vim)" id_section_pluginvim
550 SectionIn 3
551
552 StrCpy $1 "$1 -create-directories vim"
553 SectionEnd
554SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555
556##########################################################
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100558Section "$(str_section_nls)" id_section_nls
559 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100561 SetOutPath $0\lang
562 File /r ${VIMRT}\lang\*.*
563 SetOutPath $0\keymap
564 File ${VIMRT}\keymap\README.txt
565 File ${VIMRT}\keymap\*.vim
566 SetOutPath $0
567 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
568 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
569 "$0\libintl-8.dll" "$0"
570 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
571 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
572 "$0\libiconv-2.dll" "$0"
573 !if /FileExists "${GETTEXT}\gettext${BIT}\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}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
577 "$0\libgcc_s_sjlj-1.dll" "$0"
578 !endif
579
580 ${If} ${SectionIsSelected} ${id_section_editwith}
581 ${If} ${RunningX64}
582 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
583 SetOutPath $0\GvimExt64
584 ClearErrors
585 !define LIBRARY_X64
586 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
587 "${GETTEXT}\gettext64\libintl-8.dll" \
588 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
589 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
590 "${GETTEXT}\gettext64\libiconv-2.dll" \
591 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
592 !undef LIBRARY_X64
593 ${EndIf}
594
595 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
596 SetOutPath $0\GvimExt32
597 ClearErrors
598 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
599 "${GETTEXT}\gettext32\libintl-8.dll" \
600 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
601 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
602 "${GETTEXT}\gettext32\libiconv-2.dll" \
603 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
604 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
605 # Install libgcc_s_sjlj-1.dll only if it is needed.
606 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
607 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
608 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
609 !endif
610 ${EndIf}
611SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000612!endif
613
614##########################################################
615Section -call_install_exe
616 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100617 DetailPrint "$(str_msg_registering)"
618 nsExec::Exec "$0\install.exe $1"
619 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000620
621 ${If} ${SectionIsSelected} ${id_section_pluginhome}
622 ReadEnvStr $3 "COMSPEC"
623 Call GetHomeDir
624 Pop $4
625 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
626 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627SectionEnd
628
629##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100630!macro SaveSectionSelection section_id reg_value
631 ${If} ${SectionIsSelected} ${section_id}
632 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
633 ${Else}
634 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
635 ${EndIf}
636!macroend
637
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100639
640 # Get estimated install size
641 SectionGetSize ${id_section_exe} $3
642 ${If} ${SectionIsSelected} ${id_section_console}
643 SectionGetSize ${id_section_console} $4
644 IntOp $3 $3 + $4
645 ${EndIf}
646 ${If} ${SectionIsSelected} ${id_section_editwith}
647 SectionGetSize ${id_section_editwith} $4
648 IntOp $3 $3 + $4
649 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100650!ifdef HAVE_NLS
651 ${If} ${SectionIsSelected} ${id_section_nls}
652 SectionGetSize ${id_section_nls} $4
653 IntOp $3 $3 + $4
654 ${EndIf}
655!endif
656
657 # Register EstimatedSize and AllowSilent.
658 # Other information will be set by the install.exe (dosinst.c).
659 ${If} ${RunningX64}
660 SetRegView 64
661 ${EndIf}
662 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
663 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
664 ${If} ${RunningX64}
665 SetRegView lastused
666 ${EndIf}
667
668 # Store the selections to the registry.
669 ${If} ${RunningX64}
670 SetRegView 64
671 ${EndIf}
672 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
673 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
674 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
675 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
676 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
677 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
678 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
679 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100680!ifdef HAVE_NLS
681 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
682!endif
683 ${If} ${RunningX64}
684 SetRegView lastused
685 ${EndIf}
686
Bram Moolenaar071d4272004-06-13 20:20:40 +0000687 BringToFront
688SectionEnd
689
690##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100691!macro LoadSectionSelection section_id reg_value
692 ClearErrors
693 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
694 ${IfNot} ${Errors}
695 ${If} $3 = 1
696 !insertmacro SelectSection ${section_id}
697 ${Else}
698 !insertmacro UnselectSection ${section_id}
699 ${EndIf}
700 ${EndIf}
701!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200702
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200703!macro LoadDefaultVimrc out_var reg_value default_value
704 ClearErrors
705 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
706 ${If} ${Errors}
707 ${OrIf} ${out_var} == ""
708 StrCpy ${out_var} ${default_value}
709 ${EndIf}
710!macroend
711
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100712Function .onInit
713!ifdef HAVE_MULTI_LANG
714 # Select a language (or read from the registry).
715 !insertmacro MUI_LANGDLL_DISPLAY
716!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200717
Christian Brabandt7d603842021-07-24 21:19:42 +0200718 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
719 # Check $VIM
720 ReadEnvStr $3 "VIM"
721 ${If} $3 != ""
722 StrCpy $INSTDIR $3
723 ${EndIf}
724 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100725
726 call CheckOldVim
727 Pop $3
728 ${If} $3 == ""
729 # No old versions of Vim found. Unselect and hide the section.
730 !insertmacro UnselectSection ${id_section_old_ver}
731 SectionSetInstTypes ${id_section_old_ver} 0
732 SectionSetText ${id_section_old_ver} ""
733 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200734 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100735 StrCpy $INSTDIR $3
736 ${EndIf}
737 ${EndIf}
738
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100739 ${If} ${RunningX64}
740 SetRegView 64
741 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200742 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100743 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
744 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
745 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
746 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
747 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
748 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
749 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
750 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100751!ifdef HAVE_NLS
752 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
753!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200754 # Load the default _vimrc settings from the registry (if any).
755 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
756 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
757 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100758 ${If} ${RunningX64}
759 SetRegView lastused
760 ${EndIf}
761
762 # User variables:
763 # $0 - holds the directory the executables are installed to
764 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
765 # registration (since a non-OLE gvim will not complain, and we want to
766 # always register an OLE gvim).
767 # $2 - holds the names to create batch files for
768 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
769 StrCpy $1 "-register-OLE"
770 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200771FunctionEnd
772
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100773Function .onInstSuccess
774 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
775FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200776
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100777Function .onInstFailed
778 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200779FunctionEnd
780
781##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100782Function SetCustom
783 # Display the _vimrc setting dialog using nsDialogs.
784
785 # Check if a _vimrc should be created
786 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
787 Abort
788 ${EndIf}
789
790 !insertmacro MUI_HEADER_TEXT \
791 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
792
793 nsDialogs::Create 1018
794 Pop $vim_dialog
795
796 ${If} $vim_dialog == error
797 Abort
798 ${EndIf}
799
800 ${If} ${RunningX64}
801 SetRegView 64
802 ${EndIf}
803
804 GetFunctionAddress $3 ValidateCustom
805 nsDialogs::OnBack $3
806
807
808 # 1st group - Compatibility
809 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
810 Pop $3
811
812 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
813 Pop $3
814 ${NSD_CreateDropList} 18% 19% 75% 8% ""
815 Pop $vim_nsd_compat
816 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
817 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
818 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
819 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
820
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200821 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100822 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200823 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100824 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200825 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100826 StrCpy $4 0
827 ${Else} # default
828 StrCpy $4 3
829 ${EndIf}
830 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
831
832
833 # 2nd group - Key remapping
834 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
835 Pop $3
836
837 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
838 Pop $3
839 ${NSD_CreateDropList} 38% 54% 55% 8% ""
840 Pop $vim_nsd_keymap
841 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
842 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
843
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200844 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100845 StrCpy $4 1
846 ${Else} # default
847 StrCpy $4 0
848 ${EndIf}
849 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
850
851
852 # 3rd group - Mouse behavior
853 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
854 Pop $3
855
856 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
857 Pop $3
858 ${NSD_CreateDropList} 23% 87% 70% 8% ""
859 Pop $vim_nsd_mouse
860 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
861 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
862 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
863
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200864 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100865 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200866 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100867 StrCpy $4 1
868 ${Else} # default
869 StrCpy $4 0
870 ${EndIf}
871 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
872
873 ${If} ${RunningX64}
874 SetRegView lastused
875 ${EndIf}
876
877 nsDialogs::Show
878FunctionEnd
879
880Function ValidateCustom
881 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
882 ${If} $3 = 0
883 StrCpy $vim_compat_stat "vi"
884 ${ElseIf} $3 = 1
885 StrCpy $vim_compat_stat "vim"
886 ${ElseIf} $3 = 2
887 StrCpy $vim_compat_stat "defaults"
888 ${Else}
889 StrCpy $vim_compat_stat "all"
890 ${EndIf}
891
892 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
893 ${If} $3 = 0
894 StrCpy $vim_keymap_stat "default"
895 ${Else}
896 StrCpy $vim_keymap_stat "windows"
897 ${EndIf}
898
899 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
900 ${If} $3 = 0
901 StrCpy $vim_mouse_stat "default"
902 ${ElseIf} $3 = 1
903 StrCpy $vim_mouse_stat "windows"
904 ${Else}
905 StrCpy $vim_mouse_stat "xterm"
906 ${EndIf}
907FunctionEnd
908
909##########################################################
910# Description for Installer Sections
911
912!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
913 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
914 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
915 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
916 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
917 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100925!ifdef HAVE_NLS
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
927!endif
928!insertmacro MUI_FUNCTION_DESCRIPTION_END
929
930
931##########################################################
932# Uninstaller Functions and Sections
933
934Function un.onInit
935!ifdef HAVE_MULTI_LANG
936 # Get the language from the registry.
937 !insertmacro MUI_UNGETLANGUAGE
938!endif
939FunctionEnd
940
941Section "un.$(str_unsection_register)" id_unsection_register
942 SectionIn RO
943
Bram Moolenaar071d4272004-06-13 20:20:40 +0000944 # Apparently $INSTDIR is set to the directory where the uninstaller is
945 # created. Thus the "vim61" directory is included in it.
946 StrCpy $0 "$INSTDIR"
947
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100949 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200950 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100951 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000952
953 # We may have been put to the background when uninstall did something.
954 BringToFront
955
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100956 # Delete the installer language setting.
957 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
958SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100960Section "un.$(str_unsection_exe)" id_unsection_exe
961
962 StrCpy $0 "$INSTDIR"
963
964 # Delete gettext and iconv DLLs
965 ${If} ${FileExists} "$0\libiconv-2.dll"
966 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
967 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200968 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100969 ${If} ${FileExists} "$0\libintl-8.dll"
970 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
971 "$0\libintl-8.dll"
972 ${EndIf}
973 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
974 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
975 "$0\libgcc_s_sjlj-1.dll"
976 ${EndIf}
977
978 # Delete other DLLs
979 Delete /REBOOTOK $0\*.dll
980
981 # Delete 64-bit GvimExt
982 ${If} ${RunningX64}
983 !define LIBRARY_X64
984 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
985 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
986 "$0\GvimExt64\gvimext.dll"
987 ${EndIf}
988 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
989 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
990 "$0\GvimExt64\libiconv-2.dll"
991 ${EndIf}
992 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
993 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
994 "$0\GvimExt64\libintl-8.dll"
995 ${EndIf}
996 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
997 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
998 "$0\GvimExt64\libwinpthread-1.dll"
999 ${EndIf}
1000 !undef LIBRARY_X64
1001 RMDir /r $0\GvimExt64
1002 ${EndIf}
1003
1004 # Delete 32-bit GvimExt
1005 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1006 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1007 "$0\GvimExt32\gvimext.dll"
1008 ${EndIf}
1009 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1010 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1011 "$0\GvimExt32\libiconv-2.dll"
1012 ${EndIf}
1013 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1014 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1015 "$0\GvimExt32\libintl-8.dll"
1016 ${EndIf}
1017 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1018 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1019 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1020 ${EndIf}
1021 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001022
Bram Moolenaar071d4272004-06-13 20:20:40 +00001023 ClearErrors
1024 # Remove everything but *.dll files. Avoids that
1025 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001026 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027 RMDir /r $0\colors
1028 RMDir /r $0\compiler
1029 RMDir /r $0\doc
1030 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001031 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 RMDir /r $0\indent
1033 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001034 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001036 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 RMDir /r $0\syntax
1038 RMDir /r $0\tools
1039 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 RMDir /r $0\lang
1041 RMDir /r $0\keymap
1042 Delete $0\*.exe
1043 Delete $0\*.bat
1044 Delete $0\*.vim
1045 Delete $0\*.txt
1046
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001047 ${If} ${Errors}
1048 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1049 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050
1051 # No error message if the "vim62" directory can't be removed, the
1052 # gvimext.dll may still be there.
1053 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001054SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001055
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001056# Remove "vimfiles" directory under the specified directory.
1057!macro RemoveVimfiles dir
1058 ${If} ${FileExists} ${dir}\vimfiles
1059 RMDir ${dir}\vimfiles\colors
1060 RMDir ${dir}\vimfiles\compiler
1061 RMDir ${dir}\vimfiles\doc
1062 RMDir ${dir}\vimfiles\ftdetect
1063 RMDir ${dir}\vimfiles\ftplugin
1064 RMDir ${dir}\vimfiles\indent
1065 RMDir ${dir}\vimfiles\keymap
1066 RMDir ${dir}\vimfiles\plugin
1067 RMDir ${dir}\vimfiles\syntax
1068 RMDir ${dir}\vimfiles
1069 ${EndIf}
1070!macroend
1071
1072SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1073 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1074 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001075 Call un.GetHomeDir
1076 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001077
1078 ${If} $0 != ""
1079 !insertmacro RemoveVimfiles $0
1080 ${EndIf}
1081 SectionEnd
1082
1083 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1084 # get the parent dir of the installation
1085 Push $INSTDIR
1086 Call un.GetParent
1087 Pop $0
1088
1089 # if a plugin dir was created at installation remove it
1090 !insertmacro RemoveVimfiles $0
1091 SectionEnd
1092SectionGroupEnd
1093
1094Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095 # get the parent dir of the installation
1096 Push $INSTDIR
1097 Call un.GetParent
1098 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001100 ${IfNot} ${Silent}
1101 Delete $0\_vimrc
1102 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001103 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001105
1106##########################################################
1107# Description for Uninstaller Sections
1108
1109!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1110 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1111 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1112 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1113 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1114 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1115 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1116!insertmacro MUI_UNFUNCTION_DESCRIPTION_END