" Vundle Plugin Manager - START
" Required
set nocompatible
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" Plugins - load with :PluginInstall
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/vim-gitbranch'
Plugin 'tmsvg/pear-tree'

" Colorscheme
Plugin 'joshdick/onedark.vim'
Plugin 'fneu/breezy' "lightline
Plugin 'itchyny/lightline.vim'

" Required
call vundle#end()
filetype plugin indent on
" Vundle Plugin Manager - END

" Plugin Settings

" Lightline Statusbar
" absolutepath or filename
set laststatus=2
let g:lightline = {
	\ 'colorscheme': 'breezy',
	\ 'active': {
	\    'left': [ [ 'mode', 'paste' ],
	\              [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
	\ },
	\ 'component_function': {
	\	'gitbranch': 'gitbranch#name'
	\ },
	\ }

" Breezy
set termguicolors

" Onedark Colorscheme
let g:onedark_hide_endofbuffer=1
let g:onedark_terminal_italics=1

" PearTree
let g:pear_tree_smart_openers=1
let g:pear_tree_smart_closers=1
let g:pear_tree_smart_backspace=1

let g:pear_tree_pairs = {
            \ '(': {'closer': ')'},
            \ '[': {'closer': ']'},
            \ '{': {'closer': '}'},
            \ "'": {'closer': "'"},
            \ '"': {'closer': '"'},
            \ '<': {'closer': '>'}
            \ }

" Other configurations
" Coloooooors
syntax on
colorscheme onedark
filetype on
filetype indent plugin on
set colorcolumn=80

" Numbers at the left side
set number
:highlight LineNr ctermfg=white "color
"set relativenumber

" Parathesis highlighting
set showmatch
set mat=5

" General
set noswapfile
set confirm "cant quit wo saving
"set showmode " shows editing mode in status
set noshowmode " reverse of above
"set showcmd " shows commands in status
set noshowcmd " reverse of above
set cursorline " highlight current line
set encoding=utf-8
set mouse=a
set mouse=c
set undolevels=1337
set backspace=indent,eol,start

" Indents
set tabstop=4
set softtabstop=4
set shiftwidth=4
"set noexpandtab " tabs are not spaces
set expandtab " tabs are spaces
set smartindent

" File specific indents
autocmd FileType rust setlocal shiftwidth=2 softtabstop=2 expandtab
autocmd FileType perl setlocal shiftwidth=4 softtabstop=4 expandtab
autocmd FileType yaml setlocal shiftwidth=2 softtabstop=2 expandtab

" Whitespaces
set list
"hi SpecialKey ctermbg=Darkgray " colored tabs
"set listchars=tab:>-,trail:\\ " default
set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,trail:·

" Search
set incsearch
set ignorecase
set smartcase " case sens only when capitol letters
set hlsearch " highlight all results
nnoremap<leader><space> :nohlsearch<CR>

" Macros (cmap old new)
cmap Wq wq
cmap Q q
cmap W w
cmap q1 q!
map <C-f> :Ex <CR>

" go to line edited, when closed
if has("autocmd")
	au BufReadPost * if line("' f\"") > 0 && line("'\"") <= line("$")
		\| exe "normal! g'\"" | endif
endif

" no clue, got it from a co-worker
au BufNewFile,BufRead *.itex set filetype=tex
