-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
311 lines (256 loc) · 7.66 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
set nocompatible
"call pathogen#runtime_append_all_bundles()
"call pathogen#infect()
" ---------------------------------
" UI
" ---------------------------------
syntax enable
set background=dark
"colorscheme boo
set title
set titleold=
set number
set nolist
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set visualbell t_vb=
set mouse=a
set showcmd
set showmode
set ch=1
set grepprg=ack
set grepformat=%f:%l:%m
set binary
set autoindent
set smartindent
set smarttab
set guicursor=a:blinkon0
set nowrap
set backspace=indent,eol,start
set nospell
set linespace=0
set tabstop=4
set shiftwidth=2
set softtabstop=2
set shiftround
set expandtab
set nosmarttab
set formatoptions+=n
set virtualedit=block
set isk+=_,$,@,%,#,-
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,latin1,default
set ignorecase
set smartcase
set hlsearch
set incsearch
set gdefault
set foldenable
set nostartofline
set scrolljump=5
set scrolloff=3
set splitbelow
set splitright
set ttimeout
set ttimeoutlen=20
set notimeout
set clipboard=unnamed
set laststatus=2
"set statusline+=%f
"set statusline+=%=
"set statusline+=%{SyntasticStatuslineFlag()}%*
"set statusline+=\ [
"set statusline+=%{strlen(&ft)?&ft:'none'} "
" highlight VCS conflicts
"match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
"let g:rails_statusline=0
"let loaded_matchparen = 1
set fo-=r
if has("gui_running")
set guioptions=egmrt
set lines=40 columns=120
set go-=T
set go-=r
endif
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" resize splits when window is resized
au VimResized * exe "normal! \<c-w>="
" ---------------------------------
" Completion
" ---------------------------------
set completeopt=longest,menuone,preview
set wildmode=list:longest,list:full
set wildignore+=*/.hg,*/.git,*/.svn
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.pyc
set wildignore+=*.sw?
set wildignore+=.DS_Store
set wildmenu
set complete=.,t
"set wildignore=*~
" ---------------------------------
" Buffers
" ---------------------------------
set hidden
set nobackup
set nowritebackup
set noswapfile
if has("undofile")
set undofile
set undodir=~/.undo
end
" ---------------------------------
" Mappings
" ---------------------------------
let mapleader = ","
nnoremap ; :
" code folding
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>
nmap <leader>f4 :set foldlevel=4<CR>
nmap <leader>f5 :set foldlevel=5<CR>
nmap <leader>f6 :set foldlevel=6<CR>
nmap <leader>f7 :set foldlevel=7<CR>
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" cd to current file's directory
nmap <leader>cd %:p:h
" feature toggles
function! MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
exec 'inoremap '.a:key." \<C-O>".cmd
endfunction
command! -nargs=+ MapToggle call MapToggle(<f-args>)
MapToggle <F1> hlsearch
MapToggle <F2> wrap
MapToggle <F3> number
MapToggle <F4> paste
" new line creation with return
map <S-Enter> O<ESC>
map <Enter> o<ESC>
" indentation
vnoremap < <gv
vnoremap > >gv
" window splitting
nmap <leader>swh :topleft vnew<CR>
nmap <leader>swl :botright vnew<CR>
nmap <leader>swk :topleft new<CR>
nmap <leader>swj :botright new<CR>
nmap <leader>sh :leftabove vnew<CR>
nmap <leader>sl :rightbelow vnew<CR>
nmap <leader>sk :leftabove new<CR>
nmap <leader>sj :rightbelow new<CR>
" window movement
map <C-h> <C-w>h
map <C-l> <C-w>l
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-q> <C-w>q
map <leader>/ :CtrlP<CR>
map <leader>b :CtrlPBuffer<CR>
map <leader>h :CtrlPMRU<CR>
nnoremap Y y$
"map <C-U> :silent !syncit<CR>
""cmap Ws :w | :silent !syncit
"command Ws w | silent !syncit
" insert mode completion
inoremap <C-L> <C-X><C-L>
inoremap <C-F> <C-X><C-F>
" quick access to ack
map <leader>a :Ack
" Ex Mode is annoying.
" Use this for formatting instead.
map Q gq
" Save even if we forgot to open the file with sudo
cmap w!! %!sudo tee > /dev/null %
" Close inactive (hidden) buffers
" http://stackoverflow.com/questions/2974192/how-can-i-pare-down-vims-buffer-list-to-only-include-active-buffers
" http://stackoverflow.com/questions/1534835/how-do-i-close-all-buffers-that-arent-shown-in-a-window-in-vim
function! CloseHiddenBuffers()
" figure out which buffers are visible in any tab
let visible = {}
for t in range(1, tabpagenr('$'))
for b in tabpagebuflist(t)
let visible[b] = 1
endfor
endfor
" close any buffer that are loaded and not visible
let l:tally = 0
for b in range(1, bufnr('$'))
if bufloaded(b) && !has_key(visible, b)
let l:tally += 1
exe 'bw ' . b
endif
endfor
echon "Deleted " . l:tally . " buffers"
endfunction
command! -nargs=* Only call CloseHiddenBuffers()
" quick access to running shell commands
function! s:ExecuteInShell(command) " {{{
let command = join(map(split(a:command), 'expand(v:val)'))
let winnr = bufwinnr('^' . command . '$')
silent! execute winnr < 0 ? 'botright vnew ' . fnameescape(command) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap nonumber
echo 'Execute ' . command . '...'
silent! execute 'silent %!'. command
silent! redraw
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>:AnsiEsc<CR>'
silent! execute 'nnoremap <silent> <buffer> q :q<CR>'
silent! execute 'AnsiEsc'
echo 'Shell command ' . command . ' executed.'
endfunction " }}}
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
nnoremap <leader>! :Shell
" ---------------------------------
" Plugins
" ---------------------------------
let g:fuf_file_exclude = '\v\.DS_Store|\.bak|\.swp'
let g:statline_show_encoding = 0
let g:syntastic_enable_signs = 1
let g:syntastic_disabled_filetypes = ['html']
let g:ctrlp_by_filename = 1
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = { 'file': '\.eot$\|\.woff$\|\.svg$\|\.ttf$\|\.jpg$\|\.gif$\|\.png$' }
" ---------------------------------
" Auto Commands
" ---------------------------------
" set filetype
autocmd BufRead *.less set filetype=css
autocmd BufRead *.jsx set filetype=javascript
autocmd BufRead *.mkd set filetype=mkd
autocmd BufRead *.markdown set filetype=mkd
autocmd BufRead *.god set filetype=ruby
autocmd BufRead *.as set filetype=actionscript
autocmd BufRead *.tsv set filetype=tsv
"au BufNewFile,BufRead *.sls,*.yaml,*.yml so ~/.vim/syntax/yaml.vim
" set completion
"autocmd FileType ruby set omnifunc=rubycomplete#Complete
"autocmd FileType python set omnifunc=pythoncomplete#Complete
"autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
"autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
"autocmd FileType php set omnifunc=phpcomplete#CompletePHP
"autocmd FileType c set omnifunc=ccomplete#Complete
autocmd Filetype gitcommit set tw=68 spell
autocmd Filetype python,javascript,php,sh,bash,zsh set ts=4 sts=4 sw=4 expandtab
autocmd Filetype tsv set ts=4 sts=4 sw=4 noexpandtab
" don't use cindent for javascript
autocmd FileType javascript setlocal nocindent
autocmd FileType php set keywordprg=pman
autocmd FileType php set iskeyword-=-
" ---------------------------------
" OS X Stuff
" ---------------------------------
if system('uname') =~ 'Darwin'
let $PATH = $HOME .
\ '/usr/local/bin:/usr/local/sbin:' .
\ '/usr/pkg/bin:' .
\ '/opt/local/bin:/opt/local/sbin:' .
\ $PATH
endif