Shougo / ddu.vim

Dark deno-powered UI framework for Vim/Neovim
MIT License
294 stars 23 forks source link

I do not understand how to call defaultAction or add input #15

Closed jeffwillette closed 2 years ago

jeffwillette commented 2 years ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

Hi. I am migrating from Denite and I get the general flow of how this new plugin works, but I cannot figure out how to accomplish two things.

1) How to define and call actions in the init.vim file? Currently I can pull up the ddu buffer, but then I have no way to open files. 2) How to refine input with the fuzzy finder? for instance if 'file_rec' pulls up too many files, how can I refine my search after the buffer comes up?

Expected

I have looked through the documentation, but I do not see any examples of how to do this.

Environment Information

  2 denops: health#denops#check                                                                                                                                                   
  3 ========================================================================                                                                                                      
  4   - info: supported deno version: `1.17.1`                                                                                                                                    
  5   - info: detected deno version: `1.20.6`                                                                                                                                     
  6   - ok: deno version check: passed                                                                                                                                            
  7   - info: supported neovim version: `0.6.0`                                                                                                                                   
  8   - info: detected neovim version: `0.7.0`                                                                                                                                    
  9   - ok: neovim version check: passed                                                                                                                                          
 10   - info: denops status: `running`                                                                                                                                            
 11   - ok: denops status check: passed                                                                                                                                           
 12                                                                                                                                                                               
 13 nvim: health#nvim#check                                                                                                                                                       
 14 ========================================================================                                                                                                      
 15 ## configuration                                                                                                                                                              
 16   - ok: no issues found                                                                                                                                                       
 17                                                                                                                                                                               
 18 ## performance                                                                                                                                                                
 19   - ok: build type: relwithdebinfo                                                                                                                                            
 20                                                                                                                                                                               
 21 ## remote plugins                                                                                                                                                             
 22   - ok: up to date                                                                                                                                                            
 23                                                                                                                                                                               
 24 ## terminal                                                                                                                                                                   
 25   - info: key_backspace (kbs) terminfo entry: key_backspace=\177                                                                                                              
 26   - info: key_dc (kdch1) terminfo entry: key_dc=\e[3~                                                                                                                         
 27   - info: $ssh_tty='/dev/pts/3'                                                                                                                                               
 28                                                                                                                                                                               
 29 ## tmux                                                                                                                                                                       
 30   - ok: escape-time: 10                                                                                                                                                       
 31   - info: checking stuff                                                                                                                                                      
 32   - ok: focus-events: on                                                                                                                                                      
 33   - info: $term: screen-256color                                                                                                                                              
 34                                                                                                                                                                               
 35 provider: health#provider#check                                                                                                                                               
 36 ========================================================================                                                                                                      
 37 ## clipboard (optional)                                                                                                                                                       
 38   - ok: clipboard tool found: tmux                                                                                                                                            
 39                                                                                                                                                                               
 40 ## python 3 provider (optional)                                                                                                                                               
 41   - info: pyenv: path: /st1/jeff/.pyenv/libexec/pyenv                                                                                                                         
 42   - info: pyenv: root: /st1/jeff/.pyenv                                                                                                                                       
 43   - info: using: g:python3_host_prog = "/st1/jeff/.venv/nvim/bin/python"                                                                                                      
 44   - info: executable: /st1/jeff/.venv/nvim/bin/python                                                                                                                         
 45   - info: python version: 3.8.13                                                                                                                                              
 46   - info: pynvim version: 0.4.3                                                                                                                                               
 47   - ok: latest pynvim is installed.                                                                                                                                           
 48                                                                                                                                                                               
 49 ## python virtualenv                                                                                                                                                          
 50   - info: $virtual_env is set to: /st1/jeff/.venv/env                                                                                                                         
 51   - info: python version: 3.8.13                                                                                                                                              
 52   - ok: $virtual_env provides :!python.                                                                                                                                       
 53                                                                                                                                                                               
 54 ## ruby provider (optional)                                                                                                                                                   
 55   - warning: `ruby` and `gem` must be in $path.                                                                                                                               
 56     - advice:                                                                                                                                                                 
 57       - install ruby and verify that `ruby` and `gem` commands work.                                                                                                          
 58                                                                                                                                                                               
 59 ## node.js provider (optional)                                                                                                                                                
 60   - warning: `node` and `npm` (or `yarn`) must be in $path.                                                                                                                   
 61     - advice:                                                                                                                                                                 
 62       - install node.js and verify that `node` and `npm` (or `yarn`) commands work.                                                                                           
 63                                                                                                                                                                               
 64 ## perl provider (optional)                                                                                                                                                   
 65   - error: perl provider error:                                                                                                                                               
 66     - advice:                                                                                                                                                                 
 67       - "neovim::ext" cpan module is not installed                                                                                                                            
 68                                                                                                                                                                               
 69 vim.lsp: require("vim.lsp.health").check()                                                                                                                                    
 70 ========================================================================                                                                                                      
 71   - info: lsp log level : warn                                                                                                                                                
 72   - info: log path: /st1/jeff/.cache/nvim/lsp.log                                                                                                                             
 73   - info: log size: 2 kb                                                                                                                                                      
 74                                                                                                                                                                               
 75 vim.treesitter: require("vim.treesitter.health").check()                                                                                                                      
 76 ========================================================================                                                                                                      
 77   - info: runtime abi version : 14                                                                                                                                            
 78   - ok: loaded parser for c: abi version 13 

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

 call plug#begin('~/.config/nvim/plugged')

Plug 'vim-denops/denops.vim'                                                                 

Plug 'Shougo/ddu.vim'                        
Plug 'shun/ddu-source-buffer'                        
Plug 'Shougo/ddu-ui-ff'                                          
Plug 'shun/ddu-source-rg'              
Plug 'Shougo/ddu-source-file_rec'                                                     

call ddu#custom#patch_global({         
    \ 'ui': 'ff',                                                          
    \ })                                                              

call ddu#custom#patch_global({                                              
    \   'kindOptions': {                                                 
    \     'file': {                                               
    \       'defaultAction': 'open',                      
    \     },                              
    \   }                                                                     
    \ })            

call ddu#custom#patch_global({                            
    \   'sourceOptions': {    
    \     '_': {                                           
    \       'matchers': ['matcher_substring'],                                 
    \     },                                                                    
    \     'file_rec': {'path': expand("~")},               
    \   }                                                              
    \ })                                                                  

call ddu#custom#patch_global({
    \   'sourceParams' : {                                                
    \     'rg' : {     
    \       'args': ['--column', '--no-heading', '--color', 'never'],
    \     },                            
    \   },                                                                                    
    \ })                                                                        

function! s:ddu_rg_live() abort                   
  call ddu#start({                            
        \   'volatile': v:true,        
        \   'sources': [{            
        \     'name': 'rg',                           
        \     'options': {'matchers': []},
        \   }],                      
        \   'uiParams': {'ff': { 
        \     'ignoreEmpty': v:false,                           
        \     'autoResize': v:false,
        \   }},                        
        \ })                                                                    
endfunction                                                                                                             

" open list of buffers, open directory for seatch, search for test in files (rg)                            
nnoremap <leader><leader> <Cmd>call ddu#start({'sources': [{'name': 'buffer'}]})<CR>
nnoremap <leader><Space> <Cmd>call ddu#start({'sources': [{'name': 'file_rec'}]})<CR>
nnoremap <leader><Space><Space> <Cmd>call <SID>ddu_rg_live()<CR>
nnoremap <CR> <Cmd>ddu#ui_action('default')<CR>  

How to reproduce the problem from neovim/Vim startup (Required!)

  1. foo
  2. bar
  3. baz

Screenshot (if possible)

jeffwillette commented 2 years ago

For those who may find this later. I found the examples in the documentation for the ff UI and not in the main ddu documentation. Using the stock example there seems to work well. Below should be added to the init.vim

autocmd FileType ddu-ff call s:ddu_ff_my_settings()
function! s:ddu_ff_my_settings() abort  
  nnoremap <buffer> <CR>                                                                      
  \ <Cmd>call ddu#ui#ff#do_action('itemAction')<CR>
  nnoremap <buffer> <Space>             
  \ <Cmd>call ddu#ui#ff#do_action('toggleSelectItem')<CR>
  nnoremap <buffer> i                             
  \ <Cmd>call ddu#ui#ff#do_action('openFilterWindow')<CR>
  nnoremap <buffer> q                  
  \ <Cmd>call ddu#ui#ff#do_action('quit')<CR>
endfunction                             

autocmd FileType ddu-ff-filter call s:ddu_filter_my_settings()
function! s:ddu_filter_my_settings() abort
  inoremap <buffer> <CR>                                        
  \ <Esc><Cmd>close<CR>
  nnoremap <buffer> <CR>
  \ <Cmd>close<CR>                                                              
endfunction                                                                                                             

" open list of buffers, open directory for seatch, search for test in files (rg)                            
nnoremap <leader><leader> <Cmd>call ddu#start({'sources': [{'name': 'buffer'}]})<CR>
nnoremap <leader><Space> <Cmd>call ddu#start({'sources': [{'name': 'file_rec'}]})<CR>
"nnoremap <leader><Space><Space> <Cmd>call ddu#start({'volatile': v:true, 'sources': [{'name': 'rg'}]})<CR>
nnoremap <leader><Space><Space> <Cmd>call <SID>ddu_rg_live()<CR>
"nnoremap <CR> <Cmd>ddu#ui_action('default')<CR>          

I still have a remaining problem though. Now when I call the defaultAction, I get an error which reads

[ddu] Invalid kind: file

jeffwillette commented 2 years ago

I see now that the 'kind' is actually another module which needs to be installed to implement file operations. I did not know everything would be so modular down to this micro level. Sorry for the noise, I hope this thread helps someone in the future.

This is what I needed to install https://github.com/Shougo/ddu-kind-file

Shougo commented 2 years ago

Yes. All features are modular in ddu.vim.

Shougo commented 2 years ago

For those who may find this later. I found the examples in the documentation for the ff UI and not in the main ddu documentation.

Because, it is UI feature instead of ddu.vim.

Shougo commented 2 years ago

You need to read sources documentation. For example, in ddu-source-file:

## Required

### denops.vim

https://github.com/vim-denops/denops.vim

### ddu.vim

https://github.com/Shougo/ddu.vim

### ddu-kind-file

https://github.com/Shougo/ddu-kind-file

The dependency is already documented.