set noloadplugins
filetype off

if !has('nvim') && !empty($CONDA_PREFIX) && has('python3_dynamic')
  " Do not depend on stacked environment. Both should work:
  " Enter-CondaEnvironment -Name vim_python &&
  "   Enter-CondaEnvironment -Stack -Name venv
  " Enter-CondaEnvironment -Name vim_python
  let s:conda_env = '/miniconda3/envs/panvimwiki'
  if isdirectory(expand("$LOCALAPPDATA" .. s:conda_env))
    let &pythonthreehome = expand("$LOCALAPPDATA" .. s:conda_env)
  elseif isdirectory(expand("$HOME" .. s:conda_env))
    let &pythonthreehome = expand("$HOME" .. s:conda_env)
  endif
  if has('linux')
    let &pythonthreedll=expand(&pythonthreehome .. "/lib/libpython3.so")
  endif
endif

" Absolute path to this vimrc file.
let g:vimdir = fnamemodify(resolve(expand('<sfile>:p')), ':h')
" Default parent directory for Vimwiki files, converted output and templates.
let s:my_wiki = g:vimdir
let g:my_wiki = empty($MY_WIKI) ? s:my_wiki : $MY_WIKI

" Bundle directory for plugins.
let s:bundle = resolve(g:vimdir..'/bundle')
let g:vader_path = empty($VADER_PATH) ? s:bundle..'/vader.vim' : $VADER_PATH
let g:vimwiki_path = empty($VIMWIKI_PATH) ? s:bundle..'/vimwiki' : $VIMWIKI_PATH
let g:panvimwiki_path = empty($PANVIMWIKI_PATH) ? s:bundle..'/panvimwiki' : $PANVIMWIKI_PATH


execute 'set rtp+=' .. vader_path
execute 'set rtp+=' .. vimwiki_path
execute 'set rtp+=' .. panvimwiki_path
execute 'set rtp+=' .. panvimwiki_path .. '/after'
" Avoid sourcing user vimrc, plugin, which can override Vimwiki configuration
" below
execute 'set rtp-=' .. expand("~/.vim")
execute 'set rtp-=' .. expand("~/.vim/after")

" Configure Vimwiki
let s:wiki_1 = {}
let s:wiki_1.path = g:my_wiki . '/vimwiki/'
let s:wiki_1.path_html = g:my_wiki . '/vimwiki_html/html'
let s:wiki_1.template_path = g:my_wiki . '/vimwiki_html/templates/'
let g:vimwiki_list = [ s:wiki_1 ]

" Configure Panvimwiki
let g:panvimwiki_settings = {}
let g:panvimwiki_settings.extra_args = [
      \ '--shift-heading-level-by', '1',
      \ '--data-dir', s:wiki_1.template_path
      \ ]
let g:panvimwiki_settings.format = 'docx'

set loadplugins
filetype plugin indent on
syntax enable
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
