# Core & Util
[[plugins]]
repo = 'edkolev/promptline.vim'
on_cmd = ['PromptlineSnapshot']

# g:asyncomplete_preprocessor 強制上書きなので、当座は使わない
# [[plugins]] # cargoが必要
# repo = 'tsufeki/asyncomplete-fuzzy-match'
# depends = ['asyncomplete.vim']
# on_if= 'g:user.function.executable("cargo")'
# build = 'cargo build --release'

[[plugins]]
repo = 'tyru/notify-changed.vim'
on_cmd = ['NotifyChanged']

[[plugins]]
repo = 'powerman/vim-plugin-AnsiEsc'
on_cmd = ['AnsiEsc']
depends = ['vital.vim']
hook_source = '''
  let g:no_ansiesc_menu = 1
  let g:no_cecutil_maps = 1
  " based on https://qiita.com/1000k/items/6d4953d2dd52fdd86556
  command! AnsiEscStripCode %s/\e\[[0-9;]*m//g
  " command! AnsiEscStripCode %s/^.*$/\=g:V.import('Data.String').remove_ansi_sequences(\0)/g
'''

[[plugins]]
repo = 'thinca/vim-scouter'
on_cmd = ['Scouter', 'ScouterVerbose']

# colorscheme
[[plugins]]
repo = 'vim-scripts/ScrollColors'
on_cmd = ['SCROLLCOLOR']

[[plugins]]
repo = 'kato-k/vim-colorscheme-settings'
on_if = 'exists("*popup_create")'
on_cmd = ['SwitchColorscheme', 'SwitchBackGround']
hook_source = '''
  " " off default
  " let g:colorschemes_settings#use_default_colorschemes = v:false

  " " resource file
  " let g:colorschemes_settings#rc_file_path = g:user.file.colorrc " noting yet
'''

[[plugins]] # cmigemoが必要
repo = 'haya14busa/vim-migemo'
on_if = 'g:user.function.executable("cmigemo")'
depends = ['vital.vim']
hook_post_source = '''
  let s:Filepath = g:V.import('System.Filepath')

  " s:dict
  let g:migemodict = ''

  if g:user.system.windows
    let s:dict = fnamemodify(
          \ s:Filepath.realpath(
          \   g:user.dir.dictionary . '/Migemo/' . &encoding . '/migemo-s:dict'
          \ ),
          \ ':p')
    if filereadable(s:dict)
      let g:migemodict = s:dict
    endif
  endif

  if empty(g:migemodict)
    let s:dict = fnamemodify(
          \ s:Filepath.realpath(
          \   g:user.dir.vim . '/s:dict/' . &encoding . '/migemo-s:dict'
          \ ),
          \ ':p')
    if filereadable(s:dict)
      let g:migemodict = s:dict
    endif
  endif
'''

[[plugins]] # fzf
repo = 'yuki-yano/fzf-preview.vim'
# rev  = 'release/rpc'
rev  = 'feature/windows_compatibility'
on_if = 'g:user.function.executable("fzf") && g:user.function.executable("node")'
depends = ['fzf', 'fzf.vim', 'vim-devicons']
hook_add = '''
  " filelist preview
  if g:user.system.windows
    let g:fzf_preview_default_fzf_options = {
      \  '--reverse'        : v:true,
      \  '--preview-window' : 'right:50%:noborder',
      \}

    let g:fzf_binary_preview_command = 'echo binary'
    let g:fzf_preview_if_binary_command = '( ver > nul )'
    if g:user.function.executable('file')
      let g:fzf_preview_if_binary_command = '( file --mime {} | findstr binary > nul )'
    endif

    " currently fallback safe pattern
    if g:user.function.executable('false')
      let g:fzf_preview_if_binary_command = 'false'
    endif
  endif

  if g:user.function.executable('bat')
    let g:fzf_preview_command = 'bat --color always --style grid {-1}'
  elseif g:user.function.executable('head')
    let g:fzf_preview_command = 'head -100 {-1}'
  elseif g:user.function.executable('cat')
    let g:fzf_preview_command = 'cat {-1}'
  else
    if g:user.system.windows
      let g:fzf_preview_command = 'echo command nothing'
    else
      let g:fzf_preview_command = 'echo "command nothing"'
    endif
  endif

  " " filelist command
  " " let g:fzf_preview_filelist_command
  " " grep command
  " " let g:fzf_preview_grep_cmd

  " ! should not be escaped
  if g:user.function.executable('rg')
    let g:fzf_preview_filelist_command = 'rg --files --hidden --follow --no-messages --glob "!.git/*" --glob !"* *"'
    let g:fzf_preview_directory_files_command = 'rg --files --hidden --follow --no-messages -g !"* *"'
  endif

  " " filelist post process
  " if g:user.function.executable('exa')
  "   let g:fzf_preview_filelist_postprocess_command = 'xargs -d "\n" exa --color=always'
  " else
  "   let g:fzf_preview_filelist_postprocess_command = ''
  " endif

  " Use vim-devicons
  if dein#tap('vim-devicons')
    let g:fzf_preview_use_dev_icons = 1
  endif
'''

[[plugins]] # WebAPIのライブラリ curlが必要
repo = 'mattn/webapi-vim'
on_if = 'g:user.function.executable("curl")'

[[plugins]]
repo = 'mbbill/undotree'
on_if = 'has("persistent_undo")'
hook_post_source = '''
  nnoremap <silent> <F6> :UndotreeToggle<CR>
'''

# dirvish
# [[plugins]]
# repo = 'bounceme/remote-viewer'
# on_if= 'g:user.function.executable("ssh") || g:user.function.executable("curl")'
# depends = ['vim-dirvish']

# [[plugins]]
# repo = 'kristijanhusak/vim-dirvish-git'
# # git is installed, need for basic
# depends = ['vim-dirvish']
# hook_source = '''
#  let g:dirvish_git_show_ignored = 1
# '''

[[plugins]]
repo = 'deton/eblook.vim'
on_if = 'g:user.function.executable("eblook")'
hook_source = '''
  " 'book'    辞書ディレクトリ。(eblookのbookコマンドの引数)
  " 'name'    辞書名。(eblookのselectコマンドの引数)
  " 'title'   辞書識別子
  " 'appendix'  Appendix
  " 'skip'    この辞書を検索対象にするかどうか
  " 'autoformat'  content表示時に長い行を|gq|で整形するかどうか
  " let g:eblook_dictlist1 = [
  "   \    {
  "   \       'book'       : '',
  "   \       'name'       : '',
  "   \       'title'      : '',
  "   \       'appendix'   : '',
  "   \       'skip'       : '',
  "   \       'autoformat' : '',
  "   \    },
  "   \ ]

  " buffer setting
  augroup vimrc_init_eblook
    autocmd!
    autocmd FileType
      \ eblook nested setlocal nonumber
      \                        norelativenumber
      \                        signcolumn=no
      \                        foldcolumn=0
    " autocmd VimEnter,VimResized *
    "   \ let g:eblook_entrywin_height   = min([max([(&lines/6),  4]),  8]) - 1
    " autocmd VimEnter,VimResized *
    "   \ let g:eblook_contentwin_height = min([max([(&lines/3), 10]), 25]) - 1
  augroup END

  if g:user.system.windows
    " Windows環境用のコード
    let g:eblookenc='cp932'
  else
    " non Windows
  endif

  let s:dictdir = substitute(g:user.dir.dictionary, '\', '/', 'g')
  let g:eblook_dictlist1 = [
    \    {
    \       'book'       : s:dictdir . '/FreePWING/ASCDATES',
    \       'name'       : 'ascdates',
    \       'title'      : 'パソコン用語辞典 (1998年版アスキー DATES手帳巻末)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/BIBLENAM',
    \       'name'       : 'biblenam',
    \       'title'      : 'HITCHCOCK,S BIBLE NAMES DICTIONARY',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/CG',
    \       'name'       : 'cg',
    \       'title'      : 'CG 用語辞典 Ver.1.50h (日本大学吉川研究室)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/DEVIL',
    \       'name'       : 'devil',
    \       'title'      : '惡魔の辭典 (Devil,s Dictionary)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/EBD',
    \       'name'       : 'ebd',
    \       'title'      : 'Easton,s 1897 Bible Dictionary',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/EDICT',
    \       'name'       : 'edict',
    \       'title'      : 'EDICT',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/EIJIRO',
    \       'name'       : 'eijiro',
    \       'title'      : '英辞郎 Ver.144.8',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/FLOWER',
    \       'name'       : 'flower',
    \       'title'      : '花の咲く草木名小事典 (K,s Bookshelf)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/GENE95',
    \       'name'       : 'gene95',
    \       'title'      : 'GENE95辞書',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/FOLDOC',
    \       'name'       : 'foldoc',
    \       'title'      : 'Free On-line Dictionary of Computing (FOLDOC)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/FUMEIKAI',
    \       'name'       : 'fumeikai',
    \       'title'      : '不明解略語辞典',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/JARGON',
    \       'name'       : 'jargon',
    \       'title'      : 'The Jargon File',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/LSD',
    \       'name'       : 'lsd',
    \       'title'      : 'ライフサイエンス辞書4',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/PEJV',
    \       'name'       : 'pejv',
    \       'title'      : '実用エスペラント小辞典 (第1版)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/ROGET',
    \       'name'       : 'roget',
    \       'title'      : 'ロジェーのシソーラス (Roget,s Thesaurus)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/RYAKU',
    \       'name'       : 'ryaku',
    \       'title'      : '略語辞典辞典 (K,s Bookshelf)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/VERA',
    \       'name'       : 'vera',
    \       'title'      : 'V.E.R.A. -- Virtual Entity of Relevant Acronyms',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/WDIC',
    \       'name'       : 'wdic',
    \       'title'      : '通信用語の基礎知識 (2004年後期版)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/WEB',
    \       'name'       : 'web',
    \       'title'      : 'Webster,s Revised Unabridged Dictionary (1913)',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/WORDNET',
    \       'name'       : 'wordnet',
    \       'title'      : 'WordNet(r) 1.6',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/WWASW',
    \       'name'       : 'wwasw',
    \       'title'      : '物故者名士録',
    \       'skip'       : 0,
    \    },
    \    {
    \       'book'       : s:dictdir . '/FreePWING/YASOU',
    \       'name'       : 'yasou',
    \       'title'      : '身近な野草を調べよう',
    \       'skip'       : 0,
    \    },
    \ ]
  unlet s:dictdir
'''
hook_post_source = '''
  " map key : map  <unique> <silent> <Leader><C-Y> <Plug>EblookInput
  " map key : vmap <unique> <silent> <Leader>y     <Plug>EblookSearch
  " unmap select-mode
  silent! sunmap <Leader><C-Y>
  silent! sunmap <Leader>y
'''

[[plugins]]
repo = 'tyru/open-browser-github.vim'
depends = ['open-browser.vim']
on_if = 'g:user.function.executable("hub")'

[[plugins]]
repo = 'iberianpig/tig-explorer.vim'
on_if = 'g:user.function.executable("tig")'

[[plugins]]
repo = 'ConradIrwin/vim-bracketed-paste'
on_if = '!has("patch-8.0.0210")'

# Doc & File & Web

# UI
# [[plugins]]
# repo = 'mattn/vim-nyancat'
# on_if= '!(has("win32") || has("win64") || has("win32unix")) && !has("gui_running")'

[[plugins]]
repo = 'edkolev/tmuxline.vim'
# statusline,airline,lightline
depends = ['lightline.vim']
on_if = 'exists("$TMUX")'
hook_post_source = '''
  Tmuxline lightline
'''

[[plugins]]
repo = 'miyakogi/seiya.vim'
on_if = '!has("gui_running")'
hook_source = '''
  " let g:seiya_auto_enable=1
'''

# # Clap
# [[plugins]]
# repo = 'liuchengxu/vim-clap'
# on_event = ['VimEnter']
# on_if= 'g:user.function.executable("cargo") && has("python3")'
# build = ':Clap install-binary'
#
# [[plugins]]
# repo = 'tamago324/vim-clap-help'
# on_source = ['vim-clap']
#
# [[plugins]]
# repo = 'hokorobi/vim-clap-filelist'
# on_source = ['vim-clap']
# hook_post_source = '''
#   " let g:clap_filelist_file = expand(g:user.dir.cache_home . '/mrulist')
#   " based on https://qiita.com/hokorobi/items/615277a0ea8ab7c9c4c3
#   if !empty(get(g:, 'ctrlp_cache_dir', ''))
#     let g:clap_filelist_file = expand(g:ctrlp_cache_dir . '/mru/cache.txt')
#   endif
# '''
#
# [[plugins]]
# repo = 'hokorobi/vim-clap-launcher'
# on_source = ['vim-clap']
# hook_source = '''
#   let g:clap_launcher_file = expand(g:user.dir.vim . '/launcher')
# '''

# LeaderF
[[plugins]]
repo = 'Yggdroot/LeaderF'
if = 'has("python3")'
depends = ['vital.vim', 'vim-devicons']
hook_post_update = '''
  if g:user.system.windows
    let s:cmd = 'install.bat'
  else
    let s:cmd = './install.sh'
  endif
  let g:dein#plugin.build = s:cmd
  unlet s:cmd
'''
hook_source = '''
  if (has('popupwin') || exists('*popup_create') || has('nvim-0.4.2'))
    let g:Lf_WindowPosition = 'popup'
    let g:Lf_PreviewInPopup = 1
  endif

  let g:Lf_ReverseOrder = 1

  " search cache strategy like ctrlp
  let g:Lf_UseCache = 1
  let g:Lf_CacheDirectory = expand(g:user.dir.cache_home . '/leaderf')
  call g:user.function.mkdir(g:Lf_CacheDirectory)

  if g:user.function.executable('jvgrep')
    let g:Lf_DefaultExternalTool = 'jvgrep'
    let g:Lf_ExternalCommand = 'jvgrep --no-color -Rril "" "%s"'
  elseif g:user.function.executable('pt')
    let g:Lf_DefaultExternalTool = 'pt'
    let g:Lf_ExternalCommand = 'pt --nocolor --nogroup -S -l "" "%s"'
  elseif g:user.function.executable('ag')
    let g:Lf_DefaultExternalTool = 'ag'
    let g:Lf_ExternalCommand = 'ag -a --nocolor --nogroup -S -l "" %s'
  else
    let g:Lf_DefaultExternalTool = ''
  endif

  " overwrite external command if files exists
  if g:user.function.executable('files')
    let g:Lf_ExternalCommand = 'cd "%s" && files -H=0 -a -m ""'
  endif

  if has_key(g:, 'Lf_ExternalCommand')
    let g:Lf_UseCache = 0
  endif

  let g:Lf_WorkingDirectoryMode = 'Ac'

  " color
  let g:Lf_StlColorscheme   = 'gruvbox_material'
  let g:Lf_PopupColorscheme = 'gruvbox_material'

  " separator
  " like lightline (powerline arrow)
  let g:Lf_StlSeparator = { 'left': nr2char(0xe0b0), 'right': nr2char(0xe0b2) }

  " size
  " let g:Lf_PopupWidth
  " let g:Lf_PopupHeight
  " let g:Lf_PreviewPopupWidth

  autocmd vimrc_init_core VimEnter,VimResized * let g:Lf_PopupWidth  = min([max([(&columns * 3)/4, 20]), (&columns - 2)])
  autocmd vimrc_init_core VimEnter,VimResized * let g:Lf_PopupHeight = min([max([(&lines   * 3)/4, 15]), (&lines - (2 + 1 + &cmdheight))])

  " mapping
  " conflict workaround : prefix <Leader>L as LeaderF

  " keymap info
  let g:user.plugin.info.whichkey.desc.leader['L'] = {
    \  'name' : '+LeaderF',
    \ }

  let g:Lf_ShortcutF = '<Leader>Lf'
  let g:Lf_ShortcutB = '<Leader>Lb'
'''
hook_post_source = '''
  let s:List     = g:V.import('Data.List')

  " root marker use findroot value
  let g:Lf_RootMarkers = s:List.concat([
    \ g:user.rootmarker.dirs,
    \ g:user.rootmarker.files])
  let g:Lf_WorkingDirectoryMode = 'a'
'''

[[plugins]]
repo = 'tamago324/LeaderF-filer'
on_source = ['LeaderF']
depends = ['LeaderF', 'vim-devicons']
hook_source = '''
  " Plug 'ryanoasis/vim-devicons'
  let g:Lf_FilerShowDevIcons = 1
'''

[[plugins]]
repo = 'markwu/LeaderF-prosessions'
on_source = ['LeaderF']

[[plugins]]
repo = 'tamago324/LeaderF-bookmark'
on_source = ['LeaderF']
hook_source = '''
  " same as fern
  let g:Lf_BookmarkFilePath = expand(g:user.dir.vim . '/bookmark.json')
'''
hook_post_source = '''
  if exists('g:fern#scheme#bookmark#store#file')
    " use fern's bookmark
    let g:Lf_BookmarkFilePath = g:fern#scheme#bookmark#store#file
  endif
'''

[[plugins]]
repo = 'linjiX/LeaderF-git'
on_source = ['LeaderF']
# optional depends
# depends = ['vim-fugitive']

[[plugins]]
repo = 'hilarryxu/LeaderF-funky'
on_source = ['LeaderF']

[[plugins]]
repo = 'Yggdroot/LeaderF-marks'
on_source = ['LeaderF']

[[plugins]]
repo = 'Yggdroot/LeaderF-changes'
on_source = ['LeaderF']

# [[plugins]]
# repo = 'xltan/LeaderF-tjump'
# on_source = ['LeaderF']

[[plugins]]
repo = 'tamago324/LeaderF-sonictemplate'
on_source = ['LeaderF']
depends = ['LeaderF', 'vim-sonictemplate']

# Edit operation
# Align
[[plugins]]
repo = 'godlygeek/tabular'
on_cmd = ['AddTabularPattern', 'AddTabularPipeline', 'Tabularize', 'GTabularize']
on_source = ['splitjoin.vim']

# Quick Fix
## Edit
[[plugins]]
repo = 'itchyny/vim-qfedit'
on_ft = ['qf']

[[plugins]]
repo = 'yssl/QFEnter'
on_ft = ['qf']
hook_source = '''
  " ctrlp like
  let g:qfenter_keymap = {}
  let g:qfenter_keymap.open       = ['<CR>', '<2-LeftMouse>']
  let g:qfenter_keymap.vopen      = ['<C-v>']
  let g:qfenter_keymap.hopen      = ['<C-CR>', '<C-s>', '<C-x>']
  let g:qfenter_keymap.topen      = ['<C-t>']
  let g:qfenter_keymap.open_keep  = ['<Leader><CR>',  '<Leader><2-LeftMouse>']
  let g:qfenter_keymap.vopen_keep = ['<Leader><C-v>']
  let g:qfenter_keymap.hopen_keep = ['<Leader><C-CR>', '<Leader><C-s>', '<Leader><C-x>']
  let g:qfenter_keymap.topen_keep = ['<Leader><C-t>']
'''

[[plugins]]
repo = 'thinca/vim-qfreplace'
on_ft = ['qf']
[plugins.ftplugin]
qf = '''
  nnoremap <buffer> r <Cmd>Qfreplace<CR>
'''

## preview
[[plugins]]
repo = 'bfrg/vim-qf-preview'
# repo = 'tsuyoshicho/vim-qf-preview'
# rev  = 'fix/keymap'
on_ft = ['qf']
[plugins.ftplugin]
qf = '''
  " keymap start preview
  nmap <buffer> <C-P> <plug>(qf-preview-open)
'''

## highlight
# use vim-qfhl
# [[plugins]]
# repo = 'jceb/vim-hier'
# on_ft = ['qf']

[[plugins]]
repo = 'thinca/vim-qfhl'
on_ft = ['qf']
hook_source = '''
  let g:qfhl_startup = 'enable'
'''

[[plugins]]
repo = 'thinca/vim-partedit'
on_cmd = ['Partedit', 'ParteditEnd']

[[plugins]]
# repo = 'soramugi/auto-ctags.vim'
repo = 'tsuyoshicho/auto-ctags.vim'
rev  = 'feature/asyncprocess'
on_if = 'g:user.function.executable("ctags")'
hook_source = '''
  " in .ctags
  let g:auto_ctags_tags_args = ['--tag-relative=yes', '--recurse=yes', '--sort=yes', '--extra=+f']
  " universal ctags need
  let g:auto_ctags_tags_args = get(g:,'auto_ctags_tags_args',[]) + ['--output-format=e-ctags']

  let g:auto_ctags = 1
  " let g:auto_ctags_filetype_mode = 1
  let g:auto_ctags_directory_list = ['.git', '.svn', '.hg', '.bzr', 'CVS', '.']
  let g:auto_ctags_search_recursively = 1
  let g:auto_ctags_absolute_path = 1
  let s:home = ''
  if has('path_extra')
    let s:home = ';$HOME'
  endif
  for s:dir in g:auto_ctags_directory_list
    if s:dir !=? '.'
      execute 'set tags+=./' . s:dir . '/tags' . s:home
    endif
  endfor

  " git リポジトリ内などでも直にtagsを生成する関数
  function! s:direct_auto_ctags()
    let s:ctags_list_backup = copy(g:auto_ctags_directory_list)
    let s:ctags_search_backup = g:auto_ctags_search_recursively

    " set current only
    let g:auto_ctags_directory_list = ['.']
    let g:auto_ctags_search_recursively = 1

    " call ctags create process
    call auto_ctags#ctags(1)

    " recover backups
    let g:auto_ctags_directory_list = copy(s:ctags_list_backup)
    let g:auto_ctags_search_recursively = s:ctags_search_backup

    unlet s:ctags_list_backup
    unlet s:ctags_search_backup
  endfunction

  " コマンド定義
  command! CtagsDirect call <SID>direct_auto_ctags()
'''

[[plugins]] # Twitter
repo = 'twitvim/twitvim'
on_if = 'g:user.function.executable("curl") && g:user.function.executable("openssl")'
hook_source = '''
  let g:twitvim_force_ssl = 1
  let g:twitvim_count = 40
  let g:twitvim_token_file = expand(g:user.dir.vim . '/twitvim.token')
  if exists('$HTTP_PROXY')
    let s:proxy_url_pattern =
                \ '^\%(\([^:]*\):\/\/\)\='
                \ . '\%(\([^:@]*\)\(:[^@]*\)\=@\)\='
                \ . '\([^:]*\)\%(:\(\d*\)\)\=/\=$'
    let g:twitvim_proxy = substitute($HTTP_PROXY,
                \ s:proxy_url_pattern, '\4:\5', '')
    let s:proxy_login = substitute($HTTP_PROXY,
                \ s:proxy_url_pattern, '\2', '')
    let s:proxy_pass = substitute($HTTP_PROXY,
                \ s:proxy_url_pattern, '\3', '')
    let g:twitvim_proxy_login = substitute(s:proxy_login . s:proxy_pass,
                \ '%40', '@', 'g')
  endif
'''

[[plugins]]
repo = 'LeafCage/laptime.vim'
on_func = ['laptime#new']

[[plugins]]
repo = 'rbtnn/vim-vimscript_lasterror'
on_cmd = ['VimscriptLastError']

[[plugins]]
repo = 'LumaKernel/vim-messages-qf'
on_cmd = ['MessagesQF']
on_func = ['g:messages_qf#messages']
hook_source = '''
  command! MessagesQF call g:messages_qf#messages() | copen
'''

[[plugins]]
repo = '0Delta/vimodoro'
on_cmd = ['Pomodoro', 'PomodoroStop']

[[plugins]]
repo = 'tyru/restart.vim'
on_cmd = ['Restart']

[[plugins]]
repo = 'Asheq/close-buffers.vim'
on_cmd = ['Bdelete', 'Bwipeout']
hook_source = '''
  nnoremap <silent> Q     :<C-u>Bdelete menu<CR>
'''

[[plugins]]
repo = 'mhinz/vim-sayonara'
on_cmd = ['Sayonara']

[[plugins]]
repo = 'tyru/capture.vim'
on_cmd = ['Capture']
hook_source = '''
  let g:capture_open_command = 'tabnew'
'''

[[plugins]]
repo = 'LeafCage/lastmess.vim'
on_cmd = ['LastMess']

[[plugins]]
repo = 'LeafCage/echos.vim'
on_cmd = ['Echos']

[[plugins]]
repo = 'tweekmonster/helpful.vim'
on_cmd = ['HelpfulVersion']
on_ft = ['help', 'vim']
hook_source = '''
  let g:helpful = 1
'''

[[plugins]]
repo = 'notomo/helpeek.vim'
on_cmd = ['Helpeek']

# per filetypes
# C/C++ use clnagd / lsp for lsp client
# [[plugins]]
# repo = 'rhysd/vim-clang-format'
# on_if = 'g:user.function.executable("clang-format")'
# hook_source = '''
#   let g:clang_format#auto_formatexpr = 1
# '''

[[plugins]]
repo = 'justinmk/vim-syntax-extra'
on_ft = ['c', 'yacc', 'lex']

[[plugins]]
repo = 'vim-jp/vim-cpp'
on_ft = ['c', 'cpp']

[[plugins]]
# repo = 'octol/vim-cpp-enhanced-highlight'
repo = 'bfrg/vim-cpp-modern'
on_ft = ['c', 'cpp']
hook_source = '''
  " let g:cpp_class_scope_highlight = 1
  " let g:cpp_member_variable_highlight = 1
  " let g:cpp_class_decl_highlight = 1

  " Disable function highlighting (affects both C and C++ files)
  " let g:cpp_no_function_highlight = 1

  " Enable highlighting of C++11 attributes
  let g:cpp_attributes_highlight = 1

  " Highlight struct/class member variables (affects both C and C++ files)
  let g:cpp_member_highlight = 1

  " Put all standard C and C++ keywords under Vim's highlight group 'Statement'
  " (affects both C and C++ files)
  " let g:cpp_simple_highlight = 1
'''

# use LSP clangd for c,cpp
# [[plugins]]
# repo = 'vim-scripts/OmniCppComplete'
# # repo = 'FromtonRouge/OmniCppComplete'
# on_ft = ['c', 'cpp']
# hook_source = '''
#   autocmd vimrc_init_core FileType c   setlocal omnifunc=omni#cpp#complete#Main
#   autocmd vimrc_init_core FileType cpp setlocal omnifunc=omni#cpp#complete#Main
# '''

# [[plugins]] # RFC
# repo = 'mhinz/vim-rfc'
# depends = ['rfc-syntax']
# on_if = 'has("ruby")'

[[plugins]] # toml syntax
repo = 'cespare/vim-toml'
if = '!has("patch-8.2.3520") && !has("nvim-0.6")'
on_ft = ['toml']

[[plugins]] # yaml syntax
repo = 'stephpy/vim-yaml'
on_ft = ['yaml']

[[plugins]] # GFM syntax
repo = 'rhysd/vim-gfm-syntax'
on_ft = ['markdown']
hook_source = '''
  if has('gui_running')
    let g:gfm_syntax_emoji_conceal = 1
  endif
'''

[[plugins]]
repo = 'iwataka/vim-markdown-ex'
# no depends : use default markdown styler or other
on_ft = ['markdown']

[[plugins]]
# repo = 'mzlogin/vim-markdown-toc'
repo = 'tsuyoshicho/vim-markdown-toc'
rev  = 'develop'
# rev  = 'pr-merged'
# TODO : I send Fix PR. When merged it then to restore original
on_ft = ['markdown','mdx']
hook_source = '''
  let g:vmt_auto_update_on_save = 1
  " let g:vmt_dont_insert_fence = 0
  let g:vmt_include_headings_before = 1
  let g:vmt_cycle_list_item_markers = 1
  let g:vmt_fence_text         = 'start of TOC'
  let g:vmt_fence_closing_text = 'end   of TOC'
'''

# [[plugins]]
# repo = 'jxnblk/vim-mdx-js'
# on_ft = ['markdown', 'mdx']

[[plugins]]
repo = 'nelstrom/vim-markdown-folding'
on_ft = ['markdown']
hook_source = '''
  " let g:markdown_fold_style = 'nested'
  let g:markdown_fold_style = 'stacked'
  let g:markdown_fold_override_foldtext = 0
'''

# deno's plugin 'kat0h/dps-bufpreview.vim' conflict command
# When deno exists, disable it
[[plugins]]
repo = 'skanehira/preview-markdown.vim'
if = '!g:user.function.executable("deno")'
on_ft = ['markdown']
hook_source = '''
  " open window vartical when value is 1
  let g:preview_markdown_vertical = 1
  " use specified command to parse markdown, default is mdr
  if g:user.function.executable('mdcat')
    let g:preview_markdown_parser = 'mdcat'
  endif
'''

[[plugins]] # need pdftotext
repo = 'makerj/vim-pdf'
on_if = 'g:user.function.executable("pdftotext")'

[[plugins]] # need pandoc,asciidoctor,java,xdg-open
repo = 'iwataka/minidown.vim'
on_ft = ['markdown','asciidoc','rst','textile']
on_if = 'g:user.function.executable("pandoc")'
hook_post_source = '''
  let g:minidown_pandoc_from = extend({
      \ 'markdown': 'markdown+pipe_tables+raw_html+fenced_code_blocks+gfm_auto_identifiers+ascii_identifiers+backtick_code_blocks+autolink_bare_uris+intraword_underscores+strikeout+hard_line_breaks+emoji+shortcut_reference_links+angle_brackets_escapable+smart+yaml_metadata_block',
      \ 'rst'     : 'rst',
      \ 'textile' : 'textile',
      \}, get(g:,'minidown_pandoc_from',{}), "keep")
'''

[[plugins]] # need docutils's rst2html.py
repo = 'previm/previm'
# shoud depends
depends = ['open-browser.vim']
on_ft = ['markdown','asciidoc','rst','textile']

[[plugins]]
repo = 'tokorom/vim-review'
on_ft = ['review']

[[plugins]]
repo = 'aklt/plantuml-syntax'
on_ft = ['plantuml']
hook_source = '''
  if g:user.system.windows && g:user.function.executable('plantumlc')
    let g:plantuml_executable_script = 'plantumlc -tsvg'
  endif
'''

[[plugins]]
# repo = 'scrooloose/vim-slumlord'
repo = 'tsuyoshicho/vim-slumlord'
rev  = 'feature/aggressive'
depends = ['plantuml-syntax']
on_ft = ['plantuml']
hook_source = '''
  if g:user.system.windows && g:user.function.executable('plantumlc')
    let s:bin_path = fnamemodify(system('where plantumlc'), ":p")
    let s:lib_path = fnamemodify(s:bin_path, ":p:h") . '/../lib/plantuml/tools/plantuml.jar'

    let g:slumlord_plantuml_jar_path = fnamemodify(s:lib_path, ":p")
  endif

  " let g:slumlord_separate_win = 0 " In place
  let g:slumlord_separate_win = 1 " separate window

  let g:slumlord_asciiart_utf = 0 " ascii
  " let g:slumlord_asciiart_utf = 1 " UTF
'''
# hook_post_source = '''
#   augroup vimrc_init_slumlord
#     autocmd!
#     autocmd bufwritepre *.puml silent call slumlord#updatePreview({'write': 1})
#   augroup END
# '''

[[plugins]]
# repo = 'weirongxu/plantuml-previewer.vim'
repo = 'tsuyoshicho/plantuml-previewer.vim'
rev  = 'develop'
# TODO : I send Fix PR. When merged it then to restore original
depends = ['open-browser.vim']
on_ft = ['plantuml']
on_if = 'g:user.function.executable("dot") && g:user.function.executable("java")'
hook_source = '''
  if g:user.system.windows && g:user.function.executable('plantumlc')
    let s:bin_path = exepath('plantumlc')
    let s:lib_path = fnamemodify(s:bin_path, ":p:h:h") . '/lib/plantuml/tools/plantuml.jar'

    let g:plantuml_previewer#plantuml_jar_path = fnamemodify(s:lib_path, ":p")
    let g:plantuml_previewer#save_format = 'svg'
  endif
'''

# include stable
[[plugins]] # asciidoc syntax
repo = 'habamax/vim-asciidoctor'
on_ft = ['asciidoc']

[[plugins]]
repo = 'matcatc/vim-asciidoc-folding'
on_ft = ['asciidoc']
hook_source = '''
  let g:asciidoc_fold_style = 'nested'
  let g:asciidoc_fold_override_foldtext = 0
'''

[[plugins]]
repo = 'amiorin/vim-textile'
on_ft = ['textile']

[[plugins]]
repo = 'neoclide/vim-jsx-improve'
on_ft = ['javascript','jsx','typescript']
hook_source = '''
  " configurable if need

  let g:javascript_plugin_jsdoc = 1
  let g:javascript_plugin_ngdoc = 1
  let g:javascript_plugin_flow = 1

  " Syntax
  " let g:javascript_conceal_null
  " let g:javascript_conceal_return
  " let g:javascript_conceal_undefined
  " let g:javascript_conceal_NaN
  " let g:javascript_conceal_prototype
  " let g:javascript_conceal_this
  " let g:javascript_conceal_super
  " let g:javascript_conceal_function
  " let g:javascript_conceal_arrow_function
  " let g:javascript_conceal_noarg_arrow_function
  " let g:javascript_conceal_underscore_arrow_function

  " Indent
  " let g:javascript_opfirst
  " let g:javascript_continuation
  "
  " ftplugin
  let g:jsx_improve_motion_disable = 1

  augroup vimrc_init_vim_jsx_improve
    autocmd!
    autocmd FileType javascript setlocal foldmethod=syntax
    autocmd BufNewFile,BufRead *.jsx setlocal filetype=javascript.jsx
    autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescript.jsx
  augroup END
'''

[[plugins]]
repo = 'othree/es.next.syntax.vim'
on_ft = ['javascript']

[[plugins]]
repo = 'othree/yajs.vim'
on_ft = ['javascript']

[[plugins]]
repo = 'othree/javascript-libraries-syntax.vim'
depends = ['vim-jsx-improve']
# depends = ['vim-javascript']
on_ft = ['javascript']
hook_source = '''
  " let g:used_javascript_libs =
'''

[[plugins]]
repo = 'styled-components/vim-styled-components'
on_ft = ['javascript','jsx','typescript']

[[plugins]]
repo = 'jason0x43/vim-js-indent'
# on_ft = ['javascript', 'typescript']
on_ft = ['typescript']

[[plugins]]
repo = 'elzr/vim-json'
on_ft = ['json']

[[plugins]]
repo = 'gutenye/json5.vim'
on_ft = ['json5']

[[plugins]]
repo = 'chrisbra/csv.vim'
on_ft = ['csv']
hook_source = '''
  let g:csv_disable_fdt = 1
'''

[[plugins]]
repo = 'pdurbin/vim-tsv'
on_ft = ['tsv']

[[plugins]]
repo = 'mechatroner/rainbow_csv'
on_ft = ['csv', 'tsv']

[[plugins]] # Colorize
# repo = 'ap/vim-css-color'
repo = 'chrisbra/Colorizer'
on_ft = ['clojure', 'css', 'dosini', 'elm', 'go', 'html', 'i3', 'i3config', 'javascript', 'json', 'jsx', 'less', 'moon', 'perl', 'php', 'python', 'r', 'ruby', 'sass', 'scss', 'stylus', 'typescript', 'sh', 'vim', 'xdefaults', 'xml', 'yaml']
hook_source = '''
  let g:colorizer_auto_filetype = join(g:dein#plugin.on_ft, ',')
'''

# or
# [[plugins]] # Currently not work in windows
# repo = 'RRethy/vim-hexokinase'
# on_ft = (same as other colorize)
# hook_post_update = '''
#   " not installed global
#   if !g:user.function.executable('hexokinase')
#     if g:user.system.windows
#       if !g:user.system.cygwin
#         let s:cmd = 'mingw32-make hexokinase'
#       else
#         let s:cmd = 'make hexokinase'
#       endif
#     elseif g:user.function.executable('gmake')
#       let s:cmd = 'gmake hexokinase'
#     else
#       let s:cmd = 'make hexokinase'
#     endif
#     let g:dein#plugin.build = s:cmd
#     unlet s:cmd
#   endif
# '''
# hook_source = '''
#   " custom path if need
#   if g:user.function.executable('hexokinase')
#     let g:Hexokinase_executable_path = exepath('hexokinase')
#   endif
#
#   let g:Hexokinase_highlighters = ['foregroundfull']
#
#   " All possible values
#   let g:Hexokinase_optInPatterns = [
#     \  'full_hex',
#     \  'rgb',
#     \  'rgba',
#     \  'hsl',
#     \  'hsla',
#     \  'colour_names',
#     \]
#
#   let g:Hexokinase_ftEnabled = copy(g:dein#plugin.on_ft)
# '''

[[plugins]]
repo = 'hail2u/vim-css3-syntax'
on_ft = ['css']
[plugins.ftplugin]
css = '''
  setlocal iskeyword+=-
'''

[[plugins]]
repo = 'cakebaker/scss-syntax.vim'
on_ft = ['scss']

[[plugins]]
repo = 'othree/html5.vim'
on_ft = ['html']

# [[plugins]]
# repo = 'relastle/vim-nayvy'
# on_ft = ['python']
# # work require pyflakes,fzf(fzf vim plugin)

[[plugins]]
repo = 'hynek/vim-python-pep8-indent'
on_ft = ['python']

[[plugins]] # need merged = 0/lazy
repo = 'aliev/vim-compiler-python'
on_ft = ['python']

[[plugins]]
repo = 'heavenshell/vim-pydocstring'
# repo = 'tsuyoshicho/vim-pydocstring'
# rev  = 'develop'
on_ft = ['python']
hook_post_update = '''
  " command use pipx(if exists), path setup and pipx command install manually.
  if g:user.function.executable('pipx')
    let g:dein#plugin.build = 'pipx upgrade doq'
  elseif g:user.system.windows && g:user.function.executable('pip')
    let g:dein#plugin.build = 'pip install --upgrade doq'
  elseif g:user.function.executable('pip3')
    let g:dein#plugin.build = 'pip3 install --user --upgrade doq'
  endif
'''
hook_source = '''
  if g:user.function.executable('doq')
    let g:pydocstring_doq_path = 'doq'
  endif

  let g:pydocstring_enable_mapping = 0
'''
[plugins.ftplugin]
python = '''
  nmap <silent> <buffer> <LocalLeader><C-l> <Plug>(pydocstring)
'''

[[plugins]]
repo = 'bps/vim-textobj-python'
depends = ['vim-textobj-user']
on_ft = ['python']
hook_add = '''
  let g:textobj_python_no_default_key_mappings = 1
'''
[plugins.ftplugin]
python = '''
  call textobj#user#map('python', {
    \   'class': {
    \     'select-a': '<buffer>acp',
    \     'select-i': '<buffer>icp',
    \     'move-n': '<buffer>]cp',
    \     'move-p': '<buffer>[cp',
    \   },
    \   'function': {
    \     'select-a': '<buffer>afp',
    \     'select-i': '<buffer>ifp',
    \     'move-n': '<buffer>]fp',
    \     'move-p': '<buffer>[fp',
    \   }
    \ })
'''

[[plugins]]
repo = 'JesseKPhillips/d.vim'
on_ft = ['d']

[[plugins]]
repo = 'udalov/kotlin-vim'
on_ft = ['kotlin']

[[plugins]]
repo = 'mattn/vim-xxdcursor'
on_ft = ['xxd']

[[plugins]]
repo = 'vim-jp/syntax-vim-ex'
on_ft = ['vim']

[[plugins]]
repo = 'rbtnn/vim-vimscript_formatter'
on_ft = ['vim']

[[plugins]]
repo = 'rbtnn/vim-vimscript_indentexpr'
on_ft = ['vim']

[[plugins]]
repo = 'rbtnn/vim-vimscript_tagfunc'
on_ft = ['vim']

[[plugins]]
repo = 'thinca/vim-ft-help_fold'
on_ft = ['help']

[[plugins]]
repo = 'machakann/vim-vimhelplint'
on_ft = ['help']
[plugins.ftplugin]
help = '''
  nnoremap <silent><buffer> <LocalLeader>r <Cmd>VimhelpLint!<CR>
'''

[[plugins]]
repo = 'lfilho/cosco.vim'
depends = ['vim-repeat']
on_ft = ['javascript', 'typescript', 'jsx', 'json', 'css', 'php', 'c', 'cpp']
hook_source = '''
  augroup vimrc_init_cosco
    autocmd!
    " autocmd FileType "<ft>"
    "  \ nmap <silent><buffer> <Leader>; <Plug>(cosco-commaOrSemiColon)
    "   " \ | imap <silent><buffer> <Leader>; <c-o><Plug>(cosco-commaOrSemiColon)
    call execute(
      \  'autocmd FileType'
      \  . ' '
      \  . join(copy(g:dein#plugin['on_ft']), ',')
      \  . ' '
      \  . 'nmap <silent><buffer> <Leader>; <Plug>(cosco-commaOrSemiColon)'
      \)
  augroup END

  " comment ignore
  let g:cosco_ignore_comment_lines = 1

  " " allow/ignore
  " let g:cosco_filetype_whitelist = copy(g:dein#plugin['on_ft'])
  " let g:cosco_filetype_blacklist = []

  " " auto insert
  " let g:auto_comma_or_semicolon = 1
  " let g:auto_comma_or_semicolon_events = ["InsertLeave"]
'''

[[plugins]]
repo = 'ekalinin/Dockerfile.vim'
on_ft = ['Dockerfile', 'docker-compose']

[[plugins]]
repo = 'pboettch/vim-cmake-syntax'
on_ft = ['cmake']

[[plugins]]
repo = 'marshallward/vim-restructuredtext'
on_ft = ['rst']

[[plugins]]
repo = 'alcesleo/vim-uppercase-sql'
on_ft = ['sql']

[[plugins]]
repo = 'MTDL9/vim-log-highlighting'
on_ft = ['log']

[[plugins]]
repo = 'hashivim/vim-terraform'
on_ft = ['terraform']

[[plugins]]
repo = 'itchyny/vim-haskell-indent'
on_ft = ['haskell']

# EOF