Skip to content

Commit 3da5da2

Browse files
committed
Bundle vimtutor with MacVim and provide Help menu item to open it
MacVim has previously not included vimtutor, meaning the user had to obtain it elsewhere. Change the build scripts to copy it over to the app bundle so that it's under MacVim.app/Contents/bin just like `mvim` etc. Also, provide a Help menu item to open vimtutor. The menu action will also make sure to override the PATH first to prevent accidentally opening other installed MacVim/Vim versions since vimtutor works by searching PATH instead of explicitly passing in the Vim executable path.
1 parent d0139e4 commit 3da5da2

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

runtime/doc/usr_01.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ On Unix, if Vim has been properly installed, you can start it from the shell:
118118
On MS-Windows you can find it in the Program/Vim menu. Or execute
119119
vimtutor.bat in the $VIMRUNTIME directory.
120120

121+
On MacVim, you can run `vimtutor` from the shell, or select "Vim Tutor" in the
122+
Help menu.
123+
121124
This will make a copy of the tutor file, so that you can edit it without
122125
the risk of damaging the original.
123126
There are a few translated versions of the tutor. To find out if yours is

runtime/menu.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ if has("gui_macvim")
102102
an <silent> 9999.2 Help.MacVim\ Website <Nop>
103103
an 9999.3 &Help.-sep0- <Nop>
104104
endif
105+
if has("gui_macvim")
106+
" Run vimtutor in GUI mode. Need to make sure to override the PATH so we use
107+
" this app instead of accidentally opening another installed Vim/MacVim.
108+
an 9999.5 &Help.Vim\ Tutor :silent !PATH="$VIM/../../bin":/usr/bin:/bin:/usr/sbin:/sbin $VIM/../../bin/vimtutor -g&<CR>
109+
tln 9999.5 &Help.Vim\ Tutor <C-W>:silent !PATH="$VIM/../../bin":/usr/bin:/bin:/usr/sbin:/sbin $VIM/../../bin/vimtutor -g&<CR>
110+
an 9999.6 &Help.-sep-vim-tutor- <Nop>
111+
endif
105112
an 9999.10 &Help.&Overview<Tab><F1> :help<CR>
106113
an 9999.20 &Help.&User\ Manual :help usr_toc<CR>
107114
an 9999.30 &Help.&How-To\ Links :help how-to<CR>

src/MacVim/MMAppController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ - (void)refreshMainMenu
906906
// of Screen" to the Window menu, and on repeated calls it will keep adding
907907
// the same item over and over again, without resolving for duplicates. Using
908908
// copies help keep the source menu clean.
909-
NSMenu *mainMenu = [currentMainMenu copy];
909+
NSMenu *mainMenu = [[currentMainMenu copy] autorelease];
910910

911911
// If the new menu has a "Recent Files" dummy item, then swap the real item
912912
// for the dummy. We are forced to do this since Cocoa initializes the

src/MacVim/MacVim.xcodeproj/project.pbxproj

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -840,6 +840,7 @@
840840
1D1C31F00EFFBFD6003FE9A5 /* Make Document Icons */,
841841
528DA6671426D456003380F1 /* Copy Scripts */,
842842
52283AB71EBA200C00A6F6B9 /* Copy mvim scripts */,
843+
90C052E1251E889500E2D81E /* Copy vimtutor */,
843844
);
844845
buildRules = (
845846
);
@@ -1003,6 +1004,26 @@
10031004
shellScript = "# Copy all the locale translation files from the po folder to\n# runtime/lang/<lang>/LC_MESSAGES/vim.mo. Need to do this because unlike normal\n# Vim, MacVim is distributed as a standalone app package and therefore we don't\n# want to install these files to a global location (e.g.\n# /usr/local/share/locale/). This is similar to how Windows installation\n# (po/Make_mvc.mak) works.\ncd \"${SRCROOT}\"/..\nmake macvim-install-languages DEST_LANG=\"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/vim/runtime/lang\"\n";
10041005
showEnvVarsInLog = 0;
10051006
};
1007+
90C052E1251E889500E2D81E /* Copy vimtutor */ = {
1008+
isa = PBXShellScriptBuildPhase;
1009+
alwaysOutOfDate = 1;
1010+
buildActionMask = 2147483647;
1011+
files = (
1012+
);
1013+
inputFileListPaths = (
1014+
);
1015+
inputPaths = (
1016+
);
1017+
name = "Copy vimtutor";
1018+
outputFileListPaths = (
1019+
);
1020+
outputPaths = (
1021+
);
1022+
runOnlyForDeploymentPostprocessing = 0;
1023+
shellPath = /bin/sh;
1024+
shellScript = "BINPATH=$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/bin\nmkdir -p \"${BINPATH}\"\ncp -a \"${SRCROOT}/../vimtutor\" \"${BINPATH}/vimtutor\"\ncp -a \"${SRCROOT}/../gvimtutor\" \"${BINPATH}/gvimtutor\"\nchmod 755 \"${BINPATH}/vimtutor\"\nchmod 755 \"${BINPATH}/gvimtutor\"\ncd \"${BINPATH}\"\nln -fs gvimtutor mvimtutor \n";
1025+
showEnvVarsInLog = 0;
1026+
};
10061027
/* End PBXShellScriptBuildPhase section */
10071028

10081029
/* Begin PBXSourcesBuildPhase section */

0 commit comments

Comments
 (0)