call ddu#custom#patch_global(#{ \ ui: 'ff', \ }) if g:IsMacGvim() let s:Height = 35 let s:Width = 65 let s:WinRow = 2 let s:WinCol = 2 let s:previewWidth = 85 let s:previewHeight = 35 let s:previewRow = 2 let s:previewCol = 70 let s:previewSplit = 'vertical' let s:previewFloatingBorder = 'none' let s:cursorLine = 'CursorLine' endif if g:IsMacNeovim() let s:FilerHeight = 60 let s:Width = round(&columns) let s:Height = round(&lines * 0.3) let s:WinRow = 2 let s:WinCol = 2 let s:previewWidth = round(&columns) let s:previewHeight = round(&lines * 0.58) let s:previewRow = round(&lines * 0.3)+3 let s:previewCol = 2 let s:previewSplit = 'vertical' let s:previewFloatingBorder = 'double' let s:cursorLine = 'String' endif if g:IsWindowsGvim() let s:Height = 22 let s:Width = 130 let s:WinRow = 1 let s:WinCol = 1 let s:previewWidth= 130 let s:previewHeight= 21 let s:previewRow= 25 let s:previewCol= 1 let s:previewSplit = 'horizontal' let s:previewFloatingBorder = 'none' let s:cursorLine = 'CursorLine' endif if g:IsLinux() let s:Height = 22 let s:Width = 120 let s:WinRow = 2 let s:WinCol = 2 let s:previewWidth= 120 let s:previewHeight= 30 let s:previewRow= 32 let s:previewCol= 2 let s:previewSplit = 'vertical' let s:previewFloatingBorder = 'double' let s:cursorLine = 'String' endif " floating call ddu#custom#patch_global(#{ \ uiParams: #{ \ uiOptions: #{ \ filer: #{ \ toggle: v:true \ } \ }, \ ff: #{ \ prompt: '>> ' , \ highlights: #{floatingCursorLine: s:cursorLine, filterText: 'Statement', floating: "Normal", floatingBorder: "Special", selected: 'Special'}, \ autoAction: #{name: "preview", sync: v:true}, \ startAutoAction: v:true, \ floatingBorder: 'double', \ floatingTitle: 'ddu', \ floatingTitlePos: 'left', \ split: 'floating', \ previewSplit: s:previewSplit, \ previewFloatingBorder: s:previewFloatingBorder, \ previewWidth: s:previewWidth, \ previewHeight: s:previewHeight, \ previewRow: s:previewRow, \ previewCol: s:previewCol, \ previewFloating: v:true, \ winRow: s:WinRow, \ winCol: s:WinCol, \ winHeight: s:Height, \ winWidth: s:Width, \ } \ }, \ }) call ddu#custom#patch_global(#{ \ kindOptions: #{ \ file: #{ \ defaultAction: 'open', \ }, \ help: #{ \ defaultAction: 'open', \ }, \ rg: #{ \ defaultAction: 'open', \ }, \ line: #{ \ defaultAction: 'open', \ }, \ mr: #{ \ defaultAction: 'open', \ }, \ jumplist: #{ \ defaultAction: 'open', \ }, \ command_history: #{ \ defaultAction: 'execute', \ }, \ git_stash: #{ \ defaultAction: 'apply', \ }, \ action: #{ \ defaultAction: 'do', \ }, \ bookmark: #{ \ defaultAction: 'open', \ }, \ rule_switch: #{ \ defaultAction: 'open', \ }, \ aider: #{ \ defaultAction: 'add', \ }, \ prompt: #{ \ defaultAction: 'execute', \ }, \ } \ }) call ddu#custom#alias('column', 'icon_filename_for_ff', 'icon_filename') call ddu#custom#patch_global(#{ \ sourceOptions: #{ \ file: #{ \ columns: ['icon_filename'] \ }, \ file_rec: #{ \ columns: ['icon_filename_for_ff'] \ }, \ }, \ columnParams: #{ \ icon_filename: #{ \ defaultIcon: #{ icon: '' }, \ }, \ icon_filename_for_ff: #{ \ defaultIcon: #{ icon: '' }, \ padding: 0, \ pathDisplayOption: 'relative' \ } \ } \ }) call ddu#custom#patch_global(#{ \ sourceOptions: #{ \ _: #{ \ matchers: ['matcher_matchfuzzy'], \ ignoreCase: v:true, \ }, \ help: #{ \ matchers: ['matcher_substring'], \ }, \ file_external: #{ \ matchers: ['matcher_matchfuzzy'], \ }, \ jumplist: #{ \ matchers: ['matcher_matchfuzzy'], \ }, \ rg: #{ \ matchers: ['matcher_kensaku', 'matcher_matchfuzzy'], \ }, \ line: #{ \ matchers: ['matcher_kensaku'], \ }, \ vim-bookmark: #{ \ matchers: ['matcher_kensaku'], \ }, \ prompt: #{ \ matchers: ['matcher_kensaku'], \ }, \ } \ }) " Use this converter for the file_rec source " with your unique hl-group call ddu#custom#patch_global(#{ \ sourceOptions: #{ \ mr: #{ \ matchers: ['matcher_matchfuzzy'], \ converters: [ #{ name: "converter_hl_dir" } ] \ }, \ line: #{ \ matchers: ['matcher_kensaku'], \ converters: [ #{ name: "converter_hl_dir" } ] \ }, \ rg: #{ \ matchers: ['matcher_kensaku'], \ converters: [ #{ name: "converter_hl_dir" } ] \ } \ }, \ filterParams: #{ \ converter_hl_dir: #{ \ hlGroup: "myOriginalHlGroup", \ } \ } \ }) " Set highlight for your hl-group autocmd ColorScheme * highlight myOriginalHlGroup guifg=#8fbc8b guibg=#000000 call ddu#custom#patch_global('filterParams', #{ \ matcher_kensaku: #{ \ highlightMatched: 'Search', \ }, \}) call ddu#custom#patch_global(#{ \ filterParams: #{ \ matcher_substring: #{highlightMatched: "Search"}, \ matcher_matchfuzzy: #{highlightMatched: "Search", limit: 100, matchseq: v:true}, \ } \ }) call ddu#custom#patch_global({ \ 'sourceParams' : { \ 'rg' : { \ 'args': ['--json'], \ 'inputType': 'migemo', \ }, \ }, \ }) if g:IsMacNeovim() let g:dropbox_dir = '/Users/takets/Library/CloudStorage/Dropbox/files/changelog' let g:config_dir = '~/.config/' endif if g:IsWsl() let g:config_dir = '/home/takets/.config/' endif if g:IsWindowsGvim() let g:dropbox_dir = 'g:/dropbox/files/changelog' let g:config_dir = 'c:/tools/vim' endif " or git ls-files call ddu#custom#patch_global('sourceParams', { \ 'file_external': { \ 'cmd': ['git', 'ls-files'] \ }, \ }) "\ 'cmd': ['fd', '--no-ignore', '--hidden', '--exclude', '.git', '--type', 'file', '--type', 'symlink'] " 'fd', '--no-ignore', '--hidden', '--exclude', '.git', '--type', 'file', '--type', 'symlink' nmap p call ddu#start({ \ 'sourceParams' : #{ \ rg : #{ \ args: ['--json'], \ inputType: 'migemo', \ }, \ }, \ 'sources':[ \ {'name': 'rg', 'options': {'path': g:dropbox_dir}, 'params': {'input': 'worklog'}}, \ ], \ }) nnoremap pm :call DduGrepChangelogHeader() function DduGrepChangelogHeader() abort if g:IsMacGvim() || g:IsMacNeovim() || g:IsMacNeovimInWork() cd ~/repos/changelog endif if g:IsWindowsGvim() cd c:/takeda/repos/changelog endif call ddu#start({ \ 'sourceParams' : #{ \ rg : #{ \ args: ['--json'], \ }, \ }, \ 'sources':[ \ {'name': 'rg', 'params': {'inputType': 'regex', 'input': "^\\* .*20.*\\[.*"}}, \ ], \ }) endfunction nnoremap pa :call DduGrepProject() function DduGrepProject() abort if g:IsMacGvim() cd /Users/takets/Library/CloudStorage/Dropbox/files/changelog endif if g:IsWindowsGvim() cd c:/takeda/repos/changelog endif if g:IsLinux() cd /home/kf/app endif if g:IsMacNeovimInWork() cd $BACKEND_LARAVEL_DIR endif let s:input = input('project grep > ') call ddu#start({ \ 'sourceParams' : #{ \ rg : #{ \ args: ['--json'], \ matchers: ['matcher_matchfuzzy'], \ ignoreCase: v:true, \ }, \ }, \ 'sources':[ \ {'name': 'rg', 'params': {'inputType': 'migemo', 'input': s:input}}, \ ], \ }) endfunction nnoremap pw :call DduGrepProjectWord() function DduGrepProjectWord() abort if g:IsMacGvim() cd /Users/takets/Library/CloudStorage/Dropbox/files/changelog endif if g:IsWindowsGvim() cd c:/takeda/repos/changelog endif if g:IsLinux() cd /home/kf/app endif if g:IsMacNeovimInWork() cd $BACKEND_LARAVEL_DIR endif let search_word = expand("") call ddu#start({ \ 'sourceParams' : #{ \ rg : #{ \ args: ['--json'], \ }, \ }, \ 'sources':[ \ {'name': 'rg', 'params': {'inputType': 'migemo', 'input': search_word}}, \ ], \ }) endfunction nnoremap pv :call DduGrepConfig() function DduGrepConfig() abort if g:IsWindowsGvim() cd c:/takeda/repos/changelog endif if g:IsWsl() || g:IsMacNeovim() cd ~/.config/nvim endif if g:IsMacNeovimInWork() cd $BACKEND_LARAVEL_DIR endif let s:input = input('project grep > ') call ddu#start({ \ 'sourceParams' : #{ \ rg : #{ \ args: ['--json', '-g', '!plugged', '-g', '!dict'], \ }, \ }, \ 'sources':[ \ {'name': 'rg', 'params': {'inputType': 'migemo', 'input': s:input}}, \ ], \ }) endfunction nnoremap pl :call DduGrepLive() function DduGrepLive() abort call ddu#start(#{ \ sources: [#{ \ name: 'rg', \ options: #{ \ matchers: [], \ volatile: v:true, \ }, \ }], \ uiParams: #{ \ ff: #{ \ ignoreEmpty: v:false, \ autoResize: v:false, \ } \ }, \ }) endfunction " vim-lsp if g:IsWindowsGvim() let g:ddu_source_lsp_clientName = 'vim-lsp' else let g:ddu_source_lsp_clientName = 'nvim-lsp' endif call ddu#custom#patch_global(#{ \ kindOptions: #{ \ lsp: #{ \ defaultAction: 'open', \ }, \ lsp_codeAction: #{ \ defaultAction: 'apply', \ }, \ }, \}) nnoremap cd \ call ddu#start(#{ \ sync: v:true, \ sources: [#{ \ name: 'lsp_definition', \ }], \ uiParams: #{ \ ff: #{ \ immediateAction: 'open', \ }, \ } \}) nnoremap cD \ call ddu#start(#{ \ sources: [#{ \ name: 'lsp_diagnostic', \ params: #{ \ buffer: 0, \ } \ }], \}) nnoremap co \ call ddu#start(#{ \ sources: [#{ \ name: 'lsp_documentSymbol', \ }], \ sourceOptions: #{ \ lsp: #{ \ volatile: v:true, \ }, \ }, \ uiParams: #{ \ ff: #{ \ ignoreEmpty: v:false \ }, \ } \}) nnoremap cw \ call ddu#start(#{ \ sources: [#{ \ name: 'lsp_workspaceSymbol', \ }], \ sourceOptions: #{ \ lsp: #{ \ volatile: v:true, \ }, \ }, \ uiParams: #{ \ ff: #{ \ ignoreEmpty: v:false \ }, \ } \}) nmap cr \ call ddu#start(#{ \ sync: v:true, \ sources: [#{ \ name: 'lsp_references', \ }], \ uiParams: #{ \ ff: #{ \ immediateAction: 'open', \ }, \ } \}) call ddu#custom#patch_global({ \ 'sourceOptions' : { \ 'markdown' : { \ 'sorters': [], \ }, \ }, \ 'sourceParams' : { \ 'markdown' : { \ 'style': 'none', \ 'chunkSize': 5, \ 'limit': 1000, \ }, \ }, \ }) call ddu#custom#patch_global({ \ 'kindOptions': { \ 'ai-review-request': { \ 'defaultAction': 'open', \ }, \ 'ai-review-log': { \ 'defaultAction': 'resume', \ }, \ 'word': { \ 'defaultAction': 'append', \ }, \ } \ }) call ai_review#config({ 'chat_gpt': { 'model': 'gpt-4-0125-preview' } }) if g:IsWindowsGvim() || g:IsMacGvim() || g:IsLinux() || g:IsMacNeovim() nnoremap ad \ call ddu#start({'sources': [{'name': 'aider'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'aider'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'aider'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'vim-bookmark'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'vim-bookmark'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'vim-bookmark'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'rule_switch'}]}) nnoremap \ call ddu#start({'sources': [{'name': 'mr', 'params': {'kind': 'mrw'}}]}) vnoremap c \ ycall ddu#start({'sources': [{'name': 'prompt', 'params': {'command': 'CopilotChat', 'selected': @@}}]}) vnoremap c \ ycall ddu#start({'sources': [{'name': 'prompt', 'params': {'command': 'CopilotChat', 'selected': @@}}]}) vnoremap g \ ycall ddu#start({'sources': [{'name': 'prompt', 'params': {'command': 'GpAppend', 'selected': @@}}]}) vnoremap g \ ycall ddu#start({'sources': [{'name': 'prompt', 'params': {'command': 'GpAppend', 'selected': @@}}]}) vnoremap G \ ycall ddu#start({'sources': [{'name': 'prompt', 'params': {'command': 'GpRewrite', 'selected': @@}}]}) vnoremap G \ ycall ddu#start({'sources': [{'name': 'prompt', 'params': {'command': 'GpRewrite', 'selected': @@}}]}) nnoremap ll \ call ddu#start({'sources': [{'name': 'line', 'params': {'matchers': 'matcher_matchfuzzy'}}]}) nnoremap F \ call ddu#start({'sources': [{'name': 'file'}]}) nnoremap h \ call ddu#start({'sources': [{'name': 'command_history'}]}) nnoremap B \ call ddu#start({'sources': [{'name': 'buffer'}]}) nnoremap J \ call ddu#start({'sources': [{'name': 'jumplist'}]}) nnoremap H \ call ddu#start({'sources': [{'name': 'help'}]}) nnoremap gf \ call ddu#start({'sources': [{'name': 'file_external'}]}) nnoremap gs \ call ddu#start({'sources': [{'name': 'git_stash'}]}) endif " autocmd User Ddu:ui:ff:openFilterWindow " \ call s:ddu_ff_filter_my_settings() " function s:ddu_ff_filter_my_settings() abort " let s:save_cr = ''->maparg('c', v:false, v:true) " " cnoremap " \ call ddu#ui#do_action('itemAction') " endfunction " autocmd User Ddu:ui:ff:closeFilterWindow " \ call s:ddu_ff_filter_cleanup() " function s:ddu_ff_filter_cleanup() abort " if s:save_cr->empty() " cunmap " else " call mapset('c', 0, s:save_cr) " endif " endfunction autocmd FileType ddu-ff call s:ddu_uu_my_settings() function! s:ddu_uu_my_settings() abort inoremap \ call ddu#ui#do_action('itemAction') nnoremap \ call ddu#ui#do_action('itemAction') call ddu#ui#ff#save_cmaps(['', '']) cnoremap \ call ddu#ui#do_action('cursorNext') cnoremap \ call ddu#ui#do_action('cursorPrevious') nnoremap o \ call ddu#ui#do_action('itemAction', {'params': {'command': 'split'}}) nnoremap v \ call ddu#ui#do_action('itemAction', {'params': {'command': 'vsplit'}}) nnoremap \ call ddu#ui#do_action('kensaku') nnoremap A \ call ddu#ui#do_action('chooseAction') nnoremap * \ call ddu#ui#do_action('toggleAllItems') nnoremap s \ call ddu#ui#do_action('toggleSelectItem') nnoremap i \ call ddu#ui#do_action('openFilterWindow') nnoremap c \ call ddu#ui#do_action('closeFilterWindow') nnoremap r \ call ddu#ui#do_action('itemAction', #{ name: 'quickfix' }) nnoremap p \ call ddu#ui#do_action('preview') nnoremap e \ call ddu#ui#do_action('expandItem', {'mode': 'toggle'}) nnoremap q \ call ddu#ui#do_action('quit') nnoremap gr \ call ddu#ui#do_action('itemAction', #{ name: 'grep' }) endfunction autocmd FileType ddu-ff-filter call s:ddu_filter_my_settings() function! s:ddu_filter_my_settings() abort inoremap \ call ddu#ui#do_action('itemAction') inoremap \ call ddu#ui#do_action('itemAction') nnoremap \ close nnoremap q \ close " insert modeのままだとiiと変な文字が入ってしまうので、を入れる inoremap \ call ddu#ui#do_action('chooseAction') nnoremap A \ call ddu#ui#do_action('chooseAction') nnoremap c \ call ddu#ui#do_action('closeFilterWindow') inoremap \ call ddu#ui#do_action('cursorNext') inoremap \ call ddu#ui#do_action('cursorPrevious') nnoremap \ call ddu#ui#do_action('toggleSelectItem') nnoremap i \ call ddu#ui#do_action('quickfix') nnoremap q \ call ddu#ui#do_action('quit') endfunction call ddu#custom#patch_local('filer', { \ 'ui': 'filer', \ 'sources': [ \ { \ 'name': 'file', \ 'params': {}, \ }, \ ], \ 'sourceOptions': { \ '_': { \ 'columns': ['filename', 'icon_filename'], \ }, \ }, \ 'kindOptions': { \ 'file': { \ 'defaultAction': 'open', \ }, \ }, \ 'uiParams': { \ 'filer': { \ 'winWidth': 40, \ 'split': 'vertical', \ 'splitDirection': 'topleft', \ } \ }, \ }) autocmd TabEnter,CursorHold,FocusGained \ call ddu#ui#do_action('checkItems') autocmd FileType ddu-filer call s:ddu_filer_my_settings() function! s:ddu_filer_my_settings() abort nnoremap \ ddu#ui#get_item()->get('isTree', v:false) ? \ "call ddu#ui#do_action('itemAction', {'name': 'narrow'})" : \ "call ddu#ui#do_action('itemAction')" nnoremap l \ ddu#ui#get_item()->get('isTree', v:false) ? \ "call ddu#ui#do_action('itemAction', {'name': 'narrow'})" : \ "call ddu#ui#do_action('itemAction')" nnoremap h \ call ddu#ui#do_action('itemAction', {'name': 'narrow', 'params': {'path': '..'}}) nnoremap e \ call ddu#ui#do_action('expandItem', {'mode': 'toggle'}) nnoremap p \ call ddu#ui#do_action('togglePreview') nnoremap s \ call ddu#ui#do_action('toggleSelectItem') nnoremap o \ call ddu#ui#do_action('itemAction', {'name': 'open', 'params': {'command': 'split'}}) nnoremap v \ call ddu#ui#do_action('itemAction', {'name': 'open', 'params': {'command': 'vsplit'}}) nnoremap t \ call ddu#ui#do_action('itemAction', {'name': 'open', 'params': {'command': 'tabnew'}}) nnoremap a \ call ddu#ui#do_action('chooseAction') nnoremap F \ call ddu#ui#do_action('itemAction', {'name': 'newFile'}) nnoremap K \ call ddu#ui#do_action('itemAction', {'name': 'newDirectory'}) nnoremap r \ call ddu#ui#do_action('itemAction', {'name': 'rename'}) nnoremap c \ call ddu#ui#do_action('itemAction', {'name': 'copy'}) nnoremap p \ call ddu#ui#do_action('itemAction', {'name': 'paste'}) nnoremap d \ call ddu#ui#do_action('itemAction', {'name': 'delete'}) nnoremap q \ call ddu#ui#do_action('quit') nnoremap > \ call ddu#ui#filer#do_action('updateOptions', #{ \ sourceOptions: #{ \ file: #{ \ matchers: ToggleHidden('file'), \ }, \ }, \ }) nnoremap gr \ call ddu#ui#do_action('itemAction', #{ name: 'rg' }) endfunction " filer 表示 function! DduFiler() abort call ddu#start({ \ 'ui': 'filer', \ 'name': 'ui_filer_preview_layout', \ 'resume': v:true, \ 'sources': [{'name': 'file', 'options': {'path': expand('%:p:h')}}], \ 'sourceOptions': {'_': {'columns': ['icon_filename']}}, \ 'uiParams': { \ 'filer': { \ 'split': 'floating', \ 'floatingBorder': 'double', \ 'previewFloating': v:true, \ 'winWidth': &columns - 4, \ 'winHeight': &lines - 4, \ 'winCol': s:WinCol, \ 'winRow': s:WinRow, \ 'sort': 'extension', \ } \ }, \ }) endfunction nnoremap e :call DduFiler() function s:file_rec(args) let items = a:args->get('items') let action = items[0]->get('action') call ddu#start(#{ \ sources: [#{ name: 'file_rec', options: #{ path: action->get('path') } }] \ }) return 0 endfunction call ddu#custom#action('source', 'file', 'file_rec', function('s:file_rec')) " Change base path. call ddu#custom#patch_global('sourceOptions', { \ 'file_fd': {'path': expand("~")}, \ })