Advertisement
xangelux

Angelux's vimrc

Oct 30th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 16.37 KB | None | 0 0
  1. " Prelude------------------------------------------------------------------{{{
  2.   scriptencoding 'utf-8'
  3.  
  4.  
  5.   filetype plugin indent on
  6.   filetype plugin on
  7.   filetype off
  8.   " NEOBUNDLE-------------------------------------------------------------{{{
  9.  
  10.   if has('vim_starting')
  11.     set runtimepath+=~/.vim/bundle/neobundle.vim/
  12.   endif
  13.  
  14.   call neobundle#rc(expand('~/.vim/bundle/'))
  15.  
  16.   " Shougo
  17.   NeoBundleFetch 'Shougo/neobundle.vim'
  18.   NeoBundle 'Shougo/unite.vim.git'
  19.   NeoBundle 'Shougo/neosnippet.vim.git'
  20.   NeoBundle 'Shougo/vimproc'
  21.   NeoBundle 'Shougo/neocomplcache.vim.git'
  22.  
  23.   " tpope
  24.   NeoBundle 'tpope/vim-fugitive'
  25.   NeoBundle 'tpope/vim-surround.git'
  26.  
  27.   " Srcrooloose
  28.   NeoBundle 'scrooloose/nerdtree.git'
  29.   NeoBundle 'scrooloose/syntastic.git'
  30.   NeoBundle 'scrooloose/nerdcommenter.git'
  31.  
  32.   " Misc
  33.   NeoBundle 'ervandew/supertab.git'
  34.   NeoBundle 'gregsexton/gitv.git'
  35.   NeoBundle 'Lokaltog/vim-easymotion'
  36.   NeoBundle 'rstacruz/sparkup', {'rtp': 'vim/'}
  37.   NeoBundle 'dhazel/conque-term'
  38.   NeoBundle 'vim-scripts/dbext.vim'
  39.   NeoBundle 'sjl/gundo.vim.git'
  40.   NeoBundle 'Yggdroot/indentLine.git'
  41.   NeoBundle 'Glench/Vim-Jinja2-Syntax.git'
  42.   NeoBundle 'vim-scripts/ruby-matchit.git'
  43.   NeoBundle 'altercation/vim-colors-solarized.git'
  44.   NeoBundle 'tsaleh/vim-matchit.git'
  45.   NeoBundle 'honza/vim-snippets.git'
  46.   NeoBundle 'altercation/vim-colors-solarized.git'
  47.   NeoBundle 'tomasr/molokai.git'
  48.   NeoBundle 'godlygeek/tabular.git'
  49.   NeoBundle 'brookhong/DBGPavim'
  50.   NeoBundle 'php.vim'
  51.  
  52.   " }}}
  53.  
  54.   let mapleader = "," " Leader key for some bindings
  55.   imap kj <ESC>
  56.   imap KJ <ESC>
  57.   map K <nop>
  58.  
  59.   " Formatting--------------------------------------------------------------{{{
  60.     ""set formatprg=par\ -w80
  61.     set wrap               " Long lines are wraped to the next line
  62.     set tw=80 " Insert line break at column 80
  63.     set cursorline         " Highlight current line
  64.     set nu                 " Enable left side numbers
  65.     set encoding=utf-8     " Set encoding for vim to interpret
  66.     set nrformats-=octal         " set the increment/decrement (ctrl-a/ctrl-x)
  67.     set formatoptions=qrn21jtca     " See help
  68.     set linebreak
  69.  
  70.     " Indentation-----------------------------------------------------------{{{
  71.       set autowrite     " Automatically write to file when changing windows/tabs
  72.       set autoindent    " On every line break keep indentation
  73.       set smartindent   " Indents when needed and skips when in comments
  74.       set expandtab     " Don't use tab char, instead isert spaces
  75.       set softtabstop=2 " Number of spaces to insert on tab
  76.       set smarttab " When BS is used on expanded tab deletes the full tab
  77.       set ts=2 " Number of spaces inserted on each new tab
  78.       set sw=2 " Number of spaces interpreted for tab
  79.       set bs=2 " Allow backspacing over indent, eol and the start of an insert
  80.       set shiftround " Rounds indent to multiple of shiftwidth previewsly setted
  81.     "}}}
  82.  
  83.   "}}}
  84.  
  85.   set nocompatible       " Disable force compatibility for old vim
  86.   set incsearch          " Instant search on char type
  87.   set showcmd            " Always show command line
  88.   set history=1000       " Command history size
  89.   set fileencoding=utf-8 " Set encoding to file
  90.   set termencoding=utf-8 " Set encoding for shell
  91.   set timeoutlen=300     " Waiting time between keys to discard key combination
  92.   set shell=/bin/zsh\ --login " Quick command on shell instead of full Conque
  93.   set cf                       " Enable error files and jump between errors
  94.   set clipboard+=unnamed       " Yanks go to system pastebin (middle click)
  95.   set autoread          " Reload file if modified out of vim
  96.  
  97.   " Monitor vimrc file and source it when modified
  98.   autocmd! bufwritepost .vimrc source %
  99.   " Save when losing focus
  100.   au FocusLost * :silent! wall
  101.  
  102.   " Graphical options------------------------------------------------------{{{
  103.     set ruler                    " Show current line number and char
  104.     set guioptions+=cfg          " gui off, don't fork gui on detatch and show disabled menu
  105.     set guioptions-=T            " Disable tool bar
  106.     set guioptions-=m            " Disable menu bar
  107.     set guioptions-=F            " Disable footer bar
  108.     set guioptions+=LlRrb        " Bug, this is needed to delete the scrollbars
  109.     set guioptions-=LlRrb        " Turn off gui toolbar and scroll bars and take footer
  110.     set scrolloff=6              " When scrolling keep cursor 6 lines from top or bottom
  111.     set sidescroll=1             " Minimal number of chars to scroll sideways
  112.     set sidescrolloff=8          " Keep cursor 8 lines from vertical edge
  113.     set synmaxcol=200            " Limit syntax coloring column to make vim faster
  114.     set laststatus=2             " Shows the last status always
  115.     set wildmenu                 " Enhanced command completion
  116.     set wildmode=list:longest
  117.     set wildignore+=.hg,.git,.svn                   " Version control
  118.     set wildignore+=*.aux,*.out,*.toc               " LaTeX intermediate files
  119.     set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg  " binary images
  120.     set wildignore+=*.o,*.obj,*.exe,*.manifest      " compiled object files
  121.     set wildignore+=*.spl " compiled spelling word lists
  122.     set wildignore+=*.sw? " Vim swap files
  123.     set showmode          " Show current mode
  124.     set ttyfast           " Redraws more often in terminal
  125.     set lazyredraw        " Redraws only when necesary and not in execution of macros
  126.     set viewoptions=folds,options,cursor,unix,slash
  127.     set diffopt+=iwhite,vertical " ignore white space diffs
  128.     au VimResized * :wincmd = " Resize splits when rezising window
  129.   "}}}
  130.  
  131.   " Custom mapings---------------------------------------------------------{{{
  132.  
  133.     " Diffoff
  134.     nnoremap <leader>D :diffoff!<CR>
  135.  
  136.     " Toggle invisible caracters
  137.     nnoremap <leader>l :set list!<CR>
  138.  
  139.     " Break line in two
  140.     nmap Ñ i<CR><Esc>
  141.  
  142.     " Sort lines
  143.     nnoremap <leader>s vip:!sort<CR>
  144.     vnoremap <leader>s :!sort<CR>
  145.  
  146.     " When in insert mode hit <C-u> to upper case the word
  147.     " you just typed when on the end of the word
  148.     inoremap <C-u> <ESC>mzgUiw`za
  149.  
  150.     " Clean trailing space
  151.     nnoremap <leader>w mz:%s/\s\+$//<CR>:let @/=''<CR>`z
  152.  
  153.     " Window navigation made easy
  154.     :nmap <C-j> <C-w>j
  155.     :nmap <C-k> <C-w>k
  156.     :nmap <C-h> <C-w>h
  157.     :nmap <C-l> <C-w>l
  158.  
  159.     " Toggle numbers on left margin
  160.     :nnoremap <leader>n :setlocal number!<CR>
  161.  
  162.     " Toggle type of numbering (relative/absolute)
  163.     :nnoremap <leader>N :setlocal relativenumber!<CR>
  164.  
  165.     " Man pages triggered with M instead of K
  166.     :nnoremap <C-M> K
  167.  
  168.     " Get the file under the cursor in a vertical split
  169.     :map fg :vertical wincmd f<CR>
  170.  
  171.     " Gundo
  172.     nnoremap <F7> :GundoToggle<CR>
  173.  
  174.     " Drag lines ----------------------------------------------------------{{{
  175.       " <m-j> and <m-k> to drag lines in any mode
  176.       noremap <M-j> :m+<CR>
  177.       noremap <M-k> :m-2<CR>
  178.       inoremap <M-j> <Esc>:m+<CR>
  179.       inoremap <M-k> <Esc>:m-2<CR>
  180.       vnoremap <M-j> :m'>+<CR>gv
  181.      vnoremap <M-k> :m-2<CR>gv
  182.    "}}}
  183.  "}}}
  184.  
  185.  " Custom commands--------------------------------------------------------{{{
  186.    command! -nargs=1 Vb call VerticalSplitBuffer( <f-args> )
  187.    command! W w
  188.    command! Q q
  189.    command! Qa qa
  190.    command! Term ConqueTerm zsh
  191.  
  192.    " Function to mimic vertical split with buffer already opened
  193.      function! VerticalSplitBuffer( buffer )
  194.        execute "vert sb" a:buffer
  195.      endfunction
  196.  
  197.  "}}}
  198.  
  199.  " Undo, backup and info files--------------------------------------------{{{
  200.  
  201.    "For undo between sessions and more
  202.  
  203.    set backupdir=$HOME/.vim/tmp/backup/
  204.    set directory=$HOME/.vim/tmp/swap/
  205.    set viewdir=$HOME/.vim/tmp/view/
  206.    set undodir=$HOME/.vim/tmp/undo/
  207.    set backup
  208.    set noswapfile
  209.    set undofile
  210.    set viminfo='50,n$HOME/.vim/tmp/viminfo
  211.     if !isdirectory(expand(&backupdir))
  212.       call mkdir(expand(&backupdir), "p")
  213.     endif
  214.     if !isdirectory(expand(&directory))
  215.       call mkdir(expand(&directory), "p")
  216.     endif
  217.     if !isdirectory(expand(&undodir))
  218.       call mkdir(expand(&undodir), "p")
  219.     endif
  220.     if !isdirectory(expand(&viewdir))
  221.       call mkdir(expand(&viewdir), "p")
  222.     endif
  223.   "}}}
  224.  
  225.   " Markings---------------------------------------------------------------{{{
  226.     set fillchars=diff:⣿,vert: " Chars to use as diff filler and window divider
  227.     set relativenumber " Show line number and other numbers are relative to this
  228.     set showbreak=↪ " Show this char when line is wraped from the line before
  229.     " List of chars used by format␣ "invisible" chars
  230.     set listchars=tab:▸\ ,trail:·,eol:¬,extends:»,precedes:«,nbsp:+
  231.     " If showing, hide trail and eol chars when in insert mode
  232.     "augroup trailing
  233.       "au!
  234.       "au InsertEnter * :set listchars-=trail:␣,eol:¬
  235.     "augroup END
  236.     " Check if terminal supports colors or is gui running
  237.     if &t_Co > 2 || has("gui_running")
  238.       syntax enable " Syntax highlight always on
  239.       set hlsearch " Highlight ocurrences in search query
  240.       set ignorecase " Ignore case sensitive search
  241.       set showmatch " Show matching parens when cursor on one
  242.       set incsearch " Do instant search on key stroke
  243.       set smartcase " If search query has Upper case, then is case sensitive
  244.       " Clear highlighted search ocurrences
  245.       noremap <silent> <leader><space> :noh<CR>:call clearmatches()<CR>
  246.       " Keep search matches in the middle of the window.
  247.       nnoremap n nzzzv
  248.       nnoremap N Nzzzv
  249.     endif
  250.  
  251.     " Check if gui is running
  252.     " Helptags for pathogen
  253.     "Helptags
  254.     set colorcolumn=80 " highlight 1 column after max char line
  255.     if has("gui_running")
  256.       set background=dark
  257.       colorscheme solarized
  258.       " Enable spell check
  259.       setlocal spell spelllang=es_mx
  260.     else
  261.       set t_Co=256
  262.       "colorscheme molokai
  263.       " If no gui running, use default theme
  264.       colorscheme default
  265.     endif
  266.   "}}}
  267.  
  268.   " Auto-complete options--------------------------------------------------{{{
  269.     set complete=.,w,b,u,t
  270.     set completeopt=longest,menuone,preview
  271.   "}}}
  272. "}}}
  273.  
  274. " Plugins configs----------------------------------------------------------{{{
  275.  
  276.   " DBGPavim ----------------------------------------------------------------{{{
  277.     let g:dbgPavimBreakAtEntry = 1
  278.     let g:dbgPavimPort = 9009
  279.   " }}}
  280.  
  281.   " NERD Tree--------------------------------------------------------------{{{
  282.     " Vertical directory tree on a buffer for full file exploration
  283.  
  284.     noremap  <F2> :NERDTreeToggle<cr>
  285.     inoremap <F2> <esc>:NERDTreeToggle<cr>
  286.     augroup ps_nerdtree
  287.         au!
  288.         au Filetype nerdtree setlocal nolist
  289.         " au Filetype nerdtree nnoremap <buffer> K :q<cr>
  290.     augroup END
  291.  
  292.     let NERDTreeHighlightCursorline = 1
  293.     let NERDTreeIgnore = ['.vim$', '\~$', '.*\.pyc$', 'pip-log\.txt$', 'whoosh_index',
  294.                         \ 'xapian_index', '.*.pid', 'monitor.py', '.*-fixtures-.*.json',
  295.                         \ '.*\.o$', 'db.db', 'tags.bak', '.*\.pdf$', '.*\.mid$',
  296.                         \ '.*\.midi$']
  297.  
  298.     let NERDTreeMinimalUI = 1
  299.     let NERDTreeDirArrows = 1
  300.     let NERDChristmasTree = 1
  301.     let NERDTreeChDirMode = 2
  302.     let NERDTreeMapJumpFirstChild = 'gK'
  303.     let NERDTreeQuitOnOpen = 1
  304.  
  305.   " }}}
  306.  
  307.   " Guide lines configs----------------------------------------------------{{{
  308.     " Show guide lines for each indentation level
  309.     let g:indent_guides_start_level=2
  310.     let g:indent_guides_guide_size=1
  311.     if has("gui_running")
  312.       let g:indentLine_char='│'
  313.     else
  314.       let g:indentLine_char='|'
  315.     endif
  316.   "}}}
  317.  
  318.   " Minibufexpl configs----------------------------------------------------{{{
  319.     " List of opened buffers and manipulation
  320.     "let g:miniBufExplMapWindowNavVim=1
  321.     "let g:miniBufExplMapWindowNavArrows=1
  322.     "let g:miniBufExplMapCTabSwitchBufs=1
  323.     "let g:miniBufExplMapSelTarget=1
  324.     "let g:miniBufExplMaxSize = 1
  325.     "let g:miniBufExplMinSize = 1
  326.     "let g:miniBufExplSplitBelow = 0
  327.     "map <Leader>b :MiniBufExplorer<CR>
  328.     "map <Leader>c :CMiniBufExplorer<cr>
  329.     "map <Leader>u :UMiniBufExplorer<cr>
  330.     "map <Leader>t :TMiniBufExplorer<cr>
  331.   "}}}
  332.  
  333.   " Syntastic -------------------------------------------------------------{{{
  334.  
  335.     let g:syntastic_enable_signs = 1
  336.     let g:syntastic_check_on_open = 1
  337.     let g:syntastic_disabled_filetypes = ['html', 'rst']
  338.     let g:syntastic_stl_format = '[%E{%e Errors}%B{, }%W{%w Warnings}]'
  339.     let g:syntastic_jsl_conf = '$HOME/.vim/jsl.conf'
  340.  
  341.   "}}}
  342.  
  343.   " Unite -----------------------------------------------------------------{{{
  344.     nnoremap <leader>b :Unite buffer<cr>
  345.     nnoremap <leader>f :Unite -start-insert file_rec<cr>
  346.     nnoremap <leader>/ :Unite grep:.<cr>
  347.     nnoremap <leader>s :Unite -quick-match buffer<cr>
  348.     let g:unite_source_history_yank_enable = 1
  349.     nnoremap <leader>y :Unite history/yank<cr>
  350.   "}}}
  351.  
  352.   " Dbext -----------------------------------------------------------------{{{
  353.   let g:dbext_default_profile_PRUEBAS='type=SQLSRV:user=master_codice:passwd=Pass12345:host=10.1.11.15:SQLSRV_bin=sqsh:SQLSRV_cmd_options=:extra=-Scodice_qa_pruebas -D codice_net'
  354.   let g:dbext_default_profile_CALIDAD='type=SQLSRV:user=codice_qa:passwd=Master12345:host=10.1.11.110:SQLSRV_bin=sqsh:SQLSRV_cmd_options=:extra=-Scodice_qa -D codice_qa'
  355.   let g:dbext_default_profile_CALIDAD_PRUEBAS='type=SQLSRV:user=codice_qa:passwd=Master12345:host=10.1.11.15:SQLSRV_bin=sqsh:SQLSRV_cmd_options=:extra=-Scodice_qa -D codice_qa'
  356.   " }}}
  357.  
  358. "}}}
  359.  
  360. " Some configs (like the folds and Jumping tags) are copy/paste from
  361. " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc
  362. " Credit to Steve Losh
  363.  
  364. " Folds -------------------------------------------------------------------{{{
  365.   " Where should the folds start
  366.   set foldlevelstart=0
  367.  
  368.   " Space to toggle folds.
  369.   nnoremap <Space> za
  370.   vnoremap <Space> za
  371.  
  372.   " Make zO recursively open whatever top level fold we're in, no matter where the
  373.   " cursor happens to be.
  374.   nnoremap zO zCzO
  375.  
  376.   " "Focus" the current line.  Basically:
  377.   "
  378.   " 1. Close all folds.
  379.   " 2. Open just the folds containing the current line.
  380.   " 3. Move the line to a little bit (15 lines) above the center of the screen.
  381.   " 4. Pulse the cursor line.
  382.   "
  383.   " This mapping wipes out the z mark, which I never use.
  384.   "
  385.   " I use :sus for the rare times I want to actually background Vim.
  386.   nnoremap <c-z> mzzMzvzz15<c-e>`z:Pulse<cr>
  387.  
  388.   function! MyFoldText() " {{{
  389.       let line = getline(v:foldstart)
  390.  
  391.       let nucolwidth = &fdc + &number * &numberwidth
  392.       let windowwidth = winwidth(0) - nucolwidth - 3
  393.       let foldedlinecount = v:foldend - v:foldstart
  394.  
  395.       " expand tabs into spaces
  396.       let onetab = strpart('          ', 0, &tabstop)
  397.       let line = substitute(line, '\t', onetab, 'g')
  398.  
  399.       let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
  400.       let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
  401.       if has("gui_running")
  402.         return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
  403.       else
  404.         return line . '...' . repeat(" ",fillcharcount) . foldedlinecount . '...' . ' '
  405.       endif
  406.   endfunction " }}}
  407.  
  408.   set foldtext=MyFoldText()
  409.  
  410.   " Vim {{{
  411.  
  412.     " Set vim to enable folds if it finds fold syntax on the file
  413.     augroup ft_vim
  414.         au!
  415.         au FileType vim setlocal foldmethod=marker
  416.         au FileType help setlocal textwidth=78
  417.     augroup END
  418.  
  419.   " }}}
  420.  
  421. "}}}
  422.  
  423. " Jumping to tags.---------------------------------------------------------{{{
  424.   "
  425.   " Basically, <c-]> jumps to tags (like normal) and <c-\> opens the tag in a new
  426.   " split instead.
  427.   "
  428.   " Both of them will align the destination line to the upper middle part of the
  429.   " screen.  Both will pulse the cursor line so you can see where the hell you
  430.   " are.  <c-\> will also fold everything in the buffer and then unfold just
  431.   " enough for you to see the destination line.
  432.   "nnoremap <c-]> <c-]>mzzvzz15<c-e>`z:Pulse<cr>
  433.   "nnoremap <c-\> <c-w>v<c-]>mzzMzvzz15<c-e>`z:Pulse<cr>
  434. "}}}
  435.  
  436. " The following maping is here to avoid syntax misshapend, the maping uses
  437. " unbalanced curly braces which "confuses" the editor, so I save it for the
  438. " end, do not put anything below it if you use folds or rely on syntax
  439. " highlighting, it's a personal choice to use curly braces like so
  440. " maping to insert { and new line before the closing }
  441. imap {{{ {<CR><ESC>O
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement