[[plugins]]
repo = 'Shougo/denite.nvim'
on_event = 'CmdlineEnter'
hook_source = '''
  source ~/dotfiles/nvim/plugins/denite.rc.vim
'''

[[plugins]]
repo = 'thinca/vim-quickrun'
on_cmd = 'QuickRun'
hook_add = '''
  nnoremap <silent><Leader>d <cmd>QuickRun<CR>
'''
hook_source = '''
  source ~/dotfiles/nvim/plugins/quickrun.rc.vim
'''

[[plugins]]
repo = 'vim-jp/vital.vim'
on_cmd = 'Vitalize'

[[plugins]]
repo = 'itchyny/calendar.vim'
on_cmd = 'Calendar'
hook_source = '''
  if filereadable(expand('~/.cache/calendar.vim/credentials.vim', ':h:p'))
    let g:calendar_google_calendar = 1
    let g:calendar_google_task = 1
    source ~/.cache/calendar.vim/credentials.vim
  endif
'''
[plugins.ftplugin]
calendar = '''
  nnoremap <buffer> <C-j> gT
  nnoremap <buffer> <C-k> gt
'''

[[plugins]]
repo = 'Shougo/defx.nvim'
depends = ['defx-icons']
hook_source = '''
  source ~/dotfiles/nvim/plugins/defx.rc.vim
'''
hook_add = '''
  nnoremap <silent> <C-f> <cmd>Defx -buffer-name=`'defx' . t:defx_index`<CR>
  nnoremap <silent> <Space>w <cmd>Defx -buffer-name=`'defx' . t:defx_index` ~/work<CR>
  nnoremap <silent> <Space>p <cmd>Defx -buffer-name=`'defx' . t:defx_index` ~/.cache/dein/repos/github.com<CR>
'''

[[plugins]]
repo = 'kristijanhusak/defx-icons'
hook_add = '''
  let g:defx_icons_column_length = 2
'''

[[plugins]]
repo = 'Shougo/deol.nvim'
hook_add = '''
  tnoremap <C-\><C-\> <C-\><C-N><cmd>Deol -no-auto-cd -toggle<CR>
  nnoremap <expr> <C-\><C-\> '<cmd>Deol -no-auto-cd -toggle -winwidth=' . &columns/2 . ' ' .
  \ ((winnr('$') == 1 && bufname()=='') ? '<CR>' : '-split=vertical<CR>')
  nnoremap <C-\>j <cmd>Deol -no-auto-cd -toggle -split=h<CR>
'''

[[plugins]]
repo = 'rhysd/clever-f.vim'
on_map = {nxo = '<Plug>'}
hook_add = '''
  let g:clever_f_not_overwrites_standard_mappings = 1
  let g:clever_f_mark_direct = 1
  let g:clever_f_smart_case = 1
  let g:clever_f_use_migemo = 1
  nmap f <Plug>(clever-f-f)
  xmap f <Plug>(clever-f-f)
  omap f <Plug>(clever-f-f)
  nmap F <Plug>(clever-f-F)
  xmap F <Plug>(clever-f-F)
  omap F <Plug>(clever-f-F)
  nmap t <Plug>(clever-f-t)
  xmap t <Plug>(clever-f-t)
  omap t <Plug>(clever-f-t)
  nmap T <Plug>(clever-f-T)
  xmap T <Plug>(clever-f-T)
  omap T <Plug>(clever-f-T)
'''

[[plugins]]
repo = 'tyru/open-browser.vim'
on_map = '<Plug>(openbrowser'
on_cmd = 'OpenBrowserSearch'
hook_add = '''
	nmap gx <Plug>(openbrowser-smart-search)
	vmap gx <Plug>(openbrowser-smart-search)
'''
hook_source = '''
  for cmd in ['wsl-open', 'xdg-open', 'exo-open']
    if executable(cmd)
      let g:openbrowser_browser_commands = [
      \   {'name': cmd,
      \  "args": ["{browser}", "{uri}"]},
      \]
    endif
  endfor
'''

[[plugins]]
repo = 'previm/previm'
on_cmd = 'PrevimOpen'
hook_source = '''
  let g:previm_show_header=0
  if vimrc#is_wsl()
    let g:previm_open_cmd='wsl-open'
  endif
'''
depends = 'open-browser.vim'

[[plugins]]
repo = 'tani/glance-vim'
on_cmd = 'Glance'
hook_add = '''
  let g:glance#server_open = v:false
  let g:glance#markdown_plugins = ['https://esm.sh/markdown-it-mathjax3?bundle']
'''

[[plugins]]
repo = 'tyru/caw.vim'
on_map = {nx = '<Plug>'}
if = '!has("nvim")'
hook_add = '''
  nmap gc <Plug>(caw:prefix)
  xmap gc <Plug>(caw:prefix)
  nmap gcc <Plug>(caw:hatpos:toggle)
  xmap gcc <Plug>(caw:hatpos:toggle)
'''

[[plugins]]
repo = 'lambdalisue/gina.vim'
on_source = 'denite.nvim'
hook_add = '''
  nnoremap gnl <cmd>Gina log<CR>
  nnoremap gnw <cmd>Gina browse<CR>
  nnoremap gn<Space> :Gina<Space>
'''
hook_source = '''
	call gina#custom#mapping#nmap(
	      \ '/.*', '<C-j>',
	      \ 'gT'
	      \)
	call gina#custom#mapping#nmap(
	      \ '/.*', '<C-k>',
	      \ 'gt'
	      \)
	call gina#custom#mapping#nmap(
	      \ 'status', '<Space>gc',
	      \ ':<C-u>Gina commit<CR>',
	      \ {'noremap': 1, 'silent': 1},
	      \)
	call gina#custom#mapping#nmap(
	      \ 'status', '<Space>gp',
	      \ ':<C-u>Gina push<CR>',
	      \ {'noremap': 1},
	      \)
	call gina#custom#mapping#nmap(
	      \ 'branch', 'o',
	      \ ':call gina#action#call(''new'')<CR>',
	      \ {'noremap': 1, 'silent': 1},
	      \)
	call gina#custom#mapping#nmap(
	      \ 'branch', 'dd',
	      \ ':call gina#action#call(''delete'')<CR>',
	      \ {'noremap': 1, 'silent': 1},
	      \)
'''

[[plugins]]
repo = 'lambdalisue/gin.vim'
on_event = 'CmdlineEnter'
hook_add = '''
  nnoremap gs <cmd>GinStatus<CR>
  nnoremap gnb <cmd>GinBranch -a<CR>
  nnoremap gnl <cmd>GinLog --graph 
  \ --pretty=format:%Cred%h%Creset\ -%C(yellow)%d%Creset\ %s\ %Cgreen(%ai)\ %C(bold\ blue)<%an>%Creset
  \ <CR>
'''
[plugins.ftplugin]
gin-status = '''
  nnoremap <buffer> <Space>gc <cmd>Gin commit<CR>
  nnoremap <buffer> <Space>gp :Gin push<CR>
'''
gin-branch = '''
  nmap <buffer> o <Plug>(gin-action-new)
  nmap <buffer> dd <Plug>(gin-action-delete)
'''
gitcommit = '''
  setlocal spell
'''
 
[[plugins]]
repo = 'nvim-treesitter/nvim-treesitter'
if = 'has("nvim")'
on_event = 'BufRead'
lua_source = '''
require'nvim-treesitter.configs'.setup {
    highlight = {
        enable = true,
        disable = {'latex', 'help'},
    },
    refactor = {
      highlight_defintions = {
        enable = true
      },
      smart_rename = {
        enable = true,
        smart_rename = 'grr'
      },
      navigation = {
        enable = true,
        goto_definition = 'gnd',
        list_definitions = 'gnD'
      }
    },
    ignore_install = { "phpdoc", "help" },
    ensure_installed = 'all'
}
'''

[[plugins]]
repo = 'nvim-treesitter/playground'
on_source = 'nvim-treesitter'

[[plugins]]
repo = 'neovim/nvim-lspconfig'
if = 'has("nvim")'
on_event = 'BufRead'
lua_source = '''
  require('lsp_rc')
'''

[[plugins]]
repo = "jose-elias-alvarez/null-ls.nvim"
on_source = 'nvim-lspconfig'
depends = ['plenary.nvim']
lua_source = '''
  local null_ls = require("null-ls")
  vim.diagnostic.config({ 
    virtual_text = false,
    severity_sort = true,
  })
  null_ls.setup({
    sources = {
      null_ls.builtins.formatting.black,
      null_ls.builtins.formatting.deno_fmt.with({
        filetypes = { "markdown" }, -- only runs `deno fmt` for markdown
      }),
    },
  })
'''
hook_add = '''
  nnoremap \f <cmd>lua vim.lsp.buf.format({ async = true })<CR>
  nnoremap gm <cmd>lua vim.diagnostic.open_float()<CR>
'''

[[plugins]]
repo = "liuchengxu/vista.vim"
on_source = 'nvim-lspconfig'

[[plugins]]
repo = 'williamboman/mason-lspconfig.nvim'
on_source = 'nvim-lspconfig'
lua_source = '''
  require("mason-lspconfig").setup({
    ensure_installed = { "rust_analyzer", "lua_ls", "texlab", "vimls", "pyright", "bashls" },
  })
'''

[[plugins]]
repo = 'nvim-lua/popup.nvim'

[[plugins]]
repo = 'nvim-lua/plenary.nvim'

[[plugins]]
repo = 'nvim-telescope/telescope.nvim'
on_cmd = 'Telescope'
if = 'has("nvim")'
depends = ['popup.nvim', 'plenary.nvim']

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

[[plugins]]
repo = 'matsui54/denite-nvim-lsp'
if = 'has("nvim")'
on_source = 'denite.nvim'

[[plugins]]
repo = 'machakann/vim-swap'
on_map = '<plug>(swap-'
hook_add = '''
  let g:swap_no_default_key_mappings = 1

  nmap <leader>gs <Plug>(swap-interactive)
  xmap <leader>gs <Plug>(swap-interactive)
  nmap g< <Plug>(swap-prev)
  nmap g> <Plug>(swap-next)
'''

[[plugins]]
repo = 'editorconfig/editorconfig-vim'
on_cmd = 'EditorConfigEnable'

[[plugins]]
repo = 'gamoutatsumi/dps-ghosttext.vim'
depends = 'denops.vim'
on_cmd = 'GhostStart'
hook_add = '''
  let g:dps_ghosttext#ftmap = {"github.com": "markdown", "zenn.dev": "markdown"}
'''

[[plugins]]
repo = 'rhysd/git-messenger.vim'
on_cmd = 'GitMessenger'
on_map = '<Plug>(git-messenger)'
hook_add = '''
  let g:git_messenger_no_default_mappings = v:true
  let g:git_messenger_always_into_popup=v:true
  nmap <Leader>gm <Plug>(git-messenger)
'''

[[plugins]]
repo = 'lukas-reineke/indent-blankline.nvim'
on_event = 'BufRead'
hook_add = '''
let g:indentLine_fileTypeExclude = ['help', 'calendar']
'''

[[plugins]]
repo = 'thinca/vim-qfreplace'
on_cmd = 'Qfreplace'

[[plugins]]
repo = 'tyru/capture.vim'
on_cmd = 'Capture'

[[plugins]]
repo = 'thinca/vim-prettyprint'
on_cmd = ['PrettyPrint', 'PP']

[[plugins]]
repo = "mbbill/undotree"
on_cmd = 'UndotreeToggle'

[[plugins]]
repo = 'yuki-yano/fuzzy-motion.vim'
depends = 'denops.vim'
hook_add = '''
nnoremap <Space>/ <cmd>FuzzyMotion<CR>
'''
on_cmd = 'FuzzyMotion'

[[plugins]]
repo = "lewis6991/gitsigns.nvim"
lua_source = '''
require('gitsigns').setup {
  signs = {
    change = { hl = 'GitSignsChange', text = '!', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
  },
  on_attach = function(bufnr)
    local gs = package.loaded.gitsigns

    local function map(mode, l, r, opts)
      opts = opts or {}
      opts.buffer = bufnr
      vim.keymap.set(mode, l, r, opts)
    end

    -- Navigation
    map('n', ']c', function()
      if vim.wo.diff then return ']c' end
      vim.schedule(function() gs.next_hunk() end)
      return '<Ignore>'
    end, { expr = true })

    map('n', '[c', function()
      if vim.wo.diff then return '[c' end
      vim.schedule(function() gs.prev_hunk() end)
      return '<Ignore>'
    end, { expr = true })

    -- Actions
    map({ 'n', 'v' }, '<leader>hs', ':Gitsigns stage_hunk<CR>')
    map({ 'n', 'v' }, '<leader>hr', ':Gitsigns reset_hunk<CR>')
    map('n', '<leader>hS', gs.stage_buffer)
    map('n', '<leader>hu', gs.undo_stage_hunk)
    map('n', '<leader>hR', gs.reset_buffer)
    map('n', '<leader>hp', gs.preview_hunk)
    map('n', '<leader>hb', function() gs.blame_line { full = true } end)
    map('n', '<leader>tb', gs.toggle_current_line_blame)
    map('n', '<leader>hd', gs.diffthis)
    map('n', '<leader>hD', function() gs.diffthis('~') end)
    map('n', '<leader>td', gs.toggle_deleted)

    -- Text object
    map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
  end
}
'''
on_event = 'BufRead'

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

[[plugins]]
repo = "j-hui/fidget.nvim"
on_source = 'nvim-lspconfig'
lua_source = '''
  require"fidget".setup{}
'''

[[plugins]]
repo = 'cohama/lexima.vim'
hook_add = '''
  let g:lexima_ctrlh_as_backspace = 1
'''
on_event = 'InsertEnter'

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

[[plugins]]
repo = 'mattn/vim-sonictemplate'
on_cmd = 'Template'
hook_add = '''
  let g:sonictemplate_vim_template_dir = '$HOME/dotfiles/nvim/template/'
'''

[[plugins]]
repo = "mfussenegger/nvim-dap"
on_event = 'BufRead'
lua_source = '''
  require('dap_rc')
'''

[[plugins]]
repo = "rcarriga/nvim-dap-ui"
on_source = 'nvim-dap'
lua_source = '''
  require("dapui").setup()
'''

[[plugins]]
repo = "theHamsta/nvim-dap-virtual-text"
on_source = 'nvim-dap'
lua_source = '''
  require("nvim-dap-virtual-text").setup()
'''

[[plugins]]
repo = "lambdalisue/fern.vim"
on_cmd = 'Fern'
depends = ['nerdfont.vim', 'fern-renderer-nerdfont.vim', 'glyph-palette.vim']
hook_add = """
  " let g:fern#disable_default_mappings = 1
  " nnoremap <silent> <C-f> <cmd>Fern .<CR>
"""
[plugins.ftplugin]
fern = '''
  nmap <silent> <buffer> p     <Plug>(fern-action-preview:toggle)
  nmap <silent> <buffer> <C-p> <Plug>(fern-action-preview:auto:toggle)
  nmap <silent> <buffer> <C-d> <Plug>(fern-action-preview:scroll:down:half)
  nmap <silent> <buffer> <C-u> <Plug>(fern-action-preview:scroll:up:half)
  nmap <silent><buffer> <CR> <Plug>(fern-action-open-or-enter)
  " nmap <silent><buffer> + <Plug>(fern-action-add_session)
  nmap <silent><buffer> c <Plug>(fern-action-clipboard-copy)
  nmap <silent><buffer> m <Plug>(fern-action-clipboard-move)
  nmap <silent><buffer> P <Plug>(fern-action-clipboard-paste)
  nmap <silent><buffer> l <Plug>(fern-action-open-or-enter)
  nmap <silent><buffer> E <Plug>(fern-action-open:side)
  nmap <silent><buffer> t <Plug>(fern-action-open:tabedit)
  nmap <silent><buffer> o <Plug>(fern-action-open-or-expand)
  " nmap <silent><buffer> O defx#async_action('open_tree', 'recursive')
  nmap <silent><buffer> K <Plug>(fern-action-new-dir)
  nmap <silent><buffer> N <Plug>(fern-action-new-file)
  " nmap <silent><buffer> S defx#do_action('multi', [['toggle_sort', 'time'], 'redraw'])
  nmap <silent><buffer> d <Plug>(fern-action-trash)
  nmap <silent><buffer> D <Plug>(fern-action-remove)
  nmap <silent><buffer> r <Plug>(fern-action-rename)
  nmap <silent><buffer> ! <Plug>(fern-action-ex)
  nmap <silent><buffer> x <Plug>(fern-action-open:system)
  nmap <silent><buffer> yy <Plug>(fern-action-yank)
  nmap <silent><buffer> . <Plug>(fern-action-hidden)
  nmap <silent><buffer> h <Plug>(fern-action-leave)
  " nmap <silent><buffer> ~ <Plug>(fern-action-cd)
  " nmap <silent><buffer> q ((&filetype =~# 'defx') && (bufname() =~# 'temp')) ?
  "   \ <Plug>(fern-action-quit) : \ ':call <SID>quit_all_defx()<CR>'
  " nmap <silent><buffer> <Esc> \ <Plug>(fern-action-quit)
  " nmap <silent><buffer> , \ <Plug>(fern-action-toggle_select) . 'j'
  " nmap <silent><buffer> * \ <Plug>(fern-action-toggle_select_all)
  nmap <silent><buffer><expr> j line('.') == line('$') ? 'gg' : 'j'
  nmap <silent><buffer><expr> k line('.') == 1 ? 'G' : 'k'
  nmap <silent><buffer> <C-l> <Plug>(fern-action-reload):nohlsearch<CR>
  " nmap <silent><buffer> <C-g> \ <Plug>(fern-action-print)
  " nmap <silent><buffer> cd \ <Plug>(fern-action-change_vim_cwd)
  " nmap <silent><buffer> ' \ defx#do_action('cd', [getcwd()])
  " nmap <silent><buffer> <Tab> <cmd>call <SID>switch_defx_buf()<CR>
  " nmap <silent><buffer><expr> L
  "   \ <Plug>(fern-action-link)

  " nmap <silent><buffer><expr> <Space>s \ ":Denite directory_rec:" . <SID>get_defx_cwd() . " -default-action=jump_defx<CR>"
  " nmap <silent><buffer><expr> <Space>a \ ":Denite file/rec:" . <SID>get_defx_cwd() . "<CR>"
  " nmap <silent><buffer><expr> <Space>g \ ":Denite grep:" . <SID>get_defx_cwd() . "<CR>"
'''

[[plugins]]
repo = "yuki-yano/fern-preview.vim"
on_source = 'fern.vim'

[[plugins]]
repo = "lambdalisue/nerdfont.vim"
hook_add = """
  let g:fern#renderer = "nerdfont"
  let g:fern#renderer#nerdfont#padding = "  "
  let g:fern#renderer#nerdfont#indent_markers=1
"""

[[plugins]]
repo = "lambdalisue/fern-renderer-nerdfont.vim"

[[plugins]]
repo = "lambdalisue/glyph-palette.vim"
[plugins.ftplugin]
fern = '''
  call glyph_palette#apply()
'''

[[plugins]]
repo = "thinca/vim-partedit"
on_cmd = 'Partedit'
on_func = 'partedit#start'
hook_add = '''
  command! DeinPartedit call <SID>operator_partedit()
  function! s:operator_partedit() abort
    let context = context_filetype#get()
    if context.range == [[0, 0], [0, 0]]
      echohl WarningMsg
      echomsg 'Context is not found'
      echohl NONE
      return
    endif
    call partedit#start(context.range[0][0], context.range[1][0],
          \ {'filetype': context.filetype})
    nnoremap <buffer><nowait> <C-q> <Cmd>w<CR><Cmd>ParteditEnd<CR>
  endfunction
'''

[[plugins]]
repo = "folke/neodev.nvim"
on_source = 'nvim-lspconfig'

[[plugins]]
repo = "uga-rosa/ccc.nvim"
on_cmd = "CccHighlighterToggle"

[[plugins]]
repo = "github/copilot.vim"
on_cmd = 'Copilot'
hook_add = '''
  let g:copilot_no_tab_map = v:true
  imap <silent><script><expr> <C-v> copilot#Accept("\<CR>")
'''