-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
392 lines (343 loc) · 13.1 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
nnoremap <C-l> :echo line(".") - line("'a") + 1<CR>
nnoremap [ di{
nnoremap ] di}
imap jk <Esc>
nnoremap <m> :wall <Bar> !clear && make run<CR>
nnoremap <S-m> :wall <Bar> !clear && g++ -g -Wall -Weffc++ -o %.out % && ./%.out && rm %.out<CR>
"map c :s/^/\/\//<cr>
"map <S-c> :s/^\/\///<cr>
map <C-Tab> gt
map <C-S-Tab> gT
nmap <Tab> >>
nmap <S-Tab> <<
map <F11> :cp<CR>
map <F12> :cn<CR>
" resize current buffer by +/- 5
nnoremap <C-left> :vertical resize -5<cr>
nnoremap <C-down> :resize +5<cr>
nnoremap <C-up> :resize -5<cr>
nnoremap <C-right> :vertical resize +5<cr>
" Great sources & credits:
" Example vimrc - http://www.vi-improved.org/vimrc.php
" gmarik - https://github.com/gmarik/vimfiles/blob/master/vimrc
" durdn - https://github.com/durdn/cfg/blob/master/.vimrc
" FactoryLab - https://github.com/factorylabs/vimfiles
" lukerandall - https://github.com/lukerandall/dotvim/blob/master/vimrc
" mathiasbynens - https://github.com/mathiasbynens/dotfiles/blob/master/.vimrc
" Graphical cheat sheet - http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
" Initialization / Vundle Plugin Mangaer
set nocompatible " Disable vi compatibility (more efficient, and besides - we're using non-vi tricks here).
set fileformats=unix,dos,mac " Set file end-of-line priority.
filetype off
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
if has ("win32")
set runtimepath+=$HOME/vimfiles/bundle/vundle/
else
set runtimepath+=$HOME/.vim/bundle/vundle/
endif
call vundle#rc()
"Bundle "Valloric/YouCompleteMe"
Bundle "gmarik/vundle"
" Plugins
" Colors
Bundle "nanotech/jellybeans.vim"
" Web
Bundle "pangloss/vim-javascript"
Bundle "lepture/vim-jinja"
Bundle "lepture/vim-css"
Bundle "cakebaker/scss-syntax.vim"
Bundle "groenewege/vim-less"
Bundle "matchit.zip"
Bundle "ap/vim-css-color"
" Python
Bundle "hynek/vim-python-pep8-indent"
Bundle "python.vim--Vasiliev"
" Haskell
Bundle "bitc/lushtags"
Bundle "Twinside/vim-haskellConceal"
Bundle "Twinside/vim-hoogle"
Bundle "indenthaskell.vim"
"Bundle "haskell.vim"
Bundle "syntaxhaskell.vim"
" Markdown
Bundle "tpope/vim-markdown"
" Syntax
Bundle "scrooloose/syntastic"
Bundle "scrooloose/nerdcommenter"
" Navigation
Bundle "IndexedSearch"
Bundle "camelcasemotion"
"Bundle "Lokaltog/vim-powerline"
Bundle "majutsushi/tagbar"
Bundle "godlygeek/tabular"
Bundle "tpope/vim-unimpaired"
Bundle "L9"
Bundle "FuzzyFinder"
"Bundle "fholgado/minibufexpl.vim"
"Bundle "techlivezheng/vim-plugin-minibufexpl"
" Misc
Bundle "tpope/vim-fugitive"
Bundle "tpope/vim-surround"
Bundle "AutoTag"
"Bundle "Shougo/neocomplcache"
"Bundle "AutoComplPop"
"Bundle "embear/vim-localvimrc"
"Bundle "ryan-cf/netrw"
filetype plugin indent on " Automatically detect file types, and enable file-type-specific plugins and indentation.
set expandtab smarttab tabstop=4 softtabstop=4 shiftwidth=4
syntax on
" Colors
set t_Co=256 " Set terminal to display 256 colors.
set background=dark
" Set 'TODO' & 'FIXME' strings to be bold and standout as hell. Works for jellybeans color scheme only.
let g:jellybeans_overrides = {
\ 'Todo': {
\ 'guifg': 'ff4500',
\ 'guibg': 'eeee00',
\ 'ctermfg': '196',
\ 'ctermbg': '226',
\ 'attr': 'standout'
\ }
\ }
" Misc color overrides.
colorscheme jellybeans
" Misc.
let mapleader="," " Set <leader> key to comma.
set nostartofline
set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay).
set history=256 " Number of things to remember in history.
"set autoread " Reload file if changed outside of Vim (DANGEROUS!).
set clipboard+=unnamed " Enable OS clipboard integration.
set hidden " The current buffer can be put to the background without writing to disk.
if strpart(expand("%:p:h"), 0, 7) != "scp://"
autocmd BufEnter * lchdir %:p:h " Sets current-directory of current buffer/file. We avoid using `set autchdir` instead, because it can cause problems with some plugins.
endif
"autocmd BufWritePost .vimrc source $MYVIMRC " Source .vimrc after saving it.
"set timeoutlen=500 " Set key-combination timeout.
set title " Show title in app title bar.
set ttyfast " Fast drawing.
set scrolloff=3 " Number of lines to keep above/below cursor when scrolling.
"set debug=msg " Show Vim error messages.
" Web
autocmd BufWinEnter *.json,*jshintrc setfiletype javascript
autocmd BufWinEnter *.scss setfiletype scss
autocmd BufWinEnter *.less setfiletype less
autocmd BufWinEnter *.html,*.htm setfiletype html
autocmd FileType css,scss,less set omnifunc=csscomplete#CompleteCSS
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType html,jinja set omnifunc=htmlcomplete#CompleteTags
autocmd FileType html setlocal syntax=jinja
autocmd FileType html,css,scss,less setlocal expandtab smarttab tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType html,jinja runtime! macros/matchit.vim
autocmd BufWritePost *.scss,*.sass !compass compile ../ <afile> --force
" Python
let python_highlight_all=1 " Enable all plugin's highlighting.
let python_slow_sync=1 " For fast machines.
let python_print_as_function=1 " Color 'print' function.
autocmd FileType python setlocal linebreak nosmartindent " nosmartindent for comment indentation problem.
autocmd FileType python set omnifunc=pythoncomplete#Complete
set wildignore+=*.pyc,*.pyo
set wildignore+=*.egg,*.egg-info
" Haskell
"let g:haskell_indent_if=3
"let g:haskell_indent_case=5
let hs_highlight_boolean=1
let hs_highlight_types=1
let hs_highlight_debug=1
let hs_allow_hash_operator=1
set wildignore+=*.hi,*.o
" C++
let g:syntastic_cpp_check_header=1
let g:syntastic_cpp_include_dirs=[ 'includes', 'include', 'inc', 'headers' ]
let g:syntastic_cpp_auto_refresh_includes=1
let g:syntastic_cpp_remove_include_errors=1
let g:syntastic_cpp_compiler_options=' -Wall -Wextra -Weffc++'
" Run `make ../makefile` if exists, else use `g++`.
"autocmd FileType cpp setlocal makeprg=[[\ -f\ ../makefile\ ]]\ &&\ make\ ../makefile\ -C\ ..\ \\\|\\\|\ g++
" Run output file after successful make.
"autocmd QuickfixCmdPost make call AfterMakeC()
"function! AfterMakeC()
"if len(getqflist()) == 0
"!../bin/runme
"endif
"endfunction
set wildignore+=*.a,*.o,*.so
" Java
autocmd FileType ant setlocal expandtab smarttab tabstop=2 softtabstop=2 shiftwidth=2
set wildignore+=*.class
" Markdown
autocmd BufWinEnter *.md,*.markdown setfiletype markdown
" Syntastic
"let g:syntastic_mode_map = {
"\ 'mode': 'active',
"\ 'active_filetypes': [],
"\ 'passive_filetypes': [] }
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_check_on_open=1
let g:syntastic_auto_loc_list=2 " Close error window automatically when there are no errors.
let g:syntastic_loc_list_height=5
let g:syntastic_enable_signs=1 " Show sidebar signs.
set statusline+=%#warningmsg# " Add Error ruler.
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" Map '`' to open error window.
nnoremap <silent> ` :Errors<CR>
" Local .vimrc
"let localvimrc_ask = 0 " Don't ask for permission to load, just do it.
" Camelcase motion
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
" Powerline
"let g:Powerline_symbols="unicode"
let g:Powerline_stl_path_style = 'short'
" Tagbar
nnoremap <silent> \ :TagbarToggle<CR>
" Search tag list from current dir up till root.
set tags=./tags;/
" Status Line
set shortmess=atI " Shortens messages in status line, truncates long messages, no intro (Uganda) message.
set laststatus=2 " Always show status line.
set showcmd " Display an incomplete command in status line.
" Window/buffer mangement.
" L9 is necessary for fuzzyfinder.
let g:fuf_modesDisable = []
let g:fuf_ignoreCase = 1
let g:fuf_timeFormat = '' " Remove time string.
let g:fuf_maxMenuWidth = 70
let g:fuf_file_exclude = '\v\~$|\.(exe|dll|bak|orig|swp|o|a|pyc|class)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])'
nnoremap <Leader>1 :FufBuffer<CR>
nnoremap <Leader>2 :FufFileWithCurrentBufferDir<CR>
nnoremap <Leader>3 :FufBufferTagAll<CR>
" Mini buffer explorer
let g:miniBufExplModSelTarget = 1 " Don't open buffer in a non-modifiable buffer (e.g. TagList window).
let g:miniBufExplCheckDupeBufs = 0 " For working with many buffers simultaneously.
let g:miniBufExplShowBufNumbers = 0 " No buffer numbers.
" Neo Complete Cache
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_auto_select = 1
let g:neocomplcache_enable_smart_case = 1
let g:neocomplcache_enable_auto_delimiter = 1
" Neo Complete Cache - C/C++
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
if !exists('g:neocomplcache_same_filetype_lists')
let g:neocomplcache_same_filetype_lists = {}
endif
let g:neocomplcache_same_filetype_lists.c = 'cpp,d'
let g:neocomplcache_same_filetype_lists.cpp = 'c'
if !exists('g:neocomplcache_delimiter_patterns')
let g:neocomplcache_delimiter_patterns= {}
endif
let g:neocomplcache_delimiter_patterns.cpp = ['::']
" Pressing `enter` will complete word and close completion menu.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
endfunction
" Searching
"set hlsearch " Highlight search.
set smartcase " Be case sensitive when input has a capital letter.
set incsearch " Show matches while typing.
set ignorecase " Ignore case when searching.
set gdefault " Make searched global `/g` by default.
if exists('&wildignorecase')
set wildignorecase " In-case-sensitive dir/file completion.
endif
set wildmenu " Enable menu for commands
set wildmode=list:longest " List options when hitting tab, and match longest common command.
" Formatting & Text
set encoding=utf-8
set nowrap " No line wrapping.
set linebreak " Wrap at word.
set textwidth=80 " Desirable text width. Used for text auto-wrapping. 0 means no auto-wrapping.
set cc=+1 " Highlight one column AFTER 'textwidth'.
" Enable auto-wrapping comments, comment leader auto-insertion
" in <Insert> mode, auto-format paragraphs, keep last line indentation.
" Disable all other format options.
" NOTE: Requires 'set autoindent'. autocmd FileType is required since
" I set `formatoptions` differently for each file type (.c, .py, etc.)."
autocmd FileType * set formatoptions=r,2
set backspace=indent,eol,start " Enable backspace key. Erase previously entered characters in insert mode.
set number " Show line numbers.
set showmatch " Show matching brace on insertion or cursor over.
set matchtime=3 " How many tenths of a second to wait before showing matching braces.
" Invisible characters.
if ! has("win32")
set listchars=tab:▸\ ,trail:¬,eol:« " Invisible characters.
endif
set nolist " Don't display invisible characters.
" Indentation
set autoindent " Automatically set the indent of a new line (local to buffer).
set smartindent
"set shiftround " Round shift actions. i.e. When at 3 spaces, and I hit > ... go to 4, not 5. FIXME: Doesn't work.
" Folding
set foldenable " Turn on folding.
set foldmethod=syntax " Fold on the marker.
" set foldlevel=0 " Fold everything when opening a file.
"set foldnestmax=1 " Don't fold inner blocks.
set foldopen=block,hor,tag,percent,mark,quickfix " Which movements open folds.
" Backup
set nobackup " Disable file backup before file overwrite attempt.
set nowritebackup
"set undofile " Keep undo actions even when a file (buffer) is closed.
"if has ("win32") " Set undo files location.
"set undodir=$HOME\vimfiles\undo
"set undodir+=C:\tmp
"set undodir+=C:\temp
"set undodir+=.
"else
"set undodir=$HOME/.vim/undo
"set undodir+=/var/tmp
"set undodir+=/tmp
"set undodir+=.
"endif
" Window splitting
"set equalalways " Multiple windows, when created, are equal in size. NOTE: Doesn't work well with MiniBufExpl.vim
set splitbelow splitright " New windows are created to the bottom-right.
" Mouse
"Set mouse behaviour to be like the OS's.
if has ("win32")
behave mswin
else
behave xterm
endif
"set mouse=a " Enable mouse.
set mouse-=a " Disable mouse.
set mousehide " Hide mouse after chars typed.
behave xterm " Make mouse behave like in xterm (instead of, e.g. Windows' command-prompt mouse).
set selectmode=mouse " Enable visule selection with mouse.
" Bells
set novisualbell " No blinking
"set noerrorbells " No noise.
"set vb t_vb= " Disable any beeps or flashes on error
" Ignored files
set wildignore+=*.swp " Vim
set wildignore+=*.jpg,*.jpeg,*.png,*.gif,*.psd " Ignore images
set wildignore+=*.pdf " Ignore PDF files
set wildignore+=*.DS_STORE
" Key mappings
" Page up/down.
noremap <C-k> <C-b>
noremap <C-j> <C-f>
" Window-change actions.
noremap <Up> <C-w>k
noremap <Down> <C-w>j
noremap <Left> <C-w>h
noremap <Right> <C-w>l