NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.94k stars 231 forks source link

Cursor blinking with rcarriga/nvim-notify #220

Closed gegoune closed 2 years ago

gegoune commented 3 years ago

Description

Exactly the same as in #158 - after committing this time and if rcarriga/nvim-notify is enabled.

After commit is completed and notification displayed cursor is blinking very fast for the entire duration of when notification is displayed.

Neovim version

v0.6.0-dev+96614f84a

Operating system and version

macOS 11.5

Steps to reproduce

  1. mkdir /tmp/test; cd /tmp/test/; git init; echo test > testfile; git add testfile
  2. nvim --clean -u <minimal file from below>
  3. :Neogit commit
  4. add message, save, quit, confirm

Expected behavior

Notification pops up and cursor blink as configured in terminal emulator (Alacritty) rate.

Actual behavior

Cursor blinks very fast (like in #158) for the duration of when notification is displayed. Returns to normal after notification closes.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
vim.o.termguicolors = true
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'TimUntersberger/neogit',
        requires = {
          { 'nvim-lua/plenary.nvim' },
        },
        config = function()
          require('neogit').setup {
            disable_builtin_notifications = true,
          }
        end,
      },
      {
        'rcarriga/nvim-notify',
        config = function()
          require('notify').setup { stages = 'static' }
          vim.notify = require 'notify'
        end,
      },
      'folke/tokyonight.nvim',
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print 'Installing neogit and dependencies.'
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[colorscheme tokyonight]]
gegoune commented 3 years ago

Ah, sorry, pressed submit by mistake. Minimal config is not working, nvim-notify is erroring with Error running notification service: ...e/pack/packer/start/nvim-notify/lua/notify/util/init.lua:48: attempt to perform arithmetic on a nil value on

lua vim.notify("This is an error message", "error")

Trying to figure it out right now (@rcarriga, perhaps you know what the issue here is?)

rcarriga commented 3 years ago

I'm going to guess it's because your Normal highlight group doesn't have a foreground guifg colour

gegoune commented 3 years ago

@rcarriga Thank you! There was another blend problem after that which lead me to suspect colorscheme was messing it all up. Have updated my original post's minimal config (added tokyonight) and the bug is reproducible now.

rcarriga commented 3 years ago

Yep just tried myself and it was the use of colour names rather than hex values. Will be adding support, thanks for accidentally catching that :smile:

rcarriga commented 3 years ago

Just to weigh in here, I can't seem to reproduce. I'm going to guess this is because of terminal differences (I'm using kitty).

Based on this message https://github.com/TimUntersberger/neogit/issues/158#issuecomment-882837062 it seems like the problem is rapid redrawing, which nvim-notify does (a lot) in order to perform animations. I can see in the NeoGit code there are a number of "refreshes". My first guess would be these are the problem but since I can't reproduce I can't actually test that out

TimUntersberger commented 3 years ago

@gegoune can you try doing something like the following

autocmd User NeogitStatusRefresh echom refreshed
gegoune commented 3 years ago

Just tried, very interesting. Does not seem to be adding those messages to :messages.

TimUntersberger commented 3 years ago

@gegoune you can reproduce this by using the minimal config and also installing nvim-notify right?

gegoune commented 3 years ago

@TimUntersberger Correct, yes, minimal config provided reproduces the issue for me every time.

It might be the case that you need to have blinking cursor enabled in terminal emulator to see it. Did not try to set it to non blinking though.

TimUntersberger commented 3 years ago

@gegoune I tried to reproduce this, but I sadly can't. Could you record a small video of the blinking cursor?

gegoune commented 3 years ago

@TimUntersberger Please see it on this video, I have used minimal config from top post.

https://user-images.githubusercontent.com/69750637/135820489-b9e099d2-c755-4d9c-9f25-46d87f1fa7a4.mov

TimUntersberger commented 3 years ago

@gegoune can you show me your alacritty config? I sadly can't reproduce this even with the same terminal.

gegoune commented 3 years ago

@TimUntersberger

import:
  - ~/.local/share/nvim/site/pack/packer/start/tokyonight.nvim/extras/alacritty_tokyonight_night.yml
env:
  TERM: alacritty
window:
  decorations: full
  startup_mode: Fullscreen
scrolling:
  history: 0
font:
  normal:
    family: Iosevka Nerd Font Mono
    style: Light
  bold:
    family: Iosevka Nerd Font Mono
    style: Medium
  italic:
    family: Iosevka Nerd Font Mono
    style: Light Italic
  bold_italic:
    family: Iosevka Nerd Font Mono
    style: Medium Italic
  size: 14.0
  offset:
    x: 0
    y: 2
  use_thin_strokes: true
selection:
  semantic_escape_chars: " ,`'\"|()[]{}<>\t="
  save_to_clipboard: true
cursor:
  style:
    blinking: Always
  blink_interval: 350
  unfocused_hollow: true
shell:
  program: /usr/local/bin/tmux
  args:
    - new-session
    - -A
    - -D
    - -s
    - main
alt_send_esc: true
mouse:
  hide_when_typing: true
key_bindings:
  # Doubt keys are relevant
TimUntersberger commented 3 years ago

I tried to reproduce this with your config, but sadly can't.

There are only two differences left:

Can you try to see if the problem is still there if you aren't inside tmux?

gegoune commented 3 years ago

Aha! It does not happen without tmux, would have never thought about it! @rcarriga Any chance you can retry with tmux?

TimUntersberger commented 3 years ago

This issue might be relevant: https://github.com/neovim/neovim/issues/2528

gegoune commented 3 years ago

Although it looks very correct, @TimUntersberger, I think there is more at play here. When I simply do

lua vim.notify("This is an error message", "error")

I don't get that flickering at all.

gegoune commented 3 years ago

Here is interesting observation. I have disabled cursor blinking in Alacritty altogether but when notification is displayed it still blinks same as on the video.

gegoune commented 2 years ago

I have noticed that it happens after commit but not after push. It also doesn't happen when Packer displays its message. Does that help to narrow down the cause?

gegoune commented 2 years ago

I have just noticed something that potentially could be of help. My cursor is blinking like crazy only when there is more than one notification displayed at one time. It's static as expected (I don't havre blinking cursor in my terminal) with only one notification popup shown. @rcarriga Is this helpful somehow?

rcarriga commented 2 years ago

There's no reason that I can think of as to why it'd happen with more than one notification other than it just being more CPU intensive. It'd be interesting to see if you notice a CPU core being pinned near 100% when you have several notifications

gegoune commented 2 years ago

I can see spike in both (bigger spike) wezterm's and neovim's process. Former spikes from around 2% to >60% while cursor is blinking, latter from 0% (idle) to about 10%. I am on 6-core Mac and frankly am not sure if those numbers correspond to single core or entire cpu.

rcarriga commented 2 years ago

Hmm it doesn't sound like your CPU is getting hammered too much. Could you try my suggestion here: https://github.com/rcarriga/nvim-notify/issues/63#issuecomment-1050635189 and reduce the FPS of rendering to see if it effects the flickering

gegoune commented 2 years ago

Tried to set it to various numbers but didn't notice any difference in flickering. This is what it looks like (with 1000 in mentioned pcall):

https://user-images.githubusercontent.com/69750637/161837269-87455fbc-9761-4a54-91df-3425694e0f80.mov

rcarriga commented 2 years ago

OK as this looks like it has nothing to do with neogit I'll move discussion over to https://github.com/rcarriga/nvim-notify/issues/63 to avoid polluting another repo :sweat_smile:

gegoune commented 2 years ago

I was thinking just that while replying to other issue.

@TimUntersberger Apologies for the noise, it seems like it has nothing to do with your amazing plugin (thanks so much!) apart of the fact that it sends two notifications at one which seem to be somehow causing that behaviour. I really appreciate your patience with me going on with this issue here.