dotfiles

custom dotfiles
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

.vimrc (6619B)


      1 " ░█░█░▀█▀░█▄█░░
      2 " ░▀▄▀░░█░░█░█░░
      3 " ░░▀░░▀▀▀░▀░▀░░
      4 
      5 " use vim settings, rather than vi settings
      6 " must be first, because it changes other options as a side effect
      7 set nocompatible
      8 
      9 " security
     10 set modelines=0
     11 
     12 " paste without auto indentation
     13 set paste
     14 
     15 " hide buffers, not close them
     16 set hidden
     17 
     18 " maintain undo history between sessions
     19 set undofile
     20 set undodir=~/.vim/undo
     21 set noswapfile
     22 
     23 " lazy file name tab completion
     24 set wildmode=longest,list,full
     25 set wildmenu
     26 set wildignorecase
     27 
     28 " case insensitive search
     29 set ignorecase
     30 set smartcase
     31 set infercase
     32 
     33 " make backspace behave in a sane manner
     34 set backspace=indent,eol,start
     35 
     36 " searching
     37 set hlsearch
     38 set incsearch
     39 
     40 " use indents of 4 spaces
     41 set shiftwidth=4
     42 
     43 " tabs are spaces, not tabs
     44 set noexpandtab
     45 
     46 " an indentation every four columns
     47 set tabstop=4
     48 
     49 " let backspace delete indent
     50 set softtabstop=4
     51 
     52 " enable auto indentation
     53 set autoindent
     54 
     55 " remove trailing whitespaces and ^M chars
     56 autocmd FileType c,cpp,java,php,js,python,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
     57 set list
     58 set listchars=
     59 set listchars+=tab:·\ 
     60 set listchars+=trail:·
     61 set listchars+=extends:»
     62 set listchars+=precedes:«
     63 
     64 " let mapleader=","
     65 vnoremap <silent> <leader>y :w !xsel -i -b<CR>
     66 nnoremap <silent> <leader>y V:w !xsel -i -b<CR>
     67 nnoremap <silent> <leader>p :silent :r !xsel -o -b<CR>
     68 
     69 " switch tabs
     70 nnoremap <C-n> :tabn<CR>
     71 nnoremap <C-p> :tabp<CR>
     72 
     73 " nerdtree
     74 nnoremap <C-j> :NERDTreeToggle<CR>
     75 
     76 " noh
     77 nnoremap <C-c> :noh<CR>
     78 
     79 " toggle autoindent
     80 nnoremap <F8> :setl noai<CR>
     81 nnoremap <F9> :setl ai<CR>
     82 
     83 " goyo
     84 nnoremap <C-w>g :Goyo<CR>
     85 
     86 " open shell in current buffer dir
     87 nnoremap <leader>z :cd %:p:h <bar>!zsh<CR>
     88 
     89 " columns
     90 " 80 soft 120 hard
     91 let &colorcolumn="80"
     92 
     93 " COMMANDS
     94 " json pretty print
     95 command J :%!python -mjson.tool
     96 
     97 " remove trailing white space
     98 command Nows :%s/\s\+$//
     99 
    100 " remove blank lines
    101 command Nobl :g/^\s*$/d
    102 
    103 " toggle spellcheck
    104 command Spell :setlocal spell! spell?
    105 
    106 " make current buffer executable
    107 command Chmodx :!chmod a+x %
    108 
    109 " INTERFACE
    110 " show matching brackets/parenthesis
    111 set showmatch
    112 
    113 " disable startup message
    114 set shortmess+=I
    115 
    116 " syntax highlighting and colors
    117 syntax on
    118 colorscheme mutiny
    119 filetype off
    120 
    121 " stop unnecessary rendering
    122 set lazyredraw
    123 
    124 " show line numbers
    125 set number
    126 
    127 " no line wrapping
    128 set nowrap
    129 set linebreak
    130 
    131 " no folding
    132 set foldlevel=99
    133 set foldminlines=99
    134 
    135 " highlight line
    136 set cursorline
    137 
    138 " PLUGINS
    139 filetype plugin indent on
    140 " to install from the shell run:
    141 " `git clone https://github.com/gmarik/Vundle.vim.git ~/dotfiles/vim/.vim/bundle/Vundle.vim && vim +BundleInstall +qall && PYTHON=/usr/bin/python2 ~/dotfiles/vim/.vim/bundle/YouCompleteMe/install.sh --clang-completer && pacman -S the_silver_searcher`
    142 " `mkdir ~/dot/vim/.vim/bundle ; git clone https://github.com/gmarik/Vundle.vim.git ~/dot/vim/.vim/bundle/Vundle.vim && vim +BundleInstall +qall`
    143 if 1 " boolean for plugin loading
    144   set rtp+=~/.vim/bundle/Vundle.vim
    145   call vundle#begin()
    146   Plugin 'gmarik/Vundle.vim'
    147   Plugin 'tpope/vim-fugitive'
    148   Plugin 'scrooloose/nerdtree'
    149   Plugin 'vimwiki/vimwiki'
    150   Plugin 'itchyny/lightline.vim'
    151   Plugin 'rking/ag.vim'
    152   Plugin 'ajh17/VimCompletesMe'
    153   Plugin 'mhinz/vim-signify'
    154   Plugin 'junegunn/goyo.vim'
    155   Plugin 'gregsexton/gitv'
    156   call vundle#end()
    157 
    158   " nerdtree - workaround for https://github.com/scrooloose/nerdtree/issues/643
    159   let g:NERDTreeDirArrows = 1
    160   let g:NERDTreeShowHidden = 1
    161   " smaller default window size
    162   let g:NERDTreeWinSize = 25
    163 
    164   " ag, the silver searcher http://git.io/AEu3dQ + http://git.io/d9N0MA
    165   let g:ag_prg="ag -i --vimgrep"
    166   let g:ag_highlight=1
    167   " map \ to the ag command for quick searching
    168   nnoremap \ :Ag<SPACE>
    169 
    170   " vimwiki https://vimwiki.github.io
    171   let pyratewiki = {}
    172   let pyratewiki.path = '~/lib/documents/pyratewiki'
    173   let pyratewiki.path_html = '~/lib/documents/pyratewiki/html'
    174   let pyratewiki.syntax = 'markdown'
    175   let pyratewiki.ext = '.md'
    176 
    177   let g:vimwiki_list = [pyratewiki]
    178 
    179   " vim-signify (diffs)
    180   let g:signify_sign_add = '░'
    181   let g:signify_sign_change = '░'
    182   let g:signify_sign_delete = '░'
    183 
    184   " lightline
    185   set laststatus=2
    186   let g:lightline = {
    187   \ 'colorscheme': 'mutiny',
    188   \ 'active': {
    189   \   'left': [ [ 'filename' ],
    190   \             [ 'readonly', 'fugitive' ] ],
    191   \   'right': [ [ 'percent', 'lineinfo' ],
    192   \              [ 'fileencoding', 'filetype' ] ]
    193   \ },
    194   \ 'component_function': {
    195   \   'modified': 'WizMod',
    196   \   'readonly': 'WizRO',
    197   \   'fugitive': 'WizGit',
    198   \   'filename': 'WizName',
    199   \   'filetype': 'WizType',
    200   \   'fileformat' : 'WizFormat',
    201   \   'fileencoding': 'WizEncoding',
    202   \   'mode': 'WizMode',
    203   \ },
    204   \ 'separator': {'left': '▓▒░', 'right': '░▒▓' },
    205   \ 'subseparator': { 'left': '▒', 'right': '░' }
    206   \ }
    207 
    208   " vimcompletesme
    209 " omnifuncs
    210 augroup omnifuncs
    211   au!
    212   autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    213   autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    214   autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
    215   " use python3: https://stackoverflow.com/questions/28043652/vim-unknown-function-pythoncompletecomplete
    216   autocmd FileType python setlocal omnifunc=python3complete#Complete
    217   autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
    218   autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP
    219 augroup end
    220 
    221 " completions
    222 let b:vcm_tab_complete = 'omni'
    223 set omnifunc=syntaxcomplete#Complete
    224 " select the completion with enter
    225 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
    226 " close preview on completion complete
    227 augroup completionhide
    228   au!
    229   autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
    230 augroup end
    231 
    232   function! WizMod()
    233     return &ft =~ 'help\|vimfiler' ? '' : &modified ? '»' : &modifiable ? '' : ''
    234   endfunction
    235 
    236   function! WizRO()
    237     return &ft !~? 'help\|vimfiler' && &readonly ? 'x' : ''
    238   endfunction
    239 
    240   function! WizGit()
    241     if &ft !~? 'help\|vimfiler' && exists("*FugitiveHead")
    242       return FugitiveHead()
    243     endif
    244     return ''
    245   endfunction
    246 
    247   function! WizName()
    248     return ('' != WizMod() ? WizMod() . ' ' : '') .
    249           \ ('' != expand('%:t') ? expand('%:t') : '[none]') 
    250   endfunction
    251 
    252   function! WizType()
    253     return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : '') : ''
    254   endfunction
    255 
    256   function! WizFormat()
    257     return ''
    258   endfunction
    259 
    260   function! WizEncoding()
    261     return winwidth(0) > 70 ? (strlen(&fenc) ? &enc : &enc) : ''
    262   endfunction
    263 
    264 endif