" indentation
set autoindent
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
filetype indent on
" highlight tabs (yuck) and any trailing spaces (also yuck)
set list listchars=tab:\¤\ ,trail:·

" readability
set number
set relativenumber
set ruler
set wrap
set linebreak
set background=dark
syntax on

" set case-insensitive, for searches
set ic

" don't leave crumbs laying around
set noswapfile

" switch between buffers without having to save
set hidden

" set "paste" mode key, takes things litterally without much autoformatting,
" useful for quickly adding tabs to Makefiles in addition to
" copying pre-formatted text from the X buffer.
set pastetoggle=<F2>

" auto format C-style comments
set comments=sl:/*,mb:*,elx:*/

" some settings for :hardcopy (print to file)
set printoptions=number:y,header:0,paper:letter
set printfont=inconsolata:h1i2

" set up some things differently for vimdiff
if &diff
    " so far I've found molokai_dark provides a nice contrast for the diff highlights.
    colorscheme molokai_dark
    " when diffing, usually you just want to go from diff to diff, and when you want to reference
    " a line number it is usually an absolute line number.
    set norelativenumber
endif

" TODO: setup Dart syntax highlighting
" Dart syntax rules don't come with the standard vim distrobution (yet),
" so I included a third-party rule file on asa.
" I'll need to configure a third-party location in the syncthing area.
" Till then, leave commented out:
"
" automatic Dart file type detection
"au BufRead,BufNewFile *.dart set filetype=dart

" Fortran doesn't work well :-(
let fortran_do_enddo=1
let fortran_more_precise=1
" toggle between Fixed-Format and Free-Format syntax highlighting
nmap <F11> :set syntax=fortran<CR>:let b:fortran_fixed_source=!b:fortran_fixed_source<CR>:set syntax=text<CR>:set syntax=fortran<CR>:set textwidth=0<CR>
nmap <F12> :filetype detect<CR>

" removes trailing spaces
function! TrimWhiteSpace()
    %s/\s\+$//e
endfunction

" remove trailing whitespace from a file when F3 is pressed.
map <F3> :call TrimWhiteSpace()<CR>

" automattically trim whitespace (ended up not usually wanting to do this...)
"nnoremap <silent> <Leader>rts :call TrimWhiteSpace()<CR>
"autocmd FileWritePre    * :call TrimWhiteSpace()
"autocmd FileAppendPre   * :call TrimWhiteSpace()
"autocmd FilterWritePre  * :call TrimWhiteSpace()
"autocmd BufWritePre     * :call TrimWhiteSpace()
