blob: 992d0501b55ea7f49c8a72c568ce4521a4cef314 [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"
Christos Longrosc62dacb2024-03-06 20:53:02 +0100170 !include "lang\greek.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100171 !include "lang\italian.nsi"
172 !include "lang\japanese.nsi"
Bram Moolenaar809fcec2020-09-20 21:43:03 +0200173 !include "lang\russian.nsi"
Ivan Pešiće1051922024-03-05 23:34:00 +0400174 !include "lang\serbian.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100175 !include "lang\simpchinese.nsi"
176 !include "lang\tradchinese.nsi"
Bram Moolenaar1a928c22020-01-18 16:10:40 +0100177 !include "lang\turkish.nsi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100178!endif
179
Bram Moolenaardabfde02019-05-17 12:37:27 +0200180##########################################################
181# Version resources
182
183VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Vim"
184VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Vim Developers"
185VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Vim"
186VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) 1996"
187VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Vi Improved - A Text Editor"
Bram Moolenaar9d591522019-05-26 20:49:42 +0200188VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
189VIProductVersion "${VER_MAJOR}.${VER_MINOR}.${PATCHLEVEL}.0"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100190
191# Global variables
192Var vim_dialog
193Var vim_nsd_compat
194Var vim_nsd_keymap
195Var vim_nsd_mouse
196Var vim_compat_stat
197Var vim_keymap_stat
198Var vim_mouse_stat
199
Bram Moolenaar071d4272004-06-13 20:20:40 +0000200
Bram Moolenaar5d424742018-02-04 19:11:30 +0100201# Reserve files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100202ReserveFile ${VIMSRC}\installw32.exe
Bram Moolenaar5d424742018-02-04 19:11:30 +0100203
Bram Moolenaar071d4272004-06-13 20:20:40 +0000204##########################################################
205# Functions
206
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100207# Get parent directory
208# Share this function both on installer and uninstaller
209!macro GetParent un
210Function ${un}GetParent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211 Exch $0 ; old $0 is on top of stack
212 Push $1
213 Push $2
214 StrCpy $1 -1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100215 ${Do}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216 StrCpy $2 $0 1 $1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100217 ${If} $2 == ""
218 ${OrIf} $2 == "\"
219 ${ExitDo}
220 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221 IntOp $1 $1 - 1
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100222 ${Loop}
223 StrCpy $0 $0 $1
224 Pop $2
225 Pop $1
226 Exch $0 ; put $0 on top of stack, restore $0 to original value
227FunctionEnd
228!macroend
229
230!insertmacro GetParent ""
231!insertmacro GetParent "un."
232
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000233# Get home directory
234!macro GetHomeDir un
235Function ${un}GetHomeDir
236 Push $0
237 Push $1
238 ReadEnvStr $0 "HOME"
239 ${If} $0 == ""
240 ReadEnvStr $0 "HOMEDRIVE"
241 ReadEnvStr $1 "HOMEPATH"
242 StrCpy $0 "$0$1"
243 ${If} $0 == ""
244 ReadEnvStr $0 "USERPROFILE"
245 ${EndIf}
246 ${EndIf}
247 Pop $1
248 Exch $0 # put $0 on top of stack, restore $0 to original value
249FunctionEnd
250!macroend
251
252!insertmacro GetHomeDir ""
253!insertmacro GetHomeDir "un."
254
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100255# Check if Vim is already installed.
256# return: Installed directory. If not found, it will be empty.
257Function CheckOldVim
258 Push $0
259 Push $R0
260 Push $R1
261 Push $R2
262
263 ${If} ${RunningX64}
264 SetRegView 64
265 ${EndIf}
266
267 ClearErrors
268 StrCpy $0 "" # Installed directory
269 StrCpy $R0 0 # Sub-key index
270 StrCpy $R1 "" # Sub-key
271 ${Do}
272 # Eumerate the sub-key:
273 EnumRegKey $R1 HKLM ${UNINST_REG_KEY} $R0
274
275 # Stop if no more sub-key:
276 ${If} ${Errors}
277 ${OrIf} $R1 == ""
278 ${ExitDo}
279 ${EndIf}
280
281 # Move to the next sub-key:
282 IntOp $R0 $R0 + 1
283
284 # Check if the key is Vim uninstall key or not:
285 StrCpy $R2 $R1 4
286 ${If} $R2 S!= "Vim "
287 ${Continue}
288 ${EndIf}
289
290 # Verifies required sub-keys:
291 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "DisplayName"
292 ${If} ${Errors}
293 ${OrIf} $R2 == ""
294 ${Continue}
295 ${EndIf}
296
297 ReadRegStr $R2 HKLM "${UNINST_REG_KEY}\$R1" "UninstallString"
298 ${If} ${Errors}
299 ${OrIf} $R2 == ""
300 ${Continue}
301 ${EndIf}
302
303 # Found
304 Push $R2
305 call GetParent
306 call GetParent
307 Pop $0 # Vim directory
308 ${ExitDo}
309
310 ${Loop}
311
312 ${If} ${RunningX64}
313 SetRegView lastused
314 ${EndIf}
315
316 Pop $R2
317 Pop $R1
318 Pop $R0
319 Exch $0 # put $0 on top of stack, restore $0 to original value
Bram Moolenaar071d4272004-06-13 20:20:40 +0000320FunctionEnd
321
Bram Moolenaar4a228972021-05-01 22:41:39 +0200322Function LaunchApplication
323 SetOutPath $0
Bram Moolenaar5f628a12021-05-02 13:59:46 +0200324 ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
Bram Moolenaar4a228972021-05-01 22:41:39 +0200325FunctionEnd
326
Bram Moolenaar071d4272004-06-13 20:20:40 +0000327##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100328Section "$(str_section_old_ver)" id_section_old_ver
329 SectionIn 1 2 3 RO
330
331 # run the install program to check for already installed versions
332 SetOutPath $TEMP
333 File /oname=install.exe ${VIMSRC}\installw32.exe
334 DetailPrint "$(str_msg_uninstalling)"
335 ${Do}
336 nsExec::Exec "$TEMP\install.exe -uninstall-check"
337 Pop $3
338
339 call CheckOldVim
340 Pop $3
341 ${If} $3 == ""
342 ${ExitDo}
343 ${Else}
344 # It seems that the old version is still remaining.
345 # TODO: Should we show a warning and run the uninstaller again?
346
347 ${ExitDo} # Just ignore for now.
348 ${EndIf}
349 ${Loop}
350 Delete $TEMP\install.exe
351 Delete $TEMP\vimini.ini # install.exe creates this, but we don't need it.
352
353 # We may have been put to the background when uninstall did something.
354 BringToFront
355SectionEnd
356
357##########################################################
358Section "$(str_section_exe)" id_section_exe
Bram Moolenaar49150a42017-09-17 21:00:03 +0200359 SectionIn 1 2 3 RO
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360
361 # we need also this here if the user changes the instdir
362 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
363
364 SetOutPath $0
365 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
Bram Moolenaarafde13b2019-04-28 19:46:49 +0200366!if /FileExists "${VIMSRC}\vim${BIT}.dll"
367 File ${VIMSRC}\vim${BIT}.dll
368!endif
Christian Brabandtcf6ad8e2022-02-13 13:11:32 +0000369!if /FileExists "${VIMRT}\libsodium.dll"
370 File ${VIMRT}\libsodium.dll
371!endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000372 File /oname=install.exe ${VIMSRC}\installw32.exe
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200373 File /oname=uninstall.exe ${VIMSRC}\uninstallw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374 File ${VIMSRC}\vimrun.exe
Bram Moolenaarfec246d2016-08-28 18:47:14 +0200375 File /oname=tee.exe ${VIMSRC}\teew32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
Bram Moolenaar19166732018-12-21 17:59:33 +0100377 File ..\vimtutor.bat
378 File ..\README.txt
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200379 File ..\uninstall.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380 File ${VIMRT}\*.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000381
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200382 File ${VIMTOOLS}\diff.exe
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100383 File ${VIMTOOLS}\winpty${BIT}.dll
Bram Moolenaar98ebd2b2017-08-19 13:29:19 +0200384 File ${VIMTOOLS}\winpty-agent.exe
385
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386 SetOutPath $0\colors
K.Takata44b9abb2022-08-24 18:08:00 +0100387 File /r ${VIMRT}\colors\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388
389 SetOutPath $0\compiler
390 File ${VIMRT}\compiler\*.*
391
392 SetOutPath $0\doc
393 File ${VIMRT}\doc\*.txt
394 File ${VIMRT}\doc\tags
395
396 SetOutPath $0\ftplugin
397 File ${VIMRT}\ftplugin\*.*
398
399 SetOutPath $0\indent
400 File ${VIMRT}\indent\*.*
401
Ken Takata1a9aba82024-01-16 17:14:29 +0100402 SetOutPath $0\keymap
403 File ${VIMRT}\keymap\*.*
404
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405 SetOutPath $0\macros
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100406 File /r ${VIMRT}\macros\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407
Bram Moolenaar6a95c882019-03-26 23:02:46 +0100408 SetOutPath $0\pack
409 File /r ${VIMRT}\pack\*.*
Bram Moolenaar38623c82018-05-10 21:24:35 +0200410
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411 SetOutPath $0\plugin
412 File ${VIMRT}\plugin\*.*
413
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000414 SetOutPath $0\autoload
K.Takata44b9abb2022-08-24 18:08:00 +0100415 File /r ${VIMRT}\autoload\*.*
Bram Moolenaar18144c82006-04-12 21:52:12 +0000416
Bram Moolenaar44433da2022-05-06 18:08:52 +0100417 SetOutPath $0\import\dist
418 File ${VIMRT}\import\dist\*.*
419
Christian Brabandt176711f2022-03-11 15:24:11 +0000420 SetOutPath $0\bitmaps
421 File ${VIMSRC}\vim.ico
422
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 SetOutPath $0\syntax
h-east9b53c052024-02-13 21:09:22 +0100424 File /r /x testdir /x generator ${VIMRT}\syntax\*.*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000426 SetOutPath $0\spell
427 File ${VIMRT}\spell\*.txt
428 File ${VIMRT}\spell\*.vim
429 File ${VIMRT}\spell\*.spl
430 File ${VIMRT}\spell\*.sug
431
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432 SetOutPath $0\tools
433 File ${VIMRT}\tools\*.*
434
435 SetOutPath $0\tutor
436 File ${VIMRT}\tutor\*.*
437SectionEnd
438
439##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100440Section "$(str_section_console)" id_section_console
Bram Moolenaar071d4272004-06-13 20:20:40 +0000441 SectionIn 1 3
442
443 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100444 File /oname=vim.exe ${VIMSRC}\vimw32.exe
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445 StrCpy $2 "$2 vim view vimdiff"
446SectionEnd
447
448##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100449Section "$(str_section_batch)" id_section_batch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450 SectionIn 3
451
452 StrCpy $1 "$1 -create-batfiles $2"
453SectionEnd
454
455##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100456SectionGroup $(str_group_icons) id_group_icons
457 Section "$(str_section_desktop)" id_section_desktop
458 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100460 StrCpy $1 "$1 -install-icons"
461 SectionEnd
462
463 Section "$(str_section_start_menu)" id_section_startmenu
464 SectionIn 1 3
465
466 StrCpy $1 "$1 -add-start-menu"
467 SectionEnd
468SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000469
470##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100471Section "$(str_section_edit_with)" id_section_editwith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000472 SectionIn 1 3
473
Bram Moolenaar071d4272004-06-13 20:20:40 +0000474 SetOutPath $0
Bram Moolenaar6199d432017-10-14 19:05:44 +0200475
Bram Moolenaar442b4222010-05-24 21:34:22 +0200476 ${If} ${RunningX64}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200477 # Install 64-bit gvimext.dll into the GvimExt64 directory.
478 SetOutPath $0\GvimExt64
479 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100480 !define LIBRARY_SHELL_EXTENSION
481 !define LIBRARY_X64
482 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
483 "${VIMSRC}\GvimExt\gvimext64.dll" \
484 "$0\GvimExt64\gvimext.dll" "$0"
485 !undef LIBRARY_X64
486 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar442b4222010-05-24 21:34:22 +0200487 ${EndIf}
Bram Moolenaar6199d432017-10-14 19:05:44 +0200488
Bram Moolenaar6199d432017-10-14 19:05:44 +0200489 # Install 32-bit gvimext.dll into the GvimExt32 directory.
490 SetOutPath $0\GvimExt32
491 ClearErrors
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100492 !define LIBRARY_SHELL_EXTENSION
493 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
494 "${VIMSRC}\GvimExt\gvimext.dll" \
495 "$0\GvimExt32\gvimext.dll" "$0"
496 !undef LIBRARY_SHELL_EXTENSION
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497
498 # We don't have a separate entry for the "Open With..." menu, assume
499 # the user wants either both or none.
500 StrCpy $1 "$1 -install-popup -install-openwith"
501SectionEnd
502
503##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100504Section "$(str_section_vim_rc)" id_section_vimrc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505 SectionIn 1 3
506
507 StrCpy $1 "$1 -create-vimrc"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100508
509 ${If} ${RunningX64}
510 SetRegView 64
511 ${EndIf}
512 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_compat" "$vim_compat_stat"
513 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_keyremap" "$vim_keymap_stat"
514 WriteRegStr HKLM "${UNINST_REG_KEY_VIM}" "vim_mouse" "$vim_mouse_stat"
515 ${If} ${RunningX64}
516 SetRegView lastused
517 ${EndIf}
518
519 ${If} $vim_compat_stat == "vi"
520 StrCpy $1 "$1 -vimrc-compat vi"
521 ${ElseIf} $vim_compat_stat == "vim"
522 StrCpy $1 "$1 -vimrc-compat vim"
523 ${ElseIf} $vim_compat_stat == "defaults"
524 StrCpy $1 "$1 -vimrc-compat defaults"
525 ${Else}
526 StrCpy $1 "$1 -vimrc-compat all"
527 ${EndIf}
528
529 ${If} $vim_keymap_stat == "default"
530 StrCpy $1 "$1 -vimrc-remap no"
531 ${Else}
532 StrCpy $1 "$1 -vimrc-remap win"
533 ${EndIf}
534
535 ${If} $vim_mouse_stat == "default"
536 StrCpy $1 "$1 -vimrc-behave default"
537 ${ElseIf} $vim_mouse_stat == "windows"
538 StrCpy $1 "$1 -vimrc-behave mswin"
539 ${Else}
540 StrCpy $1 "$1 -vimrc-behave unix"
541 ${EndIf}
542
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543SectionEnd
544
545##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100546SectionGroup $(str_group_plugin) id_group_plugin
547 Section "$(str_section_plugin_home)" id_section_pluginhome
548 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000550 # use ShellExecAsUser below instead
551 # StrCpy $1 "$1 -create-directories home"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100552 SectionEnd
553
554 Section "$(str_section_plugin_vim)" id_section_pluginvim
555 SectionIn 3
556
557 StrCpy $1 "$1 -create-directories vim"
558 SectionEnd
559SectionGroupEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560
561##########################################################
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562!ifdef HAVE_NLS
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100563Section "$(str_section_nls)" id_section_nls
564 SectionIn 1 3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100566 SetOutPath $0\lang
567 File /r ${VIMRT}\lang\*.*
568 SetOutPath $0\keymap
569 File ${VIMRT}\keymap\README.txt
570 File ${VIMRT}\keymap\*.vim
571 SetOutPath $0
572 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
573 "${GETTEXT}\gettext${BIT}\libintl-8.dll" \
574 "$0\libintl-8.dll" "$0"
575 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
576 "${GETTEXT}\gettext${BIT}\libiconv-2.dll" \
577 "$0\libiconv-2.dll" "$0"
578 !if /FileExists "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll"
579 # Install libgcc_s_sjlj-1.dll only if it is needed.
580 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
581 "${GETTEXT}\gettext${BIT}\libgcc_s_sjlj-1.dll" \
582 "$0\libgcc_s_sjlj-1.dll" "$0"
583 !endif
584
585 ${If} ${SectionIsSelected} ${id_section_editwith}
586 ${If} ${RunningX64}
587 # Install DLLs for 64-bit gvimext.dll into the GvimExt64 directory.
588 SetOutPath $0\GvimExt64
589 ClearErrors
590 !define LIBRARY_X64
591 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
592 "${GETTEXT}\gettext64\libintl-8.dll" \
593 "$0\GvimExt64\libintl-8.dll" "$0\GvimExt64"
594 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
595 "${GETTEXT}\gettext64\libiconv-2.dll" \
596 "$0\GvimExt64\libiconv-2.dll" "$0\GvimExt64"
597 !undef LIBRARY_X64
598 ${EndIf}
599
600 # Install DLLs for 32-bit gvimext.dll into the GvimExt32 directory.
601 SetOutPath $0\GvimExt32
602 ClearErrors
603 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
604 "${GETTEXT}\gettext32\libintl-8.dll" \
605 "$0\GvimExt32\libintl-8.dll" "$0\GvimExt32"
606 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
607 "${GETTEXT}\gettext32\libiconv-2.dll" \
608 "$0\GvimExt32\libiconv-2.dll" "$0\GvimExt32"
609 !if /FileExists "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll"
610 # Install libgcc_s_sjlj-1.dll only if it is needed.
611 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
612 "${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll" \
613 "$0\GvimExt32\libgcc_s_sjlj-1.dll" "$0\GvimExt32"
614 !endif
615 ${EndIf}
616SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000617!endif
618
619##########################################################
620Section -call_install_exe
621 SetOutPath $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100622 DetailPrint "$(str_msg_registering)"
623 nsExec::Exec "$0\install.exe $1"
624 Pop $3
Christopher Plewrighteea0a002023-02-17 20:04:51 +0000625
626 ${If} ${SectionIsSelected} ${id_section_pluginhome}
627 ReadEnvStr $3 "COMSPEC"
628 Call GetHomeDir
629 Pop $4
630 ShellExecAsUser::ShellExecAsUser "" "$3" '/c "cd /d "$4" & mkdir vimfiles & cd vimfiles & mkdir colors compiler doc ftdetect ftplugin indent keymap plugin syntax"' SW_HIDE
631 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000632SectionEnd
633
634##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100635!macro SaveSectionSelection section_id reg_value
636 ${If} ${SectionIsSelected} ${section_id}
637 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 1
638 ${Else}
639 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" ${reg_value} 0
640 ${EndIf}
641!macroend
642
Bram Moolenaar071d4272004-06-13 20:20:40 +0000643Section -post
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100644
645 # Get estimated install size
646 SectionGetSize ${id_section_exe} $3
647 ${If} ${SectionIsSelected} ${id_section_console}
648 SectionGetSize ${id_section_console} $4
649 IntOp $3 $3 + $4
650 ${EndIf}
651 ${If} ${SectionIsSelected} ${id_section_editwith}
652 SectionGetSize ${id_section_editwith} $4
653 IntOp $3 $3 + $4
654 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100655!ifdef HAVE_NLS
656 ${If} ${SectionIsSelected} ${id_section_nls}
657 SectionGetSize ${id_section_nls} $4
658 IntOp $3 $3 + $4
659 ${EndIf}
660!endif
661
662 # Register EstimatedSize and AllowSilent.
663 # Other information will be set by the install.exe (dosinst.c).
664 ${If} ${RunningX64}
665 SetRegView 64
666 ${EndIf}
667 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "EstimatedSize" $3
668 WriteRegDWORD HKLM "${UNINST_REG_KEY_VIM}" "AllowSilent" 1
669 ${If} ${RunningX64}
670 SetRegView lastused
671 ${EndIf}
672
673 # Store the selections to the registry.
674 ${If} ${RunningX64}
675 SetRegView 64
676 ${EndIf}
677 !insertmacro SaveSectionSelection ${id_section_console} "select_console"
678 !insertmacro SaveSectionSelection ${id_section_batch} "select_batch"
679 !insertmacro SaveSectionSelection ${id_section_desktop} "select_desktop"
680 !insertmacro SaveSectionSelection ${id_section_startmenu} "select_startmenu"
681 !insertmacro SaveSectionSelection ${id_section_editwith} "select_editwith"
682 !insertmacro SaveSectionSelection ${id_section_vimrc} "select_vimrc"
683 !insertmacro SaveSectionSelection ${id_section_pluginhome} "select_pluginhome"
684 !insertmacro SaveSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100685!ifdef HAVE_NLS
686 !insertmacro SaveSectionSelection ${id_section_nls} "select_nls"
687!endif
688 ${If} ${RunningX64}
689 SetRegView lastused
690 ${EndIf}
691
Bram Moolenaar071d4272004-06-13 20:20:40 +0000692 BringToFront
693SectionEnd
694
695##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100696!macro LoadSectionSelection section_id reg_value
697 ClearErrors
698 ReadRegDWORD $3 HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
699 ${IfNot} ${Errors}
700 ${If} $3 = 1
701 !insertmacro SelectSection ${section_id}
702 ${Else}
703 !insertmacro UnselectSection ${section_id}
704 ${EndIf}
705 ${EndIf}
706!macroend
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200707
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200708!macro LoadDefaultVimrc out_var reg_value default_value
709 ClearErrors
710 ReadRegStr ${out_var} HKLM "${UNINST_REG_KEY_VIM}" ${reg_value}
711 ${If} ${Errors}
712 ${OrIf} ${out_var} == ""
713 StrCpy ${out_var} ${default_value}
714 ${EndIf}
715!macroend
716
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100717Function .onInit
718!ifdef HAVE_MULTI_LANG
719 # Select a language (or read from the registry).
720 !insertmacro MUI_LANGDLL_DISPLAY
721!endif
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200722
Christian Brabandt7d603842021-07-24 21:19:42 +0200723 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
724 # Check $VIM
725 ReadEnvStr $3 "VIM"
726 ${If} $3 != ""
727 StrCpy $INSTDIR $3
728 ${EndIf}
729 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100730
731 call CheckOldVim
732 Pop $3
733 ${If} $3 == ""
734 # No old versions of Vim found. Unselect and hide the section.
735 !insertmacro UnselectSection ${id_section_old_ver}
736 SectionSetInstTypes ${id_section_old_ver} 0
737 SectionSetText ${id_section_old_ver} ""
738 ${Else}
Christian Brabandt7d603842021-07-24 21:19:42 +0200739 ${If} $INSTDIR == ${DEFAULT_INSTDIR}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100740 StrCpy $INSTDIR $3
741 ${EndIf}
742 ${EndIf}
743
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100744 ${If} ${RunningX64}
745 SetRegView 64
746 ${EndIf}
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200747 # Load the selections from the registry (if any).
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100748 !insertmacro LoadSectionSelection ${id_section_console} "select_console"
749 !insertmacro LoadSectionSelection ${id_section_batch} "select_batch"
750 !insertmacro LoadSectionSelection ${id_section_desktop} "select_desktop"
751 !insertmacro LoadSectionSelection ${id_section_startmenu} "select_startmenu"
752 !insertmacro LoadSectionSelection ${id_section_editwith} "select_editwith"
753 !insertmacro LoadSectionSelection ${id_section_vimrc} "select_vimrc"
754 !insertmacro LoadSectionSelection ${id_section_pluginhome} "select_pluginhome"
755 !insertmacro LoadSectionSelection ${id_section_pluginvim} "select_pluginvim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100756!ifdef HAVE_NLS
757 !insertmacro LoadSectionSelection ${id_section_nls} "select_nls"
758!endif
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200759 # Load the default _vimrc settings from the registry (if any).
760 !insertmacro LoadDefaultVimrc $vim_compat_stat "vim_compat" "all"
761 !insertmacro LoadDefaultVimrc $vim_keymap_stat "vim_keyremap" "default"
762 !insertmacro LoadDefaultVimrc $vim_mouse_stat "vim_mouse" "default"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100763 ${If} ${RunningX64}
764 SetRegView lastused
765 ${EndIf}
766
767 # User variables:
768 # $0 - holds the directory the executables are installed to
769 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
770 # registration (since a non-OLE gvim will not complain, and we want to
771 # always register an OLE gvim).
772 # $2 - holds the names to create batch files for
773 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
774 StrCpy $1 "-register-OLE"
775 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200776FunctionEnd
777
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100778Function .onInstSuccess
779 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
780FunctionEnd
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200781
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100782Function .onInstFailed
783 MessageBox MB_OK|MB_ICONEXCLAMATION "$(str_msg_install_fail)" /SD IDOK
Bram Moolenaarc3fdf7f2017-10-28 18:36:48 +0200784FunctionEnd
785
786##########################################################
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100787Function SetCustom
788 # Display the _vimrc setting dialog using nsDialogs.
789
790 # Check if a _vimrc should be created
791 ${IfNot} ${SectionIsSelected} ${id_section_vimrc}
792 Abort
793 ${EndIf}
794
795 !insertmacro MUI_HEADER_TEXT \
796 $(str_vimrc_page_title) $(str_vimrc_page_subtitle)
797
798 nsDialogs::Create 1018
799 Pop $vim_dialog
800
801 ${If} $vim_dialog == error
802 Abort
803 ${EndIf}
804
805 ${If} ${RunningX64}
806 SetRegView 64
807 ${EndIf}
808
809 GetFunctionAddress $3 ValidateCustom
810 nsDialogs::OnBack $3
811
812
813 # 1st group - Compatibility
814 ${NSD_CreateGroupBox} 0 0 100% 32% $(str_msg_compat_title)
815 Pop $3
816
817 ${NSD_CreateLabel} 5% 10% 35% 8% $(str_msg_compat_desc)
818 Pop $3
819 ${NSD_CreateDropList} 18% 19% 75% 8% ""
820 Pop $vim_nsd_compat
821 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vi)
822 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_vim)
823 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_defaults)
824 ${NSD_CB_AddString} $vim_nsd_compat $(str_msg_compat_all)
825
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200826 ${If} $vim_compat_stat == "defaults"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100827 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200828 ${ElseIf} $vim_compat_stat == "vim"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100829 StrCpy $4 1
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200830 ${ElseIf} $vim_compat_stat == "vi"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100831 StrCpy $4 0
832 ${Else} # default
833 StrCpy $4 3
834 ${EndIf}
835 ${NSD_CB_SetSelectionIndex} $vim_nsd_compat $4
836
837
838 # 2nd group - Key remapping
839 ${NSD_CreateGroupBox} 0 35% 100% 31% $(str_msg_keymap_title)
840 Pop $3
841
842 ${NSD_CreateLabel} 5% 45% 90% 8% $(str_msg_keymap_desc)
843 Pop $3
844 ${NSD_CreateDropList} 38% 54% 55% 8% ""
845 Pop $vim_nsd_keymap
846 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_default)
847 ${NSD_CB_AddString} $vim_nsd_keymap $(str_msg_keymap_windows)
848
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200849 ${If} $vim_keymap_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100850 StrCpy $4 1
851 ${Else} # default
852 StrCpy $4 0
853 ${EndIf}
854 ${NSD_CB_SetSelectionIndex} $vim_nsd_keymap $4
855
856
857 # 3rd group - Mouse behavior
858 ${NSD_CreateGroupBox} 0 69% 100% 31% $(str_msg_mouse_title)
859 Pop $3
860
861 ${NSD_CreateLabel} 5% 79% 90% 8% $(str_msg_mouse_desc)
862 Pop $3
863 ${NSD_CreateDropList} 23% 87% 70% 8% ""
864 Pop $vim_nsd_mouse
865 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_default)
866 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_windows)
867 ${NSD_CB_AddString} $vim_nsd_mouse $(str_msg_mouse_unix)
868
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200869 ${If} $vim_mouse_stat == "xterm"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100870 StrCpy $4 2
Bram Moolenaarceb56dd2020-07-14 22:24:40 +0200871 ${ElseIf} $vim_mouse_stat == "windows"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100872 StrCpy $4 1
873 ${Else} # default
874 StrCpy $4 0
875 ${EndIf}
876 ${NSD_CB_SetSelectionIndex} $vim_nsd_mouse $4
877
878 ${If} ${RunningX64}
879 SetRegView lastused
880 ${EndIf}
881
882 nsDialogs::Show
883FunctionEnd
884
885Function ValidateCustom
886 ${NSD_CB_GetSelectionIndex} $vim_nsd_compat $3
887 ${If} $3 = 0
888 StrCpy $vim_compat_stat "vi"
889 ${ElseIf} $3 = 1
890 StrCpy $vim_compat_stat "vim"
891 ${ElseIf} $3 = 2
892 StrCpy $vim_compat_stat "defaults"
893 ${Else}
894 StrCpy $vim_compat_stat "all"
895 ${EndIf}
896
897 ${NSD_CB_GetSelectionIndex} $vim_nsd_keymap $3
898 ${If} $3 = 0
899 StrCpy $vim_keymap_stat "default"
900 ${Else}
901 StrCpy $vim_keymap_stat "windows"
902 ${EndIf}
903
904 ${NSD_CB_GetSelectionIndex} $vim_nsd_mouse $3
905 ${If} $3 = 0
906 StrCpy $vim_mouse_stat "default"
907 ${ElseIf} $3 = 1
908 StrCpy $vim_mouse_stat "windows"
909 ${Else}
910 StrCpy $vim_mouse_stat "xterm"
911 ${EndIf}
912FunctionEnd
913
914##########################################################
915# Description for Installer Sections
916
917!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
918 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_old_ver} $(str_desc_old_ver)
919 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_exe} $(str_desc_exe)
920 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_console} $(str_desc_console)
921 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_batch} $(str_desc_batch)
922 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_icons} $(str_desc_icons)
923 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_desktop} $(str_desc_desktop)
924 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_startmenu} $(str_desc_start_menu)
925 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_editwith} $(str_desc_edit_with)
926 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_vimrc} $(str_desc_vim_rc)
927 !insertmacro MUI_DESCRIPTION_TEXT ${id_group_plugin} $(str_desc_plugin)
928 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginhome} $(str_desc_plugin_home)
929 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_pluginvim} $(str_desc_plugin_vim)
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100930!ifdef HAVE_NLS
931 !insertmacro MUI_DESCRIPTION_TEXT ${id_section_nls} $(str_desc_nls)
932!endif
933!insertmacro MUI_FUNCTION_DESCRIPTION_END
934
935
936##########################################################
937# Uninstaller Functions and Sections
938
939Function un.onInit
940!ifdef HAVE_MULTI_LANG
941 # Get the language from the registry.
942 !insertmacro MUI_UNGETLANGUAGE
943!endif
944FunctionEnd
945
946Section "un.$(str_unsection_register)" id_unsection_register
947 SectionIn RO
948
Bram Moolenaar071d4272004-06-13 20:20:40 +0000949 # Apparently $INSTDIR is set to the directory where the uninstaller is
950 # created. Thus the "vim61" directory is included in it.
951 StrCpy $0 "$INSTDIR"
952
Bram Moolenaar071d4272004-06-13 20:20:40 +0000953 # delete the context menu entry and batch files
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100954 DetailPrint "$(str_msg_unregistering)"
Bram Moolenaar30e8e732019-09-27 13:08:36 +0200955 nsExec::Exec "$0\uninstall.exe -nsis"
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100956 Pop $3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000957
958 # We may have been put to the background when uninstall did something.
959 BringToFront
960
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100961 # Delete the installer language setting.
962 DeleteRegKey ${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
963SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000964
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100965Section "un.$(str_unsection_exe)" id_unsection_exe
966
967 StrCpy $0 "$INSTDIR"
968
969 # Delete gettext and iconv DLLs
970 ${If} ${FileExists} "$0\libiconv-2.dll"
971 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
972 "$0\libiconv-2.dll"
Bram Moolenaar6199d432017-10-14 19:05:44 +0200973 ${EndIf}
Bram Moolenaaraf610b82018-12-21 16:22:50 +0100974 ${If} ${FileExists} "$0\libintl-8.dll"
975 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
976 "$0\libintl-8.dll"
977 ${EndIf}
978 ${If} ${FileExists} "$0\libgcc_s_sjlj-1.dll"
979 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
980 "$0\libgcc_s_sjlj-1.dll"
981 ${EndIf}
982
983 # Delete other DLLs
984 Delete /REBOOTOK $0\*.dll
985
986 # Delete 64-bit GvimExt
987 ${If} ${RunningX64}
988 !define LIBRARY_X64
989 ${If} ${FileExists} "$0\GvimExt64\gvimext.dll"
990 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
991 "$0\GvimExt64\gvimext.dll"
992 ${EndIf}
993 ${If} ${FileExists} "$0\GvimExt64\libiconv-2.dll"
994 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
995 "$0\GvimExt64\libiconv-2.dll"
996 ${EndIf}
997 ${If} ${FileExists} "$0\GvimExt64\libintl-8.dll"
998 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
999 "$0\GvimExt64\libintl-8.dll"
1000 ${EndIf}
1001 ${If} ${FileExists} "$0\GvimExt64\libwinpthread-1.dll"
1002 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1003 "$0\GvimExt64\libwinpthread-1.dll"
1004 ${EndIf}
1005 !undef LIBRARY_X64
1006 RMDir /r $0\GvimExt64
1007 ${EndIf}
1008
1009 # Delete 32-bit GvimExt
1010 ${If} ${FileExists} "$0\GvimExt32\gvimext.dll"
1011 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1012 "$0\GvimExt32\gvimext.dll"
1013 ${EndIf}
1014 ${If} ${FileExists} "$0\GvimExt32\libiconv-2.dll"
1015 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1016 "$0\GvimExt32\libiconv-2.dll"
1017 ${EndIf}
1018 ${If} ${FileExists} "$0\GvimExt32\libintl-8.dll"
1019 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1020 "$0\GvimExt32\libintl-8.dll"
1021 ${EndIf}
1022 ${If} ${FileExists} "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1023 !insertmacro UninstallLib DLL NOTSHARED REBOOT_NOTPROTECTED \
1024 "$0\GvimExt32\libgcc_s_sjlj-1.dll"
1025 ${EndIf}
1026 RMDir /r $0\GvimExt32
Bram Moolenaar6199d432017-10-14 19:05:44 +02001027
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 ClearErrors
1029 # Remove everything but *.dll files. Avoids that
1030 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +00001031 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032 RMDir /r $0\colors
1033 RMDir /r $0\compiler
1034 RMDir /r $0\doc
1035 RMDir /r $0\ftplugin
Bram Moolenaar44433da2022-05-06 18:08:52 +01001036 RMDir /r $0\import
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 RMDir /r $0\indent
1038 RMDir /r $0\macros
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001039 RMDir /r $0\pack
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +00001041 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 RMDir /r $0\syntax
1043 RMDir /r $0\tools
1044 RMDir /r $0\tutor
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 RMDir /r $0\lang
1046 RMDir /r $0\keymap
1047 Delete $0\*.exe
1048 Delete $0\*.bat
1049 Delete $0\*.vim
1050 Delete $0\*.txt
1051
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001052 ${If} ${Errors}
1053 MessageBox MB_OK|MB_ICONEXCLAMATION $(str_msg_rm_exe_fail) /SD IDOK
1054 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001055
1056 # No error message if the "vim62" directory can't be removed, the
1057 # gvimext.dll may still be there.
1058 RMDir $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001059SectionEnd
Bram Moolenaar071d4272004-06-13 20:20:40 +00001060
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001061# Remove "vimfiles" directory under the specified directory.
1062!macro RemoveVimfiles dir
1063 ${If} ${FileExists} ${dir}\vimfiles
1064 RMDir ${dir}\vimfiles\colors
1065 RMDir ${dir}\vimfiles\compiler
1066 RMDir ${dir}\vimfiles\doc
1067 RMDir ${dir}\vimfiles\ftdetect
1068 RMDir ${dir}\vimfiles\ftplugin
1069 RMDir ${dir}\vimfiles\indent
1070 RMDir ${dir}\vimfiles\keymap
1071 RMDir ${dir}\vimfiles\plugin
1072 RMDir ${dir}\vimfiles\syntax
1073 RMDir ${dir}\vimfiles
1074 ${EndIf}
1075!macroend
1076
1077SectionGroup "un.$(str_ungroup_plugin)" id_ungroup_plugin
1078 Section /o "un.$(str_unsection_plugin_home)" id_unsection_plugin_home
1079 # get the home dir
Christopher Plewrighteea0a002023-02-17 20:04:51 +00001080 Call un.GetHomeDir
1081 Pop $0
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001082
1083 ${If} $0 != ""
1084 !insertmacro RemoveVimfiles $0
1085 ${EndIf}
1086 SectionEnd
1087
1088 Section "un.$(str_unsection_plugin_vim)" id_unsection_plugin_vim
1089 # get the parent dir of the installation
1090 Push $INSTDIR
1091 Call un.GetParent
1092 Pop $0
1093
1094 # if a plugin dir was created at installation remove it
1095 !insertmacro RemoveVimfiles $0
1096 SectionEnd
1097SectionGroupEnd
1098
1099Section "un.$(str_unsection_rootdir)" id_unsection_rootdir
Bram Moolenaar071d4272004-06-13 20:20:40 +00001100 # get the parent dir of the installation
1101 Push $INSTDIR
1102 Call un.GetParent
1103 Pop $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104
Bram Moolenaara8d22e32019-04-12 21:29:33 +02001105 ${IfNot} ${Silent}
1106 Delete $0\_vimrc
1107 ${Endif}
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001108 RMDir $0
Bram Moolenaar071d4272004-06-13 20:20:40 +00001109SectionEnd
Bram Moolenaaraf610b82018-12-21 16:22:50 +01001110
1111##########################################################
1112# Description for Uninstaller Sections
1113
1114!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
1115 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_register} $(str_desc_unregister)
1116 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_exe} $(str_desc_rm_exe)
1117 !insertmacro MUI_DESCRIPTION_TEXT ${id_ungroup_plugin} $(str_desc_rm_plugin)
1118 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_home} $(str_desc_rm_plugin_home)
1119 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_plugin_vim} $(str_desc_rm_plugin_vim)
1120 !insertmacro MUI_DESCRIPTION_TEXT ${id_unsection_rootdir} $(str_desc_rm_rootdir)
1121!insertmacro MUI_UNFUNCTION_DESCRIPTION_END