fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Neovim: Opening a file via `:FZF` clears messages (e.g. warning W325 for existing swapfile is not shown)

Open camoz opened this issue 1 year ago • 3 comments

Checklist

  • [X] I have read through the manual page (man fzf)
  • [X] I have searched through the existing issues
  • [ ] For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.52.0 (bcda25a5)

OS

  • [X] Linux
  • [ ] macOS
  • [ ] Windows
  • [ ] Etc.

Shell

  • [X] bash
  • [ ] zsh
  • [ ] fish

Problem / Steps to reproduce

Neovim 0.10 changed how to handle files for which there already exists a running neovim process. From https://neovim.io/doc/user/news-0.10.html:

By default, the swapfile "ATTENTION" E325 dialog is skipped if the swapfile is owned by a running Nvim process, instead of prompting. If you always want the swapfile dialog, delete the default SwapExists handler: autocmd! nvim_swapfile. default-autocmds

Neovim will show a warning instead. This can be easily tested by:

  • First nvim instance: :e ~/foobar -> save
  • Second nvim instance: :e ~/foobar -> it prints W325: Ignoring swapfile from Nvim process ...

However, when opening the second file with :FZF, the warning is not shown.

I think there are two reasons why it might be really nice to fix this:

  • Neovim sets 'hidden' by default, which makes it easy to have some unsaved changes in a background buffer.
  • Since opening files with FZF is so easy, it may encourage workflows where one opens the same file in multiple windows.

Is there a way to fix this?

camoz avatar May 27 '24 16:05 camoz

Neovim actually prints the warning message, but the message is cleared from the screen after the file is open. You can see it from :messages. Not sure how I can prevent it from being cleared.

junegunn avatar May 28 '24 10:05 junegunn

function! Foo()
  let opts = {}
  function! opts.on_exit(...)
    bd
    echom 'This message will be cleared'
    sleep 1
  endfunction

  tabnew
  call termopen('sleep 1', opts)
  startinsert
endfunction

call Foo()
function! Bar()
  let opts = {}
  function! opts.on_exit(...)
    bd
    echom 'This message will not be cleared'
    sleep 1
  endfunction

  tabnew
  call termopen('sleep 1', opts)
endfunction

call Bar()

junegunn avatar May 28 '24 11:05 junegunn

I am having this problem when using neovim on Nixos using Kitty in Hyprland. I am aware this issue is open for the fzf program, but i'm struggling to figure out how to remedy it in my own, non-fzf environment. If anyone has a solution please let me know!

A-kly avatar Sep 16 '25 19:09 A-kly