dotfiles

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

.vimrc (7329B)


      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><CR>
     88 
     89 " list buffers and wait for number
     90 nnoremap <leader>b :ls<CR>:b
     91 
     92 " wrap and spellcheck when writing
     93 nnoremap <C-w>w :set wrap<CR>:Spell<CR>
     94 
     95 " fzf
     96 "nnoremap <leader>f :cd $HOME/src <bar>FZF<CR>
     97 nnoremap <leader>f :cd $HOME/src <bar>FZF<CR>
     98 
     99 " list registers
    100 nnoremap <leader>r :registers<CR>
    101 
    102 " columns
    103 " 80 soft 120 hard
    104 let &colorcolumn="80"
    105 
    106 " COMMANDS
    107 " json pretty print
    108 command J :%!python -mjson.tool
    109 
    110 " remove trailing white space
    111 command Nows :%s/\s\+$//
    112 
    113 " remove blank lines
    114 command Nobl :g/^\s*$/d
    115 
    116 " toggle spellcheck
    117 command Spell :setlocal spell! spell?
    118 
    119 " make current buffer executable
    120 command Chmodx :!chmod a+x %
    121 
    122 " git commit shortcut
    123 command Gc Git commit -S
    124 command Gf Git fetch
    125 command Gp Git push
    126 command -nargs=* Gco Git checkout
    127 command Gm Git merge
    128 
    129 " INTERFACE
    130 " show matching brackets/parenthesis
    131 set showmatch
    132 
    133 " disable startup message
    134 set shortmess+=I
    135 
    136 " syntax highlighting and colors
    137 syntax on
    138 colorscheme mutiny
    139 filetype off
    140 
    141 " stop unnecessary rendering
    142 set lazyredraw
    143 
    144 " show line numbers
    145 set number
    146 
    147 " no line wrapping
    148 set nowrap
    149 set linebreak
    150 
    151 " no folding
    152 set foldlevel=99
    153 set foldminlines=99
    154 
    155 " highlight line
    156 set cursorline
    157 
    158 " MACROS
    159 " target blank links
    160 " used in blog md files
    161 let @t='{target="_blank" rel="noreferrer"}'
    162 
    163 " PLUGINS
    164 filetype plugin indent on
    165 " to install from the shell run:
    166 " `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`
    167 " `mkdir ~/dot/vim/.vim/bundle ; git clone https://github.com/gmarik/Vundle.vim.git ~/dot/vim/.vim/bundle/Vundle.vim && vim +BundleInstall +qall`
    168 if 1 " boolean for plugin loading
    169   set rtp+=~/.vim/bundle/Vundle.vim
    170   call vundle#begin()
    171   Plugin 'gmarik/Vundle.vim'
    172   Plugin 'tpope/vim-fugitive'
    173   Plugin 'scrooloose/nerdtree'
    174   Plugin 'vimwiki/vimwiki'
    175   Plugin 'itchyny/lightline.vim'
    176   Plugin 'rking/ag.vim'
    177   Plugin 'ajh17/VimCompletesMe'
    178   Plugin 'mhinz/vim-signify'
    179   Plugin 'junegunn/goyo.vim'
    180   Plugin 'rbong/vim-flog'
    181   Plugin 'ctrlpvim/ctrlp.vim'
    182   call vundle#end()
    183 
    184   " nerdtree - workaround for https://github.com/scrooloose/nerdtree/issues/643
    185   let g:NERDTreeDirArrows = 1
    186   let g:NERDTreeShowHidden = 1
    187   let g:NERDTreeMinimalUI = 1
    188   " smaller default window size
    189   let g:NERDTreeWinSize = 25
    190   let g:webdevicons_enable_nerdtree = 1
    191   let g:NERDTreeDirArrowExpandable = '▓'
    192   let g:NERDTreeDirArrowCollapsible = '░'
    193 
    194   " ag, the silver searcher http://git.io/AEu3dQ + http://git.io/d9N0MA
    195   let g:ag_prg="ag -i --vimgrep"
    196   let g:ag_highlight=1
    197   " map \ to the ag command for quick searching
    198   nnoremap \ :Ag<SPACE>
    199 
    200   " vimwiki https://vimwiki.github.io
    201   let grimoire = {}
    202   let grimoire.path = '~/lib/documents/grimoire'
    203   let grimoire.path_html = '~/lib/documents/grimoire/html'
    204   let grimoire.syntax = 'markdown'
    205   let grimoire.ext = '.md'
    206 
    207   let g:vimwiki_list = [grimoire]
    208 
    209   " vim-signify (diffs)
    210   let g:signify_sign_add = '░'
    211   let g:signify_sign_change = '░'
    212   let g:signify_sign_delete = '░'
    213 
    214   " lightline
    215   set laststatus=2
    216   let g:lightline = {
    217   \ 'colorscheme': 'mutiny',
    218   \ 'active': {
    219   \   'left': [ [ 'filename' ],
    220   \             [ 'readonly', 'fugitive' ] ],
    221   \   'right': [ [ 'percent', 'lineinfo' ],
    222   \              [ 'fileencoding', 'filetype' ] ]
    223   \ },
    224   \ 'component_function': {
    225   \   'modified': 'WizMod',
    226   \   'readonly': 'WizRO',
    227   \   'fugitive': 'WizGit',
    228   \   'filename': 'WizName',
    229   \   'filetype': 'WizType',
    230   \   'fileformat' : 'WizFormat',
    231   \   'fileencoding': 'WizEncoding',
    232   \   'mode': 'WizMode',
    233   \ },
    234   \ 'separator': {'left': '▓▒░', 'right': '░▒▓' },
    235   \ 'subseparator': { 'left': '▒', 'right': '░' }
    236   \ }
    237 
    238   " vimcompletesme
    239 " omnifuncs
    240 augroup omnifuncs
    241   au!
    242   autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    243   autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    244   autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
    245   " use python3: https://stackoverflow.com/questions/28043652/vim-unknown-function-pythoncompletecomplete
    246   autocmd FileType python setlocal omnifunc=python3complete#Complete
    247   autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
    248   autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP
    249 augroup end
    250 
    251 " completions
    252 let b:vcm_tab_complete = 'omni'
    253 set omnifunc=syntaxcomplete#Complete
    254 " select the completion with enter
    255 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
    256 " close preview on completion complete
    257 augroup completionhide
    258   au!
    259   autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
    260 augroup end
    261 
    262   function! WizMod()
    263     return &ft =~ 'help\|vimfiler' ? '' : &modified ? '»' : &modifiable ? '' : ''
    264   endfunction
    265 
    266   function! WizRO()
    267     return &ft !~? 'help\|vimfiler' && &readonly ? 'x' : ''
    268   endfunction
    269 
    270   function! WizGit()
    271     if &ft !~? 'help\|vimfiler' && exists("*FugitiveHead")
    272       return FugitiveHead()
    273     endif
    274     return ''
    275   endfunction
    276 
    277   function! WizName()
    278     return ('' != WizMod() ? WizMod() . ' ' : '') .
    279           \ ('' != expand('%:t') ? expand('%:t') : '[none]') 
    280   endfunction
    281 
    282   function! WizType()
    283     return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : '') : ''
    284   endfunction
    285 
    286   function! WizFormat()
    287     return ''
    288   endfunction
    289 
    290   function! WizEncoding()
    291     return winwidth(0) > 70 ? (strlen(&fenc) ? &enc : &enc) : ''
    292   endfunction
    293 
    294 endif