" hook_add {{{ nnoremap [Space]s call ddt#start(#{ \ name: t:->get('ddt_ui_shell_last_name', \ 'shell-' .. win_getid()), \ ui: 'shell', \ }) nnoremap [Space]t call ddt#start(#{ \ name: t:->get('ddt_ui_terminal_last_name', \ 'terminal-' .. win_getid()), \ ui: 'terminal', \ }) nnoremap sD call ddt#ui#kill_editor() nnoremap Ddu -name=ddt -sync \ -ui-param-ff-split=`has('nvim') ? 'floating' : 'horizontal'` \ -ui-param-ff-winRow=1 \ -ui-param-ff-autoResize \ -ui-param-ff-cursorPos=`tabpagenr()` \ ddt_tab " }}} " hook_source {{{ call ddt#custom#patch_global(#{ \ nvimServer: '~/.cache/nvim/server.pipe', \ uiParams: #{ \ shell: #{ \ noSaveHistoryCommands: ['history'], \ userPrompt: \ "'| ' .. fnamemodify(getcwd(), ':~') .. MyGitStatus()", \ shellHistoryPath: '~/.cache/ddt-shell-history'->expand(), \ }, \ terminal: #{ \ command: ['zsh'], \ promptPattern: has('win32') ? '\f\+>' : '\w*% \?', \ }, \ }, \ }) function! MyGitStatus() const gitdir = '.git'->finddir(';') if gitdir ==# '' return '' endif if !'s:cached_status'->exists() let s:cached_status = {} endif const full_gitdir = gitdir->fnamemodify(':p') const gitdir_time = full_gitdir->getftime() const now = localtime() if !s:cached_status->has_key(full_gitdir) \ || gitdir_time > s:cached_status[full_gitdir].timestamp \ || now > s:cached_status[full_gitdir].check + 5 const status = printf(" %s%s", \ ['git', 'rev-parse', '--abbrev-ref','HEAD'] \ ->job#system(), \ ['git', 'status', '--short', '--ignore-submodules=all'] \ ->job#system()) \ ->substitute('\n$', '', '') \ ->split('\n') \ ->map({ _, val -> '| ' .. val }) \ ->join("\n") \ ->substitute('^| ', '', '') let s:cached_status[full_gitdir] = #{ \ check: now, \ timestamp: gitdir_time, \ status: status, \ } endif return s:cached_status[full_gitdir].status endfunction " Set terminal colors if has('nvim') let g:terminal_color_0 = '#6c6c6c' let g:terminal_color_1 = '#ff6666' let g:terminal_color_2 = '#66ff66' let g:terminal_color_3 = '#ffd30a' let g:terminal_color_4 = '#1e95fd' let g:terminal_color_5 = '#ff13ff' let g:terminal_color_6 = '#1bc8c8' let g:terminal_color_7 = '#c0c0c0' let g:terminal_color_8 = '#383838' let g:terminal_color_9 = '#ff4444' let g:terminal_color_10 = '#44ff44' let g:terminal_color_11 = '#ffb30a' let g:terminal_color_12 = '#6699ff' let g:terminal_color_13 = '#f820ff' let g:terminal_color_14 = '#4ae2e2' let g:terminal_color_15 = '#ffffff' else let g:terminal_ansi_colors = [ \ '#6c6c6c', '#ff6666', '#66ff66', '#ffd30a', \ '#1e95fd', '#ff13ff', '#1bc8c8', '#c0c0c0', \ '#383838', '#ff4444', '#44ff44', '#ffb30a', \ '#6699ff', '#f820ff', '#4ae2e2', '#ffffff', \ ] endif tnoremap tnoremap \ pum#visible() \ ? 'call pum#map#select_relative(+1)' \ : '' tnoremap \ pum#visible() \ ? 'call pum#map#select_relative(-1)' \ : '' tnoremap call pum#map#insert_relative(+1) tnoremap call pum#map#insert_relative(-1) tnoremap call pum#map#confirm() tnoremap call pum#map#confirm() " }}} " ddt-terminal {{{ nnoremap \ call ddt#ui#do_action('nextPrompt') nnoremap \ call ddt#ui#do_action('previousPrompt') nnoremap \ call ddt#ui#do_action('pastePrompt') nnoremap \ call ddt#ui#do_action('executeLine') nnoremap [Space]gd \ call ddt#ui#do_action('send', #{ \ str: 'git diff', \ }) nnoremap [Space]gc \ call ddt#ui#do_action('send', #{ \ str: 'git commit', \ }) nnoremap [Space]gs \ call ddt#ui#do_action('send', #{ \ str: 'git status', \ }) nnoremap [Space]gA \ call ddt#ui#do_action('send', #{ \ str: 'git commit --amend', \ }) nnoremap Ddu -name=ddt -sync \ -input='`ddt#ui#get_input()`' \ ddt_shell_history augroup ddt-ui-terminal autocmd! autocmd DirChanged \ :if t:->get('ddt_ui_terminal_directory') !=# v:event.cwd \ | call ddt#ui#do_action('cd', #{ \ directory: v:event.cwd, \ }) \ | endif augroup END if exists('b:ddt_terminal_directory') execute 'tcd' b:ddt_terminal_directory->fnameescape() endif " }}} " ddt-shell {{{ nnoremap \ call ddt#ui#do_action('nextPrompt') nnoremap \ call ddt#ui#do_action('previousPrompt') nnoremap \ call ddt#ui#do_action('pastePrompt') nnoremap \ call ddt#ui#do_action('executeLine') inoremap \ call ddt#ui#do_action('executeLine') inoremap \ call ddt#ui#do_action('terminate') nnoremap [Space]gd \ call ddt#ui#do_action('send', #{ \ str: 'git diff', \ }) nnoremap [Space]gc \ call ddt#ui#do_action('send', #{ \ str: 'git commit', \ }) nnoremap [Space]gs \ call ddt#ui#do_action('send', #{ \ str: 'git status', \ }) nnoremap [Space]gA \ call ddt#ui#do_action('send', #{ \ str: 'git commit --amend', \ }) inoremap \ pum#visible() \ ? 'call pum#map#insert_relative(+1, "empty")' \ : ddc#map#manual_complete(#{ sources: ['shell_history'] }) inoremap \ pum#visible() \ ? 'call pum#map#insert_relative(-1, "empty")' \ : ddc#map#manual_complete(#{ sources: ['shell_history'] }) nnoremap Ddu -name=ddt -sync \ -input='`ddt#ui#get_input()`' \ ddt_shell_history augroup ddt-ui-shell autocmd! autocmd DirChanged \ :if t:->get('ddt_ui_shell_directory') !=# v:event.cwd \ | call ddt#ui#do_action('cd', #{ \ directory: v:event.cwd, \ }) \ | endif augroup END if exists('b:ddt_shell_directory') execute 'tcd' b:ddt_shell_directory->fnameescape() endif " }}}