" line number and syntax highlighting fanciness

set number
set numberwidth=1
set relativenumber
syntax enable

" add a window for the file tree

vsplit
vert res 30
silent e .

" add a window for a terminal

split
wincmd j
res 10
term ++curwin ++kill=kill

" netrw is the file tree explorer and there's
" a bit of weirdness here because it's a plugin,
" and plugins are loaded after vimrc. so you
" have to define an autocmd that will get called
" after the plugins are loaded

" what this actually does is configure it so that
" netrw opens files in the main editing window
" rather than in its own window, and also focuses
" the cursor onto the main editing window on startup

autocmd VimEnter * call <SID>vim_enter()

function s:vim_enter()
       let g:netrw_chgwin = 3
       let g:netrw_liststyle = 3
       wincmd l
endfunction

" custom function to help just a bit with writing
" gophermaps.. just does the obvious thing to fill
" out all the fields for infotext lines

function s:gopher_info()
       execute "normal ^ii\<Esc>$a     fake    (NULL)  0"
endfunction

" call it with :Info
command Info call <SID>gopher_info()

" custom function to finalize a gemlog.. what this
" does is it adds links to the capsule's home page
" and to the particular log's index to the header
" and footer of the entry, then it saves the entry
" and opens up the index, and starts writing the
" link line to the new entry out with the filename
" and date, so all i gotta do is put in the title

function s:gemlog()
       let filename = expand("%:t")
       let datestring = system('date "+%Y-%m-%d"')
       normal G
       /^#/
       execute "normal $a\<CR>\<CR>"
       execute "normal i=> index.gmi   back to gemlog\<CR>"
       execute "normal i=> /           back to home"
       execute "normal G$a\<CR>\<CR>"
       execute "normal i=>index.gmi    back to gemlog\<CR>"
       execute "normal i=> /           back to home\<Esc>"
       w
       edit index.gmi
       /^$/
       /
       execute "normal a\<CR>=> " .. filename .. "     " .. datestring .. " "
       normal ddk$a
       return 1
endfunction

" call it with :Gemlog
command Gemlog call <SID>gemlog()