syntax on

execute pathogen#infect()

""""""""" dark mode
"set background=dark
""colorscheme odyssey
"highlight CursorLine   cterm=none ctermbg=23
"highlight CursorLineNr cterm=bold ctermbg=23
"highlight CursorColumn cterm=none ctermbg=23
"highlight ColorColumn  cterm=none ctermbg=23

" light mode
"set background=light
"colorscheme shirotelin
""highlight CursorLine   cterm=none ctermbg=7
""highlight CursorLineNr cterm=bold ctermbg=7
""highlight CursorColumn cterm=none ctermbg=7
""highlight ColorColumn  cterm=none ctermbg=7
""highlight trailing whitespace, markers if line goes past screen, special

" marker for tab characters
set list
set listchars=trail:-,extends:>,precedes:<,tab:>-

" Line numbers, highlight current line
set number
set cursorline
set cursorcolumn

" Autoindentation
set autoindent

" Turn off line wrapping
set nowrap
set colorcolumn=+1

" Use 4 spaces instead of tabs
set shiftwidth  =4
set tabstop     =4
set expandtab
" uncomment for stupid backspace
"set softtabstop =4

" NERD tree
nnoremap <C-n> :NERDTreeToggle<Return>

" Show filename in mode line
set laststatus =2

"" Window switching commands
noremap <C-h> :wincmd h<Return>
noremap <C-j> :wincmd j<Return>
noremap <C-k> :wincmd k<Return>
noremap <C-l> :wincmd l<Return>

" highlight when searching
set hlsearch

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

" tab navigation
" From https://vim.fandom.com/wiki/Using_tab_pages
cabbrev te tabedit
nnoremap <C-i> :tabp<Return>
nnoremap <C-o> :tabn<Return>
nnoremap <C-t> :tabedit .<Return>
nnoremap <C-x> :set number!<Return>
nnoremap <C-s> :set cursorline!<Return>:set cursorcolumn!<Return>
nnoremap <C-p> :set paste!<Return>

" read modelines
set modeline

" copy to system clipboard (from grok)
vnoremap <C-y> :w !xclip -sel clip<CR><CR>
" the practical effect of this augroup thing is that we avoid
" non-idempotency problems with autocmd (specifically the autocmd!
" inside, which resets all the settings in the group)
augroup foo
    autocmd!
    " overrides file type plugins that think they know what i want
    " and i don't
    " -t = don't do auto line wrapping in insert mode
    " +q = do on gqq
    " +n = handle numbered lists automagically
    " +j = handle comment delimiters on J
    " +c = autowrap in insert mode only in comments
    autocmd FileType * setlocal formatoptions-=t formatoptions+=qnjc
    autocmd FileType * setlocal textwidth=69
    " markdown paragraph wrap
    autocmd FileType * setlocal formatoptions+=tn
    " python: pep8 says best textwidth is 80 chars but fuck pep8
    " but only gently. we'll go with 79
    autocmd FileType python setlocal textwidth=79
    " xml turn off line wrapping
    autocmd FileType xml setlocal formatoptions-=t
    " Erlang handle comments beginning with %% | %%% etc
    autocmd FileType erlang setlocal comments=:%%%%%,:%%%%,:%%%,:%%,:%
    autocmd FileType erlang setlocal textwidth=55
    autocmd FileType erlang setlocal formatoptions-=t
    " handle numbered lists properly in markdown
    "autocmd FileType markdown setlocal formatoptions+=n
    " ignore all prior tabs=4spaces settings but only in makefiles
    autocmd FileType make setlocal noexpandtab
augroup END
