Last active
August 22, 2018 03:00
-
-
Save slester/c2ed47d636e85192401b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" yavc: yet another vim configuration | |
"" ----------------------------------- | |
"" compiled by Stephen Lester | |
"" | |
"" requirements & setup | |
"" -------------------- | |
"" ripgrep https://github.com/BurntSushi/ripgrep | |
"" Vundle https://github.com/gmarik/Vundle.vim | |
"" ncurses5-compat-libs (Arch Linux, for YCM) | |
"" ~/.tmux.conf set -g escape-time 10 | |
"" | |
"" table of contents | |
"" ----------------- | |
"" 0. requirements | |
"" 1. plugins | |
"" 2. general | |
"" 3. text-related | |
"" 4. searching | |
"" 5. moving | |
"" 6. files | |
"" 7. interface | |
"" 8. keymaps | |
"" 9. plugin settings | |
"" 10. helper functions & autocommands | |
"" | |
"" ................................... | |
"" | |
"" custom shortcuts | |
"" | |
"" ,, clear search | |
"" ,pp toggle paste mode | |
"" ,tn new tab | |
"" ,to only tab | |
"" ,tc close tab | |
"" ,tm move tab | |
"" | |
""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" | |
"" 0. requirements | |
"" | |
set nocompatible | |
let mapleader = "," | |
"" | |
"" 1. plugins | |
"" | |
" Autoload vimplug if needed. | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
call plug#begin('~/.vim/plugged') | |
Plug 'MarcWeber/vim-addon-mw-utils' " collection of small functions | |
Plug 'Shougo/vimproc.vim', " multiple processes | |
\{'do': 'make'} | |
Plug 'airblade/vim-gitgutter' " git symbols in gutter | |
Plug 'bling/vim-airline' " fancy airline down below | |
Plug 'godlygeek/tabular' " easy alignment | |
Plug 'juanedi/predawn.vim' " colorscheme | |
Plug 'kien/rainbow_parentheses.vim' | |
Plug 'neomake/neomake' | |
Plug 'scrooloose/nerdtree' " better file browser | |
Plug 'sheerun/vim-polyglot' " syntax files | |
Plug 'tomtom/tcomment_vim' " toggling of comments | |
Plug 'valloric/youcompleteme', " autocompletion | |
\{ 'do': './install.py' } | |
call plug#end() | |
"" | |
" 2. general | |
"" | |
set noerrorbells " No. | |
set novisualbell " Bells. | |
set t_vb= " EVER. | |
set tm=500 " (Mommy Dearest reference.) | |
set nohidden " Clear the buffer after closing a tab. | |
set ttyfast " Smooth redrawing. | |
"" | |
" 3. text-related | |
"" | |
set autoindent " Indent text automatically. | |
set expandtab " Use spaces, not the tab character. | |
set tabstop=2 " Tab width is 4 spaces. | |
set shiftwidth=2 | |
set magic " Use special chars in regex. | |
set undolevels=1000 " Allow 1000 undos. | |
set backspace=2 " Make backspace work! | |
set formatoptions-=cro " Don't continue comments. | |
syntax enable " Syntax highlighting. | |
set grepprg=ag\ -s\ $* " Use ag for grep. | |
"" | |
" 4. searching | |
"" | |
set hlsearch " Highlight search results. | |
set ignorecase " Ignore case when searching. | |
set smartcase " (except when capital letters are typed!) | |
set incsearch " Search updates as you type. | |
set viminfo="h" " Don't highlight the last search upon startup. | |
" *,# searches for current selection in visual mode | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
" Use ripgrep when searching | |
if executable("rg") | |
set grepprg=rg\ --vimgrep\ --no-heading | |
set grepformat=%f:%l:%c:%m,%f:%l:%m | |
endif | |
"" | |
" 5. moving | |
"" | |
" When using j/k to move, treat wrapped | |
map j gj | |
" lines as separate lines. | |
map k gk | |
"" | |
" 6. files | |
"" | |
"" | |
" 7. interface | |
"" | |
highlight LineNr ctermfg=darkgrey | |
set background=dark " I'm a vampire. | |
set foldmethod=marker " Mark folds | |
set lazyredraw " Don't redraw when executing macros. | |
set laststatus=2 " Always show the status line | |
set number " Show line number. | |
set report=0 " Show how many lines were changed. | |
set ruler " Show current position. | |
set scrolloff=5 " Keep at least 5 lines above/below | |
set sidescrolloff=5 " Keep at least 5 lines left/right | |
set showcmd " Shows the command you're typing. | |
set showmatch " Highlight matching brackets. | |
highlight MatchParen ctermbg=4 | |
set showmode " Show current mode in statusbar. | |
set wildmenu " Tab completion when typing. | |
set wildignore=*.o,*~,*.bk,*.pyc " Ignore backup / compiled files. | |
set wildmode=list:longest,full | |
set t_ut= " Fix background color in tmux. | |
" Status line format. | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l | |
" Color scheme. | |
colorscheme predawn | |
"" | |
" 8. keymaps | |
"" | |
" ; mapped to : | |
noremap ; : | |
" ,, to clear search highlight | |
nmap <silent> <Leader><Leader> :nohlsearch<CR> | |
" ,f to open NERDTree | |
nmap <silent> <Leader>f :NERDTree<CR> | |
" Mappings for tabs. | |
map <Leader>ta :tab all<cr> | |
map <Leader>tn :tabnew<cr> | |
map <Leader>to :tabonly<cr> | |
map <Leader>tc :tabclose<cr> | |
map <Leader>tm :tabmove | |
" Toggle paste mode on and off. | |
map <Leader>pp :setlocal paste!<cr> | |
" jk to escape insert mode quickly. | |
imap jk <Esc> | |
"" | |
" 9. plugin settings | |
"" | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline_powerline_fonts = 1 | |
let g:airline_detect_paste = 1 | |
set statusline+=%#warningmsg# | |
set statusline+=%* | |
"" | |
" 10. helper functions & autocommands | |
"" | |
" Autoremove trailing whitespace. | |
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | |
" Don't autoinsert comments | |
autocmd BufNewFile,BufRead * setlocal formatoptions-=cro | |
" Restore cursor position to where it was before | |
augroup JumpCursorOnEdit | |
au! | |
autocmd BufReadPost * | |
\ if expand("<afile>:p:h") !=? $TEMP | | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ let JumpCursorOnEdit_foo = line("'\"") | | |
\ let b:doopenfold = 1 | | |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | | |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | | |
\ let b:doopenfold = 2 | | |
\ endif | | |
\ exe JumpCursorOnEdit_foo | | |
\ endif | | |
\ endif | |
" Need to postpone using "zv" until after reading the modelines. | |
autocmd BufWinEnter * | |
\ if exists("b:doopenfold") | | |
\ exe "normal zv" | | |
\ if(b:doopenfold > 1) | | |
\ exe "+".1 | | |
\ endif | | |
\ unlet b:doopenfold | | |
\ endif | |
augroup END | |
" Don't use default clipboard register. | |
if system('uname') =~ 'Darwin' | |
set clipboard=unnamed | |
else | |
set clipboard=unnamedplus | |
endif | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
endif | |
return '' | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment