From b85ab88ef4bc1250f29cb05cca238370a4f440e3 Mon Sep 17 00:00:00 2001 From: Josh Petrie Date: Mon, 24 Jan 2022 20:02:02 -0800 Subject: [PATCH] Use `did_install_default_mac_menus` to skip macOS-specific menu setup. Previously, if you used `did_install_default_menus` to skip default menu generation, you'd get an error at startup about macmenu not finding the menus it expected to. This changes lets you set `did_install_default_mac_menus` after setting `did_install_default_menus` to fix the error, or simply to disable all of MacVim's default command key and action mappings. --- runtime/doc/gui_mac.txt | 14 ++++- runtime/menu.vim | 115 +++++++++++++++++++++------------------- 2 files changed, 72 insertions(+), 57 deletions(-) diff --git a/runtime/doc/gui_mac.txt b/runtime/doc/gui_mac.txt index c41093826a..a0bdd0b246 100644 --- a/runtime/doc/gui_mac.txt +++ b/runtime/doc/gui_mac.txt @@ -1,4 +1,4 @@ -*gui_mac.txt* For Vim version 8.2. Last change: 2020 Aug 13 +*gui_mac.txt* For Vim version 8.2. Last change: 2022 Jan 24 VIM REFERENCE MANUAL by Bjorn Winckler @@ -94,6 +94,18 @@ with the Apple Human Interface Guidelines (HIG). The Help menu's search can be used to search Vim's documentation. You can use it to quickly find the documentation you want in addition to using |:help|. +If you want to disable configuration of command key equivalents when Vim +sources |menu.vim| you can add this line to your .vimrc file: > + :let did_install_default_mac_menus = 1 + +This is particularly useful if you have opted to disable generation of the +default menus themselves (by setting 'did_install_default_menus = 1'). +Otherwise, you may get errors on startup due to missing menus. + +Because 'filetype' and 'syntax' both cause Vim to source |menu.vim|, you +must set 'did_install_default_mac_menus' before executing those commands in +your .vimrc. + *macvim-window-title* The default window title does not include the argument list because it looks really bad once you start using tabs. For example, dropping two files, then diff --git a/runtime/menu.vim b/runtime/menu.vim index d1cf3c2990..87f429ec1f 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -1299,62 +1299,65 @@ unlet s:cpo_save if has("gui_macvim") - " - " Set up menu key equivalents (these should always have the 'D' modifier - " set), action bindings, and alternate items. - " - " Note: menu items which should execute an action are bound to ; the - " action message is specified here via the :macmenu command. - " - macm File.New\ Window key= action=newWindow: - macm File.New\ Tab key= - macm File.Open… key= action=fileOpen: - macm File.Open\ Tab\.\.\.:tabnew key= - macm File.Open\ Recent action=recentFilesDummy: - macm File.Close\ Window:qa key= - macm File.Close key= action=performClose: - macm File.Save:w key= - macm File.Save\ All key= alt=YES - macm File.Save\ As…:sav key= - macm File.Print key= - - macm Edit.Undou key= action=undo: - macm Edit.Redo^R key= action=redo: - macm Edit.Cut"+x key= action=cut: - macm Edit.Copy"+y key= action=copy: - macm Edit.Paste"+gP key= action=paste: - macm Edit.Select\ AllggVG key= action=selectAll: - macm Edit.Find.Find… key= - macm Edit.Find.Find\ Next key= action=findNext: - macm Edit.Find.Find\ Previous key= action=findPrevious: - macm Edit.Find.Use\ Selection\ for\ Find key= action=useSelectionForFind: - macm Edit.Font.Show\ Fonts action=orderFrontFontPanel: - macm Edit.Font.Bigger key= action=fontSizeUp: - macm Edit.Font.Smaller key= action=fontSizeDown: - - macm Tools.Spelling.To\ Next\ Error]s key= - macm Tools.Spelling.Suggest\ Correctionsz= key= - macm Tools.Make:make key= - macm Tools.List\ Errors:cl key= - macm Tools.Next\ Error:cn key= - macm Tools.Previous\ Error:cp key= - macm Tools.Older\ List:cold key= - macm Tools.Newer\ List:cnew key= - - macm Window.Minimize key= action=performMiniaturize: - macm Window.Minimize\ All key= action=miniaturizeAll: alt=YES - macm Window.Zoom key= action=performZoom: - macm Window.Zoom\ All key= action=zoomAll: alt=YES - macm Window.Toggle\ Full\ Screen\ Mode key= - macm Window.Show\ Next\ Tab key= - macm Window.Show\ Previous\ Tab key= - macm Window.Bring\ All\ To\ Front action=arrangeInFront: - macm Window.Stay\ in\ Front action=stayInFront: - macm Window.Stay\ in\ Back action=stayInBack: - macm Window.Stay\ Level\ Normal action=stayLevelNormal: - - macm Help.MacVim\ Help key= - macm Help.MacVim\ Website action=openWebsite: + if !exists("did_install_default_mac_menus") + let did_install_default_mac_menus = 1 + " + " Set up menu key equivalents (these should always have the 'D' modifier + " set), action bindings, and alternate items. + " + " Note: menu items which should execute an action are bound to ; the + " action message is specified here via the :macmenu command. + " + macm File.New\ Window key= action=newWindow: + macm File.New\ Tab key= + macm File.Open… key= action=fileOpen: + macm File.Open\ Tab\.\.\.:tabnew key= + macm File.Open\ Recent action=recentFilesDummy: + macm File.Close\ Window:qa key= + macm File.Close key= action=performClose: + macm File.Save:w key= + macm File.Save\ All key= alt=YES + macm File.Save\ As…:sav key= + macm File.Print key= + + macm Edit.Undou key= action=undo: + macm Edit.Redo^R key= action=redo: + macm Edit.Cut"+x key= action=cut: + macm Edit.Copy"+y key= action=copy: + macm Edit.Paste"+gP key= action=paste: + macm Edit.Select\ AllggVG key= action=selectAll: + macm Edit.Find.Find… key= + macm Edit.Find.Find\ Next key= action=findNext: + macm Edit.Find.Find\ Previous key= action=findPrevious: + macm Edit.Find.Use\ Selection\ for\ Find key= action=useSelectionForFind: + macm Edit.Font.Show\ Fonts action=orderFrontFontPanel: + macm Edit.Font.Bigger key= action=fontSizeUp: + macm Edit.Font.Smaller key= action=fontSizeDown: + + macm Tools.Spelling.To\ Next\ Error]s key= + macm Tools.Spelling.Suggest\ Correctionsz= key= + macm Tools.Make:make key= + macm Tools.List\ Errors:cl key= + macm Tools.Next\ Error:cn key= + macm Tools.Previous\ Error:cp key= + macm Tools.Older\ List:cold key= + macm Tools.Newer\ List:cnew key= + + macm Window.Minimize key= action=performMiniaturize: + macm Window.Minimize\ All key= action=miniaturizeAll: alt=YES + macm Window.Zoom key= action=performZoom: + macm Window.Zoom\ All key= action=zoomAll: alt=YES + macm Window.Toggle\ Full\ Screen\ Mode key= + macm Window.Show\ Next\ Tab key= + macm Window.Show\ Previous\ Tab key= + macm Window.Bring\ All\ To\ Front action=arrangeInFront: + macm Window.Stay\ in\ Front action=stayInFront: + macm Window.Stay\ in\ Back action=stayInBack: + macm Window.Stay\ Level\ Normal action=stayLevelNormal: + + macm Help.MacVim\ Help key= + macm Help.MacVim\ Website action=openWebsite: + endif endif if has("touchbar")