-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
402 lines (325 loc) · 11.8 KB
/
Copy pathvimrc
File metadata and controls
402 lines (325 loc) · 11.8 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
" Use Vim settings, rather then Vi settings (much better!).
set nocompatible
" =============== vim-plug Initialization ===============
" This loads all the plugins in ~/.vim/plugged
" Use vim-plug plugin to manage all other plugins
call plug#begin()
"Autocompletion bundles
Plug 'Shougo/neocomplcache.vim'
Plug 'jiangmiao/auto-pairs'
"file/directory movement bundles
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-eunuch'
if executable("ctags")
"requires exuberant-ctags
Plug 'majutsushi/tagbar'
endif
Plug 'tpope/vim-projectile'
"handy editing bundles
Plug 'sjl/gundo.vim'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'godlygeek/tabular'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-abolish'
Plug 'vim-scripts/YankRing.vim'
Plug 'mhinz/vim-startify'
Plug 'Shougo/unite.vim'
Plug 'Yggdroot/indentLine'
Plug 'nelstrom/vim-visual-star-search'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'tpope/vim-sleuth'
"Language support bundles
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-git'
Plug 'jnwhiteh/vim-golang'
"misc bundles
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'joonty/vdebug'
Plug 'christoomey/vim-tmux-navigator'
Plug 'mileszs/ack.vim'
Plug 'Keithbsmiley/investigate.vim'
" Colorschemes
Plug 'nanotech/jellybeans.vim'
Plug 'chriskempson/base16-vim'
Plug 'reedes/vim-thematic'
call plug#end()
" ================ General Config ====================
set t_Co=256 "Always use all 256 colors
set number "Line numbers are good
set hidden "It's okay to have buffers that are hidden
set showcmd "show partially written commands (in the bottom-right corner)
set backspace=indent,eol,start "Allow backspace in insert mode
set history=10000 "Store lots of :cmdline history
set gcr=a:blinkon0 "Disable cursor blink, does not work in terminal
set visualbell "No sounds
set t_vb= "No flashes
set autoread "Reload files changed outside vim
set cursorline "highlight the current line always
set ruler "get a handy ruler in the corner
set encoding=utf-8 "Necessary to show unicode glyphs for powerline
set fileformats=unix,mac,dos "get all the file formats, set to particular one using :set fileformat= command
set showmatch "show matching bracket always
set mouse=a "set mouse mode to all, so i can use it
set laststatus=2 "always show the status line, required with powerline
set nofoldenable "Say no to code folding...
set cpoptions+=$ "show $ at the end of the selection when using c
set listchars=tab:▸\ ,eol:¬ "set characters to represent tabs and \n when visible
set scrolloff=3 "scroll with some context
set sidescrolloff=5
set spelllang=en_gb "set spell to use british english
set ignorecase "ignore case when looking for patterns
set smartcase "override ignore case when pattern has upper case
set hlsearch "highlight matched patterns
set incsearch "search incrementally for pattern
set virtualedit=block "allow virtual editing in visual mode
"use system clipboard by default for yanking and pasting
set clipboard=unnamed
if has("unix")
" X system clipboard is different,so
set clipboard=unnamedplus
endif
"use persistent undo if available
if has('persistent_undo')
set undofile
endif
syntax on
" ================ remapped keys =====================
" remap leader key
let mapleader = " "
" shows invisibles in normal mode
nmap <leader>l :set list!<CR>
"logical movement
noremap j gj
noremap k gk
" toggle spell check
nmap <leader>s :set spell!<CR>
"never press shift to enter commands again
nmap ; :
" remove highlighting
nmap <leader>rh :noh<CR>
" a more logical Y in normal mode
nnoremap Y y$
" I can type :help on my own, thanks.
inoremap <F1> <Esc>
noremap <F1> <Esc>
vnoremap <F1> <Esc>
" Quickly edit the vimrc file in the repo
nmap <silent> <leader>ev :tabe $MYVIMRC<CR>
" ================ Persistent swp/backup ==================
" Keep swaps and backups in one place,
" but avoid the current directory
if isdirectory(expand('~/.cache/vim'))
set directory^=~/.cache/vim//
set backupdir^=~/.cache/vim//
set undodir=~/.cache/vim//
else "never store it in the current directory ever
if !isdirectory(expand('$HOME/.vim_cache'))
silent execute '!mkdir '.expand('$HOME/.vim_cache')
endif
set backupdir^=$HOME/.vim_cache/
set directory^=$HOME/.vim_cache/
set undodir=~/.vim_cache/
endif
" ================ Indentation ======================
" default settings
set autoindent
set smartindent
set smarttab
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set shiftround "round off indent to multiple of shiftwidth, untested
filetype plugin indent on
set nowrap "Don't wrap lines
set linebreak "Wrap lines at convenient points, without inserting <EOL>s
if has('autocmd')
augroup FileBasedSettings
autocmd!
"Adjust indentation by filetype
autocmd FileType go setlocal ai ts=8 sw=8 noexpandtab
"Spellcheck git messages
autocmd BufRead COMMIT_EDITMSG setlocal spell
augroup END
"Auto source vimrc when saved
augroup VimReload
autocmd!
autocmd BufWritePost $MYVIMRC,vimrc echo "Reloading vimrc..."
autocmd BufWritePost $MYVIMRC,vimrc so $MYVIMRC
autocmd BufWritePost $MYVIMRC,vimrc echo "DONE"
augroup END
"Always open help in a new tab
augroup HelpInTabs
autocmd!
autocmd BufEnter *.txt call HelpInNewTab()
function! HelpInNewTab ()
if &buftype == 'help'
execute "normal \<C-W>T"
endif
endfunction
augroup END
"automatically move to last position in a file
augroup ReloadPosition
"automatically jump to the last place you were in a previous session
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$")
\| exe "normal! g`\""
\| endif
augroup END
endif
" ================ Completion =======================
set wildmenu
set wildmode=longest,full
set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.gitkeep,*~ "stuff to ignore when tab completing
" ================ Appearance =======================
let base16colorspace=256
"thematic configuration
let g:thematic#defaults = {
\ 'airline-theme': 'dark',
\ 'background': 'dark',
\ 'laststatus': 2,
\ 'typeface': 'Source Code Pro',
\ 'font-size': 10,
\ }
let g:thematic#themes = {
\ 'solarized-dark':{
\ 'colorscheme': 'base16-solarized',
\ 'background': 'dark',
\ },
\ 'solarized-light':{
\ 'colorscheme': 'base16-solarized',
\ 'background': 'light',
\ },
\ 'lakeside':{
\ 'colorscheme': 'base16-atelierlakeside',
\ },
\ 'tomorrow':{
\ 'colorscheme': 'base16-tomorrow',
\ },
\ 'seaside':{
\ 'colorscheme': 'base16-seaside',
\ },
\ 'paraiso':{
\ 'colorscheme': 'base16-paraiso',
\ 'airline-theme': 'base16_paraiso',
\ },
\ }
let g:thematic#theme_name = 'paraiso'
" ================ Plugin customisation =============
"syntastic
let g:syntastic_error_symbol='✗' "change the default error symbol
"NERDTree
let NERDTreeIgnore = ['\.pyc$'] "ignore files in file browser
" open NERDTree window
nnoremap <F4> :NERDTreeToggle<CR>
"Gundo
let g:gundo_preview_bottom = 1 "improve how gundo window is displayed
" open gundo window
nnoremap <F3> :GundoToggle<CR>
"Yankring
let g:yankring_persist = 0 "don't persist yankring across session
let g:yankring_history_dir = '~/.vim'
" open tagbar window
nmap <F8> :TagbarToggle<CR>
" signify configuration options
let g:signify_vcs_list = [ 'git', 'perforce' ]
" Options for neocomplcache
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'"
" Plugin key-mappings.
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#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 neocomplcache#smart_close_popup() . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? neocomplcache#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> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()"
" Enable omni completion.
augroup NeoOmniCompleteSettings
autocmd!
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown 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
augroup END
" Settings for Unite
" Use the fuzzy matcher for everything
call unite#filters#matcher_default#use(['matcher_fuzzy'])
" Set up some custom ignores
call unite#custom_source('file_rec,file_rec/async,file,buffer,grep',
\ 'ignore_pattern', join([
\ '\.git/',
\ ], '\|'))
" Map space to the prefix for Unite
nnoremap [unite] <Nop>
nmap <space> [unite]
" General fuzzy search
nnoremap <silent> [unite]<space> :<C-u>Unite
\ -buffer-name=files buffer file_rec<CR>
" Quick buffer and mru
nnoremap <silent> [unite]b :<C-u>Unite -buffer-name=buffers buffer<CR>
" Quick yank history
nnoremap <silent> [unite]y :<C-u>Unite -buffer-name=yanks history/yank<CR>
" Quick file search
nnoremap <silent> [unite]f :<C-u>Unite -buffer-name=files file_rec file/new<CR>
" Quick help
nnoremap <silent> [unite]h :<C-u>Unite -buffer-name=help help<CR>
" Quick line using the word under cursor
nnoremap <silent> [unite]l :<C-u>UniteWithCursorWord -buffer-name=search_file line<CR>
" Quick commands
nnoremap <silent> [unite]c :<C-u>Unite -buffer-name=commands command<CR>
" create mappings inside unite buffers
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
"mappings to leave unite
nmap <buffer> <ESC> <Plug>(unite_exit)
imap <buffer> <ESC> <Plug>(unite_insert_leave)
"mappings to move in unite buffers
imap <buffer> <c-j> <Plug>(unite_insert_leave)
nmap <buffer> <c-j> <Plug>(unite_loop_cursor_down)
nmap <buffer> <c-k> <Plug>(unite_loop_cursor_up)
imap <buffer> <c-a> <Plug>(unite_choose_action)
nmap <buffer> <C-r> <Plug>(unite_redraw)
imap <buffer> <C-r> <Plug>(unite_redraw)
"mappings to open in split
inoremap <silent><buffer><expr> <C-s> unite#do_action('split')
nnoremap <silent><buffer><expr> <C-s> unite#do_action('split')
inoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
nnoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
nnoremap <silent><buffer><expr> cd unite#do_action('lcd')
endfunction
" Start in insert mode
let g:unite_enable_start_insert = 1
" Enable history yank source
let g:unite_source_history_yank_enable = 1
" Open in bottom right
let g:unite_split_rule = "botright"
" Shorten the default update date of 500ms
let g:unite_update_time = 200
let g:unite_cursor_line_highlight = 'TabLineSel'
" config for airline
let g:airline_left_sep = ''
let g:airline_right_sep = ''