Browse Source

clean up vimrc, set tmux $TERM to xterm-256color

Removed some unused settings, shifted other bits around, commented out ones that
might be useful later. 'xterm-256color' has implications for some vim tty
settings. Also added bundles for vdebug and vim-repeat.
Weiyi Lou 12 years ago
parent
commit
bb3cabc3fc
3 changed files with 97 additions and 88 deletions
  1. 24 19
      tmux/tmux.conf
  2. 8 1
      vim/vimrc.bundles.local
  3. 65 68
      vim/vimrc.local

+ 24 - 19
tmux/tmux.conf

@@ -1,12 +1,17 @@
-# use Ctrl-A as the tmux command prefix instead of Ctrl-B
+# Use `Ctrl-A` as the tmux command prefix instead of `Ctrl-B`.
 unbind C-b
 set-option -g prefix C-a
 
-# start windows and panes from 1, not 0
+# Report the same $TERM value as we use for our terminal emulator (yes, go and
+# set this) This influences, among other things, certain vim settings related to
+# colours, rendering speed and mouse support.
+set -g default-terminal "xterm-256color"
+
+# Start windows and panes from `1`, not `0`.
 set-option -g base-index 1
 set-option -g pane-base-index 1
 
-# history scrollback
+# History scrollback.
 set-option -g history-limit 9999999
 
 # Display a status line message when activity occurs in a window for which the
@@ -26,7 +31,7 @@ set-option -g mouse-select-pane
 set-option -g mouse-resize-pane on
 set-option -g mouse-select-window on
 
-# act like vim
+# Act like vim.
 set-option -g status-keys vi
 set-window-option -g mode-keys vi # vi keys in copy mode (prefix+[)
 
@@ -35,14 +40,14 @@ set-window-option -g mode-keys vi # vi keys in copy mode (prefix+[)
 # General Key Bindings
 #######################
 
-# act like vim. enhance copy mode to use more vim like keys for copying
+# Act like vim. Enhance copy mode to use more vim like keys for copying.
 bind-key -t vi-copy 'v' begin-selection
 bind-key -t vi-copy 'y' copy-selection
 
-# prefix+R to reload the config file
+# Use prefix+r to reload the config file.
 bind-key C-r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded";
 
-# detach client like screen, C-a C-d
+# Detach client like screen, <C-a> <C-d>.
 bind-key C-d detach-client
 
 
@@ -50,7 +55,7 @@ bind-key C-d detach-client
 # Window/Pane/Session Manipulation
 ###################################
 
-# Window Movement
+# Window Movement.
 bind-key -r C-h previous-window
 bind-key -r C-l next-window
 bind-key C-a last-window
@@ -65,42 +70,42 @@ bind-key -n M-8 select-window -t 8
 bind-key -n M-9 select-window -t 9
 bind-key -n M-0 select-window -t 10
 
-# Window Creation/Destruction
+# Window Creation/Destruction.
 bind-key C-c new-window
-# Remember `prefix+,` for renaming windows
+# Remember prefix+, for renaming windows.
 
-# Pane Movement
+# Pane Movement.
 bind-key h select-pane -L
 bind-key j select-pane -D
 bind-key k select-pane -U
 bind-key l select-pane -R
 
-# Pane Creation/Destruction
-unbind % # Remove default binding for horizontal split since we’re replacing
+# Pane Creation/Destruction.
+unbind % # Remove default binding for horizontal split since we’re replacing it.
 bind-key -n C-\ split-window -h
 bind-key -n C-_ split-window -v
 bind-key C-x kill-pane
 
-# Pane Sychronisation
+# Pane Sychronisation.
 bind-key s set -w synchronize-panes
 
-# Session Switching/Destruction
+# Session Switching/Destruction.
 bind-key C-s choose-session
 bind-key X kill-session
-# Remember `prefix+$` for renaming sessions
+# Remember prefix+$ for renaming sessions.
 
 
 ########################
 # Visual
 ########################
 
-# Use solarized colour palette
+# Use solarized colour palette.
 source ~/dotfiles/tmux/tmux-colors-solarized/tmuxcolors-256.conf
 
-# Use powerline plugin
+# Use powerline plugin.
 #source ~/dotfiles/powerline/powerline/powerline/bindings/tmux/powerline.conf
 
-# we'd rather roll our own not-so-blue-and-annoying color scheme
+# We would rather roll our own not-so-blue-and-annoying color scheme.
 # TODO work this into a powerline config in ~/.config/powerline
 set -g status on
 ##set -g status-position top

+ 8 - 1
vim/vimrc.bundles.local

@@ -21,13 +21,20 @@
 
 " Add Wanted Bundles {
   Bundle 'tacahiroy/ctrlp-funky'
+  Bundle 'joonty/vdebug'
+  Bundle 'tpope/vim-repeat'
 " }"
 
 " Remove Unwanted Bundles {
 
   " Keep all other spf13-vim sections except 'general'.
   if !exists('g:spf13_bundle_groups')
-    let g:spf13_bundle_groups=['neocomplcache', 'programming', 'php', 'ruby', 'python', 'go', 'twig', 'javascript', 'haskell', 'html', 'misc', 'scala']
+    if has('lua') && (v:version > 703 || v:version == 703 && has('patch885'))
+      let autoCompLibrary = 'neocomplete'
+    else
+      let autoCompLibrary = 'neocomplcache'
+    end
+    let g:spf13_bundle_groups=[autoCompLibrary, 'programming', 'php', 'ruby', 'python', 'go', 'twig', 'javascript', 'haskell', 'html', 'misc', 'scala']
   endif
 
   " General {

+ 65 - 68
vim/vimrc.local

@@ -1,6 +1,7 @@
 if has("autocmd")
 
   " Show trailing white space
+  highlight ExtraWhitespace ctermfg=red ctermbg=red guifg=red guibg=red
   autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
   autocmd InsertLeave * match ExtraWhitespace /\s\+$/
 
@@ -33,21 +34,20 @@ set colorcolumn=+1  " mark out the limits of the textwidth
 
 
 """"""""
-"" UI - Colours
-""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"" UI - Mouse & Cursor
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+set virtualedit=block " Freedom of movement in visual block mode
 
-set t_Co=16
+" The following two settings are related to how vim reacts to the incoming $TERM
+" value from either the terminal emulator (e.g. iTerm2) or tmux. In the best
+" case, both of these should be set to xterm-256color. This will result in vim
+" reacting with the settings below:
+"set t_Co=256
+"set ttymouse=xterm2 " Needed to allow mouse support to resize windows
+"set ttyfast " Allows for instantaneous refresh when using the mouse to select
 
-" show trailing white space
-highlight ExtraWhitespace ctermfg=red ctermbg=red guifg=red guibg=red
-
-" reverse indent guides highlighting
-highlight IndentGuidesOdd ctermbg=darkgrey
-highlight IndentGuidesEven ctermbg=black
-
-""""""""
-"" UI - Statusline (now using powerline)
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Have not gotten solarized to work properly yet highlighting of cursor,
+" width limit line and number and fold columns are wrong.
 
 
 """"""""
@@ -69,9 +69,8 @@ inoremap jk <ESC>
 " Add extra lines up and down
 nnoremap <leader>j    o<Esc>k
 nnoremap <leader>k    O<Esc>j
-
-" Edit .vimrc
-"nnoremap <leader>v    :e $MYVIMRC<CR>
+" Get rid of spf13-vim's python/json mapping, which interferes with the above
+nunmap <leader>jt
 
 " Clear trailing white space
 nnoremap <silent> <leader>$    :%s/\s\+$//g<CR>
@@ -82,7 +81,13 @@ nnoremap <silent> <leader><TAB>    :%s/<TAB>/  /g<CR>
 " Backspace to clear current search (and stop highlighting)
 nnoremap <silent> <backspace>    :call ClearSearch()<CR>
 
-nnoremap <silent> <leader>n    :set number!<CR>
+function! ClearSearch()
+  if (@/ != "")
+    let @/=""
+    redraw
+  endif
+endfunction
+
 nnoremap <silent> <leader>w    :set wrap!<CR>
 
 " Toggle paste mode - no autoindenting of pasted material
@@ -92,16 +97,43 @@ nnoremap <silent> <leader>p    :set paste! paste?<CR>
 nnoremap <silent> <leader>l    :set list!<CR>
 
 " Toggle keyboard layout
-nnoremap <silent> <leader><space>    :call CycleKeymap()<CR>
+"nnoremap <silent> <leader><space>    :call CycleKeymap()<CR>
+
+"function! CycleKeymap()
+  "if has('keymap')
+    "if (&keymap == '')
+      "set keymap=colemak
+      "echo 'Colemak keymap selected'
+    "elseif (&keymap == 'colemak')
+      "set keymap=dvorak
+      "echo 'Dvorak keymap selected'
+    "else
+      "set keymap=
+      "echo 'Qwerty keymap selected'
+    "endif
+  "else
+    "echo 'Keymaps not supported'
+  "endif
+"endfunction
 
 " Toggle scrollbind for moving multiple splits in sync together
 nnoremap <silent> <leader>sb    :set scrollbind! scrollbind?<CR>
 
 " Toggle mouse support.
-"nnoremap <silent> <leader>m    :call ToggleMouse()<CR>
+nnoremap <silent> <leader>m    :call ToggleMouse()<CR>
+
+function! ToggleMouse()
+  if &mouse == 'a'
+    set mouse=
+    echo 'Mouse usage disabled'
+  else
+    set mouse=a
+    echo 'Mouse usage enabled'
+  endif
+endfunction
 
 " Toggle NERDTree file browser
-nnoremap <silent> <leader>d    :NERDTreeToggle<CR>
+nnoremap <silent> <leader>d    :NERDTreeMirrorToggle<CR>
 
 " Toggle Commenting out lines with NERDCommenter
 nnoremap <silent> <leader>,    :call NERDComment("n", "toggle")<CR>
@@ -109,7 +141,7 @@ vnoremap <silent> <leader>,    <ESC>:call NERDComment("x", "toggle")<CR>
 
 " Git commands with Fugitive
 nnoremap <silent> <leader>gc   :Gcommit -v<CR>
-"nnoremap <silent> <leader>gl   :Glog<CR><CR>
+nnoremap <silent> <leader>gl   :Glog<CR><CR>
 nnoremap <silent> <leader>gap  :Git add -p<CR>
 
 " Function definition jumping with CtrlP's Funky plugin
@@ -125,7 +157,7 @@ nmap L $
 vmap H ^
 vmap L $
 
-" Smart way to move between windows
+" Smart way to move between windows, without spf13-vim's vertical maximisation.
 "nnoremap <C-j> <C-w>j
 "nnoremap <C-k> <C-w>k
 "nnoremap <C-h> <C-w>h
@@ -148,6 +180,14 @@ vmap L $
 "xnoremap <silent> <expr> ^ ScreenMovement("^")
 "xnoremap <silent> <expr> $ ScreenMovement("$")
 
+"function! ScreenMovement(movement)
+  "if &wrap
+    "return 'g' . a:movement
+  "else
+    "return a:movement
+  "endif
+"endfunction
+
 
 """"""""
 "" Plugin options
@@ -165,6 +205,9 @@ let g:tagbar_autoclose = 1 " close sidebar after we go to selection
 """"""""" Indent Guides
 let g:indent_guides_auto_colors = 0
 let g:indent_guides_guide_size = 2
+" reverse indent guides highlighting
+"highlight IndentGuidesOdd ctermbg=grey
+highlight IndentGuidesEven ctermbg=black
 
 
 """"""""" Syntastic
@@ -188,57 +231,11 @@ let g:vdebug_options = {
 let g:vim_markdown_folding_disabled = 1
 
 
-""""""""" Sparkup
-let g:sparkupNextMapping = '<leader>n' " resolve conflict with vim-multiple-cursors
-
 """"""""" PIV
 let g:DisableAutoPHPFolding = 1
 
 """"""""
 "" Functions
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
-function! ToggleMouse()
-  if &mouse == 'a'
-    set mouse=
-    echo "Mouse usage disabled"
-  else
-    set mouse=a
-    echo "Mouse usage enabled"
-  endif
-endfunction
-
-function! ScreenMovement(movement)
-  if &wrap
-    return "g" . a:movement
-  else
-    return a:movement
-  endif
-endfunction
-
-function! ClearSearch()
-  if (@/ != "")
-    let @/=""
-    redraw
-  endif
-endfunction
-
-function! CycleKeymap()
-  if has('keymap')
-    if (&keymap == '')
-      set keymap=colemak
-      echo "Colemak keymap selected"
-    elseif (&keymap == 'colemak')
-      set keymap=dvorak
-      echo "Dvorak keymap selected"
-    else
-      set keymap=
-      echo "Qwerty keymap selected"
-    endif
-  else
-    echo "Keymaps not supported"
-  endif
-endfunction
 
 for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
   execute 'source' filePath