" System gvimrc file for MacVim
"
" Maintainer:	Bjorn Winckler <bjorn.winckler@gmail.com>
" Last Change:	Sun Mar 15 2009
"
" This is a work in progress.  If you feel so inclined, please help me improve
" this file.


" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
" <CR> would not be recognized.  See ":help 'cpoptions'".
let s:cpo_save = &cpo
set cpo&vim


"
" Global default options
"

if !exists("syntax_on")
  syntax on
endif

if !exists("colors_name")
    " Use the macvim color scheme by default
    colorscheme macvim
endif

" To make tabs more readable, the label only contains the tail of the file
" name and the buffer modified flag.
set guitablabel=%M%t


" Send print jobs to Preview.app.  This does not delete the temporary ps file
" that is generated by :hardcopy.
set printexpr=system('open\ -a\ Preview\ '.v:fname_in)\ +\ v:shell_error


"
" Extra menus
"


" File menu

aunmenu File.New
aunmenu File.Open\.\.\.
aunmenu File.Close
aunmenu File.-SEP4-
aunmenu File.Exit
aunmenu File.Save-Exit

an <silent> 10.290 File.New\ Window             <Nop>
an  10.295 File.New\ Tab                        :tabnew<CR>
an <silent> 10.310 File.Open\.\.\.              <Nop>
an <silent> 10.325 File.Open\ Recent            <Nop>
an 10.328 File.-SEP0-                           <Nop>
an <silent> 10.330 File.Close\ Window<Tab>:qa   :conf qa<CR>
an <silent> 10.332 File.Close                   :conf q<CR>
an <silent> 10.341 File.Save\ All               :browse conf wa<CR>
an 10.350 File.Save\ As\.\.\.<Tab>:sav	        :browse confirm saveas<CR>


" Edit menu

" The following function is aken from menu.vim
fun! s:FixFText()
  " Fix text in nameless register to be used with :promptfind.
  return substitute(@", "[\r\n]", '\\n', 'g')
endfun

aunmenu Edit.Find
aunmenu Edit.Find\ and\ Replace

an <silent> 20.410.10 Edit.Find.Find\.\.\.  :promptfind<CR>
vunmenu Edit.Find.Find\.\.\.
vnoremenu <silent> Edit.Find.Find\.\.\.     y:promptfind <C-R>=<SID>FixFText()<CR><CR>
an 20.410.20 Edit.Find.Find\ Next           <Nop>
an 20.410.30 Edit.Find.Find\ Previous       <Nop>
vmenu 20.410.35 Edit.Find.Use\ Selection\ for\ Find y:let @/=@"<CR>:<BS>

an 20.460 Edit.-SEP4-                       <Nop>
an 20.465.10 Edit.Font.Show\ Fonts          <Nop>
an 20.465.20 Edit.Font.-SEP5-               <Nop>
an 20.465.30 Edit.Font.Bigger               <Nop>
an 20.465.40 Edit.Font.Smaller              <Nop>
an 20.470 Edit.Special\ Characters\.\.\.    <Nop>


" Window menu (should be next to Help so give it a high priority)
aunmenu Window

an <silent> 9900.300 Window.Minimize            <Nop>
an <silent> 9900.301 Window.Minimize\ All       <Nop>
an <silent> 9900.310 Window.Zoom                <Nop>
an <silent> 9900.311 Window.Zoom\ All           <Nop>
an <silent> 9900.320 Window.Toggle\ Full\ Screen\ Mode  :set invfullscreen<CR>
an 9900.330 Window.-SEP1-                       <Nop>
" TODO! Grey out if no tabs are visible.
an <silent> 9900.340 Window.Previous\ Tab       :tabprevious<CR>
an <silent> 9900.350 Window.Next\ Tab           :tabnext<CR>
an 9900.360 Window.-SEP2-                       <Nop>
an <silent> 9900.370 Window.Bring\ All\ To\ Front <Nop>


" Help menu
an 9999.1 Help.MacVim\ Help                 :h gui_mac<CR>
an <silent> 9999.2 Help.MacVim\ Website     <Nop>
an 9999.3 Help.-sep0-                       <Nop>


"
" Toolbar
"
" These items are special ('*' means zero or more arbitrary characters):
"   -space*-        an empty space
"   -flexspace*-    a flexible space
"   -*-             a separator item

" Remove some items so that all items are visible at the default window size.
"aunmenu ToolBar.Undo
"aunmenu ToolBar.Redo
"aunmenu ToolBar.-sep2-
"aunmenu ToolBar.Cut
"aunmenu ToolBar.Copy
"aunmenu ToolBar.Paste
"aunmenu ToolBar.-sep3-
aunmenu ToolBar.Replace
aunmenu ToolBar.FindNext
aunmenu ToolBar.FindPrev
aunmenu ToolBar.-sep5-
aunmenu ToolBar.-sep6-
aunmenu ToolBar.RunCtags
aunmenu ToolBar.TagJump
"aunmenu ToolBar.-sep7-
aunmenu ToolBar.FindHelp

"an 1.295 ToolBar.-flexspace7-   <Nop>



" This is so that HIG Cmd and Option movement mappings can be disabled by
" adding the line
"   let macvim_skip_cmd_opt_movement = 1
" to the user .vimrc
"
if !exists("macvim_skip_cmd_opt_movement")
  no   <D-Left>       <Home>
  no!  <D-Left>       <Home>
  no   <M-Left>       <C-Left>
  no!  <M-Left>       <C-Left>

  no   <D-Right>      <End>
  no!  <D-Right>      <End>
  no   <M-Right>      <C-Right>
  no!  <M-Right>      <C-Right>

  no   <D-Up>         <C-Home>
  ino  <D-Up>         <C-Home>
  map  <M-Up>         {
  imap <M-Up>         <C-o>{

  no   <D-Down>       <C-End>
  ino  <D-Down>       <C-End>
  map  <M-Down>       }
  imap <M-Down>       <C-o>}

  imap <M-BS>         <C-w>
  imap <D-BS>         <C-u>
endif " !exists("macvim_skip_cmd_opt_movement")


" This is so that the HIG shift movement related settings can be enabled by
" adding the line
"   let macvim_hig_shift_movement = 1
" to the user .vimrc (not .gvimrc!).
"
if exists("macvim_hig_shift_movement")
  " Shift + special movement key (<S-Left>, etc.) and mouse starts insert mode
  set selectmode=mouse,key
  set keymodel=startsel,stopsel

  " HIG related shift + special movement key mappings
  nn   <S-D-Left>     <S-Home>
  vn   <S-D-Left>     <S-Home>
  ino  <S-D-Left>     <S-Home>
  nn   <S-M-Left>     <S-C-Left>
  vn   <S-M-Left>     <S-C-Left>
  ino  <S-M-Left>     <S-C-Left>

  nn   <S-D-Right>    <S-End>
  vn   <S-D-Right>    <S-End>
  ino  <S-D-Right>    <S-End>
  nn   <S-M-Right>    <S-C-Right>
  vn   <S-M-Right>    <S-C-Right>
  ino  <S-M-Right>    <S-C-Right>

  nn   <S-D-Up>       <S-C-Home>
  vn   <S-D-Up>       <S-C-Home>
  ino  <S-D-Up>       <S-C-Home>

  nn   <S-D-Down>     <S-C-End>
  vn   <S-D-Down>     <S-C-End>
  ino  <S-D-Down>     <S-C-End>
endif " exists("macvim_hig_shift_movement")



"
" 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 <Nop>; the
" action message is specified here via the :macmenu command.
"

macm File.New\ Window                       key=<D-n> action=newWindow:
macm File.New\ Tab                          key=<D-t>
macm File.Open\.\.\.                        key=<D-o> action=fileOpen:
macm File.Open\ Tab\.\.\.                   key=<D-T>
macm File.Open\ Recent                      action=recentFilesDummy:
macm File.Close\ Window                     key=<D-W>
macm File.Close                             key=<D-w> action=performClose:
macm File.Save                              key=<D-s>
macm File.Save\ All                         key=<D-M-s> alt=YES
macm File.Save\ As\.\.\.                    key=<D-S>
macm File.Print                             key=<D-p>

macm Edit.Undo                              key=<D-z> action=undo:
macm Edit.Redo                              key=<D-Z> action=redo:
macm Edit.Cut                               key=<D-x> action=cut:
macm Edit.Copy                              key=<D-c> action=copy:
macm Edit.Paste                             key=<D-v> action=paste:
macm Edit.Select\ All                       key=<D-a> action=selectAll:
macm Edit.Find.Find\.\.\.                   key=<D-f>
macm Edit.Find.Find\ Next                   key=<D-g> action=findNext:
macm Edit.Find.Find\ Previous               key=<D-G> action=findPrevious:
macm Edit.Find.Use\ Selection\ for\ Find    key=<D-e>
macm Edit.Special\ Characters\.\.\.         key=<D-M-t>
macm Edit.Font.Show\ Fonts                  action=orderFrontFontPanel:
macm Edit.Font.Bigger                       key=<D-=> action=fontSizeUp:
macm Edit.Font.Smaller                      key=<D--> action=fontSizeDown:
macm Edit.Special\ Characters\.\.\.         action=orderFrontCharacterPalette:

macm Tools.Spelling.To\ Next\ error         key=<D-;>
macm Tools.Spelling.Suggest\ Corrections    key=<D-:>
macm Tools.Make                             key=<D-b>
macm Tools.List\ Errors                     key=<D-l>
macm Tools.List\ Messages                   key=<D-L>
macm Tools.Next\ Error                      key=<D-C-Right>
macm Tools.Previous\ Error                  key=<D-C-Left>
macm Tools.Older\ List                      key=<D-C-Up>
macm Tools.Newer\ List                      key=<D-C-Down>

macm Window.Minimize        key=<D-m>       action=performMiniaturize:
macm Window.Minimize\ All   key=<D-M-m>     action=miniaturizeAll:  alt=YES
macm Window.Zoom            key=<D-C-z>     action=performZoom:
macm Window.Zoom\ All       key=<D-M-C-z>   action=zoomAll:         alt=YES
macm Window.Toggle\ Full\ Screen\ Mode  key=<D-F>
macm Window.Previous\ Tab               key=<D-{>
macm Window.Next\ Tab                   key=<D-}>
macm Window.Bring\ All\ To\ Front       action=arrangeInFront:

macm Help.MacVim\ Help                  key=<D-?>
macm Help.MacVim\ Website               action=openWebsite:

" Restore the previous value of 'cpoptions'.
let &cpo = s:cpo_save
unlet s:cpo_save
