Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 of 10 tasks
camoz opened this issue May 27, 2024 · 2 comments
Labels

Comments

@camoz
Copy link

camoz commented May 27, 2024

Checklist

  • I have read through the manual page (man fzf)
  • 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 (bcda25a)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • 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?

@junegunn
Copy link
Owner

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
Copy link
Owner

junegunn commented May 28, 2024

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants