-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.symlink
205 lines (161 loc) · 4.49 KB
/
vimrc.symlink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
set nocompatible
filetype off
" set up vundle
" https://github.com/VundleVim/Vundle.vim
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'bling/vim-airline'
Plugin 'elzr/vim-json'
Plugin 'ervandew/supertab'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'kchmck/vim-coffee-script'
Plugin 'kien/ctrlp.vim'
Plugin 'mileszs/ack.vim'
Plugin 'pangloss/vim-javascript'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-surround'
call vundle#end()
scriptencoding utf-8
set encoding=utf-8
syntax on #enable
filetype plugin indent on
" set 256 colors
set t_Co=256
" set default font
set guifont=Monaco\ for\ Powerline
" airline config
let g:airline_powerline_fonts = 1
"let g:airline_theme = 'pencil'
" set dark background
let g:solarized_termcolors=256
set background=dark
" turn on line numbers
set number
" no line wrapping
set nowrap
" show invisible characters
set list
" allow files to be hidden without saving
set hidden
" turn off toolbar in gui vim
set guioptions=t
" new split windows should be on the right or bottom
set splitright
set splitbelow
" set tab options
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
" set list options
set listchars=""
set listchars=tab:\ \
set listchars+=trail:.
set listchars+=extends:>
" set backup and swap options
set backup
set backupdir=~/.vim/_backups
set directory=~/.vim/_temp
" set backup
set backspace=indent,eol,start
" set highlight search
set hlsearch
colorscheme solarized
" use jk instead of escape
:imap jk <Esc>
" set leader to comma
let mapleader=","
" misc mappings
map <Leader>ra :%s/
nmap <Leader>so :source ~/.vimrc<cr>
nmap <Leader>pi :source ~/.vimrc<cr>:PluginInstall<cr>
nmap <Leader>pu :source ~/.vimrc<cr>:PluginInstall!<cr>
set runtimepath^=~/.vim/bundle/ctrlp.vim
" --- Plugin Key Mappings ---
" CtrlP
map <Leader>r :CtrlP<CR>
map <Leader>b :CtrlPBuffer<CR>
" Fugitive
map <Leader>gs :Gstatus<CR>
map <Leader>gc :Gcommit<CR>
" map leader n to toggle NERDTree
map <leader>n :NERDTreeToggle<CR>
" map command / to toggle comments
map <leader>ct <plug>NERDCommenterToggle<cr>
imap <leader>ct <ESC><plug>NERDCommenterToggle i
" run current test
nnoremap <leader>t :call RunTestFile()<CR>
nnoremap <leader>T :w\|:silent !tmux send-keys -t bottom C-u 'rspec -f d -t focus' C-m <CR>\|:redraw!<CR>
" function key mappings
set pastetoggle=<F2>
" cd to the directory containing the file in the buffer
nmap <silent> <leader>cd :lcd %:h<CR>
" Some helpers to edit mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
map <leader>tn :tabnew<cr>
" allow using + and - for window resizing
if bufwinnr(1)
map + <C-W>+
map - <C-W>-
endif
if has("statusline") && !&cp
set laststatus=2 " always show the status bar
" Start the status line
"set statusline=%f\ %m\ %r
"set statusline+=Line:%l/%L[%p%%]
"set statusline+=Col:%v
"set statusline+=Buf:#%n
"set statusline+=[%b][0x%B]
"set statusline+=%=%{fugitive#statusline()}
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Running Tests
" Testing functions borrowed from Gary Berhardt
" [github.com/garybernhardt/dotfiles/blob/master/.vimrc]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RunTestFile(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
if in_test_file
call SetTestFile()
elseif !exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number . " -b")
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:grb_test_file=@%
endfunction
" Write the file and run tests for the given filename
function! RunTests(filename)
if match(a:filename, '\.feature$') != -1
exec ":silent !tmux send-keys -t bottom 'cucumber -r features " . a:filename . "' C-m"
exec ":redraw!"
else
exec ":silent !tmux send-keys -t bottom 'rspec --color " . a:filename . "' C-m"
exec ":redraw!"
end
endfunction