Skip to content

Instantly share code, notes, and snippets.

@bsag
Last active October 20, 2018 21:13
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bsag/39eb930087c46521b763 to your computer and use it in GitHub Desktop.
Save bsag/39eb930087c46521b763 to your computer and use it in GitHub Desktop.
My vim and tmux configs, using airline (as discussed [here](http://www.rousette.org.uk/blog/archives/tinkering-with-vim/). The Powerline theme is pretty much the default (may be a bit old now) and I just commented out a few plugins I didn't need. I use the patched Sauce Code Pro for my powerline/airline font.
" Set up Vundle to manage plugins
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-haml'
Plugin 'kchmck/vim-coffee-script'
Plugin 'kien/ctrlp.vim'
Plugin 'bling/vim-airline'
Plugin 'altercation/vim-colors-solarized'
Plugin 'jmcantrell/vim-virtualenv'
Plugin 'davidoc/taskpaper.vim'
Plugin 'gcmt/wildfire.vim'
Plugin 'mattn/emmet-vim'
Plugin 'vim-pandoc/vim-pandoc'
Plugin 'vim-pandoc/vim-pandoc-syntax'
Plugin 'vim-pandoc/vim-pandoc-after'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'rking/ag.vim'
Plugin 'ervandew/supertab'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'
Plugin 'sjl/gundo.vim'
Plugin 'edkolev/tmuxline.vim'
Plugin 'edkolev/promptline.vim'
" Local plugins
filetype plugin indent on " required
" Brief help
" :PluginList - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin commands are not allowed.
" Put your stuff after this line
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" this mapping Enter key to <C-y> to chose the current highlight item
" and close the selection list, same as other IDEs.
" CONFLICT with some plugins like tpope/Endwise
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Pandoc integration with third party plugins
let g:pandoc#after#modules#enabled = ["supertab", "ultisnips"]
let g:pandoc_no_folding = 1
" Extends % switching between all kinds of matching object
runtime macros/matchit.vim
" Basic stuff
set noswapfile
set nobackup
set encoding=utf-8
set hidden
set autoread " Read changes immediately if file changed outside vim
set clipboard=unnamed " Use OS X clipboard
syntax on
" Theme
set background=dark
colorscheme solarized
" Airline config
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
let g:airline#extensions#tabline#fnamecollapse = 0
let g:airline#extensions#virtualenv#enabled = 1
let g:airline#extensions#tmuxline#enabled = 0
let g:airline_inactive_collapse = 0
let g:virtualenv_auto_activate = 1
set laststatus=2
" Emmet config
let g:user_emmet_install_global = 0
autocmd FileType html,css EmmetInstall
let g:user_emmet_leader_key='<C-Z>'
" Gundo config
nnoremap <F5> :GundoToggle<CR>
let g:gundo_preview_height = 20
let g:gundo_preview_bottom = 1
let g:gundo_close_on_revert = 1
"""""""""""""""""""""
" tmuxline config "
"""""""""""""""""""""
let g:tmuxline_theme = 'airline_insert'
let g:tmuxline_preset = {
\ 'a': '#S',
\ 'b': '#F',
\ 'c': '#W',
\ 'win': ['#I', '#W'],
\ 'cwin': ['#I', '#W'],
\ 'x': '%a',
\ 'y': ['%b %d', '%R'],
\ 'z': '#h'}
"""""""""""""""""""""""
" promptline config "
"""""""""""""""""""""""
let g:promptline_theme = 'airline'
let g:promptline_preset = {
\'a': [ promptline#slices#python_virtualenv() ],
\'b': [ promptline#slices#cwd({'dir_limit': 2}) ],
\'c': [ promptline#slices#vcs_branch(), '$(git rev-parse --short HEAD 2>/dev/null)' ],
\'x': [ promptline#slices#git_status() ],
\'warn': [ promptline#slices#last_exit_code() ]}
" Text Formatting
" ----------------------------------------------------------------------------
set autoindent " automatic indent new lines
set smartindent " be smart about it
set wrap " wrap lines
set shiftwidth=4
set tabstop=4
set expandtab
set softtabstop=4
set smarttab
set formatoptions+=n " support for numbered/bullet lists
set virtualedit=block " allow virtual edit in visual block ..
set linebreak
set tw=500
" ----------------------------------------------------------------------------
" Remapping
" ---------------------------------------------------
" lead with ,
let mapleader = " "
let maplocalleader = ","
" Fast save
nnoremap <Leader>w :w!<cr>
" reflow paragraph with Q in normal and visual mode
nnoremap Q gqap
vnoremap Q gq
" make Y consistent with C and D. See :help Y.
nnoremap Y y$
" sane movement with wrap turned on
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
" remap arrow keys
nnoremap <left> :bprev<CR>
nnoremap <right> :bnext<CR>
nnoremap <up> :tabnext<CR>
nnoremap <down> :tabprev<CR>
" Help mode remapping
" Enter to jump to link, Delete to go back
" q to quit help
autocmd filetype help nnoremap <buffer><cr> <c-]>
autocmd filetype help nnoremap <buffer><bs> <c-T>
autocmd filetype help nnoremap <buffer>q :q<CR>
" ----------------------------------------------------------------------------
" UI
" ----------------------------------------------------------------------------
set ruler " show the cursor position all the time
set noshowcmd " don't display incomplete commands
set nolazyredraw " turn off lazy redraw
set number relativenumber " relative line numbers
set wildmenu " turn on wild menu
set wildmode=list:longest,full
set ch=2 " command line height
set backspace=2 " allow backspacing over everything in insert mode
set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
set shortmess=filtIoOA " shorten messages
set report=0 " tell us about changes
set nostartofline " don't jump to the start of line when scrolling
" ----------------------------------------------------------------------------
" Visual Cues
" ----------------------------------------------------------------------------
set showmatch " brackets/braces that is
set mat=5 " duration to show matching brace (1/10 sec)
set incsearch " do incremental searching
set laststatus=2 " always show the status line
set ignorecase " ignore case when searching
set hlsearch " don't highlight searches
set visualbell
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
" Open Marked.app with current file
nnoremap <leader>m :!open -b com.brettterpstra.marked2 %<CR>
" Taskpaper settings
"
"let g:task_paper_styles={'today': 'ctermfg=Blue guifg=Blue'}
" ---------------------------------------------------------------------------
" Strip all trailing whitespace in file
" ---------------------------------------------------------------------------
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
map <Leader>s :call DeleteTrailingWS()<CR>
" Special macros and abbreviations
"
" ISO date stamps
iab <expr> dts strftime("%Y-%m-%d")
cab <expr> dts strftime("%Y-%m-%d")
# Default Theme
if patched_font_in_use; then
TMUX_POWERLINE_SEPARATOR_LEFT_BOLD="⮂"
TMUX_POWERLINE_SEPARATOR_LEFT_THIN="⮃"
TMUX_POWERLINE_SEPARATOR_RIGHT_BOLD="⮀"
TMUX_POWERLINE_SEPARATOR_RIGHT_THIN="⮁"
else
TMUX_POWERLINE_SEPARATOR_LEFT_BOLD="◀"
TMUX_POWERLINE_SEPARATOR_LEFT_THIN="❮"
TMUX_POWERLINE_SEPARATOR_RIGHT_BOLD="▶"
TMUX_POWERLINE_SEPARATOR_RIGHT_THIN="❯"
fi
TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR=${TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR:-'235'}
TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR=${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR:-'255'}
TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR=${TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR:-$TMUX_POWERLINE_SEPARATOR_RIGHT_BOLD}
TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SEPARATOR=${TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SEPARATOR:-$TMUX_POWERLINE_SEPARATOR_LEFT_BOLD}
# Format: segment_name background_color foreground_color [non_default_separator]
if [ -z $TMUX_POWERLINE_LEFT_STATUS_SEGMENTS ]; then
TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=(
"tmux_session_info 148 234" \
"hostname 33 0" \
#"ifstat 30 255" \
#"ifstat_sys 30 255" \
#"lan_ip 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" \
"wan_ip 24 255" \
"vcs_branch 29 88" \
"vcs_compare 60 255" \
"vcs_staged 64 255" \
"vcs_modified 9 255" \
"vcs_others 245 0" \
)
fi
if [ -z $TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS ]; then
TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS=(
#"earthquake 3 0" \
"pwd 89 211" \
"mailcount 9 255" \
"now_playing 234 37" \
#"cpu 240 136" \
#"load 237 167" \
#"tmux_mem_cpu_load 234 136" \
"battery 137 127" \
"weather 37 255" \
#"rainbarf 0 0" \
#"xkb_layout 125 117" \
"date_day 235 136" \
"date 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \
"time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \
#"utc_time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \
)
fi
## keybindings
unbind C-b
unbind C-a
unbind %
unbind ,
unbind .
unbind n
unbind p
unbind '"'
unbind l
unbind &
unbind "'"
unbind Up
unbind Down
unbind Left
unbind Right
set-option -g prefix C-a # C-a for perfix just like screen
bind-key C-a last-window
bind-key | split-window -h -c "#{pane_current_path}"
bind-key \ split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"
bind-key x kill-pane
bind-key X kill-window
bind-key q confirm-before kill-session
bind-key Q confirm-before kill-server
bind-key , previous-window # <
bind-key . next-window # >
bind-key n command-prompt 'rename-window %%'
bind-key N command-prompt 'rename-session %%'
bind-key r source-file ~/.tmux.conf; display-message " ✱ ~/.tmux.conf is reloaded"
bind-key R refresh-client
bind-key a send-key C-a
# PANES
# display pane numbers and select with a number key
bind f display-panes
set-option -g display-panes-time 2000
# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
# resize panes
# also increase repeat time
set-option -g repeat-time 1000
bind -r Left resize-pane -L 5
bind -r Down resize-pane -D 5
bind -r Up resize-pane -U 5
bind -r Right resize-pane -R 5
bind -r z resize-pane -Z
# set terminal colours
set -g default-terminal screen-256color
set -g status-bg colour0
set -g status-fg colour0
# Use tmuxline config file to set the status bar appearance
source-file ~/git/bitbucket/dotfiles/tmux/tmuxline-snapshot
## set window notifications
# set-option -g visual-activity on
# set-option -g visual-content on
# set-window-option -g monitor-activity on
set-window-option -g automatic-rename off
## tmux window titling for X
set-option -g set-titles on
# set-option -g set-titles-string '[#I] #W'
# set-window-option -g window-status-format ' #I #W '
# set-window-option -g window-status-attr bold
# starts windows and panes at 1 not 0
set-option -g base-index 1
setw -g pane-base-index 1
# set shorter delay
set -sg escape-time 1
## enable mouse
set-option -g mode-mouse on
set-option -g mouse-select-window on
set-option -g mouse-select-pane on
# copy mode
set-window-option -g mode-keys vi
# Integrate with OS X pasteboard.
set -g default-command "reattach-to-user-namespace -l zsh"
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# This tmux statusbar config was created by tmuxline.vim
# on Tue, 22 Jul 2014
set -g status-justify "centre"
set -g status "on"
set -g status-left-style "none"
set -g message-command-style "fg=colour7,bg=colour11"
set -g status-right-style "none"
set -g pane-active-border-style "fg=colour3"
set -g status-utf8 "on"
set -g status-style "bg=colour0,none"
set -g message-style "fg=colour7,bg=colour11"
set -g pane-border-style "fg=colour11"
set -g status-right-length "100"
set -g status-left-length "100"
setw -g window-status-activity-style "fg=colour3,bg=colour0,none"
setw -g window-status-separator ""
setw -g window-status-style "fg=colour10,bg=colour0,none"
set -g status-left "#[fg=colour15,bg=colour3,bold] #S #[fg=colour3,bg=colour11,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour11] #F #[fg=colour11,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour10,bg=colour0] #W #[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour10,bg=colour0] %a #[fg=colour11,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour11] %b %d  %R #[fg=colour3,bg=colour11,nobold,nounderscore,noitalics]#[fg=colour15,bg=colour3] #h "
setw -g window-status-format "#[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]#[default] #I  #W #[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]"
setw -g window-status-current-format "#[fg=colour0,bg=colour11,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour11] #I  #W #[fg=colour11,bg=colour0,nobold,nounderscore,noitalics]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment