lambdalisue / vim-fern

🌿 General purpose asynchronous tree viewer written in Pure Vim script
MIT License
1.29k stars 49 forks source link

Cursor keeps invisible when default colorscheme (or potentially other colorschemes) is used in Neovim #177

Closed Iron-E closed 4 years ago

Iron-E commented 4 years ago

Description

Hello, thank you for this plugin! It's been a great alternative to NERDTree for me.

A few days ago I started to experience my cursor disappearing after I enter a fern buffer.

Steps to Reproduce

  1. Use the :Fern command.
  2. Notice your cursor is now invisible, although exists.
    • You can edit a file and the cursor will still be invisible.

Manually setting the buffer type to fern using :setf doesn't reproduce the bug.

Attempts to Workaround

I have tried the following things to see if they resolve the issue (to no success):

The only way to fix is by restarting Vim.

Vim Information

I am using the latest Neovim 0.5 nightly.

lambdalisue commented 4 years ago

It's a new feature. You can disable it by https://github.com/lambdalisue/fern.vim/blob/master/doc/fern.txt#L378

let g:fern#disable_viewer_hide_cursor = 1
Iron-E commented 4 years ago

The cursor is supposed to stay invisible even after I leave a fern buffer and begin to edit a file?

Just so I'm sure we're on the same page— the issue isn't that the cursor is hidden while in the fern buffer (I like that feature!), it's that it stays hidden while editing text after having been in a fern buffer (until I restart Vim).

I'll set the variable for the meantime. Thanks for pointing it out!


For posterity, I tried this feature in Neovim 0.4.3 and it behaves differently. Instead of disappearing, the cursor turns into a bar, which persists after leaving Vim and into my terminal (I use a block cursor, for reference).

On both versions the cursor is not restored, although the way in which the cursor is not restored is different.

lambdalisue commented 4 years ago

On both versions the cursor is not restored, although the way in which the cursor is not restored is different.

That's sound an unexpected behavior. In my environment, the cursor is restored on Vim/Neovim. Please provide your environment information and minimal vimrc and minimal steps to reproduce so that I can investigate.


This is an expected behavior

Kapture 2020-08-26 at 09 09 11

lambdalisue commented 4 years ago

I'd also like to know what happens if you execute :call fern#internal#cursor#restore() manually after the cursor disappeared. If the cursor does not appear again, the function has some bug. If the cursor is appeared, BufLeave,WinLeave,CmdwinEnter,CmdlineEnter are not invoked.

lambdalisue commented 4 years ago

~It seems the following settings in Vim cause it?~ No he said the cursor is not restored.

set cursorlineopt=number
Iron-E commented 4 years ago

Here's a minimal configuration which reproduces the bug for me:

set termguicolors         " Set color mode

call plug#begin(expand("~/.local/share/nvim/plugged"))
    Plug 'https://github.com/lambdalisue/fern.vim.git'
call plug#end()

:call fern#internal#cursor#restore() doesn't restore the cursor, although I did notice that unless I used termguicolors everything worked perfectly (as the gif demonstrates).

lambdalisue commented 4 years ago

Thanks. The behavior has reproduced with set termguicolors on Neovim 0.5.0. I'll investigate 👍

lambdalisue commented 4 years ago

It seems the default Cursor highlight xxx guifg=bg guibg=fg does NOT work and set guicursor+=a:Cursor/lCursor is just ignored. So that we cannot restore cursor when termguicolors is enabled on default colorscheme.

https://github.com/neovim/neovim/issues/6508#issuecomment-294253742

lambdalisue commented 4 years ago

@Iron-E Please try #180

Iron-E commented 4 years ago

Thanks for the branch! The cursor doesn't appear to be restored, although I wonder if this could be an issue with Neovim.

I can't seem to set the cursor's highlight group to anything, even with nvim -u NORC -c 'set termguicolors'. I did more reading on junegunn/seoul256.vim#41 and it seems like others are having trouble getting Neovim to behave properly in this way too. Perhaps I should open a ticket there referencing this?

Edit: My hand-written colorscheme exhibits this behavior too.

lambdalisue commented 4 years ago

@Iron-E Could you try if the following fix the issue on the current master (not #180)?

highlight Cursor cterm=reverse gui=reverse
Iron-E commented 4 years ago

After setting Plug back to the master branch the highlight command doesn't affect it. For posterity I went through and tried to run the Neovim FAQ procedure for changing cursor colors and it didn't restore it either.

My colorscheme actually uses those settings for the Cursor highlight group too.

Iron-E commented 4 years ago

I cloned the repo and started poking around inside of the #restore() function, and found that if I make Vim sleep for a few milliseconds, the Cursor comes back. I'll issue a PR to merge if the solution is adequate

lambdalisue commented 4 years ago

After setting Plug back to the master branch the highlight command doesn't affect it. For posterity I went through and tried to run the Neovim FAQ procedure for changing cursor colors and it didn't restore it either.

My colorscheme actually uses those settings for the Cursor highlight group too.

Hum... Then I think we are facing different issues. You have to make sure that Neovim FAQ procedure works on your environment.

lambdalisue commented 4 years ago

I closed this issue because