forked from lightningdb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc
executable file
·261 lines (210 loc) · 6.36 KB
/
vimrc
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
set nocompatible
set magic
syntax on
let mapleader = ","
set hls
set incsearch
set showcmd
set hidden
set wildmenu
set autoread
set nobackup
set nowritebackup
set smartindent
set gdefault
set cursorline
set nu " Line numbers on
set nowrap " Line wrapping off
set directory=/tmp
" Command-T settings
let g:CommandTMaxHeight = 15
set wildignore+=vendor/rails/**,teamsite/**,spec/fixtures/**
" Visual
set novisualbell " No blinking .
set noerrorbells " No noise.
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
" Show $ at end of line and trailing space as ~
set lcs=tab:\ \ ,eol:$,trail:~,extends:>,precedes:<
" BUT, turn the above off by default
" need both for vim to start with whitespace and line-endings off
set list
:set list!
" no toolbar, no menu
set guioptions-=T
set guioptions-=m
" os x backspace fix
set backspace=indent,eol,start
fixdel
" tabs -> spaces
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set mouse=a " turn mouse on
" %% expands to the current directory
cnoremap %% <C-R>=expand('%:h').'/'<cr>
let g:surround_{char2nr('-')} = "<% \r %>"
let g:surround_{char2nr('=')} = "<%= \r %>"
" #########################
" BINDINGS
" #########################
nnoremap <leader><leader> <c-^>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
map <leader>q :BufO<CR>
map <leader>f :Ack<space>
" A function to search for word under cursor, using Ack plugin
function! SearchWord()
normal "zyiw
exe ':Ack '.@z
endfunction
map <leader>F :call SearchWord()<CR>
" space = pagedown, - = pageup
noremap <Space> <PageDown>
noremap - <PageUp>
nnoremap <F2><F2> :vsplit<CR>
nnoremap <F4><F4> :set invwrap wrap?<CR> " use f4f4 to toggle wordwrap
nnoremap <F5><F5> :set invhls hls?<CR> " use f5f5 to toggle search hilight
" Yankring Show
nnoremap <silent> <F3> :YRShow<cr>
inoremap <silent> <F3> <ESC>:YRShow<cr>
map <C-t> <Esc>:%s/[ ^I]*$//<CR>:retab<CR> " remove trailing space and retab
nmap <leader>s :source ~/.vimrc<CR>
nmap <leader>v :e ~/.vimrc<CR>
nnoremap <leader>d :NERDTreeToggle<CR>
nmap <S-H> :BufSurfBack<CR>
nmap <S-L> :BufSurfForward<CR>
" CTags
map <Leader>rt :!ctags --extra=+f --exclude=teamsite --exclude=public -R *<CR><CR>
" Flush Command T (rescans directories)
map <Leader>tf :CommandTFlush<CR>
map <Leader>t :CommandT<CR>
" Toggle off whitespace highlighting
map <Leader>w :set list!<CR>
" Don't use Ex mode, use Q for formatting
map Q gq
" #########################
" END BINDINGS
" #########################
" #### From DestroyAllSoftware screencast on file navigation in vim
set winwidth=84 " always have enough width to view file
" ####
let html_use_css=1
filetype off " set up vundle to allow plugin bundling
set runtimepath+=$HOME/.vim/bundle/vundle
call vundle#rc()
Bundle 'vim-scripts/BufOnly.vim'
Bundle 'wincent/Command-T'
Bundle 'vim-scripts/YankRing.vim'
Bundle 'mileszs/ack.vim'
Bundle 'vim-scripts/genutils'
Bundle 'vim-scripts/LustyExplorer'
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/nerdtree'
Bundle 'ervandew/supertab'
Bundle 'godlygeek/tabular'
Bundle 'xaviershay/tslime.vim'
Bundle 'Townk/vim-autoclose'
Bundle 'slack/vim-bufexplorer'
Bundle 'ton/vim-bufsurf'
Bundle 'altercation/vim-colors-solarized'
Bundle 'tpope/vim-cucumber'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-haml'
Bundle 'wgibbs/vim-irblack'
Bundle 'pangloss/vim-javascript'
Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-ragtag'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-repeat'
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-surround'
Bundle 'vim-scripts/vimwiki'
Bundle 'gmarik/vundle'
" snipmate dependencies
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
"Bundle 'honza/snipmate-snippets'
Bundle 'lightningdb/snipmate-snippets'
Bundle 'lightningdb/vim-snipmate'
source $HOME/.vim/bundle/snipmate-snippets/support_functions.vim
filetype off " set up vundle to allow plugin bundling
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
" vimwiki options
let g:vimwiki_list = [{ 'path': '~/vimwiki/' }]
let g:vimwiki_table_auto_fmt=0
"statusline setup
set statusline=%f "tail of the filename
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%h "help file flag
set statusline+=%y "filetype
set statusline+=%r "read only flag
set statusline+=%m "modified flag
set statusline+=%{fugitive#statusline()}
"display a warning if &paste is set
set statusline+=%#error#
set statusline+=%{&paste?'[paste]':''}
set statusline+=%*
set statusline+=%= "left/right separator
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
set laststatus=2
command! Rroutes :R config/routes.rb
command! Rblueprints :R spec/blueprints.rb
nmap <Leader>aa :Tabularize /\|<CR>
vmap <Leader>aa :Tabularize /\|<CR>
" #### From DestroyAllSoftware screencast on file navigation in vim
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
:silent !echo;echo;echo;echo;echo
exec ":!bundle exec spec " . a:filename
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:ldb_test_file=@%
endfunction
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_spec_file = match(expand("%"), '_spec.rb$') != -1
if in_spec_file
call SetTestFile()
elseif !exists("t:ldb_test_file")
return
end
call RunTests(t:ldb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number)
endfunction
" Run this file
map <leader>r :call RunTestFile()<cr>
" Run only the example under the cursor
map <leader>R :call RunNearestTest()<cr>
" Run all test files
map <leader>rr :call RunTests('spec')<cr>
set t_Co=256
colorscheme solarized
set background=light
" toggle the background for solarized light or dark
call togglebg#map("<F5>")