Shougo / ddu-ui-filer

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

Not found UI action: getItem #46

Closed glassesneo closed 2 months ago

glassesneo commented 2 months ago

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

Problems summary

vim.fn["ddu#ui#getItem"]doesn't work

Expected

vim.fn["ddu#ui#getItem"] works

Environment Information

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

set rtp+=~/.cache/dpp/repos/github.com/vim-denops/denops.vim
set rtp+=~/.cache/dpp/repos/github.com/Shougo/ddu.vim
set rtp+=~/.cache/dpp/repos/github.com/Shougo/ddu-ui-filer
set rtp+=~/.cache/dpp/repos/github.com/Shougo/ddu-source-file
set rtp+=~/.cache/dpp/repos/github.com/Shougo/ddu-column-filename
set rtp+=~/.cache/dpp/repos/github.com/Shougo/ddu-kind-file

lua <<EOF
local doAction = vim.fn["ddu#ui#do_action"]
local multiActions = vim.fn["ddu#ui#multi_actions"]
local customAction = vim.fn["ddu#custom#action"]

vim.fn["ddu#custom#patch_local"]("filer", {
  ui = "filer",
  uiParams = { filer = {
    split = "floating",
    splitDirection = "floating",
  }},
  sources = { "file" },
  sourceOptions = { file = {
    columns = { "filename" },
  }},
})

local function mapAction(mode, key, action, args)
  vim.keymap.set(mode, key, function()
    if args ~= nil and next(args) then
      doAction(action, args)
    else
      doAction(action)
    end
  end, { noremap = true, silent = true, buffer = true })
end

local function mapMultiActions(mode, key, actionTable)
  vim.keymap.set(mode, key, function()
    multiActions(actionTable)
  end, { noremap = true, silent = true, buffer = true })
end

customAction("ui", "filer", "switchPreview", function()
  doAction("getItem")
  doAction("preview")
end)

vim.api.nvim_create_autocmd("FileType", { pattern = "ddu-filer",
  callback = function()
    mapAction("n", "q", "quit")
    mapMultiActions("n", "j", {{"cursorNext"}, {"switchPreview"}})
    mapMultiActions("n", "k", {{"cursorPrevious"}, {"switchPreview"}})
  end
})
EOF

call ddu#start(#{ name: 'filer' })

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

  1. Start neovim with the config above
  2. Move cursor by j or k

Screenshot (if possible)

None

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

[ddu] Not found UI action: getItem
Shougo commented 2 months ago

doAction("getItem") is not needed.

And I have fixed the problem.

Shougo commented 2 months ago
vim.api.nvim_create_autocmd("FileType", { pattern = "ddu-filer",
  callback = function()
    mapAction("n", "q", "quit")
    mapMultiActions("n", "j", {{"cursorNext"}, {"preview"}})
    mapMultiActions("n", "k", {{"cursorPrevious"}, {"preview"}})
  end
})