nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.8k stars 220 forks source link

FEATURE: Neotree Rendering Causes Cursor Flickering; Synchronous Rendering Desired #1212

Open quolpr opened 12 months ago

quolpr commented 12 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I have a keybinding set up as follows:

nmap('_', '<cmd>Neotree source=filesystem reveal=true position=current <CR>', 'Open neotree')

When I trigger this keybind on the currently focused buffer to open Neotree, I've noticed that the cursor's position flickers during the rendering process.

I'm suggesting if it might be possible for the Neotree rendering to be executed synchronously. In essence, I'd prefer the system to wait until all the folders are loaded and only then display the content. While it might introduce a slight delay, I believe it's preferable to the current flickering which, to some users like myself, can be uncomfortable or even straining to the eyes.

To illustrate:

Current Behavior (when I use the above keybind):

https://github.com/nvim-neo-tree/neo-tree.nvim/assets/7958527/dbfcf8f1-4c13-4d8b-afe1-f5c633ffb33a

Desired Behavior (using fern as an example):

https://github.com/nvim-neo-tree/neo-tree.nvim/assets/7958527/343118c8-f8b7-4ab3-938b-7c55a1b5884f

(and the command for fern is this — :Fern . -reveal=% -wait

I truly appreciate all the hard work you've put into this project. It's fantastic! Thanks for taking the time to consider this suggestion.

pysan3 commented 11 months ago

Correct me if I'm wrong I believe you want this option?

https://github.com/nvim-neo-tree/neo-tree.nvim/blob/80dc74d081823649809f78370fa5b204aa9a853a/lua/neo-tree/defaults.lua#L400

quolpr commented 9 months ago

@pysan3 hey! Sorry for the long reply. This flag works, but only at some situation.

This is when I open and neo-tree no need to "scroll" the buffer:

https://github.com/nvim-neo-tree/neo-tree.nvim/assets/7958527/091a7441-2508-4472-a76f-694875b058e2

And here is when tree list is long and neo-tree need to scroll to exact file:

https://github.com/nvim-neo-tree/neo-tree.nvim/assets/7958527/4f5d9f22-1842-42f7-ad63-cbca21ff257b

So, could neo-tree make scroll before actually showing the content? Otherwise it feels painful for me 🥲

I am using latest neo-tree 3.15.0 with this config:

  {
    'nvim-neo-tree/neo-tree.nvim',
    branch = 'v3.x',
    dependencies = {
      'nvim-lua/plenary.nvim',
      'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
      'MunifTanjim/nui.nvim',
      '3rd/image.nvim',
    },
    config = function()
      require('neo-tree').setup {
        enable_diagnostics = false,
        close_if_last_window = false,
        default_component_configs = {
          last_modified = { enabled = false },
          file_size = { enabled = false },
          created = { enabled = false },
          type = { enabled = false },
        },
        filesystem = {
          async_directory_scan = 'never',
        },
      }
    end,
  },