Skip to content

Performance issue/unstable with recent commits? #767

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

Closed
tmpm697 opened this issue Feb 23, 2023 · 17 comments
Closed

Performance issue/unstable with recent commits? #767

tmpm697 opened this issue Feb 23, 2023 · 17 comments
Labels
bug Something isn't working question Further information is requested

Comments

@tmpm697
Copy link

tmpm697 commented Feb 23, 2023

this plugin became unstable with recent commits, the last stable one i can actually use is d9e50c185f5728d8cb64943566449180b2903fd4 -- that's from last dec 2022.

recent ones cause my buffer flick when use with persisted.nvim to save/restore session. check this: olimorris/persisted.nvim#51

@charbelnicolas
Copy link

I've completely stopped using neo-tree since the last few days for the same reasons, it's becoming very glitchy and lots of issues have been popping up...

@charbelnicolas
Copy link

Using neo-tree with sessions is messy too...

@tmpm697
Copy link
Author

tmpm697 commented Feb 24, 2023

@cseickel : can you pump up a bit with new commits? currently not stable for usage.

@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 24, 2023

Hi! A few days ago, I pushed #748 and #761 to clean up invalid buffers caused by session restore, which could cause bugs as mentioned in #740. This might be the cause of the bugs that you have seen, and I'm terribly sorry for that 😞. However, I can't seem to reproduce the issue that you mentioned. Could you provide me with some steps on how to do this?

@nhat-vo nhat-vo added bug Something isn't working question Further information is requested labels Feb 24, 2023
@tmpm697
Copy link
Author

tmpm697 commented Feb 24, 2023

@nhat-vo : I used neotree with persisted.nvim as i mentioned in 1st post with linked issue.
basically i used events from persisted.nvim that would close/re-open session before/after save/restore

so neotree would not stored in the saved session, but i got issue that all buffers deleted and neotree randomly restored and sometime not.

also i'm observing cursor shifted at the end of buffer (most bottom left) and some kind of error message after doing :qa that can related to neotree. (or smth else)

I use nvim-nightly and latest neotree and persisted.nvim. like i mentioned, the previous commit from 2022 work for me and i currently at that commit to prevent current bug.

There's smth that also affected my startup time with neotree, reached to ~150ms and if i use previous commit, never above 100ms (with lazy.nvim profiling)

@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 24, 2023

@tmpm697 Could you provide a minimal config, please 😄?

@tmpm697
Copy link
Author

tmpm697 commented Feb 24, 2023

just tried with all latest neotree and persisted.nvim again, got this error:
neotree still not restore correctly with persisted.nvim, sometime does sometime not.

Error executing vim.schedule lua callback: ...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:165: Invalid window id: 1011
stack traceback:
▒░[C]: in function 'nvim_set_current_win'
▒░...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:165: in function <...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:163>
Error executing vim.schedule lua callback: ...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:165: Invalid window id: 1036
stack traceback:
▒░[C]: in function 'nvim_set_current_win'
▒░...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:165: in function <...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:163>
Error executing vim.schedule lua callback: ...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:165: Invalid window id: 1046
stack traceback:
▒░[C]: in function 'nvim_set_current_win'
▒░...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:165: in function <...re/nvim/lazy/neo-tree.nvim/lua/neo-tree/command/init.lua:163>

my neotree config:

return {
  -- file explorer
  "nvim-neo-tree/neo-tree.nvim",
  dependencies = {
    "nvim-lua/plenary.nvim",
    -- "nvim-tree/nvim-web-devicons",
    "MunifTanjim/nui.nvim",
  },
  cmd = "Neotree",
  -- commit = "d9e50c185f5728d8cb64943566449180b2903fd4", -- recent commits cause flick

  config = function()
    -- Unless you are still migrating, remove the deprecated commands from v1.x
    vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])

    -- If you want icons for diagnostic errors, you'll need to define them somewhere:
    vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError" })
    vim.fn.sign_define("DiagnosticSignWarn", { text = " ", texthl = "DiagnosticSignWarn" })
    vim.fn.sign_define("DiagnosticSignInfo", { text = " ", texthl = "DiagnosticSignInfo" })
    vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
    -- NOTE: this is changed from v1.x, which used the old style of highlight groups
    -- in the form "LspDiagnosticsSignWarning"

    require("neo-tree").setup({
      use_default_mappings = false, -- no default mappings enable, define keybidings yourself
      close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab
      popup_border_style = "rounded",
      enable_git_status = true,
      enable_diagnostics = true,
      sort_case_insensitive = false, -- used when sorting files and directories in the tree
      sort_function = nil, -- use a custom function for sorting files and directories in the tree
      default_component_configs = {
        container = {
          enable_character_fade = true,
        },
        indent = {
          indent_size = 2,
          padding = 1, -- extra padding on left hand side
          -- indent guides
          with_markers = true,
          indent_marker = "│",
          last_indent_marker = "└",
          highlight = "NeoTreeIndentMarker",
          -- expander config, needed for nesting files
          with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
          expander_collapsed = "",
          expander_expanded = "",
          expander_highlight = "NeoTreeExpander",
        },
        icon = {
          folder_closed = "",
          folder_open = "",
          folder_empty = "ﰊ",
          -- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
          -- then these will never be used.
          default = "*",
          highlight = "NeoTreeFileIcon",
        },
        modified = {
          symbol = "[+]",
          highlight = "NeoTreeModified",
        },
        name = {
          trailing_slash = false,
          use_git_status_colors = true,
          highlight = "NeoTreeFileName",
        },
        git_status = {
          symbols = {
            -- Change type
            added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
            modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
            deleted = "⊖", -- this can only be used in the git_status source
            renamed = "➜", -- this can only be used in the git_status source
            -- Status type
            untracked = "★",
            ignored = "◌",
            unstaged = "✗",
            staged = "✓",
            conflict = "",
          },
        },
      },
      window = {
        position = "left",
        width = 40,
        mapping_options = {
          noremap = true,
          nowait = true,
        },
        mappings = {
          ["<space>"] = {
            "toggle_node",
            nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
          },
          ["<tab>"] = "open",
          ["<cr>"] = "open",
          ["P"] = { "toggle_preview", config = { use_float = true } },
          ["s"] = "open_vsplit",
          ["z"] = "close_all_nodes",
          ["Z"] = "expand_all_nodes",
          ["a"] = {
            "add",
            config = {
              show_path = "none", -- "none", "relative", "absolute"
            },
          },
          ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
          ["d"] = "delete",
          ["r"] = "rename",
          ["y"] = "copy_to_clipboard",
          ["x"] = "cut_to_clipboard",
          ["p"] = "paste_from_clipboard",
          ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
          ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
          ["q"] = "close_window",
          ["R"] = "refresh",
          ["?"] = "show_help",
          ["<"] = "prev_source",
          [">"] = "next_source",
        },
      },
      nesting_rules = {},
      filesystem = {
        filtered_items = {
          visible = false, -- when true, they will just be displayed differently than normal items
          hide_dotfiles = true,
          hide_gitignored = true,
          hide_hidden = true, -- only works on Windows for hidden files/directories
          hide_by_name = {
            --"node_modules"
          },
          hide_by_pattern = { -- uses glob style patterns
            --"*.meta",
            --"*/src/*/tsconfig.json",
          },
          always_show = { -- remains visible even if other settings would normally hide it
            --".gitignored",
          },
          never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
            --".DS_Store",
            --"thumbs.db"
          },
          never_show_by_pattern = { -- uses glob style patterns
            --".null-ls_*",
          },
        },
        follow_current_file = true, -- NOTE: -- This will find and focus the file in the active buffer every
        group_empty_dirs = false, -- when true, empty folders will be grouped together
        hijack_netrw_behavior = "open_current", --NOTE: -- netrw disabled, opening a directory opens neo-tree
        use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
        window = {
          mappings = {
            -- ["<bs>"] = "navigate_up",
            ["-"] = "navigate_up",
            ["."] = "set_root",
            ["H"] = "toggle_hidden",
            -- ["/"] = "fuzzy_finder",
            ["/"] = "filter_on_submit",
            ["D"] = "fuzzy_finder_directory",
            -- ["f"] = "filter_on_submit",
            ["f"] = "fuzzy_finder",
            ["<c-x>"] = "clear_filter",
            ["[g"] = "prev_git_modified",
            ["]g"] = "next_git_modified",
          },
        },
      },
      buffers = {
        follow_current_file = true, -- This will find and focus the file in the active buffer every
        -- time the current file is changed while the tree is open.
        group_empty_dirs = true, -- when true, empty folders will be grouped together
        show_unloaded = true,
        window = {
          mappings = {
            ["bd"] = "buffer_delete",
            ["<bs>"] = "navigate_up",
            ["."] = "set_root",
          },
        },
      },
      git_status = {
        window = {
          position = "float",
          mappings = {
            ["A"] = "git_add_all",
            ["gu"] = "git_unstage_file",
            ["ga"] = "git_add_file",
            ["gr"] = "git_revert_file",
            ["gc"] = "git_commit",
            ["gp"] = "git_push",
            ["gg"] = "git_commit_and_push",
          },
        },
      },

    })

  end,
}


@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 24, 2023

@tmpm697 I used the neotree config that you sent, combined with persistent.nvim config as below:

  {
    "olimorris/persisted.nvim",
    config = function()
      require("persisted").setup({
        autoload = true,
        on_autoload_no_session = function()
          vim.notify("No existing session to load.")
        end,
      })

      vim.api.nvim_create_autocmd({ "User" }, {
        pattern = "PersistedSavePre",
        group = group,
        callback = function()
          pcall(vim.cmd, "bw neo-tree")
        end,
      })
    end,
  },

Then I tried opening Neotree, opened a few buffers, then do :qa. When I restore the session, things seems to be looking fine. You could find a video of what I did here. If you have any steps to produce the error, let me know.

@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 24, 2023

I see. The issue here is that #761 added a hook to close any neo-tree buffer on session load, and this also closes the neo-tree buffer that you loaded in PersistedTelescopeLoadPost. I will add a more rigorous check for invalid buffers so that neo-tree buffers created on autocmds like this are not closed.

@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 24, 2023

@tmpm697 I just pushed #771, which fixes the flick you mentioned. Other than that, do you have any issue?

@charbelnicolas
Copy link

I'm using Workspaces Nvim and using this:

require('workspaces').setup({
	hooks = {
		open_pre = { 'NeoTreeClose', 'SessionsStop', 'silent %bdelete!' },
		open = { function() require('sessions').load('.nvim/session', { silent = true }) end, 'Neotree show filesystem' }
	}
})

and this is what I get:

2023-02-24_17-05-21.mp4

This works perfectly with Nvim Tree:

2023-02-24_17-08-42.mp4

Neo Tree closes itself automagically...

@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 25, 2023

@charbelnicolas #771 (just got merged into main) should fix this bug. If you have time, try switching to main and let me know if the problem persists. Again, I'm very sorry for the inconvenience 😥.

@tmpm697
Copy link
Author

tmpm697 commented Feb 25, 2023

@nhat-vo main LGFM.

@charbelnicolas
Copy link

charbelnicolas commented Feb 25, 2023

@charbelnicolas #771 (just got merged into main) should fix this bug. If you have time, try switching to main and let me know if the problem persists. Again, I'm very sorry for the inconvenience 😥.

This did not fix the issue I'm having. IMO, neo tree shouldn't close anything automagically because it leads to these kinds of issues.

UPDATE: Hmm, now that I think about it, I never changed branches, lol

@nhat-vo
Copy link
Collaborator

nhat-vo commented Feb 27, 2023

@charbelnicolas So was the bug fixed for you? The closing was just there to avoid any collision (in #740), which might cause neo-tree to behave incorrectly.

@charbelnicolas
Copy link

@charbelnicolas So was the bug fixed for you? The closing was just there to avoid any collision (in #740), which might cause neo-tree to behave incorrectly.

Yes, thank you

@nhat-vo
Copy link
Collaborator

nhat-vo commented Apr 9, 2023

Closing as solved.

@nhat-vo nhat-vo closed this as completed Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants