let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
  silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

if empty(glob('~/.vim/plugged'))
  silent! :PlugInstall | q
endif

autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
  \| PlugInstall --sync | source $MYVIMRC
  \| endif

call plug#begin('~/.vim/plugged')
  Plug 'petobens/colorish'
  Plug 'tpope/vim-surround'
  Plug 'jiangmiao/auto-pairs'
  Plug 'junegunn/fzf', { 'do': { -> fzf#install()  }  }
  Plug 'junegunn/fzf.vim'
  Plug 'mtdl9/vim-log-highlighting'
  Plug 'machakann/vim-highlightedyank'
  Plug 'itchyny/lightline.vim'
  Plug 'tpope/vim-fugitive'
  Plug 'mhinz/vim-signify'
call plug#end()

let mapleader = "\<Space>"
set background=dark
colorscheme onedarkish

highlight CursorLine ctermbg=NONE guibg=NONE
highlight CursorLineNr ctermfg=magenta guifg=magenta
highlight HighlightedyankRegion ctermfg=NONE guifg=NONE
highlight Normal ctermbg=NONE guibg=NONE
highlight NormalNC ctermbg=NONE guibg=NONE
highlight Search ctermfg=yellow guifg=yellow
highlight Search ctermbg=black guibg=black

let g:highlightedyank_highlight_duration = 80
let g:lightline = { 'colorscheme': 'one', }

let $FZF_DEFAULT_OPTS = '--bind=tab:up,shift-tab:down'
let g:fzf_layout = { 'window': 'enew' }

set laststatus=2

set number
set relativenumber
set cursorline

set noincsearch
set ignorecase

set clipboard=unnamedplus
set noswapfile

set tabstop=2
set shiftwidth=2
set expandtab

vnoremap < <gv
vnoremap > >gv
nnoremap <C-U> <C-U>zz
nnoremap <C-D> <C-D>zz

nnoremap <leader>gs :Git status<CR>
nnoremap <leader>gl :Git log<CR>
nnoremap <leader>ga :Git add<CR>
nnoremap <leader>gc :Git commit<CR>
nnoremap <leader>gd :Git diff<CR>

nnoremap <leader>e :Ex<CR>
nnoremap <leader>/ :Rg<Space>

nnoremap <leader>bd :bd<CR>
nnoremap H :bprevious<CR>
nnoremap L :bnext<CR>

nnoremap <leader>wh :split<CR>
nnoremap <leader>wv :vsplit<CR>
nnoremap <leader>wd :q<CR>
nnoremap <leader>ww :wincmd w<CR>
nnoremap <leader>wW :wincmd W<CR>

nnoremap <Leader>ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')<CR>
nnoremap <leader><ESC> :noh<CR>
