Shougo / ddu-ui-ff

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

File pops up instead of opening ddu-ui #153

Closed staticWagomU closed 2 months ago

staticWagomU commented 2 months ago

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

Problems summary

When ddu with uiParams set to floatingBorder: 'single'is started with winbar set, ddu-ui is not opened in a popup but the previously opened buffer is opened in a popup and an error occurs.

Expected

I want ddu-ui to open

Environment Information

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

set rtp+=~/tmp/denops.vim
set rtp+=~/tmp/ddu.vim
set rtp+=~/tmp/ddu-ui-ff
set rtp+=~/tmp/ddu-source-file_rec

call ddu#custom#patch_local('hoge', #{
      \ ui: 'ff',
      \ sources: [
      \  #{
      \    name: 'file_rec',
      \  },
      \ ],
      \ uiParams: #{
      \   ff: #{
      \    floatingTitle: 'Hoge',
      \    autoResize: v:true,
      \    split: 'floating',
      \    floatingBorder: 'single',
      \   },
      \ },
      \})

lua << EOF
vim.api.nvim_create_autocmd({ 'VimEnter', 'BufEnter', 'BufModifiedSet', 'WinEnter', 'WinLeave' }, {
  group = vim.api.nvim_create_augroup('Hoge', { clear = true }),
  pattern = '*',
  callback = function()
    for _, buf in ipairs(vim.fn.getbufinfo({ buflisted = 1 })) do
        local winid = vim.fn.bufwinid(buf.bufnr)
        if winid ~= -1 then
          vim.fn.setwinvar(winid, '&winbar', 'Fuga')
        end
    end
  end,
})
EOF

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

  1. Open any file
  2. Run call call ddu#start(#{name:'hoge'})

Screenshot (if possible)

image

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

[ddu] ui: ff "redraw()" failed
[ddu] Error: Failed to call 'nvim_open_win' in Neovim: Vim:E5555: API call: WinLeave Autocommands for "*": Vim(append):Error executing lua callback: Vim:E36: Not enough ro
om
[ddu] stack traceback:
[ddu] ^I[C]: in function 'setwinvar'
[ddu] ^I[string ":lua"]:8: in function <[string ":lua"]:4> (code: 0)
[ddu]     at Neovim.call (file:///home/beige/tmp/denops.vim/denops/@denops-private/host/nvim.ts:68:15)
[ddu]     at eventLoopTick (ext:core/01_core.js:168:7)
[ddu]     at async Ui.redraw (file:///home/beige/tmp/ddu-ui-ff/denops/@ddu-uis/ff.ts:430:27)
[ddu]     at async file:///home/beige/tmp/ddu.vim/denops/ddu/ext.ts:942:7
[ddu]     at async Lock.lock (https://jsr.io/@lambdalisue/async/2.1.1/lock.ts:51:14)
[ddu]     at async uiRedraw (file:///home/beige/tmp/ddu.vim/denops/ddu/ext.ts:916:3)
[ddu]     at async Ddu.uiRedraw (file:///home/beige/tmp/ddu.vim/denops/ddu/ddu.ts:790:5)
[ddu]     at async Ddu.start (file:///home/beige/tmp/ddu.vim/denops/ddu/ddu.ts:239:5)
[ddu]     at async file:///home/beige/tmp/ddu.vim/denops/ddu/app.ts:252:9
[ddu]     at async Lock.lock (https://jsr.io/@lambdalisue/async/2.1.1/lock.ts:51:14)
[ddu] ui: ff "redraw()" failed
[ddu] Error: Failed to call 'nvim_open_win' in Neovim: Vim:E5555: API call: WinLeave Autocommands for "*": Vim(append):Error executing lua callback: Vim:E36: Not enough ro
om
[ddu] stack traceback:
[ddu] ^I[C]: in function 'setwinvar'
[ddu] ^I[string ":lua"]:8: in function <[string ":lua"]:4> (code: 0)
[ddu]     at Neovim.call (file:///home/beige/tmp/denops.vim/denops/@denops-private/host/nvim.ts:68:15)
[ddu]     at eventLoopTick (ext:core/01_core.js:168:7)
[ddu]     at async Ui.redraw (file:///home/beige/tmp/ddu-ui-ff/denops/@ddu-uis/ff.ts:430:27)
[ddu]     at async file:///home/beige/tmp/ddu.vim/denops/ddu/ext.ts:942:7
[ddu]     at async Lock.lock (https://jsr.io/@lambdalisue/async/2.1.1/lock.ts:51:14)
[ddu]     at async uiRedraw (file:///home/beige/tmp/ddu.vim/denops/ddu/ext.ts:916:3)
[ddu]     at async Ddu.uiRedraw (file:///home/beige/tmp/ddu.vim/denops/ddu/ddu.ts:790:5)
[ddu]     at async Ddu.#redrawInternal (file:///home/beige/tmp/ddu.vim/denops/ddu/ddu.ts:761:5)
[ddu]     at async file:///home/beige/tmp/ddu.vim/denops/ddu/ddu.ts:577:13
Shougo commented 2 months ago

Hm... It seems feature.

You can test setlocal winbar=Hoge when empty floating window.

Shougo commented 2 months ago

It works for me.

lua << EOF
vim.api.nvim_create_autocmd({ 'VimEnter', 'BufEnter', 'BufModifiedSet', 'WinEnter', 'WinLeave' }, {
  group = vim.api.nvim_create_augroup('Hoge', { clear = true }),
  pattern = '*',
  callback = function()
    for _, buf in ipairs(vim.fn.getbufinfo({ buflisted = 1 })) do
        local winid = vim.fn.bufwinid(buf.bufnr)
        if winid ~= -1 and vim.fn.line('$', winid) > 1 then
          vim.fn.setwinvar(winid, '&winbar', 'Fuga')
        end
    end
  end,
})
vim.api.nvim_create_autocmd({ 'User' }, {
  group = vim.api.nvim_create_augroup('Hoge', { clear = true }),
  pattern = 'Ddu:uiDone',
  callback = function()
    if vim.fn.line('$') > 1 then
      vim.fn.setwinvar(vim.fn.win_getid(), '&winbar', 'Fuga')
    end
  end,
})
EOF