hook_add = '''
let g:python_highlight_all = v:true
let g:awk_is_gawk = v:true
let g:is_bash = v:true
let g:rust_bang_comment_leader = v:true
let g:markdown_fenced_languages = ['ts=typescript']
let g:vim_indent_cont = 6
let g:vimsyn_embed = 'lP'
let g:vimsyn_noerror = v:true

let g:loaded_2html_plugin      = v:true
let g:loaded_getscript         = v:true
let g:loaded_getscriptPlugin   = v:true
let g:loaded_gzip              = v:true
let g:loaded_gtags             = v:true
let g:loaded_gtags_cscope      = v:true
let g:loaded_logiPat           = v:true
let g:loaded_man               = v:true
let g:loaded_matchit           = v:true
let g:loaded_matchparen        = v:true
let g:loaded_netrw             = v:true
let g:loaded_netrwFileHandlers = v:true
let g:loaded_netrwPlugin       = v:true
let g:loaded_netrwSettings     = v:true
let g:loaded_rrhelper          = v:true
let g:loaded_shada_plugin      = v:true
let g:loaded_spellfile_plugin  = v:true
let g:loaded_sql_completion    = v:true
let g:loaded_syntax_completion = v:true
let g:loaded_tar               = v:true
let g:loaded_tarPlugin         = v:true
let g:loaded_tutor_mode_plugin = v:true
let g:loaded_vimball           = v:true
let g:loaded_vimballPlugin     = v:true
let g:loaded_zip               = v:true
let g:loaded_zipPlugin         = v:true
'''

[ftplugin]
_ = '''
setlocal formatoptions-=r
setlocal formatoptions-=o
setlocal formatoptions+=mMBl
'''

dockerfile = '''
function! s:set_abbrev(instruction) abort
  execute 'inoreabbrev <expr><buffer>' a:instruction
        \ printf("(getline('.')[:col('.') - 2] ==# '%s')", a:instruction)
        \ printf("? '%s' : '%s'", toupper(a:instruction), a:instruction)
endfunction

call s:set_abbrev('add')
call s:set_abbrev('arg')
call s:set_abbrev('cmd')
call s:set_abbrev('copy')
call s:set_abbrev('entrypoint')
call s:set_abbrev('env')
call s:set_abbrev('expose')
call s:set_abbrev('from')
call s:set_abbrev('healthcheck')
call s:set_abbrev('label')
call s:set_abbrev('onbuild')
call s:set_abbrev('run')
call s:set_abbrev('shell')
call s:set_abbrev('user')
call s:set_abbrev('volume')
call s:set_abbrev('workdir')

inoreabbrev <expr><buffer> as
      \ (getline('.')[:col('.') - 2] =~# '^FROM\s\+.*\s\+') ? 'AS' : 'as'
'''

gitcommit = '''
setlocal textwidth=72 colorcolumn=+1
" based on https://zenn.dev/uochan/articles/2021-12-08-vim-conventional-commits
function! s:select_type() abort
  let title = printf('%s: ', trim(split(getline('.'), ';')[0]))
  silent! normal! "_dip
  silent! put! =title
  silent! startinsert!
endfunction
nnoremap <buffer> <CR><CR> <Cmd>call <SID>select_type()<CR>
'''

gitrebase = '''
nnoremap <buffer> <CR> <Cmd>Cycle<CR>
'''

help = '''
nnoremap <buffer> q <C-w>q
nnoremap <buffer> <CR> <C-]>zv
xnoremap <buffer> <CR> <C-]>zv
nnoremap <buffer><silent><expr> [Toggle]l
      \ printf('<Cmd>help %s@%s<CR>', expand('<cword>'),
      \ expand('%:e') ==# 'jax' ? 'en': 'ja')

let s:tag_pattern = join([
      \ '\\\@<!|[#-)!+-~]\+|', '\*[#-)!+-~]\+\*\s', '\*[#-)!+-~]\+\*$',
      \ "'[a-z]\\{2,\\}'", "'t_..'",
      \ '<[-a-zA-Z0-9_]\+>', '<[SCM]-.>',
      \ 'CTRL-.', 'CTRL-SHIFT-.', 'CTRL-Break', 'CTRL-PageUp', 'CTRL-PageDown',
      \ 'CTRL-Insert', 'CTRL-Del', 'CTRL-{char}',
      \ ], '\|')
function! s:move_link(dir, count) abort
  for cnt in range(a:count)
    let flags = (a:dir ? '' : 'b') .. 'W'
    call search(s:tag_pattern, flags, 0, 500)
  endfor
endfunction
nnoremap <buffer> <C-n> <Cmd>call <SID>move_link(1, v:count1)<CR>
nnoremap <buffer> <C-p> <Cmd>call <SID>move_link(0, v:count1)<CR>
'''

python = '''
setlocal softtabstop=4 shiftwidth=4
setlocal textwidth=80
setlocal smarttab nosmartindent
inoreabbrev <expr><buffer> improt
      \ (getline('.')[:col('.') - 2] =~# 'from\s\+.*\s\+' <Bar><Bar>
      \  getline('.')[:col('.') - 2] ==# 'improt')
      \ ? 'import' : 'improt'
'''

qf = '''
setlocal nowrap nolist
setlocal numberwidth=2
nnoremap <buffer><expr> q getwininfo(win_getid())[0].loclist
      \ ? '<Cmd>lclose<CR>'
      \ : '<Cmd>cclose<CR>'
" based on https://github.com/kuuote/dotvim/blob/9c7ba6307c/ftplugin/qf.vim#L1
nnoremap <buffer><expr> j (line('.') == line('$') ? 'gg' : 'j') .. '<CR>zz<C-w>p'
nnoremap <buffer><expr> k (line('.') == 1 ? 'G' : 'k') .. '<CR>zz<C-w>p'
" from https://github.com/mityu/dotfiles/blob/f5cb5f9a92/dot_vim/runtime/ftplugin/qf.vim#L6
nnoremap <buffer> o <CR>zz<C-w>p
nnoremap <buffer> p <CR>zz<C-w>p
'''

toml = '''
if !has('nvim') && !empty(filter(getline(1, 4),
      \ { _, val -> val =~# '\V\^\([[plugins]]\|hook_\)' }))
  call dein#toml#syntax()
endif
'''

zsh = '''
setlocal iskeyword+=-
'''

checkhealth = '''
nnoremap <buffer> q <C-w>q
'''

go = '''
setlocal noexpandtab nosmarttab shiftwidth=0
'''

tsv = '''
setlocal noexpandtab
'''

vim = '''
setlocal formatoptions-=ro textwidth=0
'''

[[plugins]]
repo = '4513echo/vim-jq_indent'

[[plugins]]
repo = 'bfrg/vim-jq'
merge_ftdetect = true

[[plugins]]
repo = 'cohama/vim-hier'
lazy = true
on_cmd = ['HierClean', 'HierStart', 'HierStop', 'HierUpdate']
on_ft = 'qf'
[plugins.ftplugin]
qf = '''
autocmd vimrc WinClosed <buffer>
      \ : if &buftype ==# 'quickfix'
      \ |   execute 'HierStop'
      \ | endif
'''

[[plugins]]
repo = 'Fymyte/rasi.vim'
merge_ftdetect = true
[plugins.ftplugin]
rasi = '''
setlocal shiftwidth=4 indentkeys=0{,0},o,O
'''

[[plugins]]
repo = 'lark-parser/vim-lark-syntax'
merge_ftdetect = true

[[plugins]]
repo = 'lifepillar/pgsql.vim'
merge_ftdetect = true
hook_add = '''
let g:sql_type_default = 'pgsql'
'''

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

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

[[plugins]]
repo = 'syusui-s/scrapbox-vim'
merge_ftdetect = true

[[plugins]]
repo = 'thinca/vim-qfreplace'
lazy = true
on_cmd = 'Qfreplace'
[plugins.ftplugin]
qf = '''
nnoremap <buffer> r <Cmd>Qfreplace<CR>
'''
qfreplace = '''
nnoremap <buffer> q <C-w>q
'''

[[plugins]]
repo = 'tmux-plugins/vim-tmux'
merge_ftdetect = true

[[plugins]]
repo = 'tpope/vim-git'
merge_ftdetect = true

[[plugins]]
repo = 'vim-skk/skkdict.vim'
merge_ftdetect = true