dotfiles

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

.vimrc (7649B)


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