" ntnsndr's vim settings

" Basics
syntax on
set noerrorbells
set notermguicolors
set autoread

" Spellcheck
set spell
hi clear SpellBad
hi SpellBad cterm=underline

" Margins
set foldcolumn=2
highlight FoldColumn ctermbg=NONE

" Line wrapping in Markdown files 
autocmd FileType markdown setlocal linebreak
autocmd FileType markdown noremap j gj
autocmd FileType markdown noremap k gk

" Tabs
set tabstop=4
set shiftwidth=4
set expandtab

"Search
set ic
set smartcase
set incsearch

" Workspace location
let g:workspace_session_directory = $HOME . '/.vim/sessions/'

" Set shell to bash
set shell=bash\ -l

" Shortcuts
command! Proximate :e ~/Cloud/Notes/Proximate.md
command! W w | bp | bw #
command! Q :wa|qa
command! -range Comment call CommentWrap(<line1>, <line2>)

function! CommentWrap(start, end)
    " Insert closing comment after the last line
    call append(a:end, '--->')
    " Insert opening comment before the first line  
    call append(a:start - 1, '<!---')
endfunction

" Create panda command for pandout
command! -nargs=1 Panda execute ':w' | execute ':!~/.scripts/panda.sh % <args>'
