Shougo / ddu-ui-filer

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

If I run the action on the top 'file', I get an error. #7

Closed nabezokodaikon closed 2 years ago

nabezokodaikon commented 2 years ago

Problems summary

If I run the action on the top 'file', I get an error.

Expected

The text at the top should represent the current directory and should operate like any other directory.

Environment Information

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

~/.config/nvim/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.call('ddu#custom#patch_global',
  'uiOptions', {filer = {
    toggle = true,
  }})

vim.call('ddu#custom#patch_global',
  'uiParams', {filer = {
    split ='no',
    toggle = true,
  }})

function ddu_filer_my_settings()
  vim.keymap.set('n', 'o', function()
    if vim.api.nvim_eval('ddu#ui#filer#is_directory()') then
      return "<Cmd>call ddu#ui#filer#do_action('expandItem', {'mode': 'toggle'})<CR>"
    else
      return "<Cmd>call ddu#ui#filer#do_action('itemAction', {'name': 'open'})<CR>"
    end
  end, { buffer = true, expr = true })
end

local ddu_filer_groupname = 'ddu-filer-group'
vim.api.nvim_create_augroup(ddu_filer_groupname, { clear = true })
vim.api.nvim_create_autocmd('FileType', {
  group = ddu_filer_groupname,
  pattern = 'ddu-filer',
  callback = ddu_filer_my_settings
})

vim.keymap.set('n', 'e', '<cmd>Ddu -ui=filer -source-option-columns=filename file<CR>', {})

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

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

  1. Start Neovim.
  2. Run call dein#update() command.
  3. Restart Neovim.
  4. Press the 'e' key.
  5. Press the 'o' key on the top item of the 'ddu-ui-filer' displayed.
  6. After that, 'ddu-ui-filer' will be inoperable.

Screenshot (if possible)

スクリーンショット 2022-08-03 20 34 52

Shougo commented 2 years ago

I have fixed the problem. Please update ddu.vim.

nabezokodaikon commented 2 years ago

If you perform a narrow operation once and then narrow again to the original directory, the current directory will be displayed at the top. Can't this be achieved the first time ddu-filer is started? スクリーンショット 2022-08-05 23 44 20

nabezokodaikon commented 2 years ago

I saw your dotfiles and solved the problem. '-source-option-path=getcwd()' So you solve the problem with.

Shougo commented 2 years ago

Yes. You need to set the initial path.