-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
317 lines (250 loc) · 8.27 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
312
313
314
315
316
317
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
" Bundle List - Original Repo
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-rsi'
Plugin 'tpope/vim-surround'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/syntastic'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'majutsushi/tagbar'
Plugin 'sjl/gundo.vim'
Plugin 'amjith/rtf-highlight'
Plugin 'airblade/vim-gitgutter'
Plugin 'rking/ag.vim'
Plugin 'tomasr/molokai'
Plugin 'Valloric/YouCompleteMe'
Plugin 'fatih/vim-go'
Plugin 'SirVer/ultisnips'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'jmcantrell/vim-virtualenv'
Plugin 'jiangmiao/auto-pairs'
"Plugin 'Yggdroot/indentLine'
Plugin 'ElmCast/elm-vim'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'alvan/vim-closetag'
Plugin 'godlygeek/tabular'
Plugin 'gorodinskiy/vim-coloresque'
Plugin 'vim-airline/vim-airline'
" Vim-script Repo
Plugin 'L9'
"Plugin 'AutoComplPop'
"Plugin 'Auto-Pairs'
Plugin 'matchit.zip'
Plugin 'vimwiki'
Plugin 'EasyGrep'
Plugin 'VisIncr'
" Colors
Plugin 'altercation/vim-colors-solarized'
Plugin 'sjl/badwolf'
" All of the Plugins must be added before the following line
call vundle#end()
set background=light
"if has("gui_running")
"colorscheme solarized
"else
"colorscheme badwolf
colorscheme solarized
"endif
if has("syntax")
syntax on
endif
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
filetype plugin indent on
endif
set hlsearch " Highlight search term
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)
set backspace=indent,eol,start " backspace for dummys
set linespace=0 " No extra spaces between rows
set winminheight=0 " windows can be 0 line high
set infercase " Fix completion to work the same as search + smartcase
set ruler " Show cursor position all the time
"set cursorline " Highlight the current line
set autoindent " Auto indent
" No bells
set visualbell t_vb=
set number " Line number
" Tabs will be spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set backupdir=~/tmp
set directory=~/tmp
if has("autocmd")
autocmd FileType html,css,scss,ruby,javascript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType markdown setlocal wrap linebreak nolist
autocmd BufNewFile,BufRead *.rss setfiletype xml
autocmd BufNewFile,BufRead *.es6 setfiletype javascript
endif
" Toggles & Switches (Leader commands) {{{1
let mapleader = ","
nmap <silent> <leader>s :set spell!<CR>
" http://stackoverflow.com/questions/2400264/is-it-possible-to-apply-vim-configurations-without-restarting/2400289#2400289
if has("autocmd")
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END
endif
" Treat j and k as up and down on long lines in wrap mode.
nnoremap j gj
nnoremap k gk
" Visually select the text that was last edited/pasted
nmap gV `[v`]
nnoremap cn :cn<CR>
nnoremap cp :cp<CR>
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
" Use system clipboard
set clipboard=unnamed
set nowrap " wrap long lines
" Set cwd from the path of the file being edited
set autochdir
"Use option key in mac as meta key
if has("gui_macvim")
set macmeta
endif
" Use the excuberant tags instead of the shitty ctags in OS X
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
set tm=500
" Vimwiki home
let g:vimwiki_list = [{'path': '~/Dropbox/notes/'}]
set wildmenu
" Leave the statusline visible
set laststatus=2
"Delete without clobbering clipboard
nnoremap x "_x
"Paste without clobbering clipboard in visual mode
vnoremap p "_dP
"Set colorcolumn to indicate the 80 char violation"
"set colorcolumn=80
" Search for tags file up the directory tree
set tags=tags;/
" F5 to insert current date.
nnoremap <F5> "=strftime("%y/%m/%d")<CR>P
inoremap <F5> <C-R>=strftime("%y/%m/%d")<CR>
" F2 to toggle paste-mode.
set pastetoggle=<F2>
" Ignore pylint errors.
" E302 - Two blank lines before function definitions.
" E701 - multiple statmenets on one line (colon)
let g:pymode_lint_ignore = "E501,E302,E701,E128,E126"
let g:pymode_lint_cwindow = 1
" NERDTree Toggle.
map <leader>n :NERDTreeToggle<CR>
set t_Co=256 " Explicitly tell vim to support 256 colors
" Highlight chars greater than 80 chars
"highlight LongLine ctermbg=green guibg=green
"match LongLine '\%>80v.\+'
" Disable <CR> for AutoPairs
let g:AutoPairsMapCR = 0
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown,javascript setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
set wildignore+=*.pyc
" Ctrlp config
let g:ctrlp_extensions = ['tag']
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(pyc|so|dll)$',
\ }
let g:EasyGrepMode = 2
let g:indent_guides_guide_size = 1
" air-line config
let g:airline#extensions#tabline#enabled = 1
" Natural Splits
set splitbelow
set splitright
" Syntastic config
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['eslint']
"let g:syntastic_javascript_checkers = ['jshint']
" YouCompleteMe config
let g:ycm_min_num_of_chars_for_completion = 1
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_filepath_completion_use_working_dir = 1
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
" A function that can save the status before executing a command.
" Useful when removing trailing spaces without losing the last cursor position.
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nmap _$ :call Preserve("%s/\\s\\+$//e")<CR>
nmap _= :call Preserve("normal gg=G")<CR>
autocmd BufWritePre *.go,*.py,*.js,*.es6,*.elm :call Preserve("%s/\\s\\+$//e")
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
"au FileType go au BufWritePre <buffer> Fmt
" Trigger configuration.
let g:UltiSnipsExpandTrigger="<C-s>"
let g:UltiSnipsJumpForwardTrigger="<C-f>"
let g:UltiSnipsJumpBackwardTrigger="<C-b>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
let g:elm_format_autosave = 1
" Always set the default shell to bash. This is needed to make syntastic work
" correctly.
set shell=/bin/bash
" Always show trailing spaces
set list listchars=tab:»·,trail:·,nbsp:·
let g:indentLine_char = '│'
nnoremap <leader>i :IndentLinesToggle<CR>
" Uses silversurfer to do Ctrl-P completion.
let g:ctrlp_use_caching = 0
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
else
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<space>', '<cr>', '<2-LeftMouse>'],
\ }
endif
" Show full path of the file in statusline.
set statusline+=%F
" Enable automatic close tag for the following file types.
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.jsx,*.js"
" Limit syntax highlighting to lines under 200 chars.
set synmaxcol=200