Source

dotfiles / vim / vimrc

Full commit
  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
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
" Modeline and notes {
" vim: set foldmarker={,} foldlevel=0 foldmethod=marker spell:
" }

" Setup Environment {
    " The following two lines are required by Vundle.
    set nocompatible        " be iMproved
    filetype off            " required!

    " Windows Compatibility
    " On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
    " across (heterogeneous) systems easier.
    if has('win32') || has('win64')
        set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
    endif

    " Setup Vundle
    set rtp+=~/.vim/bundle/vundle
    call vundle#rc()
" }

" Bundles {
    " Dependencies {
        Bundle 'gmarik/vundle'
        Bundle 'MarcWeber/vim-addon-mw-utils'
        Bundle 'tomtom/tlib_vim'
        if executable('ack')
            Bundle 'mileszs/ack.vim'
        endif
    " }

    " Colors and themes {
        Bundle 'altercation/vim-colors-solarized'
        "Bundle 'flazz/vim-colorschemes'
        Bundle 'godlygeek/csapprox'
    " }

    " General {
        Bundle 'scrooloose/nerdtree'
        Bundle 'Lokaltog/vim-powerline'
        "Bundle 'tpope/vim-surround'
        "Bundle 'AutoClose'
        "Bundle 'kien/ctrlp.vim'
        "Bundle 'vim-scripts/sessionman.vim'
        "Bundle 'matchit.zip'
        "Bundle 'Lokaltog/vim-easymotion'
        "Bundle 'godlygeek/csapprox'
        "Bundle 'jistr/vim-nerdtree-tabs'
        "Bundle 'corntrace/bufexplorer'
    " }

    " General Programming {
        " Code completion. Simply Neocomplecache rules!!!
        "Bundle 'Shougo/neocomplcache.git'

        " For snippets, neocomplcache provides a framework for snippets.
        " vim-snipmate is better, but it doesn't work so well with Neocomplecache
        "Bundle 'Shougo/neocomplcache-snippets-complete'
        "Bundle 'garbas/vim-snipmate'
        "Bundle 'honza/snipmate-snippets'

        "Bundle 'ervandew/supertab'
        "Bundle 'scrooloose/syntastic'
        " Source support_function.vim to support snipmate-snippets.
        "if filereadable(expand("~/.vim/bundle/snipmate-snippets/snippets/support_functions.vim"))
            "source ~/.vim/bundle/snipmate-snippets/snippets/support_functions.vim
        "endif

        Bundle 'scrooloose/nerdcommenter'
        "Bundle 'godlygeek/tabular'
        "if executable('ctags')
            "Bundle 'majutsushi/tagbar'
        "endif
    " }

    " Python {
        if has('python')
            " Pick either python-mode or pyflakes & pydoc
            Bundle 'klen/python-mode'

            "" a two-way integration between vim and ipython 0.11+
            "Bundle 'ivanov/vim-ipython'

            "" an integrated debugging environment in vim.
            "Bundle 'jabapyth/vim-debug'

            "" awesome python autocompletion with vim
            "" (it was rather slow 11/2012)
            "Bundle 'davidhalter/jedi-vim'
        endif
    " }

    " html {
        "Bundle 'html-autoclosetag'
        "Bundle 'chrisyip/better-css-syntax-for-vim'
    " }

    " latex {
        Bundle 'latex-box-team/latex-box'
    " }

    " misc {
        "Bundle 'spf13/vim-markdown'
        "Bundle 'spf13/vim-preview'
        "Bundle 'tpope/vim-cucumber'
        "Bundle 'puppet-syntax-highlighting'
    " }
" }

" general {
    filetype plugin indent on   " automatically detect file types.
    syntax on                   " syntax highlighting
    set mouse-=a                " automatically disable mouse usage
    scriptencoding utf-8
    set encoding=utf-8
    set modelines=2
    set laststatus=2            " always show a status line
    set showmode                " display the current mode
    set showcmd                 " show partial commands in status line and
    set visualbell
    set ttyfast
    set ruler                   " show the ruler
    set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
    set backspace=indent,eol,start  " backspace for dummies
    set history=1000            " Store a ton of history (default is 20)
    set shell=/bin/zsh
    set fillchars=diff:⣿,vert:│
    set autowrite               " Autosave files
    set title
" }

" Basic stuff {
    let mapleader = ','
    let maplocalleader = '\\'

    " Swap ; and :  Convenient.
    " Saves typing and eliminates :W style typos due to lazy holding shift.
    nnoremap ; :

    " map F1 (help) to esc
    inoremap <F1> <ESC>
    nnoremap <F1> <ESC>
    vnoremap <F1> <ESC>

    " When vimrc is edited, reload it
    "autocmd! bufwritepost vimrc source ~/.vim/vimrc
" }

" Fonts & Theme {
    " Font {
        " Choose font for linux, mac and windows.
        if has("gui_gtk2")
            set guifont=Droid\ Sans\ Mono\ 10
        elseif has("gui_macvim")
            set guifont=Consolas:h12
        elseif has("gui_win32")
            set guifont=Consolas:h10
        end
    " }

    " Theme {
        " Solarized {
            " General options
            let g:solarized_termcolors=256      " 16|256 terminal colors
            let g:solarized_termtrans=1         " 0|1 terminal transparency
            let g:solarized_degrade=0           " 0|1 for testing
            let g:solarized_bold=1              " 0|1 stop solarized from displaying bold
            let g:solarized_underline=1         " 0|1 stop solarized from displaying underline
            let g:solarized_italic=1            " 0|1 stop solarized from displaying italic
            let g:solarized_contrast="high"     " low|normal|high set contrast
            let g:solarized_visibility="high"   " low|normal|high set visibility

            " Choose theme
            colorscheme solarized               " load colorscheme

            " Choose background for gvim and vim.
            if has('gui_running')
                set background=dark
            else
                set background=dark
            endif
        " }
    " }
" }

" Scrolling and Folding {
    set scrolljump=5                " lines to scroll when cursor leaves screen
    set scrolloff=3                 " minimum lines to keep above and below cursor
    set foldenable                  " auto fold code

    """ Code folding options
    nmap <leader>f0 :set foldlevel=0<CR>
    nmap <leader>f1 :set foldlevel=1<CR>
    nmap <leader>f2 :set foldlevel=2<CR>
    nmap <leader>f3 :set foldlevel=3<CR>
    nmap <leader>f4 :set foldlevel=4<CR>
    nmap <leader>f5 :set foldlevel=5<CR>
    nmap <leader>f6 :set foldlevel=6<CR>
    nmap <leader>f7 :set foldlevel=7<CR>
    nmap <leader>f8 :set foldlevel=8<CR>
    nmap <leader>f9 :set foldlevel=9<CR>
" }

" Line Numbers {
    set number                  " Line numbers on
    set relativenumber          " Relative line numbers on
    "nnoremap <leader>n :setlocal number!<cr>       " Toggle line numbers.
" }

" Windows and Buffers {
    set hidden                  " allow buffer switching without saving
    set winminheight=0         " windows can be 2 line high
    set splitbelow              " When splitting put new window below of the current one
    set splitright              " When splitting put new window to the right of the current one
    au VimResized * :wincmd =   " Resize splits when the windows is resized.
    au FocusLost * : silent! wall " Save when losing focus

    " Redraw screen
    nnoremap <leader>u :syntax sync fromstart<cr>:redraw!<cr>

    " Moving around {
        " Easier moving in tabs and windows
        map <C-J> <C-W>j<C-W>_
        map <C-K> <C-W>k<C-W>_
        map <C-L> <C-W>l<C-W>_
        map <C-H> <C-W>h<C-W>_

        map <Leader>= <C-w>=        " Adjust viewports to the same size
    " }
" }

" Whitespace {
    " Highlight problematic whitespace with the following symbols,
    " but only show trailing whitespace when not in insert mode.
    set list
    set listchars=tab:▸\
    set listchars+=extends:❯
    set listchars+=precedes:❮
    "set listchars+=eol:¬
    augroup trailing
        au!
        au InsertEnter * :set listchars-=trail:⌴
        au InsertLeave * :set listchars+=trail:⌴
    augroup END

    " Remove trailing whitespaces when saving
    autocmd BufWritePre * :%s/\s\+$//e
    "autocmd FileType c,cpp,java,php,javascript,python,twig,xml,yml autocmd BufWritePre <buffer> :%s/\s\+$//e

    " Insert empty line above or below while staying in normal mode
    nnoremap <leader>o :set paste<CR>m`o<Esc>``:set nopaste<CR>
    nnoremap <leader>O :set paste<CR>m`O<Esc>``:set nopaste<CR>

" }

" Languages & Spellchecking {
    " Greek {
        " Use Greek letters in command mode
        :set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
    " }

    set dictionary=/usr/share/dict/words
    set spellfile=~/.vim/custom-dictionary.utf-8.add

    if version >= 700
        set spell spelllang=en,el
    endif
" }

" Syntax Highlighting {
    set synmaxcol=500           " Don't try to highlight lines longer than 120 chars.
" }

" TimeOuts {
    " Time out on key codes but not mappings.
    " Basically this makes terminal Vim work sanely.
    set notimeout
    set ttimeout
    set ttimeoutlen=10
" }

" Moving around {
    " When moving stay in the middle of the window.
    nnoremap g; g;zz
    nnoremap g, g,zz
    nnoremap <c-o> <c-o>zz

    " It's 2012.
    noremap j gj
    noremap k gk
    noremap gj j
    noremap gk k

" }

" highlight and searching {
    set incsearch                   " incremental search
    set hlsearch                    " highlight search terms
    set ignorecase                  " case insensitive search
    set smartcase                   " case sensitive when uc present

    " use sane regexes.
    nnoremap / /\v
    vnoremap / /\v

    " matching pairs
    set showmatch                   " show matching symbols (parens etc)
    set matchtime=3                 " time to show matching paren
    set matchpairs+=(:)
    set matchpairs+=[:]
    set matchpairs+={:}
    set matchpairs+=<:>

    " clear highlighted search
    nmap <silent> <leader>/ :nohlsearch<cr>

    " keep search matches in the middle of the window.
    nnoremap n nzzzv
    nnoremap n nzzzv
" }

" Tabs, spaces, wrapping {
    set tabstop=8                   " an indentation every eight columns
    set shiftwidth=4                " use indents of 4 spaces
    set shiftround                  " Always round to multiple of 'shiftwidth'
    set softtabstop=4               " let backspace delete indent
    set expandtab                   " tabs are spaces, not tabs
    set formatoptions=qrn1
    set colorcolumn=+1
    set autoindent                  " indent at the same level of the previous line

    " Wrap {
        set nowrap                      " Wrap long lines (or not!)
        set whichwrap=b,s,h,l,<,>,[,]   " backspace and cursor keys wrap to
        set textwidth=80
        " Wrapped lines goes down/up to next row, rather than next line in file.
        nnoremap j gj
        nnoremap k gk

        " Formatting, TextMate-style
        nnoremap Q gqip
        vnoremap Q gq

        " Keep the cursor in place while joining lines
        nnoremap J mzJ`z

        "Split line (sister of [J]oin lines)
        " The normal use of S is covered by cc, so don't worry about shadowing
        nnoremap S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
    " }
" }

" Backup - Undo - Swap{
    " Undo {
        set undodir=~/.vim/tmp/undo//     " undo files
        if has('persistent_undo')
            set undofile                "so is persistent undo ...
            set undolevels=1000         "maximum number of changes that can be undone
            set undoreload=10000        "maximum number lines to save for undo on a buffer reload
        endif
    " }

    " Backup {
        set backupdir=~/.vim/tmp/backup// " backups
        set backup                        " enable backups
    " }

    " Swap {
        set directory=~/.vim/tmp/swap//   " swap files
        set noswapfile                    " It's 2012, Vim.
    " }
" }

" Completion {
    " WildMenu Completion {
        set wildmenu                    " show list instead of just completing
        set wildmode=list:longest,full  " command <Tab> completion, list matches, then longest common part, then all.

        set wildignore+=.hg,.git,.svn                    " Version control
        set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
        set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
        set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
        set wildignore+=*.spl                            " compiled spelling word lists
        set wildignore+=*.sw?                            " Vim swap files
        set wildignore+=migrations                       " Django migrations
        set wildignore+=*.pyc,*.pyo                      " Python byte code
        set wildignore+=*.orig                           " Merge resolution files
    " }
" }

" Misc {
    " Clipboard {
        noremap <leader>y "*y
        noremap <leader>p :set paste<CR>"*p<CR>:set nopaste<CR>
        noremap <leader>P :set paste<CR>"*P<CR>:set nopaste<CR>
        vnoremap <leader>y "*ygv

        " Yank from the cursor to the end of the line, to be consistent with C and D.
        nnoremap Y y$
    " }

    " CursorLine {
        " Only show cursorline in the current window and in normal mode.
        augroup cline
            au!
            au WinLeave * set nocursorline
            au WinEnter * set cursorline
            au InsertEnter * set nocursorline
            au InsertLeave * set cursorline
        augroup END
    " }

    " Make Vim able to edit crontab files again.
    set backupskip=/tmp/*,/private/tmp/*"

    " Make sure Vim returns to the same line when you reopen a file.
    augroup line_return
        au!
        au BufReadPost *
            \ if line("'\"") > 0 && line("'\"") <= line("$") |
            \     execute 'normal! g`"zvzz' |
            \ endif
    augroup END

    " visual shifting (does not exit Visual mode)
    vnoremap < <gv
    vnoremap > >gv

    " For when you forget to sudo.. Really Write the file.
    cmap w!! w !sudo tee % >/dev/null

    " Stupid shift key fixes
    "cmap W w
    "cmap WQ wq
    "cmap wQ wq

    " Change Working Directory to that of the current file
    cmap cwd lcd %:p:h

    " Some helpers to edit mode : http://vimcasts.org/e/14
    " %% : Expands directory of the current file to the command line
    cnoremap %% <C-R>=expand('%:h').'/'<cr>

    " The following commands open a file in the same directory as the currently
    " edited file.
    " 'w' opens it in a new window.
    " 's' opens it in a new split.
    " 'v' opens it in a new vertical split.
    map <leader>ew :e %%
    map <leader>es :sp %%
    map <leader>ev :vsp %%
" }

" Plugins {

    " NerdTree {
        map <C-e> :NERDTreeToggle<CR>:NERDTreeMirror<CR>
        map <leader>e :NERDTreeFind<CR>
        nmap <leader>nt :NERDTreeFind<CR>

        let NERDTreeShowBookmarks=1
        let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr']
        let NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\~$']
        let NERDTreeChDirMode=2
        let NERDTreeQuitOnOpen=1
        let NERDTreeShowHidden=1
        let NERDTreeKeepTreeInNewTab=1
    " }

    " Misc {
        let g:NERDShutUp=1
        let b:match_ignorecase = 1
    " }

     "OmniComplete {
        if has("autocmd") && exists("+omnifunc")
            autocmd Filetype *
                \if &omnifunc == "" |
                \setlocal omnifunc=syntaxcomplete#Complete |
                \endif
        endif

        hi Pmenu  guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
        hi PmenuSbar  guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
        hi PmenuThumb  guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE

        " some convenient mappings
        inoremap <expr> <Esc>      pumvisible() ? "\<C-e>" : "\<Esc>"
        inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>"
        inoremap <expr> <Down>     pumvisible() ? "\<C-n>" : "\<Down>"
        inoremap <expr> <Up>       pumvisible() ? "\<C-p>" : "\<Up>"
        inoremap <expr> <C-d>      pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
        inoremap <expr> <C-u>      pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"

        " automatically open and close the popup menu / preview window
        au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
        set completeopt=menu,preview,longest
    " }

    " Neocomplecache {
        " 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
        " Use camel case completion.
        "let g:neocomplcache_enable_camel_case_completion = 1
        " Use underbar completion.
        "let g:neocomplcache_enable_underbar_completion = 1
        " Set minimum syntax keyword length.
        "let g:neocomplcache_min_syntax_length = 3
        "let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

        " Define dictionary.
        "let g:neocomplcache_dictionary_filetype_lists = {
            "\ 'default' : '',
            "\ 'vimshell' : $HOME.'/.vimshell_hist',
            "\ 'scheme' : $HOME.'/.gosh_completions'
            "\ }

        " Define keyword.
        "if !exists('g:neocomplcache_keyword_patterns')
        "let g:neocomplcache_keyword_patterns = {}
        "endif
        "let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

        " Plugin key-mappings.
        "imap <C-k>     <Plug>(neocomplcache_snippets_expand)
        "smap <C-k>     <Plug>(neocomplcache_snippets_expand)
        "inoremap <expr><C-g>     neocomplcache#undo_completion()
        "inoremap <expr><C-l>     neocomplcache#complete_common_string()

        " SuperTab like snippets behavior.
        "imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"

        " Recommended key-mappings.
        " <CR>: close popup and save indent.
        "inoremap <expr><CR>  neocomplcache#smart_close_popup() . "\<CR>"
        " <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()

        " AutoComplPop like behavior.
        "let g:neocomplcache_enable_auto_select = 1

        " Shell like behavior(not recommended).
        "set completeopt+=longest
        "let g:neocomplcache_enable_auto_select = 1
        "let g:neocomplcache_disable_auto_complete = 1
        "inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<TAB>"
        "inoremap <expr><CR>  neocomplcache#smart_close_popup() . "\<CR>"

        " Enable omni completion.
        "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

        " Enable heavy omni completion.
        "if !exists('g:neocomplcache_omni_patterns')
        "let g:neocomplcache_omni_patterns = {}
        "endif
        "let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
        "autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
        "let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
        "let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
        "let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
    " }

    " Neocomplecache Snippets {
        " Setting the author var
        " If forking, please overwrite in your .vimrc.local file
        "let g:snips_author = 'Panagiotis Mavrogiorgos <pmav99@gmail.com>'
    " }

    " Ctags {
        set tags=./tags;/,~/.vimtags
    " }

    " AutoCloseTag {
        " Make it so AutoCloseTag works for xml and xhtml files as well
        "au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
        "nmap <Leader>ac <Plug>ToggleAutoCloseMappings
    " }

    " Tabularize {
        "if exists(": Tabularize")
          "nmap <Leader>a= :Tabularize /=<CR>
          "vmap <Leader>a= :Tabularize /=<CR>
          "nmap <Leader>a: :Tabularize /:<CR>
          "vmap <Leader>a: :Tabularize /:<CR>
          "nmap <Leader>a:: :Tabularize /:\zs<CR>
          "vmap <Leader>a:: :Tabularize /:\zs<CR>
          "nmap <Leader>a, :Tabularize /,<CR>
          "vmap <Leader>a, :Tabularize /,<CR>
          "nmap <Leader>a<Bar> :Tabularize /<Bar><CR>
          "vmap <Leader>a<Bar> :Tabularize /<Bar><CR>

          "" The following function automatically aligns when typing a
          "" supported character
          "inoremap <silent> <Bar>   <Bar><Esc>:call <SID>align()<CR>a

          "function! s:align()
              "let p = '^\s*|\s.*\s|\s*$'
              "if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
                  "let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
                  "let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
                  "Tabularize/|/l1
                  "normal! 0
                  "call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
              "endif
          "endfunction

        "endif
     " }

     " Sessionman List {
        "set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize
        "nmap <leader>sl :SessionList<CR>
        "nmap <leader>ss :SessionSave<CR>
     " }

     " Buffer explorer {
        "nmap <leader>b :BufExplorer<CR>
     " }

     " JSON {
        "nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
     " }

     " python-mode {
        " Disable if python support not present
        if has('python')
           source $CONFIGURATION_FOLDER/vim/python-mode.vim
        endif
     " }

     " ctrlp {
        "let g:ctrlp_working_path_mode = 2
        "nnoremap <silent> <D-t> :CtrlP<CR>
        "nnoremap <silent> <D-r> :CtrlPMRU<CR>
        "let g:ctrlp_custom_ignore = {
            "\ 'dir':  '\.git$\|\.hg$\|\.svn$',
            "\ 'file': '\.exe$\|\.so$\|\.dll$' }
     "}

     " TagBar {
        "nnoremap <silent> <leader>tt :TagbarToggle<CR>
     "}

" }

 " Functions {

    function! InitializeDirectories()
        let separator = "."
        let parent = $HOME
        let prefix = '.vim'
        let dir_list = {
                    \ 'backup': 'backupdir',
                    \ 'views': 'viewdir',
                    \ 'swap': 'directory' }

        if has('persistent_undo')
            let dir_list['undo'] = 'undodir'
        endif

        for [dirname, settingname] in items(dir_list)
            let directory = parent . '/' . prefix . dirname . "/"
            if exists("*mkdir")
                if !isdirectory(directory)
                    call mkdir(directory)
                endif
            endif
            if !isdirectory(directory)
                echo "Warning: Unable to create backup directory: " . directory
                echo "Try: mkdir -p " . directory
            else
                let directory = substitute(directory, " ", "\\\\ ", "g")
                exec "set " . settingname . "=" . directory
            endif
        endfor
    endfunction

call InitializeDirectories()

    function! NERDTreeInitAsNeeded()
        redir => bufoutput
        buffers!
        redir END
        let idx = stridx(bufoutput, "NERD_tree")
        if idx > -1
            NERDTreeMirror
            NERDTreeFind
            wincmd l
        endif
    endfunction
" }

" LaTeX {
    let g:Tex_DefaultTargetFormat='pdf'
    let g:Tex_ViewRule_pdf='evince'
    let g:Tex_CompileRule_pdf = 'xelatex -interaction=nonstopmode $*'
" }