-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path.vimrc
More file actions
430 lines (365 loc) · 12.3 KB
/
.vimrc
File metadata and controls
430 lines (365 loc) · 12.3 KB
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
" vim: set fdm=marker :
" #Bundles {{{
" Bundler that knows how to 'make' "{{{
if has('vim_starting')
set nocompatible " Be iMproved
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
"}}}
" Run and manage child processes, dependency of many other plugins "{{{
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
"}}}
" Ultimate UI system for running fuzzy-search on different things {{{
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Slava/vim-unite-files-ag'
" Always start insert mode
let g:unite_enable_start_insert = 1
let g:unite_source_history_yank_enable = 1
let g:unite_split_rule = "botright"
" `ag` is a faster and better replacement for the standard `find`, let Unite use
" it if it exists and configure to properly use `.gitignore` or `.hgignore`
" files if those exist.
" To install `ag`: brew install ag
" or: https://github.com/ggreer/the_silver_searcher
if executable("ag")
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
let g:unite_source_grep_recursive_opt = ''
endif
" Search settings
if exists("*unite")
call unite#filters#matcher_default#use(['matcher_fuzzy'])
call unite#filters#sorter_default#use(['sorter_rank'])
call unite#set_profile('files', 'smartcase', 1)
endif
"}}}
" Auto-completion plugin integrated with Unite and vimshell {{{
NeoBundle 'Shougo/neocomplete.vim'
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#min_keyword_length = 3
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
" For no inserting <CR> key.
return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
"}}}
" Expand/shrink the visual selection by text-object blocks with `+` and `_` in
" the visual mode
NeoBundle 'terryma/vim-expand-region'
" Undo/Redo tree
NeoBundle 'sjl/gundo.vim'
" Insert/Delete brackets in pairs
NeoBundle 'jiangmiao/auto-pairs'
" Git wrapper
NeoBundle 'tpope/vim-fugitive'
" A lot of shortcuts for next/prev navigation, usually is [x and ]x for moving
" back and forth for X
NeoBundle 'tpope/vim-unimpaired'
" Easy commands to rename tabs {{{
NeoBundle 'gcmt/taboo.vim'
" required to be able to save the tab names into a session
set sessionoptions+=tabpages,globals
" }}}
" Save sessions {{{
NeoBundle 'xolox/vim-misc'
NeoBundle 'xolox/vim-session'
let g:session_autosave_periodic = 1
let g:session_autosave = 'yes'
let g:session_autoload = 'yes'
" }}}
" Fugitive menu in Unite (depends on both Fugitive and Unite.vim) {{{
let g:unite_source_menu_menus = {}
let g:unite_source_menu_menus.git = {}
let g:unite_source_menu_menus.git.description = 'git (Fugitive)'
let g:unite_source_menu_menus.git.command_candidates = [
\['▷ git status (Fugitive)',
\'Gstatus'],
\['▷ git diff (Fugitive)',
\'Gdiff'],
\['▷ git commit (Fugitive)',
\'Gcommit'],
\['▷ git log (Fugitive)',
\'exe "silent Glog | Unite quickfix"'],
\['▷ git blame (Fugitive)',
\'Gblame'],
\['▷ git stage (Fugitive)',
\'Gwrite'],
\['▷ git checkout (Fugitive)',
\'Gread'],
\['▷ git rm (Fugitive)',
\'Gremove'],
\['▷ git mv (Fugitive)',
\'exe "Gmove " input("destino: ")'],
\['▷ git push (Fugitive, output buffer)',
\'Git! push'],
\['▷ git pull (Fugitive, output buffer)',
\'Git! pull'],
\['▷ git prompt (Fugitive, output buffer)',
\'exe "Git! " input("comando git: ")'],
\['▷ git cd (Fugitive)',
\'Gcd'],
\]
" }}}
" Different stuff in the menu (depends on Unite.vim) {{{
let g:unite_source_menu_menus.all = {}
let g:unite_source_menu_menus.all.description = 'All things'
let g:unite_source_menu_menus.all.command_candidates = [
\['▷ gundo toggle undo tree', 'GundoToggle'],
\['▷ save file', 'write'],
\['▷ save all opened files', 'wall'],
\['▷ make the current window the only one on the screen', 'only'],
\['▷ open file (Unite)', 'Unite -start-insert file'],
\['▷ open file recursively (Unite)', 'Unite -start-insert files_ag'],
\['▷ open buffer (Unite)', 'Unite -start-insert buffer'],
\['▷ open directory (Unite)', 'Unite -start-insert directory -profile-name=files'],
\['▷ open tab (Unite)', 'Unite -start-insert tab'],
\['▷ toggle the background color', 'ToggleBG'],
\['▷ open the shell (VimShell)', 'VimShell'],
\['▷ open a new shell (VimShell)', 'VimShellCreate'],
\['▷ open a new shell in a tab (VimShell)', 'VimShellTab'],
\['▷ open a node interpreter (VimShell)', 'VimShellInteractive node'],
\['▷ install bundles (NeoBundleInstall)', 'NeoBundleInstall'],
\['▷ clean bundles (NeoBundleClean)', 'NeoBundleClean'],
\['▷ update bundles (NeoBundleUpdate)', 'NeoBundleUpdate'],
\['▷ rename tab (Taboo)', 'execute "TabooRename " . input("New tab name:")'],
\]
" }}}
" Surrond plugin! Surrond text with a pair of anything (s in normal) "{{{
NeoBundle 'tpope/vim-surround'
"}}}
" Vim JS autocompletion with type hints "{{{
NeoBundle 'marijnh/tern_for_vim'
let g:tern_show_argument_hints = 'on_move'
"}}}
" Syntax definitions "{{{
NeoBundle "slava/vim-spacebars"
NeoBundle "groenewege/vim-less"
NeoBundle "elzr/vim-json"
NeoBundle "tpope/vim-markdown"
NeoBundle "pangloss/vim-javascript"
NeoBundle "leafgarland/typescript-vim"
" Actually does much more than syntax highlighting but that's overkill for me
NeoBundle "kchmck/vim-coffee-script"
NeoBundle "hdima/python-syntax"
"}}}
" OMG OMG, shell in my VIM {{{
NeoBundle "Shougo/vimshell"
let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")'
let g:vimshell_prompt = '$ '
" open new splits actually in new tab
let g:vimshell_split_command = "tabnew"
if has("gui_running")
let g:vimshell_editor_command = "mvim"
endif
"}}}
" ##Visual
" Prettiness on the bottom {{{
" That weird colorful line on the bottom
NeoBundle "bling/vim-airline"
let g:airline_theme='tomorrow'
set laststatus=2
set encoding=utf-8
if has("gui_running")
let g:airline_powerline_fonts=1
" Even special font for this crap
set guifont=Source\ Code\ Pro\ for\ Powerline:h13
endif
function! AirlineOverride(...)
let g:airline_section_a = airline#section#create(['mode'])
let g:airline_section_b = airline#section#create_left(['branch'])
let g:airline_section_c = airline#section#create_left(['%f'])
let g:airline_section_y = airline#section#create([])
endfunction
autocmd VimEnter * call AirlineOverride()
" }}}
" Visually sets marks
NeoBundle "kshenoy/vim-signature"
" Colorscheme {{{
NeoBundle "Slava/vim-colors-tomorrow"
set t_Co=256
let g:tomorrow_termcolors = 256
let g:tomorrow_termtrans = 0 " set to 1 if using transparant background
let g:tomorrow_diffmode = "high"
"set background=light
set background=dark
" }}}
call neobundle#end()
" }}}
" #Essentials {{{
" Turns syntax highlighting on
syntax enable
" Numbers, can you imagine?
set number
" Extra info on the bottom
set ruler
" Highlight current line
set cursorline
" Leader key is comma
let mapleader = ","
" ##Search tweaks {{{
set hlsearch
set incsearch
" Kill current search
nnoremap <silent> <Leader>/ :nohlsearch<CR>
"}}}
" ##AutoCmd essentials{{{
if has("autocmd")
" Enable file type detection
filetype on
filetype plugin indent on
endif
"}}}
" Prefer spaces to tabs and set size to 2
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
" Allows to use mouse to move the cursor
set mouse=a
" Tweak the behavior of <Tab> in command mode
set wildmenu
set wildmode=longest:full,full
" Indentation tweaks:
" reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" dumb indent
set autoindent
" No need to switch back to English in normal mode
set langmap=ёйцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕHГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;`qwertyuiop[]asdfghjkl\\;'zxcvbnm\\,.QWERTYUIOP{}ASDFGHJKL:\\"ZXCVBNM<>
" Buffers tweaks
" Allow to switch from changed buffer
set hidden
" Splits tweaks {{{
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" I want new splits to appear to the right and to the bottom of the current
set splitbelow
set splitright
" }}}
" Wrapping tweaks "{{{
set wrap
set linebreak
set textwidth=80
set formatoptions=cq " format using textwidth, including comments and gq
"}}}
" I can type :help myself, thanks.
noremap <F1> <Esc>
" Save undo history persistently on disk, takes extra space "{{{
if has('persistent_undo') " persistend undo history
" create the directory if it doesn't exist
silent !mkdir ~/.vim/undo > /dev/null 2>&1
set undofile " Save undo's after file closes
set undodir=~/.vim/undo/ " where to save undo histories
set undolevels=100 " How many undos
set undoreload=3000 " number of lines to save for undo
endif
"}}}
" Gaming swap files "{{{
" create the directory if it doesn't exist
silent !mkdir ~/.vim/swap > /dev/null 2>&1
set backupdir=~/.vim/swap/
set directory=~/.vim/swap/
"}}}
" MacVim or GVim options "{{{
if has("gui_running")
" hide left-hand scrollbar
set guioptions-=L
" hide right-hand scrollbar
set guioptions-=r
" hide toolbar (gvim only)
set guioptions-=T
" no pop-up dialogs
set guioptions-=c
endif
"}}}
" Semicolon is just colon
nnoremap ; :
" Tweak ESC to be 'jk' typed fast
imap jk <ESC>
" Do not disable it, since kinesis has cool remap to the left thumb
" imap <ESC> <nop>
"}}}
" #Leader mappings {{{
" Show/hide invisibles by <leader>l
nnoremap <leader>l :set list!<CR>
" Toggle spelling on/off
nnoremap <silent> <leader>s :set spell!<CR>
" Tab movements
nnoremap <leader>m :tabn<CR>
nnoremap <leader>n :tabp<CR>
" Save file quickly
nnoremap <leader>w :w<CR>
" Quickly cd to directory
nnoremap <leader>d :Unite -start-insert directory -profile-name=files<CR>
" Paste from the yank history
nnoremap <leader>p :Unite -start-insert history/yank<CR>
" Trigger the git menu
nnoremap <leader>g :Unite -silent -start-insert menu:git<CR>
" Open all menus with useful stuff
nnoremap <leader>j :Unite -silent -start-insert menu:all menu:git<CR>
" Select across all buffers
nnoremap <leader>b :Unite -start-insert buffer<CR>
" }}}
" #Other mappings {{{
" Quickly open files or buffers
nnoremap <C-n> :Unite -start-insert file -profile-name=files<CR>
nnoremap <C-space> :Unite -start-insert files_ag<CR>
nnoremap <C-p> :Unite -start-insert buffer_tab<CR>
"}}}
" Automatically reload vimrc when it's saved "{{{
augroup VimrcSo
au!
autocmd BufWritePost $MYVIMRC so $MYVIMRC
augroup END
"}}}
" Set shell to bash (because vim would conflict with the default system shell)
set shell=/bin/bash
" For the VimR search rules
set wildignore=*.so,*.a,*.pyc,.meteor,.build.*,.git
" This is good enough for folding and is not as slow as "syntax"
set foldmethod=indent
try
colorscheme tomorrow
set background=dark
catch
" we don't have this theme or it throws
endtry