let $MYPLUGDIRECTORY = "~/.vim/plugged"

call plug#begin($MYPLUGDIRECTORY)

Plug 'scrooloose/nerdtree'

Plug 'luochen1990/rainbow'

Plug 'itchyny/lightline.vim'

Plug 'preservim/nerdcommenter'

Plug 'tpope/vim-fugitive'

call plug#end()

"line numbering
set relativenumber
set number

"cursor
autocmd InsertEnter * set cul
autocmd InsertLeave * set nocul

"lightline
set laststatus=2

"NERDTree
map <C-n> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

"set UTF-8
setglobal termencoding=utf-8 fileencodings= 
scriptencoding utf-8 
set encoding=utf-8 

autocmd BufNewFile,BufRead  *   try 
autocmd BufNewFile,BufRead  *   set encoding=utf-8 
autocmd BufNewFile,BufRead  *   endtry

"convert to UNIX fileformat
set fileformat=unix
