This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
261 lines (207 loc) · 6.8 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
" This is Bart Bakker's .vimrc
autocmd!
if has('vim_starting')
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
filetype off
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
call neobundle#end()
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'bling/vim-airline'
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'mac' : 'make -f make_mac.mak',
\ 'linux' : 'make',
\ },
\ }
NeoBundle 'Shougo/vimshell.vim'
NeoBundle 'Shougo/neocomplcache.vim'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'tpope/vim-eunuch'
NeoBundle 'rking/ag.vim'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'kien/rainbow_parentheses.vim'
NeoBundle 'vim-ruby/vim-ruby'
NeoBundle 'tpope/vim-rails'
NeoBundle 'tpope/vim-dispatch'
NeoBundle 'thoughtbot/vim-rspec'
NeoBundle 't9md/vim-ruby-xmpfilter'
NeoBundle 'derekwyatt/vim-scala'
NeoBundle 'cypok/vim-sml'
NeoBundle 'wlangstroth/vim-racket'
NeoBundle 'toyamarinyon/vim-swift'
NeoBundle 'moll/vim-node'
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'groenewege/vim-less'
NeoBundle 'chase/vim-ansible-yaml'
NeoBundle 'tpope/vim-fireplace'
NeoBundle 'vim-scripts/paredit.vim'
NeoBundle 'godlygeek/tabular'
NeoBundle 'plasticboy/vim-markdown'
NeoBundle 'rizzatti/dash.vim'
NeoBundle 'editorconfig/editorconfig-vim'
filetype plugin indent on
syntax on
" Allow unsaved background buffers (with marks/undo for them).
set hidden
set history=10000
set autoindent tabstop=4 shiftwidth=4 softtabstop=4 expandtab smarttab
set backspace=indent,eol,start
set hlsearch
set showmatch
set incsearch
set ignorecase smartcase
set switchbuf=useopen
set cursorline
" Keep some context when scrolling off the end of a buffer.
set scrolloff=3
set winwidth=79
set number
set numberwidth=2
set laststatus=2
set showtabline=2
set ruler
set cmdheight=1
set foldmethod=manual
set nofoldenable
" Open split panes at more natural positions
set splitbelow
set splitright
set t_Co=256
set background=dark
colorscheme brt
" Who needs backups.
set nobackup
set nowritebackup
" Move swap files out of the way - but preserve original folder structure
set directory=~/.tmp//
" disable annoying beeps
set visualbell
set noerrorbells
set showcmd
set wildmode=longest,list
set wildmenu
let mapleader=","
" Fix slow O inserts.
set timeout timeoutlen=1000 ttimeoutlen=100
" Normally, Vim messes with iskeyword when you open a shell file. This can
" leak out, polluting other file types even after a 'set ft=' change. This
" variable prevents the iskeyword change so it can't hurt anyone.
let g:sh_noisk=1
set modeline
set modelines=3
" Insert only one space when joining lines that contain sentence-terminating
" punctuation like '.'.
set nojoinspaces
" If a file is changed outside of Vim, reload without asking
set autoread
" Invisible characters
set listchars=trail:.,tab:>-,eol:$
set nolist
noremap <Leader>i :set list!<cr>
" Ignore files in .git/, swp files, build output files, etc
set wildignore=.git,.*.swp
" CtrlP
let g:ctrlp_map = '' " <c-p> binding conflicts with Vim default <c-p> for previous
nnoremap <leader>f :CtrlP<cr>
nnoremap <leader>b :CtrlPBuffer<cr>
if executable('ag')
let g:ctrlp_user_command = 'ag %s --files-with-matches --hidden --ignore .git/ --nocolor -g ""'
let g:ctrlp_use_caching = 0
else
let g:ctrlp_show_hidden = 1
endif
nnoremap <leader>g :GitGutterToggle<cr>
" Syntastic
let g:syntastic_check_on_open=0
let g:syntastic_enable_signs=1
nnoremap <silent> <leader>e :SyntasticCheck<cr>:Errors<cr>
" JavaScript
let g:syntastic_javascript_checkers = ['closurecompiler']
let g:syntastic_javascript_closurecompiler_script = 'closure-compiler'
" Dash
nnoremap <c-x><c-d> :Dash<cr>
" ctags are kept in .tags
set tags+=.tags
" insert UUID at cursor in insert mode
inoremap <expr> <c-r>!uuid GenUuid()
" neocomplcache
inoremap <expr><c-g> neocomplcache#undo_completion()
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
augroup vimrcEx
autocmd!
autocmd VimEnter * call s:Initialize()
" Don't map <Enter> when in command windows since it's used to run
" commands there
autocmd! CmdwinEnter * :unmap <cr>
autocmd! CmdwinLeave * :call MapCR()
" Rainbow parentheses
autocmd VimEnter * RainbowParenthesesToggle
autocmd Syntax clojure call s:RainbowParenthesesLoad()
autocmd FileType c setlocal noexpandtab
autocmd FileType xml setlocal formatprg=xmllint\ --format\ -
augroup END
function! MapCR()
nnoremap <cr> :write<cr>
endfunction
call MapCR()
function! s:RainbowParenthesesLoad()
RainbowParenthesesLoadRound
RainbowParenthesesLoadSquare
RainbowParenthesesLoadBraces
endfunction
function! s:Initialize()
GitGutterDisable
" Syntastic starts in active mode, switch to passive
silent SyntasticToggleMode
endfunction
function! GenUuid()
return substitute(system('uuid'), '\n$', '', '')
endfunction
" Append Git ignore patterns to wildignore.
" This only works for patterns in the root .gitignore.
function! s:WildignoreFromGitignore()
let git_root = fnamemodify(fugitive#extract_git_dir('%:p'), ':h')
let gitignore = git_root . '/.gitignore'
if (filereadable(gitignore))
let ignores = ''
for line in readfile(gitignore)
let ignored = substitute(line, '\s|\n', '', 'g')
if ignored =~ '^#|$' | con | endif " Skip comments and empty lines
if ignored =~ '^!' | con | endif " Vim supports no negative ignores
if ignored =~ '^/.\+' | let ignored = substitute(ignored, '^/', '*/', 'g') | endif
if ignored =~ '/$' | let ignored = substitute(ignored, '/$', '', 'g') | endif
let ignores .= (empty(ignores) ? '' : ",") . ignored
endfor
let set_wildignore = "set wildignore+=" . ignores
execute set_wildignore
endif
endfunction
command! WildignoreFromGitignore :call <SID>WildignoreFromGitignore()
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Work with quickfix lists
nnoremap <silent> <leader>j :exe (GetListPrefix() . "next")<cr>
nnoremap <silent> <leader>k :exe (GetListPrefix() . "prev")<cr>
nnoremap <silent> <leader>J :exe (GetListPrefix() . "last")<cr>
nnoremap <silent> <leader>K :exe (GetListPrefix() . "first")<cr>
function! GetListPrefix()
return ! empty(getloclist(0)) ? 'l' : ! empty(getqflist()) ? 'c' : 'b'
endfunction
" XMPFilter bindings
nmap <buffer> <c-x><c-m> <Plug>(xmpfilter-mark)
xmap <buffer> <c-x><c-m> <Plug>(xmpfilter-mark)
imap <buffer> <c-x><c-m> <Plug>(xmpfilter-mark)
nmap <buffer> <c-x><c-e> <Plug>(xmpfilter-run)
xmap <buffer> <c-x><c-e> <Plug>(xmpfilter-run)
imap <buffer> <c-x><c-e> <Plug>(xmpfilter-run)
set pdev=pdf
set printoptions=paper:a4,syntax:y,wrap:y,duplex:long