blob: d716a0e0c6670e0b4daef006de5ae9043cd01938 (
plain)
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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
"""""""""""""""""""""""""""""""""""""
" Miguel's .vimrc "
" Author: Michal Idziorek "
" Last Update: 2018-05-29 "
"""""""""""""""""""""""""""""""""""""
" {{{ TODO / NOTES
"
" http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/
" set exrc
" set secure
"
" https://github.com/spf13/spf13-vim
" http://antjanus.com/blog/thoughts-and-opinions/use-vim/
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/
" http://derekingrouville.com/2012/vim-is-my-ide/
" http://www.alexeyshmalko.com/2014/using-vim-as-c-cpp-ide/
"
" * check out this plugins! (and many more from vim.org)
"
" taglist.vim
" NerdTree DONE
" snipMate
" c.vim ?
" autocomplpop
" pathogen DONE
" minibufexpl DONE
" fugitive DONE
" vim-sensible DONE
" surround
" perl-support ?
" matchit
" vimspell
" conqueshell
" fuzzyfinder
" Nerd Commenter
" tSkeleton
" grep
" cppcomplete
" colortest ?
" colour sampler pack
" gundo!
" CScope / CCTree
" inline reference/ (stlrefvim?)
" emmet.io (webdev)
"
" * jump to definition / list calls
"
" * spellcheck / translate / thesaurus
"
" * change mappings to more specific mappings and use noremap!
"
" * toggle 'cursorline' via hotkey for nicer reading experience.
"
" * spellcheck
"
" * ft=c.doxygen etc.
"
" * include dependancies as git submodules (wherever possible)
" (check licenses first)
"
" * :help complete-functions
"
" * spellcheck
"
" * ctags shortcuts?
"
" * quickfix
"
" * compiler/debugger invocation
"
" * implement a plugin for fast-reading (check if one exists first ;))
"
" * release vim-colortune plugin
"
" * dictionary
"
" * load layout automatically on start
"
" * ConqueGDB Resize
"
" * Do something about startup lag (because of YouCompleteMe)
"
" * Do something about the input problems in ConqueGDB/Term (YouCompl?)
"
" }}}
" {{{ Vundle - Plugin Manager
"
" Vundle plugin manager (Replaces pathogen)"
" https://github.com/VundleVim/Vundle.vim
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" github plugins
" Plugin 'Valloric/YouCompleteMe'
Plugin 'fholgado/minibufexpl.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-sensible'
Plugin 'vim-scripts/Conque-GDB'
" My own plugins on github
" Plugin 'git://ex40.softwarefools.com/vim-potion.git'
" Plugin 'git://ex40.softwarefools.com/vim-colortune.git'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" draculatheme.com
" Plugin 'dracula/vim'
" syntax on
" color dracula
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" All of your Plugins must be added before the following line
call vundle#end()
filetype plugin indent on
" To ignore plugin indent changes, instead use:
" filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" }}}
let g:ConqueGdb_Leader = '\'
let g:ConqueTerm_CloseOnEnd = 1
set nowrap
set invlist
" PATH
" let $PATH='/home/miguel/opt/gcc-5.1.0/bin:'.$PATH
" let $PATH='/home/miguel/opt/gcc-5.2.0/bin:'.$PATH
" Basic Settings
" {{{
" let there be mapleaders
" {{{
" use <space> but remap to _ so it is visible for 'showcmd'
nmap <space> _
let mapleader="\_"
let maplocalleader="\_"
" }}}
" filetype stuff
" {{{
filetype plugin indent on
" }}}
" misc!
" {{{
let g:potion_command = "/home/miguel/int/dev/potion/bin/potion"
set nocompatible
set backspace=2
" set ruler
set showcmd
set number
set hidden
" set cursorcolumn
" set cursorline
" save before making etc.
set autowrite
" some nice candy
set laststatus=2
set wildmenu
" indent
set autoindent
set cindent
" mouse support in xterm
set mouse=a
"other
set previewheight=25
" http://robots.thoughtbot.com/vim-splits-move-faster-and-more-naturally
" set splitbelow
" set splitright
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" }}}
" set the status line
" {{{
set statusline=%f " Path to the file
set statusline+=%= " Switch to the right side
set statusline+=%l " Current line
set statusline+=/ " Separator
set statusline+=%L " Total lines
set statusline+=, " comma
set statusline+=%c " Column
set statusline+=\ (%P) " Percentage
" }}}
" terminal width / colorcolumn
" {{{
" http://richarddingwall.name/2008/05/31/is-the-80-character-line-limit-still-relevant/
"
" set tw=80
" set tw=72
" set tw=78 (for instance vims :help)
set tw=0
set colorcolumn=73
" }}}
" wrapping
" {{{
"set wrap
"set showbreak=>_
" }}}
" tabs
" {{{
set listchars=tab:>.
set tabstop=8
set shiftwidth=4
set softtabstop=4
set shiftround
" }}}
" folding
" {{{
set foldcolumn=5
set foldlevelstart=0
" }}}
" colorscheme / syntax highlight
" {{{
"colorscheme olgas
colorscheme desert
syntax enable
syntax sync fromstart
" }}}
" minimize gui
" {{{
" set guioptions=
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions-=L
set guifont=Monospace\ 9
" }}}
" searching
" {{{
set hlsearch
set incsearch
" }}}
" bracket matching and matchtime in ms.
" {{{
set showmatch
set matchtime=5
" }}}
" }}}
" Mappings / Custom Global Keybindings
" {{{
" first of all: temporary mappings, to get rid of some bad habits.
"inoremap <esc> <nop>
"inoremap <Up> <nop>
"inoremap <Down> <nop>
"inoremap <Left> <nop>
"inoremap <Right> <nop>
" alternative to esc in insert mode!
inoremap jk <esc>
" display help in new tab on <F1>
map <F1> :tab help<CR>
map <F5> :silent make \| copen \| redraw!<CR>
map <F5> :silent make \| redraw!<CR>
" retab
map <leader>rt :retab!<CR>
" toggle tabs visibility
noremap <Leader>t :set invlist<CR>
" nnoremap <C-]> <C-]>:tselect<CR>
" easy editing and sourcing of vimrc
nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>ev :e $MYVIMRC<cr>
" turn off search highlight
nnoremap <leader>h :nohlsearch<cr>
" toggle visibility of trailing whitespaces
nnoremap <leader>w :match Error /\v +$/<cr>
nnoremap <leader>W :match<cr>
" toggle and navigate quickfix window
nnoremap <leader>cn :cnext<cr>
nnoremap <leader>cp :cprevious<cr>
nnoremap <leader>cc :cc<cr>
" grep operator
" nnoremap <leader>g :silent execute "grep! -R " . shellescape(expand("<cWORD>")) . " ."<cr>:copen<cr>
nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<cr>g@
vnoremap <leader>g :<c-u>call <SID>GrepOperator(visualmode())<cr>
" buffer navigaion
nnoremap <leader>bn :MBEbn<cr>
nnoremap <leader>bp :MBEbp<cr>
nnoremap <leader>bd :MBEbd<cr>
" activate 'very magic' for searches automatically
nnoremap / /\v
nnoremap ? ?\v
" make
nnoremap <leader>mm :silent make!<cr>
nnoremap <leader>mc :silent make! clean<cr>
nnoremap <leader>mn :silent make! new<cr>
nnoremap <leader>mr :silent make!<cr>:call system("make run &")<cr>
nnoremap <leader>md :silent make!<cr>:call system("make debug &")<cr>
nnoremap <leader>ms :silent make! stop<cr>
nnoremap <leader>mf :silent make! %:r<cr>:redraw! <cr>
nnoremap <leader>mx :silent make! %:r <bar> !./%:r<cr>
" run my new 'ColorTune' plugin
" nnoremap <leader>cc :call Colortune_fill()<cr>
" session handling
nnoremap <leader>ss :call Session_save()<cr>
nnoremap <leader>sl :call Session_load()<cr>
" }}}
" layout
nnoremap <leader>ln :NERDTreeToggle<cr>
nnoremap <leader>lt :TagbarToggle<cr>
nnoremap <leader>lg :ConqueGdb<cr>
nnoremap <leader>lm :MBEToggle<cr>
nnoremap <leader>lq :copen<cr>
" File Type Specific Settings
" {{{
" Enforce custom syntax hl for some file extensions
" {{{
augroup filetype_custom
autocmd!
au BufRead,BufNewFile *.twig set filetype=htmljinja
au BufRead,BufNewFile *.md set filetype=markdown
augroup END
" }}}
" Set foldmethod=marker for vim files
" {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" Custom settings for markdown files
" {{{
augroup filetype_markdown
autocmd!
" autocmd FileType markdown setlocal spell
" autocmd FileType markdown setlocal list
augroup END
" }}}
" Simple shortcuts for cpp files
" {{{
augroup filetype_cpp
autocmd!
autocmd FileType cpp nnoremap <buffer> <localleader>c I//<esc>
autocmd FileType cpp :iabbrev <buffer> iff if () <cr>{<cr>}jkF
autocmd FileType cpp nnoremap <buffer> <leader>bo :r ~/_int/dev/misc/c++/template/template.cpp<cr>
augroup END
" }}}
" Haskell specifics
" {{{
augroup filetype_haskell
autocmd!
autocmd FileType haskell setlocal foldmethod=marker
" autocmd Filetype haskell map <F5> :w<ENTER>:term cabal -- exec runghc %<ENTER>
autocmd Filetype haskell map <F5> :w<ENTER>:term make<ENTER>
autocmd FileType haskell setlocal expandtab
augroup END
" }}}
" }}}
" Session Handling (that sucks)
" {{{
" we always want MBE, NERDTree and Tagbar
"
let g:miniBufExplBRSplit = 0 " Put new window above
function! Session_save()
NERDTreeClose
TagbarClose
MBECloseAll
mksession! .lastvimsession
NERDTree
Tagbar
MBEOpen
endfunction
function! Session_load()
NERDTreeClose
TagbarClose
MBECloseAll
" source ~/.lastvimsession
NERDTree
Tagbar
MBEOpen
call feedkeys("\<c-w>\<c-w>")
endfunction
if filereadable(".lastvimsession")
"
" augroup my_vim_leave
" autocmd!
" autocmd VimLeave * NERDTreeClose
" autocmd VimLeave * TagbarClose
" autocmd VimLeave * MBECloseAll
" autocmd VimLeave * mksession! .lastvimsession
" augroup END
"
" augroup my_vim_enter
" autocmd!
" autocmd VimEnter * source .lastvimsession
" autocmd VimEnter * NERDTree
" autocmd VimEnter * MBEOpen
" autocmd VimEnter * Tagbar
" augroup END
"
endif
" }}}
" Custom Functions
" {{{
" GrepOperator(type)
" {{{
function! s:GrepOperator(type)
let saved_unnamed_register = @@
if a:type ==# 'v'
normal! `<v`>y
elseif a:type ==# 'char'
normal! `[v`]y
else
echom "not supported"
return
endif
silent execute "grep! -R " . shellescape(@@) . " ."
copen
let @@ = saved_unnamed_register
endfunction
" }}}
" }}}
" Experimental (Disabled)
" {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""
" experimental stuff added during the course of: "
" learnvimscriptthehardway.stevelosh.com "
"""""""""""""""""""""""""""""""""""""""""""""""""""""
" move line under the cursor up and down.
" nnoremap <leader>- ddp
" nnoremap <leader>_ kddpk
" make word under curstor upper-case
" inoremap <leader><c-u> <esc>viwUea
" nnoremap <leader><c-u> viwUe
" abbreviations and typo correction
" iabbrev @@ miguel@quad
" iabbrev ccopy Copyright 2014 M. Idziorek, all rights reserved.
" iabbrev teh the
" topic handling for markdown files
" onoremap ih :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rkvg_"<cr>
" onoremap ah :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rg_vk0"<cr>
"
" single and double quoting
" nnoremap <leader>" viw<esc>a"<esc>hbi"<esc>lel
" nnoremap <leader>' viw<esc>a"<esc>hbi"<esc>lel
" vnoremap <leader>" <esc>`<i"<esc>`>la"<esc>l
" open previous buffer in new split-window
" nnoremap <leader>p :execute "leftabove vsplit ".bufname("#")<cr>
" }}}
" Vim Status Line Color
" {{{
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline guibg=Cyan ctermfg=6 guifg=Black ctermbg=0
elseif a:mode == 'r'
hi statusline guibg=Purple ctermfg=5 guifg=Black ctermbg=0
else
hi statusline guibg=DarkRed ctermfg=1 guifg=Black ctermbg=0
endif
endfunction
" }}}
"
if has("nvim")
" Make escape work in the Neovim terminal.
tnoremap <Esc> <C-\><C-n>
" Make navigation into and out of Neovim terminal splits nicer.
tnoremap <C-h> <C-\><C-N><C-w>h
tnoremap <C-j> <C-\><C-N><C-w>j
tnoremap <C-k> <C-\><C-N><C-w>k
tnoremap <C-l> <C-\><C-N><C-w>l
" I like relative numbering when in normal mode.
autocmd TermOpen * setlocal conceallevel=0 colorcolumn=0 relativenumber
" Prefer Neovim terminal insert mode to normal mode.
autocmd BufEnter term://* startinsert
endif
|