#####################################################################
# Edit util
#####################################################################

[[plugins]]
repo = 'haya14busa/vim-asterisk'
on_map = [
    '<Plug>(asterisk-z*)',
    '<Plug>(asterisk-z#)',
    '<Plug>(asterisk-gz*)',
    '<Plug>(asterisk-gz#)',
]
hook_add = '''
    map *  <Plug>(asterisk-z*)
    map #  <Plug>(asterisk-z#)
    map g* <Plug>(asterisk-gz*)
    map g# <Plug>(asterisk-gz#)
'''

[[plugins]]
repo = 'mattn/vim-sqlfmt'
on_ft = ['sql']
on_map = ['<Plug>(sqlfmt)']
on_cmd = ['SQLFmt']
hook_add = '''
    " Install command `pip install sqlparse`
    let sqlfmt_bin = fnamemodify(g:python3_host_prog, ':h') . '/'. 'sqlformat'
    let g:sqlfmt_program = sqlfmt_bin . ' -r -k upper -o %s -'
'''

[[plugins]]
repo = 'mattn/emmet-vim'
on_ft = ['html', 'djangohtml']

#####################################################################
# Programing util
#####################################################################

[[plugins]]
repo = 'tyru/caw.vim'
on_map = ['<Plug>(caw:hatpos:toggle)', '<Plug>(caw:zeropos:toggle)']
hook_add = '''
    " Add comment to beginning line(consider whitespace)
    nmap <Leader>c <Plug>(caw:hatpos:toggle)
    vmap <Leader>c <Plug>(caw:hatpos:toggle)
    " Add comment to beginning line(ignore whitespace)
    nmap <Leader>, <Plug>(caw:zeropos:toggle)
    vmap <Leader>, <Plug>(caw:zeropos:toggle)
'''

[[plugins]]
repo = 'thinca/vim-quickrun'
on_cmd = ['QuickRun']
depends = ['vim-quickrun-neovim-job']
hook_add = '''
    nnoremap <Leader>r :<C-U>QuickRun<CR>
    xnoremap <Leader>r gv:<C-U>QuickRun<CR>
'''
hook_source = 'source ~/.vim/rc/plugins/vimquickrun.rc.vim'

[[plugins]]
repo = 'lambdalisue/vim-quickrun-neovim-job'

[[plugins]]
repo = 'nicwest/vim-camelsnek'
on_cmd = ['Camel', 'CamelB', 'Snek']

[[plugins]]
repo = 'Yggdroot/indentLine'
on_cmd = ['IndentLinesToggle']
hook_add = '''
    nnoremap <silent> <Leader>i :<C-u>IndentLinesToggle<CR>
'''

# [[plugins]]
# repo = 'vim-test/vim-test'
# on_cmd = [
#     'TestNearest',
#     'TestFile',
#     'TestSuite',
#     'TestLast',
#     'TestVisit',
# ]
# depends = ['tpope/vim-dispatch']
# hook_add = '''
#     let g:test#strategy = "dispatch"
#     nnoremap <silent> <Leader>tt :TestNearest<CR>
#     nnoremap <silent> <Leader>tf :TestFile<CR>
#     nnoremap <silent> <Leader>ts :TestSuite<CR>
#     nnoremap <silent> <Leader>tl :TestLast<CR>
#     nnoremap <silent> <Leader>tv :TestVisit<CR>
# '''
# 
# [[plugins]]
# repo = 'tpope/vim-dispatch'

[[plugins]]
repo = 'prettier/vim-prettier'
build = 'yarn install'
on_ft = [
    'javascript',
    'javascript.jsx',
    'javascriptreact',
    'typescript',
    'typescript.tsx',
    'typescriptreact',
]
hook_add = '''
    nmap <Leader>py <Plug>(Prettier)
'''

#####################################################################
# Fuzzy Finder
#####################################################################

[[plugins]]
repo = 'junegunn/fzf'
build = './install --all'

[[plugins]]
repo = 'ryanoasis/vim-devicons'

[[plugins]]
repo = 'yuki-yano/fzf-preview.vim'
rev = 'release/rpc'
depends = ['fzf', 'vim-devicons']
on_cmd = [
    'FzfPreviewFromResourcesRpc',
    'FzfPreviewGitStatusRpc',
    'FzfPreviewBuffersRpc',
    'FzfPreviewLinesRpc',
    'FzfPreviewCtagsRpc',
    'FzfPreviewBufferTagsRpc',
    'FzfPreviewFromResourcesRpc',
]
hook_add = '''
    nmap [fuzzyf] <Nop>
    map <C-j> [fuzzyf]
    nnoremap <silent> [fuzzyf]<C-p> :<C-u>FzfPreviewFromResourcesRpc project_mru git<CR>
    nnoremap <silent> [fuzzyf]<C-s> :<C-u>FzfPreviewGitStatusRpc<CR>
    nnoremap <silent> [fuzzyf]<C-b> :<C-u>FzfPreviewBuffersRpc<CR>
    nnoremap <silent> [fuzzyf]<C-l> :<C-u>FzfPreviewLinesRpc --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"<CR>
    nnoremap <silent> [fuzzyf]<C-]> :<C-u>FzfPreviewCtagsRpc<CR>
    nnoremap <silent> [fuzzyf]<C-o> :<C-u>FzfPreviewBufferTagsRpc<CR>
    nnoremap <silent> [fuzzyf]<C-r> :<C-u>FzfPreviewFromResourcesRpc buffer project_mru<CR>
'''
hook_source = 'source ~/.vim/rc/plugins/fzf.rc.vim'

#####################################################################
# Other Util
#####################################################################

[[plugins]]
repo = 'kannokanno/previm'
depends = ['open-browser.vim']
on_cmd = ['PrevimOpen']
hook_add = '''
    nnoremap <leader>p :PrevimOpen<CR>
'''

[[plugins]]
repo = 'tyru/open-browser.vim'
on_map = ['<Plug>(openbrowser-smart-search)']
hook_add = '''
    let g:netrw_nogx = 1 " disable netrw's gx mapping.
    nmap <Leader>bb <Plug>(openbrowser-smart-search)
    vmap <Leader>bb <Plug>(openbrowser-smart-search)
'''

[[plugins]]
repo = 'tyru/open-browser-github.vim'
depends = ['open-browser.vim']
on_cmd = ['OpenGithubFile']
hook_add = '''
    nmap <Leader>bh :<C-u>OpenGithubFile<CR>
    vmap <Leader>bh :<C-u>OpenGithubFile<CR>
'''

[[plugins]]
repo = 'iberianpig/tig-explorer.vim'
on_cmd = [
    'TigStatus',
    'TigOpenCurrentFile',
]
hook_add = '''
    nnoremap <silent> <Leader>s :<C-u>TigStatus<CR>
    nnoremap <silent> <Leader>k :<C-u>TigOpenCurrentFile<CR>
'''

[[plugins]]
repo = 'rhysd/git-messenger.vim'
on_cmd = ['GitMessenger']
hook_add = '''
    let g:git_messenger_no_default_mappings = v:true
    nnoremap <Leader>g :<C-u>GitMessenger<CR>
'''

[[plugins]]
repo = 'junegunn/goyo.vim.git'
on_ft = ['markdown']
hook_add = '''
    function! s:goyo_enter()
        set noshowmode
        set noshowcmd
        set scrolloff=999
    endfunction

    function! s:goyo_leave()
        set showmode
        set showcmd
        set scrolloff=5
    endfunction

    augroup GoyoVisual
        autocmd!
        autocmd User GoyoEnter nested call <SID>goyo_enter()
        autocmd User GoyoLeave nested call <SID>goyo_leave()
    augroup END
'''