" save and restore folds when a file is closed and re-opened
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* loadview

filetype plugin indent on

"Fortran indentation                                                                      
let fortran_free_source=1
unlet! fortran_fixed_source
let fortran_fold=1                                                                                                           
let fortran_fold_conditionals=1
let fortran_fold_multilinecomments=1
let fortran_more_precise=1                                                                                                  
let fortran_do_enddo=1

set tabstop=4
set softtabstop=4
set shiftwidth=4

"expand tabs to spaces
set expandtab

"use indentation of previous line
setlocal autoindent 

"use two spaces indentation for fortran
autocmd Filetype fortran setlocal tabstop=2 softtabstop=2 shiftwidth=2 

" line numbers
set number

"disable arrow keys
no <down> <Nop>
no <left> <Nop>
no <right> <Nop>
no <up> <Nop>
ino <down> <Nop>
ino <left> <Nop>
ino <right> <Nop>
ino <up> <Nop>

colorscheme desert
"execute pathogen#infect()


"nmap <F8> :TagbarToggle<CR>
nmap <F9> :setlocal spell spelllang=en_us
nmap <F9>-:set nospell

" indent #ifdef's #define etc in the same
" way as other lines
"http://stackoverflow.com/a/16049909
set cinkeys=0{,0},0),:,!^F,o,O,e
" align to parenthesis,usefull for function with many arguments
set cinoptions+=(0

" use jk in autocompletion list
" http://stackoverflow.com/a/4740069
inoremap <expr> j ((pumvisible())?("\<C-n>"):("j"))
inoremap <expr> k ((pumvisible())?("\<C-p>"):("k"))

" when launched as vimdiff use special colorscheme
if &diff
  colorscheme diffcolocheme
endif

"https://stackoverflow.com/a/23259759
" show current function name , works with C,C++
fun! ShowFuncName()
  echohl ModeMsg
  echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bWn'))
  echohl None
endfun
map f :call ShowFuncName() <CR>