Commits

Steve Losh committed 8545485 Merge

Merge.

  • Participants
  • Parent commits d34fe86, 8586ee6

Comments (0)

Files changed (2)

File doc/vitality.txt

 CONTENTS                                                   *vitality-contents*
 
     1. Overview and Usage .............. |VitalityOverview|
-    2. How it Works .................... |VitalityHow|
-    3. License ......................... |VitalityLicense|
-    4. Bugs ............................ |VitalityBugs|
-    5. Contributing .................... |VitalityContributing|
-    6. Changelog ....................... |VitalityChangelog|
+    2. Configuration ................... |VitalityConfig|
+        2.1 g:vitality_fix_cursor ...... |vitality_fix_cursor|
+        2.2 g:vitality_fix_focus ....... |vitality_fix_focus|
+    3. How it Works .................... |VitalityHow|
+    4. License ......................... |VitalityLicense|
+    5. Bugs ............................ |VitalityBugs|
+    6. Contributing .................... |VitalityContributing|
+    7. Changelog ....................... |VitalityChangelog|
 
 ==============================================================================
 1. Overview and Usage                       *VitalityOverview* *VitalityUsage*
 are a fiddly little rabbit hole, so it's entirely possible that things will
 sometimes break.
 ==============================================================================
-2. How it Works                                                  *VitalityHow*
+2. Configuration                                              *VitalityConfig*
+
+You can tweak the behavior of Vitality by setting a few variables in your
+:vimrc file. Currently two options are available: >
+
+    let g:vitality_fix_cursor = 0
+    let g:vitality_fix_focus = 0
+
+------------------------------------------------------------------------------
+2.1 g:vitality_fix_cursor                                *vitality_fix_cursor*
+
+Set this to 0 if you want to disable normal/insert block/bar cursor switching.
+
+Default: 1
+
+------------------------------------------------------------------------------
+2.2 g:vitality_fix_focus                                  *vitality_fix_focus*
+
+Set this to 0 if you don't want focus events to be processed.
+
+Default: 1
+
+==============================================================================
+3. How it Works                                                  *VitalityHow*
 
 You don't need to know this.
 
 You now have a friendlier Vim/tmux/iTerm 2 environment!
 
 ==============================================================================
-3. License                                                   *VitalityLicense*
+4. License                                                   *VitalityLicense*
 
 Vitality is MIT/X11 licensed.
 
 ==============================================================================
-4. Bugs                                                         *VitalityBugs*
+5. Bugs                                                         *VitalityBugs*
 
 If you find a bug please post it on the issue tracker:
 http://github.com/sjl/vitality.vim/issues/
 
 ==============================================================================
-5. Contributing                                         *VitalityContributing*
+6. Contributing                                         *VitalityContributing*
 
 Think you can make this plugin better?  Awesome!  Fork it on BitBucket or
 GitHub and send a pull request.
 GitHub: http://github.com/sjl/vitality.vim/
 
 ==============================================================================
-6. Changelog                                               *VitalityChangelog*
+7. Changelog                                               *VitalityChangelog*
 
 v1.0.0
     * Initial stable release.

File plugin/vitality.vim

     " The "focus/save" and "nofocus/restore" each have to be in this order.
     " Trust me, you don't want to go down this rabbit hole.  Just keep them in
     " this order and no one gets hurt.
-    let &t_ti = enable_focus_reporting . save_screen
-    let &t_te = disable_focus_reporting . restore_screen
+    if g:vitality_fix_focus
+        let &t_ti = enable_focus_reporting . save_screen
+        let &t_te = disable_focus_reporting . restore_screen
+    endif
 
     " }}}
     " Insert enter/leave escapes {{{
 
-    " When entering insert mode, change the cursor to a bar.
-    let &t_SI = cursor_to_bar
+    if g:vitality_fix_cursor
+        " When entering insert mode, change the cursor to a bar.
+        let &t_SI = cursor_to_bar
 
-    " When exiting insert mode, change it back to a block.
-    let &t_EI = cursor_to_block
+        " When exiting insert mode, change it back to a block.
+        let &t_EI = cursor_to_block
+    endif
 
     " }}}
     " Focus reporting keys/mappings {{{
+    if g:vitality_fix_focus
+        " Map some of Vim's unused keycodes to the sequences iTerm2 is going to send
+        " on focus lost/gained.
+        "
+        " If you're already using f24 or f25, change them to something else.  Vim
+        " supports up to f37.
+        "
+        " Doing things this way is nicer than just mapping the raw sequences
+        " directly, because Vim won't hang after a bare <Esc> waiting for the rest
+        " of the mapping.
+        execute "set <f24>=\<Esc>[O"
+        execute "set <f25>=\<Esc>[I"
 
-    " Map some of Vim's unused keycodes to the sequences iTerm2 is going to send
-    " on focus lost/gained.
-    "
-    " If you're already using f24 or f25, change them to something else.  Vim
-    " supports up to f37.
-    "
-    " Doing things this way is nicer than just mapping the raw sequences
-    " directly, because Vim won't hang after a bare <Esc> waiting for the rest
-    " of the mapping.
-    execute "set <f24>=\<Esc>[O"
-    execute "set <f25>=\<Esc>[I"
+        " Handle the focus gained/lost signals in each mode separately.
+        "
+        " The goal is to fire the autocmd and restore the state as cleanly as
+        " possible.  This is easy for some modes and hard/impossible for others.
+        "
+        " EXAMPLES:
+        nnoremap <silent> <f24> :doautocmd FocusLost %<cr>
+        nnoremap <silent> <f25> :doautocmd FocusGained %<cr>
 
-    " Handle the focus gained/lost signals in each mode separately.
-    "
-    " The goal is to fire the autocmd and restore the state as cleanly as
-    " possible.  This is easy for some modes and hard/impossible for others.
-    "
-    " EXAMPLES:
-    nnoremap <silent> <f24> :silent doautocmd FocusLost %<cr>
-    nnoremap <silent> <f25> :silent doautocmd FocusGained %<cr>
+        onoremap <silent> <f24> <esc>:silent doautocmd FocusLost %<cr>
+        onoremap <silent> <f25> <esc>:silent doautocmd FocusGained %<cr>
 
-    onoremap <silent> <f24> <esc>:silent doautocmd FocusLost %<cr>
-    onoremap <silent> <f25> <esc>:silent doautocmd FocusGained %<cr>
+        vnoremap <silent> <f24> <esc>:silent doautocmd FocusLost %<cr>gv
+        vnoremap <silent> <f25> <esc>:silent doautocmd FocusGained %<cr>gv
 
-    vnoremap <silent> <f24> <esc>:silent doautocmd FocusLost %<cr>gv
-    vnoremap <silent> <f25> <esc>:silent doautocmd FocusGained %<cr>gv
+        inoremap <silent> <f24> <c-o>:silent doautocmd FocusLost %<cr>
+        inoremap <silent> <f25> <c-o>:silent doautocmd FocusGained %<cr>
 
-    inoremap <silent> <f24> <c-o>:silent doautocmd FocusLost %<cr>
-    inoremap <silent> <f25> <c-o>:silent doautocmd FocusGained %<cr>
-
-    cnoremap <silent> <f24> <c-\>e<SID>DoCmdFocusLost()<cr>
-    cnoremap <silent> <f25> <c-\>e<SID>DoCmdFocusGained()<cr>
+        cnoremap <silent> <f24> <c-\>e<SID>DoCmdFocusLost()<cr>
+        cnoremap <silent> <f25> <c-\>e<SID>DoCmdFocusGained()<cr>
 
     " }}}
 endfunction " }}}