Shougo / ddu-ui-ff

Fuzzy finder UI for ddu.vim
MIT License
55 stars 26 forks source link

Config Preview and filter window in vim #128

Closed Song-Tianxiang closed 11 months ago

Song-Tianxiang commented 11 months ago

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

Problems summary

I don't know how to make preview window work and if I can put filter window just in cmdline.

Expected

It's not a bug.

  1. I want to know how can I make preview window work. Checked doc but have not find infomation.

  2. Because I'm using vim, so I can not make filter window floating. Filter window in a seperate line is really ugly, can I put filter window just in cmdline? I mean, like vim's builtin / search,

Environment Information

Provide a minimal init.vim/vimrc without plugin managers (Required!)

vim9script

if !executable('deno')
    finish
endif

packadd denops

packadd ddu
packadd ddu-ui-ff
packadd ddu-kind-file
packadd ddu-source-file_old
packadd ddu-source-buffer
packadd ddu-filter-fzf
packadd ddu-filter-matcher_substring
packadd ddu-column-icon_filename

g:ddu#custom#patch_global({
    ui: 'ff',
    uiParams: {
        ff: {
            prompt: '> ',
            split: 'floating',
            floatingBorder: ['─', '│', '─', '│', '╭', '╮', '╯', '╰'],
            winHeight: '&lines - 8',
            winWidth: '&columns / 2 - 2',
            winRow: 1,
            winCol: 1,
            previewFloating: true,
            previewHeight: '&lines - 8',
            previewWidth: '&columns / 2 - 2',
            previewRow: 1,
            previewCol: '&columns / 2 + 1',
        },
    },
    sources: [
        { name: 'file_old', params: {} },
    # { name: 'buffer' },
    ],
    sourceOptions: {
        file_old: {
            columns: [ 'icon_filename' ],
        },
        _: {
            matchers: [ 'matcher_substring', ],
            # matcher_fzf
            # sorters: ['sorter_fzf'],
        },
    },
    filterParams: {
        matcher_substring: {
            highlightMatched: 'Search',
        },
        # matcher_fzf: {
        #     highlightMatched: 'Search',
        # },
    },
    kindOptions: {
        file: {
            defaultAction: 'open',
        },
    },
    columnParams: {
        icon_filename: {
            defaultIcon: { icon: '' },
        },
        # icon_filename_for_ff: {
        #     defaultIcon: { icon: '' },
        #     padding: 0,
        #     pathDisplayOption: 'relative'
        # },
    },
})

autocmd FileType ddu-ff-filter {
    inoremap <buffer> <CR> <ScriptCmd>g:ddu#ui#do_action('itemAction')<CR>
    inoremap <buffer> <C-n> <ScriptCmd>g:ddu#ui#do_action('cursorNext')<CR>
    inoremap <buffer> <C-p> <ScriptCmd>g:ddu#ui#do_action('cursorPrevious')<CR>
    nnoremap <buffer> <Esc> <ScriptCmd>g:ddu#ui#do_action('quit')<CR>
    inoremap <buffer> <C-c> <ScriptCmd>g:ddu#ui#do_action('quit')<CR>
    inoremap <buffer> <Tab> <ScriptCmd>g:ddu#ui#do_action('toggleSelectItem')<CR>
}

nnoremap <Leader>f <ScriptCmd>g:ddu#start()<CR>

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

Screenshot (if possible)

Screenshot 2023-12-14 at 7 38 20 PM

Upload the log messages by :redir and :message (if errored)

Shougo commented 11 months ago

I want to know how can I make preview window work. Checked doc but have not find infomation.

You need to execute preview action or use ddu-ui-ff-param-autoAction.

    call ddu#custom#patch_global(#{
          \   ui: 'ff',
          \   uiParams: #{
          \     ff: #{
          \       autoAction: #{
          \         name: 'preview',
          \       },
          \     },
          \   },
          \ })
Shougo commented 11 months ago

Because I'm using vim, so I can not make filter window floating. Filter window in a seperate line is really ugly, can I put filter window just in cmdline? I mean, like vim's builtin / search,

Sorry. I don't want to support it. It is my policy. The command line is not normal window.

Song-Tianxiang commented 11 months ago

Thank you. For reference, this works for me.

g:ddu#custom#patch_global({
    ui: 'ff',
    uiParams: {
        ff: {
            startAutoAction: true,
            autoAction: {
                name: 'preview',
            },
    }
})
Shougo commented 11 months ago

Because I'm using vim, so I can not make filter window floating. Filter window in a seperate line is really ugly, can I put filter window just in cmdline? I mean, like vim's builtin / search,

I think it should be implemented by another UI. Current ddu-ui-ff is already complex.