dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

improved.vim (2818B) [raw]


      1 " .vim/improved.vim -- putting the IM in VIM
      2 
      3 " GENERAL EDITOR SETTINGS {{{
      4 set number                      " Line numbers
      5 set undodir=~/.vim/undo/        " Persistent undo
      6 set undofile                    " Do indeed create said files
      7 set undolevels=1000             " Max # changes that can be undone
      8 set undoreload=10000            " Saves undofile on reload (:e) if < 10k LOC
      9 set backupdir=~/.vim/swp,.      " Backup files in ~/.vim/swp
     10 set directory=~/.vim/swp,.      " Swap files in ~/.vim/swp
     11 " }}}
     12 
     13 " PLUGIN RELATED SETTINGS {{{
     14 " If using Dirvish, don't use netrw
     15 if isdirectory(expand('~/.vim/pack/plugins/start/vim-dirvish/plugin'))
     16     " Dirvish #137
     17     let loaded_netrwPlugin = 1
     18 else
     19     let g:netrw_banner=0                " disable banner
     20     let g:netrw_liststyle=1             " details view
     21 endif
     22 
     23 let g:ale_set_loclist = 1
     24 let g:ale_python_flake8_options = '--ignore "E501,E302"'
     25 let g:ale_linters = { 'javascript': ['eslint'], 'python': ['flake8'] }
     26 let g:ale_fixers = {'javascript': ['prettier'], 'python': ['black'] }
     27 let g:ale_fix_on_save = 1
     28 " }}}
     29 
     30 " COLORSCHEME {{{
     31 " Only gruv if you can handle it
     32 " NOTE: for initial check, check $TERM, not &term, as nvim has &term=nvim
     33 set background=dark
     34 if (($TERM =~# '256color' && has("termguicolors")) || has('gui_running')) &&
     35     \ filereadable(expand("~/.vim/pack/mine/start/gruvbox/colors/gruvbox.vim"))
     36 
     37     set termguicolors
     38     colorscheme gruvbox
     39 
     40     " See :h xterm-true-color for tmux+termguicolors
     41     if &term =~# '^\(tmux\|st\|screen\)'
     42         let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
     43         let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
     44     endif
     45 
     46     augroup CurLineToggle
     47         autocmd!
     48         autocmd InsertEnter,InsertLeave * set cul!
     49     augroup END
     50 endif
     51 " }}}
     52 
     53 " KEY MAPPINGS {{{
     54 " set leader to be spacebar
     55 let mapleader = " "
     56 
     57 "Map ctrl-i/j/k/h to switch between splits
     58 nnoremap <C-j> <C-w>j
     59 nnoremap <C-k> <C-w>k
     60 nnoremap <C-h> <C-w>h
     61 nnoremap <C-l> <C-w>l
     62 
     63 " Paste from clipboard without any formatting issues
     64 nnoremap <C-p> :set paste \| put + \| set nopaste<CR>
     65 
     66 " Clear trailing whitespace (through regexp)
     67 nnoremap <leader><space> :%s/\s\+$//e<CR>
     68 
     69 " edit in current buffer dir
     70 nnoremap <leader>e :e %:h/
     71 nnoremap <leader>v :vsp %:h/
     72 nnoremap <leader>s :sp %:h/
     73 
     74 " toggle color column (to ensure short lines)
     75 nnoremap <expr> <leader>C vimrc#ToggleColorColumn()
     76 
     77 " Clear that highlight!
     78 nnoremap <BS> :nohlsearch<CR>
     79 
     80 " Get greppin quick! --> search word under cursor (escape # for VimL autoload)
     81 nnoremap <silent> <leader>G :Ggrep! <cword><CR>:copen<CR>
     82 
     83 " Toggle whitespace
     84 nnoremap <leader>w :set list!<CR>
     85 
     86 " From defaults.vim: breaks the undo chain so we can undo <C-U>
     87 inoremap <C-U> <C-G>u<C-U>
     88 " }}}
     89 
     90 " COMMANDS {{{
     91 command! CD exe 'cd ' . expand('%:h')
     92 " }}}
     93 
     94 " Load optional config (in ~/.vim)
     95 runtime! .vimrc.local