Skip to content

Instantly share code, notes, and snippets.

@trico
Last active May 24, 2017 10:38
Show Gist options
  • Save trico/9c754f971eb31bc0e53f to your computer and use it in GitHub Desktop.
Save trico/9c754f971eb31bc0e53f to your computer and use it in GitHub Desktop.
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'fatih/vim-go', { 'for': 'go'}
Plug 'ctrlpvim/ctrlp.vim'
Plug 'pbrisbin/vim-mkdir'
Plug 'thoughtbot/vim-rspec', { 'for': 'ruby' }
Plug 'tpope/vim-bundler', { 'for': 'ruby' }
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails', { 'for': 'ruby' }
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
Plug 'vim-scripts/ctags.vim'
Plug 'tomtom/tcomment_vim'
Plug 'lukaszb/vim-web-indent'
Plug 'pangloss/vim-javascript'
Plug 'rking/ag.vim'
Plug 'benmills/vimux'
Plug 'skalnik/vim-vroom'
Plug 'nelstrom/vim-textobj-rubyblock'
Plug 'kana/vim-textobj-user'
Plug 'chriskempson/base16-vim'
Plug 'w0rp/ale'
" Initialize plugin system
call plug#end()
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
runtime macros/matchit.vim
let &runtimepath.=',~/.vim/bundle/ale'
" ctrl ignore folders
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn|vendor)$'
" Use Vim settings, rather then Vi settings. This setting must be as early as
" possible, as it has side effects.
set nocompatible
" Leader
let mapleader = " "
set timeoutlen=1000 ttimeoutlen=0
set backspace=2 " Backspace deletes like most programs in insert mode
set nobackup
set nowritebackup
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set hlsearch
set laststatus=2 " Always display the status line
set autowrite " Automatically :write before running commands
set lazyredraw
set ttyfast
set relativenumber " show relative line numbers
set number " show the current line number"
set showmatch " show matching braces
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
set so=7
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
"
"change tabs
nmap <Tab> :tabn <CR>
nmap <S-Tab> :tabp <CR>
" Switch between the last two files
nnoremap <leader><leader> <c-^>
" RENAME CURRENT FILE (thanks Gary Bernhardt)
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <Leader>n :call RenameFile()<cr>
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
inoremap <S-Tab> <c-n>
" clear search
map <Leader>h :noh<CR>
" Get off my lawn
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" vim-rspec
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>s :call RunNearestSpec()<CR>
nnoremap <Leader>l :call RunLastSpec()<CR>
if exists('$TMUX')
let g:rspec_command = 'call VimuxRunCommand("rspec {spec}\n")'
else
let g:rspec_command = "!rspec --drb {spec}"
endif
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Copy-Paste
set clipboard=unnamed
" true color
set termguicolors
if &term =~# '^screen'
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
" nerd tree
nmap <silent> <leader>k :NERDTreeToggle<cr>
" close NERDTree after a file is opened
let g:NERDTreeQuitOnOpen=1
" expand to the path of the file in the current buffer
nmap <silent> <leader>y :NERDTreeFind<cr>
" Index ctags from any project, including those outside Rails
map <Leader>ct :!ctags -R --exclude=.vendor --exclude=.git --exclude=node_modules .<CR>
# color
set -g default-terminal 'screen-256color'
# set -ga terminal-overrides ',screen-256color:Tc'
set -g default-terminal "xterm"
#mouse
set -g mouse on
set -sg escape-time 0
# new pane same path
bind '%' split-window -h -c '#{pane_current_path}' # Split panes horizontal
bind '"' split-window -v -c '#{pane_current_path}' # Split panes vertically
bind c new-window -c '#{pane_current_path}' # Create new window
# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# act like GNU screen
unbind C-b
set -g prefix C-a
# make delay shorter
set -sg escape-time 0
# set vi mode for copy mode
setw -g mode-keys vi
# # more settings to make copy-mode more vim-like
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection
# 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"
# start window numbers at 1 to match keyboard order with tmux window order
set -g base-index 1
set-window-option -g pane-base-index 1
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# soften status bar color from harsh green to light gray
set -g status-bg '#666666'
set -g status-fg '#bada55'
# increase scrollback lines
set -g history-limit 10000
# switch to last pane
bind-key C-a last-pane
#### COLOUR
tm_icon="♟"
tm_color_active=colour154
tm_color_inactive=colour15
tm_color_feature=colour4
tm_color_music=colour203
tm_separator_left_bold="◀"
tm_separator_left_thin="❮"
tm_separator_right_bold="▶"
tm_separator_right_thin="❯"
set -g status-left-length 32
set -g status-right-length 150
set -g status-interval 5
# default statusbar colors
# # set-option -g status-bg colour0
set-option -g status-fg $tm_color_active
set-option -g status-bg default
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg $tm_color_inactive
set-window-option -g window-status-bg default
set -g window-status-format "#I #W"
# active window title colors
set-window-option -g window-status-current-fg $tm_color_active
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-format "#[bold]#I #W"
# pane border
set-option -g pane-border-fg $tm_color_inactive
set-option -g pane-active-border-fg $tm_color_active
# message text
set-option -g message-bg default
set-option -g message-fg $tm_color_active
# pane number display
set-option -g display-panes-active-colour $tm_color_active
set-option -g display-panes-colour $tm_color_inactive
tm_date="#[fg=$tm_color_inactive] %R %d %b"
tm_host="#[fg=$tm_color_feature,bold]#h"
tm_spotify="#[fg=$tm_color_music]#(osascript ~/applescripts/spotify.scpt)"
tm_session_name="#[fg=$tm_color_feature,bold]$tm_icon #S"
set -g status-left $tm_session_name' '
set -g status-right $tm_spotify' '$tm_date' '$tm_host
@trico
Copy link
Author

trico commented May 29, 2015

" Define bundles via Github repos
Plug 'christoomey/vim-run-interactive'
Plug 'kchmck/vim-coffee-script'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'pbrisbin/vim-mkdir'
Plug 'scrooloose/syntastic'
Plug 'slim-template/vim-slim'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'vim-ruby/vim-ruby'
Plug 'vim-scripts/tComment'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment