forked from rasendubi/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
394 lines (316 loc) · 8.25 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
393
394
set shell=/bin/sh
" Basic settings {{{
set nocompatible
let mapleader = " "
let localleader = "\\"
set number
set nowrap
set autoindent
set smartindent
set backspace=indent,eol,start
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
filetype plugin on
syntax on
set showmatch "brackets
" Enable mouse
set mouse=a
" Do not create backup files
set nobackup
set nowritebackup
set noswapfile
set showcmd
set scrolloff=2
set title
set hlsearch
nohlsearch
set incsearch
" List completions
set wildmode=longest:list,full
set langmap=йq,цw,уe,кr,еt,нy,гu,шi,щo,зp,х[,ъ],фa,ыs,вd,аf,пg,рh,оj,лk,дl,ж\\;,э',яz,чx,сc,мv,иb,тn,ьm,ю.,ё',ЙQ,ЦW,УE,КR,ЕT,НY,ГU,ШI,ЩO,ЗP,Х\{,Ъ\},ФA,ЫS,ВD,АF,ПG,РH,ОJ,ЛK,ДL,Ж\:,Э\",ЯZ,ЧX,СC,МV,ИB,ТN,ЬM,Б\<,Ю\>
set list
set listchars=tab:»\ ,trail:·,extends:>,nbsp:.
set exrc
set secure
" }}}
"" Status line settings {{{
" Always show status line
set laststatus=2
"" }}}
"NeoBundle Scripts----------------------------- {{{
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
if has('nvim')
set runtimepath+=~/.nvim/bundle/neobundle.vim/
else
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
endif
" Required:
if has('nvim')
call neobundle#begin(expand('~/.nvim/bundle'))
else
call neobundle#begin(expand('~/.vim/bundle'))
endif
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" Add or remove your Bundles here:
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'linux' : 'make',
\ 'unix' : 'gmake',
\ },
\ }
" NeoBundle 'Valloric/YouCompleteMe', {
" \ 'build' : {
" \ 'linux' : 'git submodule update --init --recursive && ./install.sh --clang-completer --system-libclang',
" \ },
" \ }
" NeoBundle 'altercation/vim-colors-solarized'
if &term != 'linux'
NeoBundle 'bling/vim-airline'
endif
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'SirVer/ultisnips'
NeoBundle 'honza/vim-snippets'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-surround'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'pbrisbin/vim-mkdir'
NeoBundle 'tpope/vim-surround'
" NeoBundle 'scrooloose/syntastic'
NeoBundle 'tomasr/molokai'
NeoBundle 'pbrisbin/vim-syntax-shakespeare'
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'aklt/plantuml-syntax'
NeoBundle 'jceb/vim-orgmode'
" NeoBundle 'flazz/vim-colorschemes'
" Required:
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"End NeoBundle Scripts------------------------- }}}
" Edit .vimrc and commands {{{
" local .vimrc
if has('nvim')
nnoremap <leader>ev :vsplit .nvimrc<CR>
else
nnoremap <leader>ev :vsplit .vimrc<CR>
endif
nnoremap <leader>gv :vsplit $MYVIMRC<CR>
" Insert <leader> and <Esc>
cnoremap <C-l> <lt>leader>
cnoremap <C-E> <lt>Esc>
" }}}
" Navigation {{{
" Start and end of line
nnoremap H ^
nnoremap L $
vnoremap L g_
nnoremap j k
nnoremap k j
nnoremap gj gk
nnoremap gk gj
vnoremap j k
vnoremap k j
vnoremap gj gk
vnoremap gk gj
" }}}
" Window manipulation {{{
" Resize window {{{
nnoremap + <C-W>+
nnoremap _ <C-W>-
" the next one conflicts with ==
" nnoremap = <C-W>>
nnoremap - <C-W><
" }}}
" Manipulate windows {{{
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
inoremap <C-h> <C-o><C-w>h
inoremap <C-j> <C-o><C-w>j
inoremap <C-k> <C-o><C-w>k
inoremap <C-l> <C-o><C-w>l
" }}}
" Remove search highlight
nnoremap <silent> <leader>/ :nohlsearch<CR>
" Use jk to exit insert-mode
" This increases productivity
inoremap jk <Esc>
" Convert word to uppercase
inoremap <C-U> <Esc>viwUea
nnoremap <silent> <leader>, :cprevious<CR>
nnoremap <silent> <leader>. :cnext<CR>
if has('nvim')
nnoremap <silent> <M-,> :cprevious<CR>
nnoremap <silent> <M-.> :cnext<CR>
endif
" Hard way (restrict use of some features) {{{
nnoremap o<Esc> :echoerr "Use <lt>leader>o instead"<cr>
nnoremap O<Esc> :echoerr "Use <lt>leader>O instead"<cr>
" }}}
" }}} (mappings)
augroup filteype_c
autocmd!
autocmd FileType c,cpp setlocal cindent
augroup end
" Python file settings {{{
augroup filetype_python
autocmd!
if has('nvim')
autocmd FileType python nnoremap <buffer> <F5> :vsplit \| ./%<CR>
autocmd FileType python nnoremap <buffer> <F4> :vsplit \| ./%
else
autocmd FileType python nnoremap <buffer> <F5> :!./%<CR>
autocmd FileType python nnoremap <buffer> <F4> :!./%
endif
augroup end
" }}}
" Vimscript file settings {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
autocmd FileType vim setlocal nolinebreak
" Insert <leader> and <Esc>
autocmd FileType vim inoremap <buffer> <C-l> <lt>leader>
autocmd FileType vim inoremap <buffer> <C-V><Esc> <lt>Esc>
autocmd FileType vim inoremap <buffer> <C-V><CR> <lt>CR>
autocmd FileType vim nnoremap <buffer> <F5> :source %<CR>
autocmd FileType vim setlocal keywordprg=:help
augroup end
" }}}
" Haskell file settings {{{
function! GHCI()
if !bufexists('ghci')
split
exec "normal \<C-w>J"
term cabal exec ghci %
file ghci
set bufhidden=hide
tnoremap <buffer> <C-r> :r<cr>
else
let win = bufwinnr('ghci')
if win != -1
exec "normal " . win . "\<C-w>w"
startinsert
end
end
endfunction
augroup filetype_haskell
autocmd!
autocmd FileType haskell,cabal setlocal expandtab
autocmd FileType haskell compiler ghc
if has('nvim')
autocmd FileType haskell nnoremap <buffer> <F5> :call GHCI()<cr>
else
autocmd FileType haskell nnoremap <buffer> <F5> :!cabal exec ghci %<cr>
endif
augroup end
" }}}
" Markdown file settings {{{
augroup filetype_markdown
autocmd!
autocmd FileType markdown setlocal wrap
autocmd FileType markdown setlocal linebreak
autocmd FileType markdown nnoremap <buffer> j gj
autocmd FileType markdown nnoremap <buffer> k gk
augroup end
" }}}
let g:airline_powerline_fonts = 1
" YCM settings {{{
let g:clang_library_path = "/usr/lib64/"
let g:clang_complete_copen = 0
let g:clang_hl_errors = 1
let g:clang_snippets = 1
let g:clang_snippets_engine = "ultisnips"
let g:clang_close_preview = 1
let g:clang_complete_macros = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_use_ultisnips_completer = 1
let g:ycm_key_list_select_completion=[]
let g:ycm_key_list_previous_completion=[]
let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"
" }}}
" Easymotion {{{
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_startofline = 0
nmap <M-f> <Plug>(easymotion-f)
nmap <M-F> <Plug>(easymotion-F)
nmap <M-t> <Plug>(easymotion-t)
nmap <M-T> <Plug>(easymotion-T)
nmap <M-w> <Plug>(easymotion-w)
nmap <M-W> <Plug>(easymotion-W)
nmap <M-b> <Plug>(easymotion-b)
nmap <M-B> <Plug>(easymotion-B)
nmap <M-e> <Plug>(easymotion-e)
nmap <M-E> <Plug>(easymotion-E)
nmap <M-/> <Plug>(easymotion-sn)
nmap <M-n> <Plug>(easymotion-next)
nmap <M-N> <Plug>(easymotion-prev)
" JK motions: Line motions
nmap <M-j> <Plug>(easymotion-j)
nmap <M-k> <Plug>(easymotion-k)
" set nohlsearch " easymotion does it
" }}}
let g:netrw_altv = 1
if &t_Co >= 256
" set background=dark
" colorscheme solarized
" highlight clear SignColumn
let g:molokai_original = 1
let g:rehash256 = 1
set cursorline
colorscheme molokai
endif
let g:load_doxygen_syntax = 1
let g:ctrlp_map = '<c-u>'
" Fast saving and closing
nnoremap <leader><leader> :w<cr>
nnoremap <leader>q :q!<cr>
nnoremap <leader>w :wq<cr>
" Opening splits
nnoremap <leader>v <C-w><C-v><C-w>l
nnoremap <leader>s <C-w>s
" Insert newline and stay in normal mode
nnoremap <silent> <leader>o o<Esc>
nnoremap <silent> <leader>O O<Esc>
if has('nvim')
nnoremap <M-h> :tabp<cr>
nnoremap <M-l> :tabn<cr>
else
" alt + h
nnoremap h :tabp<cr>
" alt + l
nnoremap <Esc>l :tabn<cr>
endif
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
endif
" swap ; and .
nnoremap . ;
nnoremap ; .
" repeat last command but prefix with !
nnoremap !: q:kI!<esc><cr>
cmap w!! w! !sudo tee % >/dev/null
" inoremap <Tab> <C-R>=strpart(getline('.'),0,col('.')-1)=~"^[ \t]*$"?"\t":repeat(' ',4-virtcol('.')%4)<cr>
if has('nvim')
tnoremap <Esc><Esc> <C-\><C-n>
end
" workman fixes
nnoremap j k
nnoremap k j
vnoremap j k
vnoremap k j