dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

.vimrc (7598B)


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