Files
dotfiles/vim/vimrc
2022-01-05 20:41:06 -05:00

94 lines
2.6 KiB
VimL

" ----------------------- settings ----------------------------------
set autoindent
set autowrite " automatically write files when changing
set background=dark
set backspace=indent,eol,start
set belloff=all
set colorcolumn=120
set expandtab " replace tabs with spaces automatically
set exrc
set foldmethod=manual
set hidden
set history=100 " command history
set icon
set incsearch
set nobackup
set nocompatible
set nofixendofline
set nohlsearch
set noswapfile
set nowrap
set number
set relativenumber
set ruler " turns on col and row in lower right
" used with `set ruler`
set ruf=%30(%=%#LineNr#%.50F\ [%{strlen(&ft)?&ft:'none'}]\ %l:%c\ %p%%%)
set scrolloff=8
set shiftwidth=2
set showmode " show command and insert mode
set signcolumn=no
set smartindent
set smarttab
set softtabstop=2
set tabstop=2
set termguicolors
set textwidth=72 " Used with line wrapping
set ttyfast " faster scrolling
set undodir=~/.vim/undodir
set undofile
set viminfo='20,<1000,s1000 " prevents truncated yanks, deletes, etc.
set wildmenu
syntax enable
filetype plugin on " sense the filesystem
let mapleader = " "
" ----------------------- plugins ----------------------------------
" Install vim-plug if not found
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
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf'
Plug 'vim-pandoc/vim-pandoc'
Plug 'rwxrob/vim-pandoc-syntax-simple'
Plug 'morhetz/gruvbox'
call plug#end()
colorscheme gruvbox
" highlight Normal guibg=none
" ----------------------- utilities ----------------------------------
" fuzzy finder
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" opens fuzzy finder under the current directory
nmap <leader>ff :call fzf#run(fzf#wrap({ 'source': 'find "$PWD" -type f' }))<CR>
" opens fuzzy finder for files under a git version control
nmap <leader>fg :call fzf#run(fzf#wrap({ 'source': 'git ls-files' }))<CR>
fun! TrimWhiteSpace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
augroup MICHAEL
autocmd!
autocmd BufWritePre * :call TrimWhiteSpace()
autocmd Filetype yaml setlocal ts=2 sts=2 sw=2 expandtab
augroup END