[[plugins]]
repo = '4513echo/vim-readme-viewer'
on_cmd = ['DeinReadme']
on_source = 'ddu.vim'
on_func = ['readme_viewer#get', 'readme_viewer#open']
hook_add = '''
let g:readme_viewer#plugin_manager = 'dein.vim'
'''

[[plugins]]
repo = '4513echo/vim-vimhelp-url'
on_cmd = ['HelpUrl']
on_func = ['vimhelp_url#create']

[[plugins]]
# NOTE: latest original is broken for only Neovim
# repo = 'bronson/vim-trailing-whitespace'
repo = 'PabloScolpino/vim-trailing-whitespace'
on_cmd = ['FixWhitespace']
on_event = ['InsertLeave']
hook_add = '''
let g:extra_whitespace_ignored_filetypes = ['diff', 'help', 'capture', 'tsv']
'''

[[plugins]]
repo = 'christoomey/vim-tmux-navigator'
if = '!has("gui_running")'
on_cmd = [
  'TmuxNavigateLeft', 'TmuxNavigateDown',
  'TmuxNavigateUp', 'TmuxNavigateRight',
]
hook_add = '''
let g:tmux_navigator_no_mappings = v:true
nnoremap <C-w>h <Cmd>TmuxNavigateLeft<CR>
nnoremap <C-w>j <Cmd>TmuxNavigateDown<CR>
nnoremap <C-w>k <Cmd>TmuxNavigateUp<CR>
nnoremap <C-w>l <Cmd>TmuxNavigateRight<CR>
'''

[[plugins]]
repo = 'cocopon/lightline-hybrid.vim'
on_source = 'lightline.vim'

[[plugins]]
repo = 'cohama/lexima.vim'
on_event = ['InsertEnter', 'CmdlineEnter']
hook_add = '''
let g:lexima_no_default_rules = v:true
let g:lexima_ctrlh_as_backspace = v:true
'''
hook_source = '''
Runtime dein/settings/lexima.vim
'''

[[plugins]]
repo = 'github/copilot.vim'
on_cmd = 'Copilot'
on_event = 'InsertEnter'
hook_add = '''
let g:copilot_no_maps = v:true
inoremap <silent><expr> <C-g>g copilot#Accept()
inoremap <silent><expr> <C-g><C-g> copilot#Accept()
inoremap <C-g>] <Cmd>call copilot#Dismiss()<CR>
inoremap <C-g><C-]> <Cmd>call copilot#Dismiss()<CR>
autocmd vimrc OptionSet buftype
      \ : if !empty(&buftype) && &buftype !=# 'acwrite' && bufname() !=# 'mininote'
      \ |   let b:copilot_enabled = v:false
      \ | endif
'''

[[plugins]]
repo = 'halkn/lightline-lsp'
on_source = 'lightline.vim'

[[plugins]]
repo = 'haya14busa/dein-command.vim'
on_cmd = ['Dein']

[[plugins]]
repo = 'haya14busa/vim-asterisk'
on_map = { nx = '<Plug>' }
hook_add = '''
let g:asterisk#keeppos = v:true
nnoremap *  <Plug>(asterisk-z*)<Plug>(VimrcSearchPost)zzzv
nnoremap #  <Plug>(asterisk-z#)<Plug>(VimrcSearchPost)zzzv
nnoremap g* <Plug>(asterisk-gz*)<Plug>(VimrcSearchPost)zzzv
nnoremap g# <Plug>(asterisk-gz#)<Plug>(VimrcSearchPost)zzzv
xnoremap *  <Plug>(asterisk-z*)<Plug>(VimrcSearchPost)zzzv
xnoremap #  <Plug>(asterisk-z#)<Plug>(VimrcSearchPost)zzzv
xnoremap g* <Plug>(asterisk-gz*)<Plug>(VimrcSearchPost)zzzv
xnoremap g# <Plug>(asterisk-gz#)<Plug>(VimrcSearchPost)zzzv
'''

[[plugins]]
repo = 'haya14busa/vim-edgemotion'
on_map = { nx = '<Plug>' }
hook_add = '''
nnoremap <C-j> <Plug>(edgemotion-j)
nnoremap <C-k> <Plug>(edgemotion-k)
xnoremap <C-j> <Plug>(edgemotion-j)
xnoremap <C-k> <Plug>(edgemotion-k)
'''

[[plugins]]
repo = 'hrsh7th/vim-searchx'
on_func = ['searchx#']
hook_add = '''
let g:searchx = #{
      \ auto_accept: v:true,
      \ markers: split('ASDFGHJKLQWERTYUIOPZXCVBNM', '.\zs'),
      \ nohlsearch: #{ jump: v:true },
      \ scrolltime: 200,
      \ scrolloff: &scrolloff,
      \ }

function! g:searchx.convert(input) abort
  if a:input !~# '\k' && a:input !~# '\v^^|[*$]$'
    return '\V' .. a:input
  endif
  return a:input->split('\s\+')->join('.\{-}')
endfunction

autocmd vimrc User SearchxEnter
      \ call timer_start(10, { -> user#ddc#cmdline_pre('/') })
autocmd vimrc User SearchxLeave call searchx#clear()
autocmd vimrc User SearchxAccept normal! zzzv

nnoremap ? <Cmd>call searchx#start(#{ dir: 0 })<CR>
nnoremap / <Cmd>call searchx#start(#{ dir: 1 })<CR>
xnoremap ? <Cmd>call searchx#start(#{ dir: 0 })<CR>
xnoremap / <Cmd>call searchx#start(#{ dir: 1 })<CR>

cnoremap <C-g> <Cmd>call searchx#next_dir()<CR>
cnoremap <C-t> <Cmd>call searchx#prev_dir()<CR>

nnoremap N <Cmd>call searchx#prev_dir()<CR><Plug>(VimrcSearchPost)zzzv
nnoremap n <Cmd>call searchx#next_dir()<CR><Plug>(VimrcSearchPost)zzzv
xnoremap N <Cmd>call searchx#prev_dir()<CR><Plug>(VimrcSearchPost)zzzv
xnoremap n <Cmd>call searchx#next_dir()<CR><Plug>(VimrcSearchPost)zzzv
'''

[[plugins]]
repo = 'hrsh7th/vim-vsnip'
on_event = ['InsertEnter']
on_source = 'ddc.vim'
hook_add = '''
let g:vsnip_snippet_dir = g:config_home .. '/snippets'
inoremap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : ''
snoremap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : ''
'''

[[plugins]]
repo = 'itchyny/lightline.vim'
hook_add = '''
autocmd vimrc VimEnter * call timer_start(0, { -> dein#source('lightline.vim') })
'''
hook_source = '''
let g:lightline = #{
      \ subseparator: #{ left: '/', right: '/' },
      \ active: #{
      \   left: [
      \     ['mode', 'paste'],
      \     ['readonly', 'filename', 'modified'],
      \     ['protocol', 'ddu', 'lsp_progress'],
      \   ],
      \   right: [
      \     ['lsp_errors', 'lsp_warnings', 'lineinfo'],
      \     ['percent'],
      \     ['colorscheme', 'fileformat', 'fileencoding', 'filetype'],
      \   ],
      \ },
      \ inactive: #{ left: [ ['filename', 'modified'] ] },
      \ component_function: #{
      \   colorscheme: 'lightline#component#vimrc#colorscheme',
      \   ddu: 'lightline#component#vimrc#ddu',
      \   fileformat: 'lightline#component#vimrc#file_format',
      \   fileencoding: 'lightline#component#vimrc#file_encoding',
      \   filename: 'lightline#component#vimrc#filename',
      \   mode: 'lightline#component#vimrc#mode',
      \   readonly: 'lightline#component#vimrc#readonly',
      \   modified: 'lightline#component#vimrc#modified',
      \   protocol: 'lightline#component#vimrc#protocol',
      \   lsp_progress: 'lightline_lsp_progress#progress',
      \ },
      \ component: #{
      \   lineinfo: '%3l:%-2v',
      \ },
      \ component_expand: #{
      \   lsp_errors: 'lightline_lsp#errors',
      \   lsp_warnings: 'lightline_lsp#warnings',
      \ },
      \ component_type: #{
      \   lsp_errors: 'error',
      \   lsp_warnings: 'warning',
      \ },
      \ }

let &laststatus = has('nvim') ? 3 : 2
call user#colorscheme#update_lightline()
messages
'''

[[plugins]]
repo = 'junegunn/fzf'
on_func = ['fzf#']
merged = false
on_cmd = ['FZF']

[[plugins]]
repo = 'junegunn/fzf.vim'
depends = ['fzf']
on_cmd = [
  'FzfFiles', 'FzfGFiles', 'FzfBuffers', 'FzfColors', 'FzfAg', 'FzfRg',
  'FzfLines', 'FzfBLines', 'FzfTags', 'FzfBTags', 'FzfMarks', 'FzfWindows',
  'FzfLocate', 'FzfHistory', 'FzfSnippets', 'FzfCommits', 'FzfBCommits',
  'FzfCommands', 'FzfMaps', 'FzfHelptags', 'FzfFiletypes',
  'FzfGhq', 'FzfDein', 'FzFActions', 'FzfMru',
]
on_func = ['fzf#']
hook_add = '''
let g:fzf_command_prefix = 'Fzf'
let g:launcher_config.fzf = {
      \ 'char': 'f',
      \ 'run': 'FzFActions',
      \ }
'''
hook_source = '''
command! -bar FzfColors call fzf#run(fzf#wrap({
      \ 'source': keys(user#colorscheme#get()),
      \ 'sink': { arg -> user#colorscheme#command(arg) },
      \ }))
command! -bar FzfReadme call fzf#run(fzf#wrap({
      \ 'source': keys(readme_viewer#get()),
      \ 'sink': { arg -> readme_viewer#open(arg, '') },
      \ }))
command! -bar FzfGhq call fzf#run(fzf#wrap({
      \ 'source': 'ghq list --full-path',
      \ 'sink': 'edit',
      \ }))
command! -bar FzfDein call fzf#run(fzf#wrap({
      \ 'source': keys(dein#get()),
      \ 'sink': { arg -> execute('edit ' .. dein#get(arg).path) },
      \ }))
command! -bar FzFActions call fzf#run(fzf#wrap({
      \ 'source': map(split(execute('command Fzf'), "\n")[1:],
      \   { _, val -> matchstr(val, '\<Fzf\a\+\>') }),
      \ 'sink': { arg -> execute(arg) },
      \ }))
command! -bar FzfMru call fzf#run(fzf#wrap({
      \ 'source': mr#mru#list(),
      \ 'sink': 'edit',
      \ }))
'''

[[plugins]]
repo = 'kana/vim-niceblock'
on_map = { x = '<Plug>' }
hook_add = '''
xnoremap I  <Plug>(niceblock-I)
xnoremap gI <Plug>(niceblock-gI)
xnoremap A  <Plug>(niceblock-A)
'''

[[plugins]]
repo = 'kana/vim-submode'
on_map = { nx = [
  '<C-w>+', '<C-w>-', '<C-w>>', '<C-w><',
  'zl', 'zh', 'zL', 'zH', 'zj', 'zk',
] }
hook_add = '''
let g:submode_always_show_submode = v:true
let g:submode_keep_leaving_key = v:true
'''
hook_source = '''
" resize window
call submode#enter_with('winsize', 'n', '', '<C-w>>', '<C-w>>')
call submode#enter_with('winsize', 'n', '', '<C-w><', '<C-w><')
call submode#enter_with('winsize', 'n', '', '<C-w>+', '<C-w>+')
call submode#enter_with('winsize', 'n', '', '<C-w>-', '<C-w>-')
call submode#map('winsize', 'n', '', '>', '<C-w>>')
call submode#map('winsize', 'n', '', '<', '<C-w><')
call submode#map('winsize', 'n', '', '+', '<C-w>+')
call submode#map('winsize', 'n', '', '-', '<C-w>-')

" scroll but cursor doesn't move
call submode#enter_with('nomove', 'nx', '', 'zl', 'zl')
call submode#enter_with('nomove', 'nx', '', 'zh', 'zh')
call submode#enter_with('nomove', 'nx', '', 'zL', 'zL')
call submode#enter_with('nomove', 'nx', '', 'zH', 'zH')
call submode#enter_with('nomove', 'nx', '', 'zj', '<C-e>')
call submode#enter_with('nomove', 'nx', '', 'zk', '<C-y>')
call submode#map('nomove', 'nx', '', 'l', 'zl')
call submode#map('nomove', 'nx', '', 'h', 'zh')
call submode#map('nomove', 'nx', '', 'L', 'zL')
call submode#map('nomove', 'nx', '', 'H', 'zH')
call submode#map('nomove', 'nx', '', 'j', '<C-e>')
call submode#map('nomove', 'nx', '', 'k', '<C-y>')
'''

[[plugins]]
repo = 'kyoh86/vim-ripgrep'
on_cmd = ['Rg']
hook_source = '''
function! s:ripgrep(args, bang) abort
  let root = a:bang ? ['.git'] : ['.']
  let cwd = ripgrep#path#traverse_root(getcwd(), root)
  let cmd = ['rg', '--json', &smartcase ? '--smart-case' : '', a:args]
  echomsg join(cmd)
  call ripgrep#call(join(cmd), cwd[0], cwd[1])
endfunction
command! -bar -bang -nargs=1 Rg call s:ripgrep(<q-args>, <bang>0)
'''

[[plugins]]
repo = 'lambdalisue/file-protocol.vim'
on_path = '^file://'

[[plugins]]
repo = 'lambdalisue/kensaku.vim'
denops_wait = false
hook_add = '''
let s:kensaku_state = #{ cmdline: '', converted: v:false }
function! s:convert_kensaku() abort
  if !s:kensaku_state.converted
    let s:kensaku_state.cmdline = getcmdline()
    let query = kensaku#query(s:kensaku_state.cmdline)
    " NOTE: Ignore regexp bug
    call setcmdline(query->substitute('\\+α', '+α', 'g'))
  else
    call setcmdline(s:kensaku_state.cmdline)
  endif
  let s:kensaku_state.converted = !s:kensaku_state.converted
endfunction
autocmd vimrc CmdlineLeave * let s:kensaku_state.converted = v:false
cnoremap <C-x><C-k> <Cmd>call <SID>convert_kensaku()<CR>
'''

[[plugins]]
repo = 'lambdalisue/suda.vim'
on_cmd = ['SudaRead', 'SudaWrite']

[[plugins]]
repo = 'lambdalisue/vim-protocol'
on_path = '^https\?://'

[[plugins]]
repo = 'lambdalisue/vim-quickrun-neovim-job'
if = 'has("nvim")'
on_source = ['vim-quickrun']

[[plugins]]
repo = 'machakann/vim-highlightedundo'
on_map = { n = '<Plug>' }
hook_add = '''
nnoremap u     <Plug>(highlightedundo-undo)
nnoremap <C-r> <Plug>(highlightedundo-redo)
nnoremap U     <Plug>(highlightedundo-Undo)
nnoremap g-    <Plug>(highlightedundo-gminus)
nnoremap g+    <Plug>(highlightedundo-gplus)
'''

[[plugins]]
repo = 'mattn/vim-lsp-settings'
depends = 'vim-lsp'
on_event = ['BufRead']
hook_add = '''
Runtime dein/settings/vim-lsp.vim
'''
hook_source = '''
if v:vim_did_enter
  call timer_start(0, { -> lsp#enable() })
else
  autocmd vimrc VimEnter *  call timer_start(0, { -> lsp#enable() })
endif
'''

[[plugins]]
repo = 'mattn/vim-maketable'
on_cmd = ['MakeTable', 'UnmakeTable']

[[plugins]]
repo = 'mattn/vim-sonictemplate'
on_map = { n = '<Plug>' }
hook_add = '''
let g:sonictemplate_vim_template_dir = [
      \ g:config_home .. '/template',
      \ ]
let g:sonictemplate_vim_vars = #{
      \ _: #{
      \   author: 'Hibiki',
      \ },
      \ help: #{
      \   author: 'Hibiki <4513echo@gmail.com>'
      \ },
      \ }
let g:sonictemplate_postfix_key = ''
nnoremap <C-x>T <Plug>(sonictemplate)
nnoremap <C-x><C-t> <Plug>(sonictemplate-intelligent)
'''

[[plugins]]
repo = 'mhinz/vim-signify'
on_event = ['BufRead']
hook_add = '''
call setcellwidths([[0x2503, 0x2503, 1]])
let g:signify_sign_add               = '┃'
let g:signify_sign_change            = '┃'
let g:signify_sign_delete            = '┃'
let g:signify_sign_delete_first_line = '┃'
let g:signify_line_highlight = v:false
'''

[[plugins]]
repo = 'micchy326/lightline-lsp-progress'
on_source = 'lightline.vim'

[[plugins]]
repo = 'ojroques/vim-oscyank'
if = '!has("gui_running")'
on_cmd = 'OSCYankRegister'
hook_add = '''
autocmd vimrc TextYankPost *
      \ : if v:event.regname ==# 'p'
      \ |   execute 'OSCYankRegister p'
      \ | endif
'''

[[plugins]]
repo = 'osyo-manga/vim-jplus'
on_map = { nx = '<Plug>' }
hook_add = '''
nnoremap J  <Plug>(jplus-getchar)<Space>
xnoremap J  <Plug>(jplus-getchar)<Space>
nnoremap gJ <Plug>(jplus)
xnoremap gJ <Plug>(jplus)
let g:jplus#config = #{
      \ _: #{
      \   delimiter: '',
      \   right_matchstr_pattern: '^\s*#\s*\zs.*\|\s*\zs.*',
      \   left_matchstr_pattern: '^.\{-}\%(\ze\s*\\$\|$\)',
      \ },
      \ vim: #{
      \   right_matchstr_pattern: '^\s*\\\s*\zs.*\|^\s*"\s*\zs.*\|\s*\zs.*',
      \ }}
'''

[[plugins]]
repo = 'prabirshrestha/vim-lsp'
on_source = 'vim-lsp-settings'

[[plugins]]
repo = 'shinchu/lightline-gruvbox.vim'
on_source = 'lightline.vim'

[[plugins]]
repo = 'Shougo/context_filetype.vim'
on_func = ['context_filetype#get']
hook_source = '''
let g:context_filetype#filetypes = extend(
      \ copy(context_filetype#default_filetypes()),
      \ #{ markdown:
      \   {'\(\h\w*\)': '\1', 'viml': 'vim'}
      \   ->map({ key, val -> #{
      \     start: '^\s*```\s*' .. key,
      \     end: '^\s*```$',
      \     filetype: val,
      \   } })
      \   ->values(),
      \ })
let g:context_filetype#ignore_patterns = #{
      \ toml: ['^\s*#\s*'],
      \ }
'''

[[plugins]]
repo = 'skanehira/denops-translate.vim'
depends = ['denops.vim']
on_cmd = ['Translate']
hook_add = '''
nnoremap <Leader>t <Cmd>Translate<CR>
xnoremap <Leader>t :Translate<CR>
'''

[[plugins]]
repo = 'statiolake/vim-quickrun-runner-nvimterm'
if = 'has("nvim")'
on_source = ['vim-quickrun']

[[plugins]]
repo = 'rhysd/clever-f.vim'
on_map = { nxo = '<Plug>(clever-f' }
hook_add = '''
nnoremap F <Plug>(clever-f-F)
nnoremap T <Plug>(clever-f-T)
nnoremap f <Plug>(clever-f-f)
nnoremap t <Plug>(clever-f-t)
onoremap F <Plug>(clever-f-F)
onoremap T <Plug>(clever-f-T)
onoremap f <Plug>(clever-f-f)
onoremap t <Plug>(clever-f-t)
xnoremap F <Plug>(clever-f-F)
xnoremap T <Plug>(clever-f-T)
xnoremap f <Plug>(clever-f-f)
xnoremap t <Plug>(clever-f-t)
nnoremap ;         <Plug>(clever-f-repeat-forward)
nnoremap <Leader>, <Plug>(clever-f-repeat-back)
xnoremap ;         <Plug>(clever-f-repeat-forward)
xnoremap <Leader>, <Plug>(clever-f-repeat-back)
onoremap ;         <Plug>(clever-f-repeat-forward)
onoremap <Leader>, <Plug>(clever-f-repeat-back)
let g:clever_f_across_no_line = v:true
let g:clever_f_ignore_case = v:true
let g:clever_f_smart_case = v:true
let g:clever_f_use_migemo = v:true
let g:clever_f_chars_match_any_signs = "\<C-g>"
let g:clever_f_timeout_ms = 5000
autocmd vimrc ColorScheme *
      \ hi def CleverFDefaultLabel guifg=red guibg=NONE gui=bold,underline
'''

[[plugins]]
repo = 'RRethy/vim-hexokinase'
on_event = ['BufRead', 'InsertLeave']
hook_add = '''
let g:Hexokinase_highlighters = ['backgroundfull']
let g:Hexokinase_optOutPatterns = ['colour_names']
let g:Hexokinase_ftOptInPatterns = #{
      \ css: [
      \   'full_hex', 'triple_hex', 'rgb',
      \   'rgba', 'hsl', 'hsla', 'colour_names'
      \ ],
      \ html: [
      \   'full_hex', 'triple_hex', 'rgb',
      \   'rgba', 'hsl', 'hsla', 'colour_names'
      \ ],
      \ }
let g:Hexokinase_ftDisabled = ['molder', 'ddu-ff', 'ddu-ff-filter']
let g:Hexokinase_executable_path = exepath('hexokinase')
'''

[[plugins]]
repo = 't9md/vim-choosewin'
on_map = { n = '<Plug>' }
hook_add = '''
let g:choosewin_overlay_enable = v:true
let g:choosewin_overlay_clear_multibyte = v:true
nnoremap <C-w>w <Plug>(choosewin)
'''

[[plugins]]
repo = 'tani/glance-vim'
depends = ['denops.vim']
on_cmd = ['Glance']
hook_add = '''
let g:glance#markdown_html = v:true
let g:glance#markdown_linkify = v:true
let g:glance#markdown_breaks = v:true
let g:glance#stylesheet = '@import url("https://unpkg.com/sakura.css/css/sakura.css");'
'''

[[plugins]]
repo = 'thinca/vim-localrc'
on_event = ['BufRead']
hook_add = '''
let g:localrc_filename = '.vimrc.local'
'''

[[plugins]]
repo = 'thinca/vim-partedit'
depends = ['context_filetype.vim']
on_cmd = ['Partedit']
on_func = ['partedit#start']
hook_add = '''
let g:partedit#opener = 'split'
function! s:operator_partedit() abort
  let context = context_filetype#get()
  if context.range == [[0, 0], [0, 0]]
    echohl WarningMsg
    echomsg '[partedit] Context is not found'
    echohl NONE
    return
  endif
  call partedit#start(context.range[0][0], context.range[1][0],
        \ #{ filetype: context.filetype })
  nnoremap <buffer> q <Cmd>ParteditEnd<Bar>close<CR>
endfunction
nnoremap <C-x><C-x> <Cmd>call <SID>operator_partedit()<CR>
'''
[plugins.ftplugin]
help = '''
let b:partedit_filetype = 'vim'
let b:partedit_prefix = "\<Tab>"
'''
toml = '''
let b:partedit_filetype = 'vim'
let b:partedit_auto_prefix = v:false
'''

[[plugins]]
repo = 'thinca/vim-quickrun'
on_cmd = ['QuickRun']
on_map = { nx = '<Plug>' }
hook_add = '''
nnoremap <Leader>rr <Plug>(quickrun)
nnoremap <Leader>r <Plug>(quickrun-op)
xnoremap <Leader>r <Plug>(quickrun)
nnoremap <silent><expr> <C-c> quickrun#session#exists()
      \ ? '<Cmd>call quickrun#session#sweep()<CR>'
      \ : '<C-c>'
let g:quickrun_config = {
      \ '_': {
      \   'hook/time/enable': v:false,
      \   'outputter': 'buffer',
      \   'outputter/buffer/close_on_empty': v:true,
      \   'outputter/buffer/opener': 'botright 10new',
      \   'outputter/error/error': 'quickfix',
      \   'outputter/error/success': 'buffer',
      \   'runner': has('nvim') ? 'neovim_job' : 'job',
      \   'runner/nvimterm/opener': 'botright 10new',
      \   'runner/terminal/opener': 'botright 10new',
      \ },
      \ 'typescript': #{
      \   type: 'deno/run',
      \ },
      \ 'typescriptreact': #{
      \   type: 'deno/run',
      \ },
      \ 'sh': #{
      \   runner: has('nvim') ? 'nvimterm' : 'terminal',
      \ },
      \ 'zsh': #{
      \   runner: has('nvim') ? 'nvimterm' : 'terminal',
      \ },
      \ 'json': #{
      \   type: 'json/gojq',
      \ },
      \ 'json/gojq': #{
      \   command: 'gojq',
      \   exec: '%c %o %a < %s',
      \ },
      \ 'yaml': #{
      \   type: 'yaml/yq',
      \ },
      \ 'yaml/yq': #{
      \   cmdopt: '--output-format=json',
      \   command: 'yq',
      \   exec: '%c eval %o < %s',
      \   tempfile: '%{tempname()}.json',
      \ },
      \ 'lua': #{
      \   type: 'lua/vim',
      \ },
      \ 'deno/run': #{
      \   cmdopt: '--no-check --allow-all --unstable',
      \   command: 'deno',
      \   exec: 'NO_COLOR=1 %c run %o %s %a',
      \   tempfile: '%{tempname()}.ts',
      \ },
      \ 'deno/terminal': #{
      \   cmdopt: '--no-check --allow-all --unstable',
      \   command: 'deno',
      \   exec: '%c run %o %s %a',
      \   runner: has('nvim') ? 'nvimterm' : 'terminal',
      \   tempfile: '%{tempname()}.ts',
      \ },
      \ 'deno/test': #{
      \   cmdopt: '--no-check --allow-all --unstable',
      \   command: 'deno',
      \   exec: 'NO_COLOR=1 %c test %o %s %a',
      \   tempfile: '%{tempname()}.ts',
      \ },
      \ }
" from https://github.com/aiotter/dotfiles/blob/8e759221/.config/nvim/plugins/others.toml#L27
autocmd vimrc WinEnter *
      \ : if winnr('$') == 1 && &filetype == 'quickrun'
      \ |   quit
      \ | endif
'''
[plugins.ftplugin]
quickrun = '''
nnoremap <buffer> q <C-w>q
nnoremap <buffer> <C-c> <Cmd>call quickrun#session#sweep()<CR>
'''

[[plugins]]
repo = 'tweekmonster/helpful.vim'
on_cmd = ['HelpfulVersion']

[[plugins]]
repo = 'tyru/capture.vim'
on_cmd = ['Capture', 'CaptureJson']
hook_source = '''
command! -bang -bar -nargs=1 -complete=expression CaptureJson
      \ call s:capture_json(<f-args>, '<bang>')
function! s:capture_json(value, bang) abort
  execute printf('Capture%s echo json_encode(%sto_string(%s))',
        \ a:bang, expand('<SID>'), a:value)
  if &filetype ==# 'capture'
    silent! execute '%!gojq'
    setlocal filetype=json
  endif
endfunction
function! s:to_string(expr) abort
  let type = type(a:expr)
  if type ==# v:t_list || type ==# v:t_dict
    return copy(a:expr)->map({ _, val -> s:to_string(val) })
  elseif type ==# v:t_func
    return string(a:expr)
  endif
  return a:expr
endfunction
'''
[plugins.ftplugin]
capture = '''
nnoremap <buffer> q <C-w>q
'''

[[plugins]]
repo = 'tyru/caw.vim'
on_map = { nx = '<Plug>' }
depends = ['context_filetype.vim', 'vim-operator-user']
hook_add = '''
let g:caw_operator_keymappings = v:true
let g:caw_no_default_keymappings = v:true
nnoremap <silent> <Bslash><Bslash> <Plug>(caw:hatpos:toggle)
nnoremap <silent> <Bslash>         <Plug>(caw:hatpos:toggle:operator)
xnoremap <silent> <Bslash>         <Plug>(caw:hatpos:toggle:operator)
'''
# NOTE: Workaround of https://github.com/tyru/caw.vim/issues/183
# based on https://github.com/tyru/caw.vim/pulls/185
lua_add = '''
local M = {}
---@param lnum integer
---@param col integer
---@return boolean
function M.has_syntax(lnum, col)
  local bufnr = vim.api.nvim_get_current_buf()
  local items = vim.inspect_pos(bufnr, lnum - 1, col - 1)
  if #items.treesitter > 0 then
    for _, capture in ipairs(items.treesitter) do
      if capture.capture == "comment" then
        return true
      end
    end
  end
  return false
end
---@diagnostic disable-next-line: duplicate-set-field
_G.package.preload.caw = function() return M end
'''
[plugins.ftplugin]
gitcommit = '''
let b:caw_oneline_comment = ';'
'''

[[plugins]]
repo = 'tyru/open-browser.vim'
on_func = ['openbrowser#open']
on_map = { nx = '<Plug>(openbrowser' }
hook_add = '''
nnoremap gx <Plug>(openbrowser-smart-search)
xnoremap gx <Plug>(openbrowser-smart-search)
let g:openbrowser_allowed_schemes = ['http', 'https']
let g:openbrowser_browser_commands = []
      \ + (empty($DISPLAY) ? [] : [#{
      \   name: 'xdg-open',
      \   args: ['{browser}', '{uri}'],
      \ }])
      \ + (empty($TMUX) ? [] : [#{
      \   name: 'w3m',
      \   args: 'tmux-w3m {uri} -t open-browser',
      \ }])
'''

[[plugins]]
repo = 'yuttie/comfortable-motion.vim'
on_func = 'comfortable_motion#flick'
hook_add = '''
let g:comfortable_motion_no_default_key_mappings = v:true
nnoremap <silent> <C-d> <Cmd>call comfortable_motion#flick(winheight(0) * 2)<CR>
nnoremap <silent> <C-u> <Cmd>call comfortable_motion#flick(winheight(0) * -2)<CR>
nnoremap <silent> <C-f> <Cmd>call comfortable_motion#flick(winheight(0) * 4)<CR>
nnoremap <silent> <C-b> <Cmd>call comfortable_motion#flick(winheight(0) * -4)<CR>
'''