" Allgemeine Einstellungen
set number
set cursorline
set shortmess+=I
set nowrap
set nocompatible
set ruler
set wildmenu
set noshowcmd
set splitright
set splitbelow
set hidden
set signcolumn=no

" Rechtsschreibprüfung
set spell
set spelllang=de,en

" Optionen für ^n-Vervollständigung
set complete=.,w,b,u,t,i

" bessere Suche
set hlsearch
set incsearch
set ignorecase
set smartcase

" Sonderzeichen anzeigen
set list
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set matchpairs+=<:>

" automatisches Einlesen geänderter Dateien
set autoread

" Suche rekursiv
set path+=**

" Tabs
set noexpandtab
set tabstop=4
set shiftwidth=4
set softtabstop=0

" Einrückungen
set smartindent
set autoindent
set cindent

" Faltungen
set foldlevel=1000
set foldcolumn=0

" Autovervollständigung
set completeopt=longest,menuone

" externe Programme
set makeprg=gmake

" Guifont
set guifont=JetBrains\ Mono\ Semibold:h12

" provider
let g:python3_host_prog='/usr/local/bin/python'
let g:loaded_node_provider=0
let g:loaded_ruby_provider=0
let g:loaded_perl_provider=0

" Swap files und UnDo
set noswapfile
set undofile
set undolevels=10000
set undoreload=10000

" Statusline
function! GitBranch()
  return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction

function! StatuslineGit()
  let l:branchname = GitBranch()
  return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
endfunction

let g:currentmode={
      \ 'n'  : 'n',
      \ 'v'  : 'v',
      \ 'V'  : 'vl',
      \ ''   : 'vb',
      \ 'i'  : 'i',
      \ 'R'  : 'r',
      \ 'Rv' : 'rv',
      \ 'c'  : 'c',
      \ 't'  : 'f',
      \}

highlight NormalColor  ctermbg=black     ctermfg=white
highlight InsertColor  ctermbg=darkgreen ctermfg=black
highlight ReplaceColor ctermbg=darkred   ctermfg=black
highlight VisualColor  ctermbg=darkblue  ctermfg=black

set laststatus=2
set statusline=
set statusline+=%#NormalColor#%{(g:currentmode[mode()]=='n')?'\ \ normal\ ':''}
set statusline+=%#InsertColor#%{(g:currentmode[mode()]=='i')?'\ \ insert\ ':''}
set statusline+=%#ReplaceColor#%{(g:currentmode[mode()]=='r')?'\ \ replace\ ':''}
set statusline+=%#ReplaceColor#%{(g:currentmode[mode()]=='rv')?'\ \ v-replace\ ':''}
set statusline+=%#VisualColor#%{(g:currentmode[mode()]=='v')?'\ \ visual\ ':''}
set statusline+=%#VisualColor#%{(g:currentmode[mode()]=='vl')?'\ \ v-line\ ':''}
set statusline+=%#VisualColor#%{(g:currentmode[mode()]=='vb')?'\ \ v-block\ ':''}
set statusline+=%#NormalColor#%{(g:currentmode[mode()]=='c')?'\ \ command\ ':''}
set statusline+=%#NormalColor#%{(g:currentmode[mode()]=='f')?'\ \ finder\ ':''}
set statusline+=%#PmenuSel#
set statusline+=%{StatuslineGit()}
set statusline+=%#Statusline#
set statusline+=\ %f
set statusline+=%m
set statusline+=%=
set statusline+=%#StatusLineNc#
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\ %p%%
set statusline+=\ %l:%c

" weitere Einstellungen
syntax enable
filetype plugin indent on

" Farbschema
set termguicolors
colorscheme habamax
highlight MatchParen gui=bold,underline cterm=bold,underline
