Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 50.50 KB | None | 0 0
  1. " Modeline and Notes {
  2. " vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
  3. "
  4. "                    __ _ _____              _
  5. "         ___ _ __  / _/ |___ /      __   __(_)_ __ ___
  6. "        / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
  7. "        \__ \ |_) |  _| |___) |_____|\ V / | | | | | | |
  8. "        |___/ .__/|_| |_|____/        \_/  |_|_| |_| |_|
  9. "            |_|
  10. "
  11. "   This is the personal .vimrc file of Steve Francia.
  12. "   While much of it is beneficial for general use, I would
  13. "   recommend picking out the parts you want and understand.
  14. "
  15. "   You can find me at http://spf13.com
  16. "
  17. "   Copyright 2014 Steve Francia
  18. "
  19. "   Licensed under the Apache License, Version 2.0 (the "License");
  20. "   you may not use this file except in compliance with the License.
  21. "   You may obtain a copy of the License at
  22. "
  23. "       http://www.apache.org/licenses/LICENSE-2.0
  24. "
  25. "   Unless required by applicable law or agreed to in writing, software
  26. "   distributed under the License is distributed on an "AS IS" BASIS,
  27. "   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. "   See the License for the specific language governing permissions and
  29. "   limitations under the License.
  30. " }
  31.  
  32. " Environment {
  33.  
  34.     " Identify platform {
  35.         silent function! OSX()
  36.             return has('macunix')
  37.         endfunction
  38.         silent function! LINUX()
  39.             return has('unix') && !has('macunix') && !has('win32unix')
  40.         endfunction
  41.         silent function! WINDOWS()
  42.             return  (has('win32') || has('win64'))
  43.         endfunction
  44.     " }
  45.  
  46.     " Basics {
  47.         set nocompatible        " Must be first line
  48.         if !WINDOWS()
  49.             set shell=/bin/sh
  50.         endif
  51.     " }
  52.  
  53.     " Windows Compatible {
  54.         " On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
  55.         " across (heterogeneous) systems easier.
  56.         if WINDOWS()
  57.           set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
  58.         endif
  59.     " }
  60.    
  61.     " Arrow Key Fix {
  62.         " https://github.com/spf13/spf13-vim/issues/780
  63.         if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt'
  64.             inoremap <silent> <C-[>OC <RIGHT>
  65.         endif
  66.     " }
  67.  
  68. " }
  69.  
  70. " Use before config if available {
  71.     if filereadable(expand("~/.vimrc.before"))
  72.         source ~/.vimrc.before
  73.     endif
  74. " }
  75.  
  76. " Use bundles config {
  77.     if filereadable(expand("~/.vimrc.bundles"))
  78.         source ~/.vimrc.bundles
  79.     endif
  80. " }
  81.  
  82. " General {
  83.  
  84.     set background=dark         " Assume a dark background
  85.  
  86.     " Allow to trigger background
  87.     function! ToggleBG()
  88.         let s:tbg = &background
  89.         " Inversion
  90.         if s:tbg == "dark"
  91.             set background=light
  92.         else
  93.             set background=dark
  94.         endif
  95.     endfunction
  96.     noremap <leader>bg :call ToggleBG()<CR>
  97.  
  98.     " if !has('gui')
  99.         "set term=$TERM          " Make arrow and other keys work
  100.     " endif
  101.     filetype plugin indent on   " Automatically detect file types.
  102.     syntax on                   " Syntax highlighting
  103.     set mouse=a                 " Automatically enable mouse usage
  104.     set mousehide               " Hide the mouse cursor while typing
  105.     scriptencoding utf-8
  106.  
  107.     if has('clipboard')
  108.         if has('unnamedplus')  " When possible use + register for copy-paste
  109.             set clipboard=unnamed,unnamedplus
  110.         else         " On mac and Windows, use * register for copy-paste
  111.             set clipboard=unnamed
  112.         endif
  113.     endif
  114.  
  115.     " Most prefer to automatically switch to the current file directory when
  116.     " a new buffer is opened; to prevent this behavior, add the following to
  117.     " your .vimrc.before.local file:
  118.     "   let g:spf13_no_autochdir = 1
  119.     if !exists('g:spf13_no_autochdir')
  120.         autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif
  121.         " Always switch to the current file directory
  122.     endif
  123.  
  124.     "set autowrite                       " Automatically write a file when leaving a modified buffer
  125.     set shortmess+=filmnrxoOtT          " Abbrev. of messages (avoids 'hit enter')
  126.     set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
  127.     set virtualedit=onemore             " Allow for cursor beyond last character
  128.     set history=1000                    " Store a ton of history (default is 20)
  129.     set spell                           " Spell checking on
  130.     set hidden                          " Allow buffer switching without saving
  131.     set iskeyword-=.                    " '.' is an end of word designator
  132.     set iskeyword-=#                    " '#' is an end of word designator
  133.     set iskeyword-=-                    " '-' is an end of word designator
  134.  
  135.     " Instead of reverting the cursor to the last position in the buffer, we
  136.     " set it to the first line when editing a git commit message
  137.     au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
  138.  
  139.     " http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
  140.     " Restore cursor to file position in previous editing session
  141.     " To disable this, add the following to your .vimrc.before.local file:
  142.     "   let g:spf13_no_restore_cursor = 1
  143.     if !exists('g:spf13_no_restore_cursor')
  144.         function! ResCur()
  145.             if line("'\"") <= line("$")
  146.                 silent! normal! g`"
  147.                 return 1
  148.             endif
  149.         endfunction
  150.  
  151.         augroup resCur
  152.             autocmd!
  153.             autocmd BufWinEnter * call ResCur()
  154.         augroup END
  155.     endif
  156.  
  157.     " Setting up the directories {
  158.         set backup                  " Backups are nice ...
  159.         if has('persistent_undo')
  160.             set undofile                " So is persistent undo ...
  161.             set undolevels=1000         " Maximum number of changes that can be undone
  162.             set undoreload=10000        " Maximum number lines to save for undo on a buffer reload
  163.         endif
  164.  
  165.         " To disable views add the following to your .vimrc.before.local file:
  166.         "   let g:spf13_no_views = 1
  167.         if !exists('g:spf13_no_views')
  168.             " Add exclusions to mkview and loadview
  169.             " eg: *.*, svn-commit.tmp
  170.             let g:skipview_files = [
  171.                 \ '\[example pattern\]'
  172.                 \ ]
  173.         endif
  174.     " }
  175.  
  176. " }
  177.  
  178. " Vim UI {
  179.  
  180.     if !exists('g:override_spf13_bundles') && filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
  181.         let g:solarized_termcolors=256
  182.         let g:solarized_termtrans=1
  183.         let g:solarized_contrast="normal"
  184.         let g:solarized_visibility="normal"
  185.         color solarized             " Load a colorscheme
  186.     endif
  187.  
  188.     set tabpagemax=15               " Only show 15 tabs
  189.     set showmode                    " Display the current mode
  190.  
  191.     set cursorline                  " Highlight current line
  192.  
  193.     highlight clear SignColumn      " SignColumn should match background
  194.     highlight clear LineNr          " Current line number row will have same background color in relative mode
  195.     "highlight clear CursorLineNr    " Remove highlight color from current line number
  196.  
  197.     if has('cmdline_info')
  198.         set ruler                   " Show the ruler
  199.         set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
  200.         set showcmd                 " Show partial commands in status line and
  201.                                     " Selected characters/lines in visual mode
  202.     endif
  203.  
  204.     if has('statusline')
  205.         set laststatus=2
  206.  
  207.         " Broken down into easily includeable segments
  208.         set statusline=%<%f\                     " Filename
  209.         set statusline+=%w%h%m%r                 " Options
  210.         if !exists('g:override_spf13_bundles')
  211.             set statusline+=%{fugitive#statusline()} " Git Hotness
  212.         endif
  213.         set statusline+=\ [%{&ff}/%Y]            " Filetype
  214.         set statusline+=\ [%{getcwd()}]          " Current dir
  215.         set statusline+=%=%-14.(%l,%c%V%)\ %p%%  " Right aligned file nav info
  216.     endif
  217.  
  218.     set backspace=indent,eol,start  " Backspace for dummies
  219.     set linespace=0                 " No extra spaces between rows
  220.     set number                      " Line numbers on
  221.     set showmatch                   " Show matching brackets/parenthesis
  222.     set incsearch                   " Find as you type search
  223.     set hlsearch                    " Highlight search terms
  224.     set winminheight=0              " Windows can be 0 line high
  225.     set ignorecase                  " Case insensitive search
  226.     set smartcase                   " Case sensitive when uc present
  227.     set wildmenu                    " Show list instead of just completing
  228.     set wildmode=list:longest,full  " Command <Tab> completion, list matches, then longest common part, then all.
  229.     set whichwrap=b,s,h,l,<,>,[,]   " Backspace and cursor keys wrap too
  230.     set scrolljump=5                " Lines to scroll when cursor leaves screen
  231.     set scrolloff=3                 " Minimum lines to keep above and below cursor
  232.     set foldenable                  " Auto fold code
  233.     set list
  234.     set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
  235.  
  236. " }
  237.  
  238. " Formatting {
  239.  
  240.     set nowrap                      " Do not wrap long lines
  241.     set autoindent                  " Indent at the same level of the previous line
  242.     set shiftwidth=4                " Use indents of 4 spaces
  243.     set expandtab                   " Tabs are spaces, not tabs
  244.     set tabstop=4                   " An indentation every four columns
  245.     set softtabstop=4               " Let backspace delete indent
  246.     set nojoinspaces                " Prevents inserting two spaces after punctuation on a join (J)
  247.     set splitright                  " Puts new vsplit windows to the right of the current
  248.     set splitbelow                  " Puts new split windows to the bottom of the current
  249.     "set matchpairs+=<:>             " Match, to be used with %
  250.     set pastetoggle=<F12>           " pastetoggle (sane indentation on pastes)
  251.     "set comments=sl:/*,mb:*,elx:*/  " auto format comment blocks
  252.     " Remove trailing whitespaces and ^M chars
  253.     " To disable the stripping of whitespace, add the following to your
  254.     " .vimrc.before.local file:
  255.     "   let g:spf13_keep_trailing_whitespace = 1
  256.     autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd BufWritePre <buffer> if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
  257.     "autocmd FileType go autocmd BufWritePre <buffer> Fmt
  258.     autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
  259.     autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
  260.     " preceding line best in a plugin but here for now.
  261.  
  262.     autocmd BufNewFile,BufRead *.coffee set filetype=coffee
  263.  
  264.     " Workaround vim-commentary for Haskell
  265.     autocmd FileType haskell setlocal commentstring=--\ %s
  266.     " Workaround broken colour highlighting in Haskell
  267.     autocmd FileType haskell,rust setlocal nospell
  268.  
  269. " }
  270.  
  271. " Key (re)Mappings {
  272.  
  273.     " The default leader is '\', but many people prefer ',' as it's in a standard
  274.     " location. To override this behavior and set it back to '\' (or any other
  275.     " character) add the following to your .vimrc.before.local file:
  276.     "   let g:spf13_leader='\'
  277.     if !exists('g:spf13_leader')
  278.         let mapleader = ','
  279.     else
  280.         let mapleader=g:spf13_leader
  281.     endif
  282.     if !exists('g:spf13_localleader')
  283.         let maplocalleader = '_'
  284.     else
  285.         let maplocalleader=g:spf13_localleader
  286.     endif
  287.  
  288.     " The default mappings for editing and applying the spf13 configuration
  289.     " are <leader>ev and <leader>sv respectively. Change them to your preference
  290.     " by adding the following to your .vimrc.before.local file:
  291.     "   let g:spf13_edit_config_mapping='<leader>ec'
  292.     "   let g:spf13_apply_config_mapping='<leader>sc'
  293.     if !exists('g:spf13_edit_config_mapping')
  294.         let s:spf13_edit_config_mapping = '<leader>ev'
  295.     else
  296.         let s:spf13_edit_config_mapping = g:spf13_edit_config_mapping
  297.     endif
  298.     if !exists('g:spf13_apply_config_mapping')
  299.         let s:spf13_apply_config_mapping = '<leader>sv'
  300.     else
  301.         let s:spf13_apply_config_mapping = g:spf13_apply_config_mapping
  302.     endif
  303.  
  304.     " Easier moving in tabs and windows
  305.     " The lines conflict with the default digraph mapping of <C-K>
  306.     " If you prefer that functionality, add the following to your
  307.     " .vimrc.before.local file:
  308.     "   let g:spf13_no_easyWindows = 1
  309.     if !exists('g:spf13_no_easyWindows')
  310.         map <C-J> <C-W>j<C-W>_
  311.         map <C-K> <C-W>k<C-W>_
  312.         map <C-L> <C-W>l<C-W>_
  313.         map <C-H> <C-W>h<C-W>_
  314.     endif
  315.  
  316.     " Wrapped lines goes down/up to next row, rather than next line in file.
  317.     noremap j gj
  318.     noremap k gk
  319.  
  320.     " End/Start of line motion keys act relative to row/wrap width in the
  321.     " presence of `:set wrap`, and relative to line for `:set nowrap`.
  322.     " Default vim behaviour is to act relative to text line in both cases
  323.     " If you prefer the default behaviour, add the following to your
  324.     " .vimrc.before.local file:
  325.     "   let g:spf13_no_wrapRelMotion = 1
  326.     if !exists('g:spf13_no_wrapRelMotion')
  327.         " Same for 0, home, end, etc
  328.         function! WrapRelativeMotion(key, ...)
  329.             let vis_sel=""
  330.             if a:0
  331.                 let vis_sel="gv"
  332.             endif
  333.             if &wrap
  334.                 execute "normal!" vis_sel . "g" . a:key
  335.             else
  336.                 execute "normal!" vis_sel . a:key
  337.             endif
  338.         endfunction
  339.  
  340.         " Map g* keys in Normal, Operator-pending, and Visual+select
  341.         noremap $ :call WrapRelativeMotion("$")<CR>
  342.         noremap <End> :call WrapRelativeMotion("$")<CR>
  343.         noremap 0 :call WrapRelativeMotion("0")<CR>
  344.         noremap <Home> :call WrapRelativeMotion("0")<CR>
  345.         noremap ^ :call WrapRelativeMotion("^")<CR>
  346.         " Overwrite the operator pending $/<End> mappings from above
  347.         " to force inclusive motion with :execute normal!
  348.         onoremap $ v:call WrapRelativeMotion("$")<CR>
  349.         onoremap <End> v:call WrapRelativeMotion("$")<CR>
  350.         " Overwrite the Visual+select mode mappings from above
  351.         " to ensure the correct vis_sel flag is passed to function
  352.         vnoremap $ :<C-U>call WrapRelativeMotion("$", 1)<CR>
  353.         vnoremap <End> :<C-U>call WrapRelativeMotion("$", 1)<CR>
  354.         vnoremap 0 :<C-U>call WrapRelativeMotion("0", 1)<CR>
  355.         vnoremap <Home> :<C-U>call WrapRelativeMotion("0", 1)<CR>
  356.         vnoremap ^ :<C-U>call WrapRelativeMotion("^", 1)<CR>
  357.     endif
  358.  
  359.     " The following two lines conflict with moving to top and
  360.     " bottom of the screen
  361.     " If you prefer that functionality, add the following to your
  362.     " .vimrc.before.local file:
  363.     "   let g:spf13_no_fastTabs = 1
  364.     if !exists('g:spf13_no_fastTabs')
  365.         map <S-H> gT
  366.         map <S-L> gt
  367.     endif
  368.  
  369.     " Stupid shift key fixes
  370.     if !exists('g:spf13_no_keyfixes')
  371.         if has("user_commands")
  372.             command! -bang -nargs=* -complete=file E e<bang> <args>
  373.             command! -bang -nargs=* -complete=file W w<bang> <args>
  374.             command! -bang -nargs=* -complete=file Wq wq<bang> <args>
  375.             command! -bang -nargs=* -complete=file WQ wq<bang> <args>
  376.             command! -bang Wa wa<bang>
  377.             command! -bang WA wa<bang>
  378.             command! -bang Q q<bang>
  379.             command! -bang QA qa<bang>
  380.             command! -bang Qa qa<bang>
  381.         endif
  382.  
  383.         cmap Tabe tabe
  384.     endif
  385.  
  386.     " Yank from the cursor to the end of the line, to be consistent with C and D.
  387.     nnoremap Y y$
  388.  
  389.     " Code folding options
  390.     nmap <leader>f0 :set foldlevel=0<CR>
  391.     nmap <leader>f1 :set foldlevel=1<CR>
  392.     nmap <leader>f2 :set foldlevel=2<CR>
  393.     nmap <leader>f3 :set foldlevel=3<CR>
  394.     nmap <leader>f4 :set foldlevel=4<CR>
  395.     nmap <leader>f5 :set foldlevel=5<CR>
  396.     nmap <leader>f6 :set foldlevel=6<CR>
  397.     nmap <leader>f7 :set foldlevel=7<CR>
  398.     nmap <leader>f8 :set foldlevel=8<CR>
  399.     nmap <leader>f9 :set foldlevel=9<CR>
  400.  
  401.     " Most prefer to toggle search highlighting rather than clear the current
  402.     " search results. To clear search highlighting rather than toggle it on
  403.     " and off, add the following to your .vimrc.before.local file:
  404.     "   let g:spf13_clear_search_highlight = 1
  405.     if exists('g:spf13_clear_search_highlight')
  406.         nmap <silent> <leader>/ :nohlsearch<CR>
  407.     else
  408.         nmap <silent> <leader>/ :set invhlsearch<CR>
  409.     endif
  410.  
  411.  
  412.     " Find merge conflict markers
  413.     map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
  414.  
  415.     " Shortcuts
  416.     " Change Working Directory to that of the current file
  417.     cmap cwd lcd %:p:h
  418.     cmap cd. lcd %:p:h
  419.  
  420.     " Visual shifting (does not exit Visual mode)
  421.     vnoremap < <gv
  422.     vnoremap > >gv
  423.  
  424.     " Allow using the repeat operator with a visual selection (!)
  425.     " http://stackoverflow.com/a/8064607/127816
  426.     vnoremap . :normal .<CR>
  427.  
  428.     " For when you forget to sudo.. Really Write the file.
  429.     cmap w!! w !sudo tee % >/dev/null
  430.  
  431.     " Some helpers to edit mode
  432.     " http://vimcasts.org/e/14
  433.     cnoremap %% <C-R>=fnameescape(expand('%:h')).'/'<cr>
  434.     map <leader>ew :e %%
  435.     map <leader>es :sp %%
  436.     map <leader>ev :vsp %%
  437.     map <leader>et :tabe %%
  438.  
  439.     " Adjust viewports to the same size
  440.     map <Leader>= <C-w>=
  441.  
  442.     " Map <Leader>ff to display all lines with keyword under cursor
  443.     " and ask which one to jump to
  444.     nmap <Leader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
  445.  
  446.     " Easier horizontal scrolling
  447.     map zl zL
  448.     map zh zH
  449.  
  450.     " Easier formatting
  451.     nnoremap <silent> <leader>q gwip
  452.  
  453.     " FIXME: Revert this f70be548
  454.     " fullscreen mode for GVIM and Terminal, need 'wmctrl' in you PATH
  455.     map <silent> <F11> :call system("wmctrl -ir " . v:windowid . " -b toggle,fullscreen")<CR>
  456.  
  457. " }
  458.  
  459. " Plugins {
  460.  
  461.     " GoLang {
  462.         if count(g:spf13_bundle_groups, 'go')
  463.             let g:go_highlight_functions = 1
  464.             let g:go_highlight_methods = 1
  465.             let g:go_highlight_structs = 1
  466.             let g:go_highlight_operators = 1
  467.             let g:go_highlight_build_constraints = 1
  468.             let g:go_fmt_command = "goimports"
  469.             let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
  470.             let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
  471.             au FileType go nmap <Leader>s <Plug>(go-implements)
  472.             au FileType go nmap <Leader>i <Plug>(go-info)
  473.             au FileType go nmap <Leader>e <Plug>(go-rename)
  474.             au FileType go nmap <leader>r <Plug>(go-run)
  475.             au FileType go nmap <leader>b <Plug>(go-build)
  476.             au FileType go nmap <leader>t <Plug>(go-test)
  477.             au FileType go nmap <Leader>gd <Plug>(go-doc)
  478.             au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
  479.             au FileType go nmap <leader>co <Plug>(go-coverage)
  480.         endif
  481.         " }
  482.  
  483.  
  484.     " TextObj Sentence {
  485.         if count(g:spf13_bundle_groups, 'writing')
  486.             augroup textobj_sentence
  487.               autocmd!
  488.               autocmd FileType markdown call textobj#sentence#init()
  489.               autocmd FileType textile call textobj#sentence#init()
  490.               autocmd FileType text call textobj#sentence#init()
  491.             augroup END
  492.         endif
  493.     " }
  494.  
  495.     " TextObj Quote {
  496.         if count(g:spf13_bundle_groups, 'writing')
  497.             augroup textobj_quote
  498.                 autocmd!
  499.                 autocmd FileType markdown call textobj#quote#init()
  500.                 autocmd FileType textile call textobj#quote#init()
  501.                 autocmd FileType text call textobj#quote#init({'educate': 0})
  502.             augroup END
  503.         endif
  504.     " }
  505.  
  506.     " PIV {
  507.         if isdirectory(expand("~/.vim/bundle/PIV"))
  508.             let g:DisableAutoPHPFolding = 0
  509.             let g:PIVAutoClose = 0
  510.         endif
  511.     " }
  512.  
  513.     " Misc {
  514.         if isdirectory(expand("~/.vim/bundle/nerdtree"))
  515.             let g:NERDShutUp=1
  516.         endif
  517.         if isdirectory(expand("~/.vim/bundle/matchit.zip"))
  518.             let b:match_ignorecase = 1
  519.         endif
  520.     " }
  521.  
  522.     " OmniComplete {
  523.         " To disable omni complete, add the following to your .vimrc.before.local file:
  524.         "   let g:spf13_no_omni_complete = 1
  525.         if !exists('g:spf13_no_omni_complete')
  526.             if has("autocmd") && exists("+omnifunc")
  527.                 autocmd Filetype *
  528.                     \if &omnifunc == "" |
  529.                     \setlocal omnifunc=syntaxcomplete#Complete |
  530.                     \endif
  531.             endif
  532.  
  533.             hi Pmenu  guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
  534.             hi PmenuSbar  guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
  535.             hi PmenuThumb  guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
  536.  
  537.             " Some convenient mappings
  538.             "inoremap <expr> <Esc>      pumvisible() ? "\<C-e>" : "\<Esc>"
  539.             if exists('g:spf13_map_cr_omni_complete')
  540.                 inoremap <expr> <CR>     pumvisible() ? "\<C-y>" : "\<CR>"
  541.             endif
  542.             inoremap <expr> <Down>     pumvisible() ? "\<C-n>" : "\<Down>"
  543.             inoremap <expr> <Up>       pumvisible() ? "\<C-p>" : "\<Up>"
  544.             inoremap <expr> <C-d>      pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
  545.             inoremap <expr> <C-u>      pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
  546.  
  547.             " Automatically open and close the popup menu / preview window
  548.             au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  549.             set completeopt=menu,preview,longest
  550.         endif
  551.     " }
  552.  
  553.     " Ctags {
  554.         set tags=./tags;/,~/.vimtags
  555.  
  556.         " Make tags placed in .git/tags file available in all levels of a repository
  557.         let gitroot = substitute(system('git rev-parse --show-toplevel'), '[\n\r]', '', 'g')
  558.         if gitroot != ''
  559.             let &tags = &tags . ',' . gitroot . '/.git/tags'
  560.         endif
  561.     " }
  562.  
  563.     " AutoCloseTag {
  564.         " Make it so AutoCloseTag works for xml and xhtml files as well
  565.         au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim
  566.         nmap <Leader>ac <Plug>ToggleAutoCloseMappings
  567.     " }
  568.  
  569.     " SnipMate {
  570.         " Setting the author var
  571.         " If forking, please overwrite in your .vimrc.local file
  572.         let g:snips_author = 'Steve Francia <steve.francia@gmail.com>'
  573.     " }
  574.  
  575.     " NerdTree {
  576.         if isdirectory(expand("~/.vim/bundle/nerdtree"))
  577.             map <C-e> <plug>NERDTreeTabsToggle<CR>
  578.             map <leader>e :NERDTreeFind<CR>
  579.             nmap <leader>nt :NERDTreeFind<CR>
  580.  
  581.             let NERDTreeShowBookmarks=1
  582.             let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$']
  583.             let NERDTreeChDirMode=0
  584.             let NERDTreeQuitOnOpen=1
  585.             let NERDTreeMouseMode=2
  586.             let NERDTreeShowHidden=1
  587.             let NERDTreeKeepTreeInNewTab=1
  588.             let g:nerdtree_tabs_open_on_gui_startup=0
  589.         endif
  590.     " }
  591.  
  592.     " Tabularize {
  593.         if isdirectory(expand("~/.vim/bundle/tabular"))
  594.             nmap <Leader>a& :Tabularize /&<CR>
  595.             vmap <Leader>a& :Tabularize /&<CR>
  596.             nmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
  597.             vmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
  598.             nmap <Leader>a=> :Tabularize /=><CR>
  599.             vmap <Leader>a=> :Tabularize /=><CR>
  600.             nmap <Leader>a: :Tabularize /:<CR>
  601.             vmap <Leader>a: :Tabularize /:<CR>
  602.             nmap <Leader>a:: :Tabularize /:\zs<CR>
  603.             vmap <Leader>a:: :Tabularize /:\zs<CR>
  604.             nmap <Leader>a, :Tabularize /,<CR>
  605.             vmap <Leader>a, :Tabularize /,<CR>
  606.             nmap <Leader>a,, :Tabularize /,\zs<CR>
  607.             vmap <Leader>a,, :Tabularize /,\zs<CR>
  608.             nmap <Leader>a<Bar> :Tabularize /<Bar><CR>
  609.             vmap <Leader>a<Bar> :Tabularize /<Bar><CR>
  610.         endif
  611.     " }
  612.  
  613.     " Session List {
  614.         set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize
  615.         if isdirectory(expand("~/.vim/bundle/sessionman.vim/"))
  616.             nmap <leader>sl :SessionList<CR>
  617.             nmap <leader>ss :SessionSave<CR>
  618.             nmap <leader>sc :SessionClose<CR>
  619.         endif
  620.     " }
  621.  
  622.     " JSON {
  623.         nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
  624.         let g:vim_json_syntax_conceal = 0
  625.     " }
  626.  
  627.     " PyMode {
  628.         " Disable if python support not present
  629.         if !has('python') && !has('python3')
  630.             let g:pymode = 0
  631.         endif
  632.  
  633.         if isdirectory(expand("~/.vim/bundle/python-mode"))
  634.             let g:pymode_lint_checkers = ['pyflakes']
  635.             let g:pymode_trim_whitespaces = 0
  636.             let g:pymode_options = 0
  637.             let g:pymode_rope = 0
  638.         endif
  639.     " }
  640.  
  641.     " ctrlp {
  642.         if isdirectory(expand("~/.vim/bundle/ctrlp.vim/"))
  643.             let g:ctrlp_working_path_mode = 'ra'
  644.             nnoremap <silent> <D-t> :CtrlP<CR>
  645.             nnoremap <silent> <D-r> :CtrlPMRU<CR>
  646.             let g:ctrlp_custom_ignore = {
  647.                 \ 'dir':  '\.git$\|\.hg$\|\.svn$',
  648.                 \ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }
  649.  
  650.             if executable('ag')
  651.                 let s:ctrlp_fallback = 'ag %s --nocolor -l -g ""'
  652.             elseif executable('ack-grep')
  653.                 let s:ctrlp_fallback = 'ack-grep %s --nocolor -f'
  654.             elseif executable('ack')
  655.                 let s:ctrlp_fallback = 'ack %s --nocolor -f'
  656.             " On Windows use "dir" as fallback command.
  657.             elseif WINDOWS()
  658.                 let s:ctrlp_fallback = 'dir %s /-n /b /s /a-d'
  659.             else
  660.                 let s:ctrlp_fallback = 'find %s -type f'
  661.             endif
  662.             if exists("g:ctrlp_user_command")
  663.                 unlet g:ctrlp_user_command
  664.             endif
  665.             let g:ctrlp_user_command = {
  666.                 \ 'types': {
  667.                     \ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
  668.                     \ 2: ['.hg', 'hg --cwd %s locate -I .'],
  669.                 \ },
  670.                 \ 'fallback': s:ctrlp_fallback
  671.             \ }
  672.  
  673.             if isdirectory(expand("~/.vim/bundle/ctrlp-funky/"))
  674.                 " CtrlP extensions
  675.                 let g:ctrlp_extensions = ['funky']
  676.  
  677.                 "funky
  678.                 nnoremap <Leader>fu :CtrlPFunky<Cr>
  679.             endif
  680.         endif
  681.     "}
  682.  
  683.     " TagBar {
  684.         if isdirectory(expand("~/.vim/bundle/tagbar/"))
  685.             nnoremap <silent> <leader>tt :TagbarToggle<CR>
  686.         endif
  687.     "}
  688.  
  689.     " Rainbow {
  690.         if isdirectory(expand("~/.vim/bundle/rainbow/"))
  691.             let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
  692.         endif
  693.     "}
  694.  
  695.     " Fugitive {
  696.         if isdirectory(expand("~/.vim/bundle/vim-fugitive/"))
  697.             nnoremap <silent> <leader>gs :Gstatus<CR>
  698.             nnoremap <silent> <leader>gd :Gdiff<CR>
  699.             nnoremap <silent> <leader>gc :Gcommit<CR>
  700.             nnoremap <silent> <leader>gb :Gblame<CR>
  701.             nnoremap <silent> <leader>gl :Glog<CR>
  702.             nnoremap <silent> <leader>gp :Git push<CR>
  703.             nnoremap <silent> <leader>gr :Gread<CR>
  704.             nnoremap <silent> <leader>gw :Gwrite<CR>
  705.             nnoremap <silent> <leader>ge :Gedit<CR>
  706.             " Mnemonic _i_nteractive
  707.             nnoremap <silent> <leader>gi :Git add -p %<CR>
  708.             nnoremap <silent> <leader>gg :SignifyToggle<CR>
  709.         endif
  710.     "}
  711.  
  712.     " YouCompleteMe {
  713.         if count(g:spf13_bundle_groups, 'youcompleteme')
  714.             let g:acp_enableAtStartup = 0
  715.  
  716.             " enable completion from tags
  717.             let g:ycm_collect_identifiers_from_tags_files = 1
  718.  
  719.             " remap Ultisnips for compatibility for YCM
  720.             let g:UltiSnipsExpandTrigger = '<C-j>'
  721.             let g:UltiSnipsJumpForwardTrigger = '<C-j>'
  722.             let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
  723.  
  724.             " Enable omni completion.
  725.             autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  726.             autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  727.             autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  728.             autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
  729.             autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  730.             autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
  731.             autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
  732.  
  733.             " Haskell post write lint and check with ghcmod
  734.             " $ `cabal install ghcmod` if missing and ensure
  735.             " ~/.cabal/bin is in your $PATH.
  736.             if !executable("ghcmod")
  737.                 autocmd BufWritePost *.hs GhcModCheckAndLintAsync
  738.             endif
  739.  
  740.             " For snippet_complete marker.
  741.             if !exists("g:spf13_no_conceal")
  742.                 if has('conceal')
  743.                     set conceallevel=2 concealcursor=i
  744.                 endif
  745.             endif
  746.  
  747.             " Disable the neosnippet preview candidate window
  748.             " When enabled, there can be too much visual noise
  749.             " especially when splits are used.
  750.             set completeopt-=preview
  751.         endif
  752.     " }
  753.  
  754.     " neocomplete {
  755.         if count(g:spf13_bundle_groups, 'neocomplete')
  756.             let g:acp_enableAtStartup = 0
  757.             let g:neocomplete#enable_at_startup = 1
  758.             let g:neocomplete#enable_smart_case = 1
  759.             let g:neocomplete#enable_auto_delimiter = 1
  760.             let g:neocomplete#max_list = 15
  761.             let g:neocomplete#force_overwrite_completefunc = 1
  762.  
  763.  
  764.             " Define dictionary.
  765.             let g:neocomplete#sources#dictionary#dictionaries = {
  766.                         \ 'default' : '',
  767.                         \ 'vimshell' : $HOME.'/.vimshell_hist',
  768.                         \ 'scheme' : $HOME.'/.gosh_completions'
  769.                         \ }
  770.  
  771.             " Define keyword.
  772.             if !exists('g:neocomplete#keyword_patterns')
  773.                 let g:neocomplete#keyword_patterns = {}
  774.             endif
  775.             let g:neocomplete#keyword_patterns['default'] = '\h\w*'
  776.  
  777.             " Plugin key-mappings {
  778.                 " These two lines conflict with the default digraph mapping of <C-K>
  779.                 if !exists('g:spf13_no_neosnippet_expand')
  780.                     imap <C-k> <Plug>(neosnippet_expand_or_jump)
  781.                     smap <C-k> <Plug>(neosnippet_expand_or_jump)
  782.                 endif
  783.                 if exists('g:spf13_noninvasive_completion')
  784.                     inoremap <CR> <CR>
  785.                     " <ESC> takes you out of insert mode
  786.                     inoremap <expr> <Esc>   pumvisible() ? "\<C-y>\<Esc>" : "\<Esc>"
  787.                     " <CR> accepts first, then sends the <CR>
  788.                     inoremap <expr> <CR>    pumvisible() ? "\<C-y>\<CR>" : "\<CR>"
  789.                     " <Down> and <Up> cycle like <Tab> and <S-Tab>
  790.                     inoremap <expr> <Down>  pumvisible() ? "\<C-n>" : "\<Down>"
  791.                     inoremap <expr> <Up>    pumvisible() ? "\<C-p>" : "\<Up>"
  792.                     " Jump up and down the list
  793.                     inoremap <expr> <C-d>   pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
  794.                     inoremap <expr> <C-u>   pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
  795.                 else
  796.                     " <C-k> Complete Snippet
  797.                     " <C-k> Jump to next snippet point
  798.                     imap <silent><expr><C-k> neosnippet#expandable() ?
  799.                                 \ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ?
  800.                                 \ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)")
  801.                     smap <TAB> <Right><Plug>(neosnippet_jump_or_expand)
  802.  
  803.                     inoremap <expr><C-g> neocomplete#undo_completion()
  804.                     inoremap <expr><C-l> neocomplete#complete_common_string()
  805.                     "inoremap <expr><CR> neocomplete#complete_common_string()
  806.  
  807.                     " <CR>: close popup
  808.                     " <s-CR>: close popup and save indent.
  809.                     inoremap <expr><s-CR> pumvisible() ? neocomplete#smart_close_popup()."\<CR>" : "\<CR>"
  810.  
  811.                     function! CleverCr()
  812.                         if pumvisible()
  813.                             if neosnippet#expandable()
  814.                                 let exp = "\<Plug>(neosnippet_expand)"
  815.                                 return exp . neocomplete#smart_close_popup()
  816.                             else
  817.                                 return neocomplete#smart_close_popup()
  818.                             endif
  819.                         else
  820.                             return "\<CR>"
  821.                         endif
  822.                     endfunction
  823.  
  824.                     " <CR> close popup and save indent or expand snippet
  825.                     imap <expr> <CR> CleverCr()
  826.                     " <C-h>, <BS>: close popup and delete backword char.
  827.                     inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
  828.                     inoremap <expr><C-y> neocomplete#smart_close_popup()
  829.                 endif
  830.                 " <TAB>: completion.
  831.                 inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
  832.                 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
  833.  
  834.                 " Courtesy of Matteo Cavalleri
  835.  
  836.                 function! CleverTab()
  837.                     if pumvisible()
  838.                         return "\<C-n>"
  839.                     endif
  840.                     let substr = strpart(getline('.'), 0, col('.') - 1)
  841.                     let substr = matchstr(substr, '[^ \t]*$')
  842.                     if strlen(substr) == 0
  843.                         " nothing to match on empty string
  844.                         return "\<Tab>"
  845.                     else
  846.                         " existing text matching
  847.                         if neosnippet#expandable_or_jumpable()
  848.                             return "\<Plug>(neosnippet_expand_or_jump)"
  849.                         else
  850.                             return neocomplete#start_manual_complete()
  851.                         endif
  852.                     endif
  853.                 endfunction
  854.  
  855.                 imap <expr> <Tab> CleverTab()
  856.             " }
  857.  
  858.             " Enable heavy omni completion.
  859.             if !exists('g:neocomplete#sources#omni#input_patterns')
  860.                 let g:neocomplete#sources#omni#input_patterns = {}
  861.             endif
  862.             let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
  863.             let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
  864.             let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
  865.             let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
  866.             let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
  867.     " }
  868.     " neocomplcache {
  869.         elseif count(g:spf13_bundle_groups, 'neocomplcache')
  870.             let g:acp_enableAtStartup = 0
  871.             let g:neocomplcache_enable_at_startup = 1
  872.             let g:neocomplcache_enable_camel_case_completion = 1
  873.             let g:neocomplcache_enable_smart_case = 1
  874.             let g:neocomplcache_enable_underbar_completion = 1
  875.             let g:neocomplcache_enable_auto_delimiter = 1
  876.             let g:neocomplcache_max_list = 15
  877.             let g:neocomplcache_force_overwrite_completefunc = 1
  878.  
  879.             " Define dictionary.
  880.             let g:neocomplcache_dictionary_filetype_lists = {
  881.                         \ 'default' : '',
  882.                         \ 'vimshell' : $HOME.'/.vimshell_hist',
  883.                         \ 'scheme' : $HOME.'/.gosh_completions'
  884.                         \ }
  885.  
  886.             " Define keyword.
  887.             if !exists('g:neocomplcache_keyword_patterns')
  888.                 let g:neocomplcache_keyword_patterns = {}
  889.             endif
  890.             let g:neocomplcache_keyword_patterns._ = '\h\w*'
  891.  
  892.             " Plugin key-mappings {
  893.                 " These two lines conflict with the default digraph mapping of <C-K>
  894.                 imap <C-k> <Plug>(neosnippet_expand_or_jump)
  895.                 smap <C-k> <Plug>(neosnippet_expand_or_jump)
  896.                 if exists('g:spf13_noninvasive_completion')
  897.                     inoremap <CR> <CR>
  898.                     " <ESC> takes you out of insert mode
  899.                     inoremap <expr> <Esc>   pumvisible() ? "\<C-y>\<Esc>" : "\<Esc>"
  900.                     " <CR> accepts first, then sends the <CR>
  901.                     inoremap <expr> <CR>    pumvisible() ? "\<C-y>\<CR>" : "\<CR>"
  902.                     " <Down> and <Up> cycle like <Tab> and <S-Tab>
  903.                     inoremap <expr> <Down>  pumvisible() ? "\<C-n>" : "\<Down>"
  904.                     inoremap <expr> <Up>    pumvisible() ? "\<C-p>" : "\<Up>"
  905.                     " Jump up and down the list
  906.                     inoremap <expr> <C-d>   pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
  907.                     inoremap <expr> <C-u>   pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
  908.                 else
  909.                     imap <silent><expr><C-k> neosnippet#expandable() ?
  910.                                 \ "\<Plug>(neosnippet_expand_or_jump)" : (pumvisible() ?
  911.                                 \ "\<C-e>" : "\<Plug>(neosnippet_expand_or_jump)")
  912.                     smap <TAB> <Right><Plug>(neosnippet_jump_or_expand)
  913.  
  914.                     inoremap <expr><C-g> neocomplcache#undo_completion()
  915.                     inoremap <expr><C-l> neocomplcache#complete_common_string()
  916.                     "inoremap <expr><CR> neocomplcache#complete_common_string()
  917.  
  918.                     function! CleverCr()
  919.                         if pumvisible()
  920.                             if neosnippet#expandable()
  921.                                 let exp = "\<Plug>(neosnippet_expand)"
  922.                                 return exp . neocomplcache#close_popup()
  923.                             else
  924.                                 return neocomplcache#close_popup()
  925.                             endif
  926.                         else
  927.                             return "\<CR>"
  928.                         endif
  929.                     endfunction
  930.  
  931.                     " <CR> close popup and save indent or expand snippet
  932.                     imap <expr> <CR> CleverCr()
  933.  
  934.                     " <CR>: close popup
  935.                     " <s-CR>: close popup and save indent.
  936.                     inoremap <expr><s-CR> pumvisible() ? neocomplcache#close_popup()."\<CR>" : "\<CR>"
  937.                     "inoremap <expr><CR> pumvisible() ? neocomplcache#close_popup() : "\<CR>"
  938.  
  939.                     " <C-h>, <BS>: close popup and delete backword char.
  940.                     inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
  941.                     inoremap <expr><C-y> neocomplcache#close_popup()
  942.                 endif
  943.                 " <TAB>: completion.
  944.                 inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
  945.                 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
  946.             " }
  947.  
  948.             " Enable omni completion.
  949.             autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  950.             autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  951.             autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  952.             autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
  953.             autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  954.             autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
  955.             autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
  956.  
  957.             " Enable heavy omni completion.
  958.             if !exists('g:neocomplcache_omni_patterns')
  959.                 let g:neocomplcache_omni_patterns = {}
  960.             endif
  961.             let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
  962.             let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
  963.             let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
  964.             let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
  965.             let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
  966.             let g:neocomplcache_omni_patterns.go = '\h\w*\.\?'
  967.     " }
  968.     " Normal Vim omni-completion {
  969.     " To disable omni complete, add the following to your .vimrc.before.local file:
  970.     "   let g:spf13_no_omni_complete = 1
  971.         elseif !exists('g:spf13_no_omni_complete')
  972.             " Enable omni-completion.
  973.             autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
  974.             autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
  975.             autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
  976.             autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
  977.             autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
  978.             autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
  979.             autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
  980.  
  981.         endif
  982.     " }
  983.  
  984.     " Snippets {
  985.         if count(g:spf13_bundle_groups, 'neocomplcache') ||
  986.                     \ count(g:spf13_bundle_groups, 'neocomplete')
  987.  
  988.             " Use honza's snippets.
  989.             let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
  990.  
  991.             " Enable neosnippet snipmate compatibility mode
  992.             let g:neosnippet#enable_snipmate_compatibility = 1
  993.  
  994.             " For snippet_complete marker.
  995.             if !exists("g:spf13_no_conceal")
  996.                 if has('conceal')
  997.                     set conceallevel=2 concealcursor=i
  998.                 endif
  999.             endif
  1000.  
  1001.             " Enable neosnippets when using go
  1002.             let g:go_snippet_engine = "neosnippet"
  1003.  
  1004.             " Disable the neosnippet preview candidate window
  1005.             " When enabled, there can be too much visual noise
  1006.             " especially when splits are used.
  1007.             set completeopt-=preview
  1008.         endif
  1009.     " }
  1010.  
  1011.     " FIXME: Isn't this for Syntastic to handle?
  1012.     " Haskell post write lint and check with ghcmod
  1013.     " $ `cabal install ghcmod` if missing and ensure
  1014.     " ~/.cabal/bin is in your $PATH.
  1015.     if !executable("ghcmod")
  1016.         autocmd BufWritePost *.hs GhcModCheckAndLintAsync
  1017.     endif
  1018.  
  1019.     " UndoTree {
  1020.         if isdirectory(expand("~/.vim/bundle/undotree/"))
  1021.             nnoremap <Leader>u :UndotreeToggle<CR>
  1022.             " If undotree is opened, it is likely one wants to interact with it.
  1023.             let g:undotree_SetFocusWhenToggle=1
  1024.         endif
  1025.     " }
  1026.  
  1027.     " indent_guides {
  1028.         if isdirectory(expand("~/.vim/bundle/vim-indent-guides/"))
  1029.             let g:indent_guides_start_level = 2
  1030.             let g:indent_guides_guide_size = 1
  1031.             let g:indent_guides_enable_on_vim_startup = 1
  1032.         endif
  1033.     " }
  1034.  
  1035.     " Wildfire {
  1036.     let g:wildfire_objects = {
  1037.                 \ "*" : ["i'", 'i"', "i)", "i]", "i}", "ip"],
  1038.                 \ "html,xml" : ["at"],
  1039.                 \ }
  1040.     " }
  1041.  
  1042.     " vim-airline {
  1043.         " Set configuration options for the statusline plugin vim-airline.
  1044.         " Use the powerline theme and optionally enable powerline symbols.
  1045.         " To use the symbols , , , , , , and .in the statusline
  1046.         " segments add the following to your .vimrc.before.local file:
  1047.         "   let g:airline_powerline_fonts=1
  1048.         " If the previous symbols do not render for you then install a
  1049.         " powerline enabled font.
  1050.  
  1051.         " See `:echo g:airline_theme_map` for some more choices
  1052.         " Default in terminal vim is 'dark'
  1053.         if isdirectory(expand("~/.vim/bundle/vim-airline-themes/"))
  1054.             if !exists('g:airline_theme')
  1055.                 let g:airline_theme = 'solarized'
  1056.             endif
  1057.             if !exists('g:airline_powerline_fonts')
  1058.                 " Use the default set of separators with a few customizations
  1059.                 let g:airline_left_sep='›'  " Slightly fancier than '>'
  1060.                 let g:airline_right_sep='‹' " Slightly fancier than '<'
  1061.             endif
  1062.         endif
  1063.     " }
  1064.  
  1065.  
  1066.  
  1067. " }
  1068.  
  1069. " GUI Settings {
  1070.  
  1071.     " GVIM- (here instead of .gvimrc)
  1072.     if has('gui_running')
  1073.         set guioptions-=T           " Remove the toolbar
  1074.         set lines=40                " 40 lines of text instead of 24
  1075.         if !exists("g:spf13_no_big_font")
  1076.             if LINUX() && has("gui_running")
  1077.                 set guifont=Andale\ Mono\ Regular\ 12,Menlo\ Regular\ 11,Consolas\ Regular\ 12,Courier\ New\ Regular\ 14
  1078.             elseif OSX() && has("gui_running")
  1079.                 set guifont=Andale\ Mono\ Regular:h12,Menlo\ Regular:h11,Consolas\ Regular:h12,Courier\ New\ Regular:h14
  1080.             elseif WINDOWS() && has("gui_running")
  1081.                 set guifont=Andale_Mono:h10,Menlo:h10,Consolas:h10,Courier_New:h10
  1082.             endif
  1083.         endif
  1084.     else
  1085.         if &term == 'xterm' || &term == 'screen'
  1086.             set t_Co=256            " Enable 256 colors to stop the CSApprox warning and make xterm vim shine
  1087.         endif
  1088.         "set term=builtin_ansi       " Make arrow and other keys work
  1089.     endif
  1090.  
  1091. " }
  1092.  
  1093. " Functions {
  1094.  
  1095.     " Initialize directories {
  1096.     function! InitializeDirectories()
  1097.         let parent = $HOME
  1098.         let prefix = 'vim'
  1099.         let dir_list = {
  1100.                     \ 'backup': 'backupdir',
  1101.                     \ 'views': 'viewdir',
  1102.                     \ 'swap': 'directory' }
  1103.  
  1104.         if has('persistent_undo')
  1105.             let dir_list['undo'] = 'undodir'
  1106.         endif
  1107.  
  1108.         " To specify a different directory in which to place the vimbackup,
  1109.         " vimviews, vimundo, and vimswap files/directories, add the following to
  1110.         " your .vimrc.before.local file:
  1111.         "   let g:spf13_consolidated_directory = <full path to desired directory>
  1112.         "   eg: let g:spf13_consolidated_directory = $HOME . '/.vim/'
  1113.         if exists('g:spf13_consolidated_directory')
  1114.             let common_dir = g:spf13_consolidated_directory . prefix
  1115.         else
  1116.             let common_dir = parent . '/.' . prefix
  1117.         endif
  1118.  
  1119.         for [dirname, settingname] in items(dir_list)
  1120.             let directory = common_dir . dirname . '/'
  1121.             if exists("*mkdir")
  1122.                 if !isdirectory(directory)
  1123.                     call mkdir(directory)
  1124.                 endif
  1125.             endif
  1126.             if !isdirectory(directory)
  1127.                 echo "Warning: Unable to create backup directory: " . directory
  1128.                 echo "Try: mkdir -p " . directory
  1129.             else
  1130.                 let directory = substitute(directory, " ", "\\\\ ", "g")
  1131.                 exec "set " . settingname . "=" . directory
  1132.             endif
  1133.         endfor
  1134.     endfunction
  1135.     call InitializeDirectories()
  1136.     " }
  1137.  
  1138.     " Initialize NERDTree as needed {
  1139.     function! NERDTreeInitAsNeeded()
  1140.         redir => bufoutput
  1141.         buffers!
  1142.         redir END
  1143.         let idx = stridx(bufoutput, "NERD_tree")
  1144.         if idx > -1
  1145.             NERDTreeMirror
  1146.             NERDTreeFind
  1147.             wincmd l
  1148.         endif
  1149.     endfunction
  1150.     " }
  1151.  
  1152.     " Strip whitespace {
  1153.     function! StripTrailingWhitespace()
  1154.         " Preparation: save last search, and cursor position.
  1155.         let _s=@/
  1156.         let l = line(".")
  1157.         let c = col(".")
  1158.         " do the business:
  1159.         %s/\s\+$//e
  1160.         " clean up: restore previous search history, and cursor position
  1161.         let @/=_s
  1162.         call cursor(l, c)
  1163.     endfunction
  1164.     " }
  1165.  
  1166.     " Shell command {
  1167.     function! s:RunShellCommand(cmdline)
  1168.         botright new
  1169.  
  1170.         setlocal buftype=nofile
  1171.         setlocal bufhidden=delete
  1172.         setlocal nobuflisted
  1173.         setlocal noswapfile
  1174.         setlocal nowrap
  1175.         setlocal filetype=shell
  1176.         setlocal syntax=shell
  1177.  
  1178.         call setline(1, a:cmdline)
  1179.         call setline(2, substitute(a:cmdline, '.', '=', 'g'))
  1180.         execute 'silent $read !' . escape(a:cmdline, '%#')
  1181.         setlocal nomodifiable
  1182.         1
  1183.     endfunction
  1184.  
  1185.     command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
  1186.     " e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
  1187.     " }
  1188.  
  1189.     function! s:IsSpf13Fork()
  1190.         let s:is_fork = 0
  1191.         let s:fork_files = ["~/.vimrc.fork", "~/.vimrc.before.fork", "~/.vimrc.bundles.fork"]
  1192.         for fork_file in s:fork_files
  1193.             if filereadable(expand(fork_file, ":p"))
  1194.                 let s:is_fork = 1
  1195.                 break
  1196.             endif
  1197.         endfor
  1198.         return s:is_fork
  1199.     endfunction
  1200.      
  1201.     function! s:ExpandFilenameAndExecute(command, file)
  1202.         execute a:command . " " . expand(a:file, ":p")
  1203.     endfunction
  1204.      
  1205.     function! s:EditSpf13Config()
  1206.         call <SID>ExpandFilenameAndExecute("tabedit", "~/.vimrc")
  1207.         call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.before")
  1208.         call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles")
  1209.      
  1210.         execute bufwinnr(".vimrc") . "wincmd w"
  1211.         call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.local")
  1212.         wincmd l
  1213.         call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.local")
  1214.         wincmd l
  1215.         call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local")
  1216.      
  1217.         if <SID>IsSpf13Fork()
  1218.             execute bufwinnr(".vimrc") . "wincmd w"
  1219.             call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.fork")
  1220.             wincmd l
  1221.             call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.fork")
  1222.             wincmd l
  1223.             call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork")
  1224.         endif
  1225.      
  1226.         execute bufwinnr(".vimrc.local") . "wincmd w"
  1227.     endfunction
  1228.      
  1229.     execute "noremap " . s:spf13_edit_config_mapping " :call <SID>EditSpf13Config()<CR>"
  1230.     execute "noremap " . s:spf13_apply_config_mapping . " :source ~/.vimrc<CR>"
  1231. " }
  1232.  
  1233. " Use fork vimrc if available {
  1234.     if filereadable(expand("~/.vimrc.fork"))
  1235.         source ~/.vimrc.fork
  1236.     endif
  1237. " }
  1238.  
  1239. " Use local vimrc if available {
  1240.     if filereadable(expand("~/.vimrc.local"))
  1241.         source ~/.vimrc.local
  1242.     endif
  1243. " }
  1244.  
  1245. " Use local gvimrc if available and gui is running {
  1246.     if has('gui_running')
  1247.         if filereadable(expand("~/.gvimrc.local"))
  1248.             source ~/.gvimrc.local
  1249.         endif
  1250.     endif
  1251. " }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement