Shougo / ddu-ui-filer

File listing UI for ddu.vim
MIT License
55 stars 8 forks source link

[Question] How can I set it up with 'patch_local'? #11

Closed nabezokodaikon closed 2 years ago

nabezokodaikon commented 2 years ago

I have set up a ddu-ui-filer with your configuration as a reference.

Ddu -name=tree -resume -source-option-path=`getcwd()` -source-option-columns=filename

call ddu#custom#patch_local('tree', {
    \   'ui': 'filer',
    \   'sources': [
    \     {'name': 'file'}
    \   ],
    \ })

But the argument is too long, I want to set it with ddu#custom#patch_local. I could set ui and sources with ddu#custom#patch_local, but the following items cannot be set with ddu#custom#patch_local.

  1. -source-option-path
  2. -source-option-columns
  3. -resume

How can I set them?

Shougo commented 2 years ago
call ddu#custom#patch_local('tree', {
      \   'ui': 'filer',
      \   'resume': v:true,
      \   'sources': [
      \     {'name': 'file'}
      \   ],
      \   'sourceOptions': {
      \     '_': {
      \       'columns': 'filename',
      \     }
      \   },
      \ })

You cannot set the path in patch_local(). You should know what you do. You must set current path in the path option. But you cannot it in patch_local(). It is executed only once.

Shougo commented 2 years ago

If your command line is too long, you can define the wrapper command.

nabezokodaikon commented 2 years ago

I see. I understand. Thank you.

nabezokodaikon commented 2 years ago

An error has occurred.

init.lua

vim.cmd('syntax off')
vim.cmd('filetype off')
vim.cmd('filetype plugin indent off')

local cache_dir = vim.env.HOME .. '/.cache'
local dein_dir = cache_dir .. '/dein'
local dein_repo_dir = dein_dir .. '/repos/github.com/Shougo/dein.vim'

if not string.match(vim.o.runtimepath, '/dein.vim') then
        if vim.fn.isdirectory(dein_repo_dir) ~= 1 then
                os.execute('git clone https://github.com/Shougo/dein.vim ' .. dein_repo_dir)
        end
        vim.o.runtimepath = dein_repo_dir .. ',' .. vim.o.runtimepath
end

if vim.call('dein#min#load_state', dein_dir) ~= 1 then
    return
end

vim.call('dein#begin', dein_dir)

vim.call('dein#add', 'vim-denops/denops.vim')
vim.call('dein#add', 'Shougo/ddu.vim')
vim.call('dein#add', 'Shougo/ddu-commands.vim')
vim.call('dein#add', 'Shougo/ddu-ui-filer')
vim.call('dein#add', 'Shougo/ddu-kind-file')
vim.call('dein#add', 'Shougo/ddu-source-file')
vim.call('dein#add', 'Shougo/ddu-column-filename')

vim.call('dein#end')
vim.call('dein#save_state')

vim.cmd([[
call ddu#custom#patch_local('tree', {
      \   'ui': 'filer',
      \   'resume': v:true,
      \   'sources': [
      \     {'name': 'file'}
      \   ],
      \   'sourceOptions': {
      \     '_': {
      \       'columns': 'filename',
      \     }
      \   },
      \ })
]])

local opt = { noremap = true, silent = true }
vim.keymap.set('n', 'e', '<cmd>Ddu -name=tree<CR>', opt)

vim.cmd('syntax on')
vim.cmd('filetype on')
vim.cmd('filetype plugin indent on')

Reproduction procedures.

  1. Start Neovim.
  2. Run call dein#update() command.
  3. Restart Neovim.
  4. Press the 'e' key.

Screenshot

スクリーンショット 2022-08-09 21 15 42

nabezokodaikon commented 2 years ago

Incidentally, when written in lua, no error occurred.

vim.call('ddu#custom#patch_local', 'tree',
  'ui', 'filer')
vim.call('ddu#custom#patch_local', 'tree',
  'sources', {{name = 'file'}})
vim.call('ddu#custom#patch_local', 'tree',
  'sourceOptions', {_ = {columns = {'filename'}, path = vim.call('getcwd')}})
Shougo commented 2 years ago

OH, it is my fault.

call ddu#custom#patch_local('tree', {
      \   'ui': 'filer',
      \   'resume': v:true,
      \   'sources': [
      \     {'name': 'file'}
      \   ],
      \   'sourceOptions': {
      \     '_': {
      \       'columns': 'filename',
      \     }
      \   },
      \ })

Must be:

call ddu#custom#patch_local('tree', {
      \   'ui': 'filer',
      \   'resume': v:true,
      \   'sources': [
      \     {'name': 'file'}
      \   ],
      \   'sourceOptions': {
      \     '_': {
      \       'columns': ['filename'],
      \     }
      \   },
      \ })

Note: columns must be list.

nabezokodaikon commented 2 years ago

Thanks for letting me know.