Giter Site home page Giter Site logo

Comments (11)

alex-courtis avatar alex-courtis commented on May 11, 2024

Thank you for the replication. This works nicely:

local log = require("nvim-tree.log")

vim.api.nvim_create_autocmd({ "CursorMoved", "TextChanged", "OptionSet" }, {
  callback = function(ev)
    log.line("dev", [[%-2d %-20s - "%s"]], ev.buf, ev.event, ev.file)
  end,
})

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

CursorMoved will happen repeatedly on every buffer. There is nothing specific to nvim-tree and nothing that can be done about it.

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

Following your reproduction steps I get the following output for:

vim.api.nvim_create_autocmd({ "OptionSet" }, {
  callback = function(ev)
    log.line("dev", [[%-2d %s %s %s %s '%s' -> '%s']], ev.buf, ev.file, vim.v.option_type, vim.v.option_command, ev.match, vim.v.option_old, vim.v.option_new)
  end,
})
[2023-07-23 17:00:57] [dev] 0   local setlocal modifiable '1' -> '0'
[2023-07-23 17:00:57] [dev] 0   local setlocal swapfile '1' -> '0'
[2023-07-23 17:00:57] [dev] 0   local setlocal bufhidden '' -> 'wipe'
[2023-07-23 17:00:57] [dev] 0   local setlocal buftype '' -> 'nofile'
[2023-07-23 17:00:57] [dev] 0   local setlocal filetype '' -> 'NvimTree'
[2023-07-23 17:00:57] [dev] 0   local setlocal buflisted '0' -> '0'
[2023-07-23 17:00:57] [dev] 0   global set eventignore 'all' -> ''
[2023-07-23 17:00:57] [dev] 0   local setlocal modifiable '0' -> '1'
[2023-07-23 17:00:57] [dev] 0   local setlocal modifiable '1' -> '0'
[2023-07-23 17:01:00] [dev] 0   global set eventignore '' -> 'BufEnter'
[2023-07-23 17:01:00] [dev] 0   global set eventignore 'BufEnter' -> ''

This activity is reasonable; most options are local and there is little use case for another plugin to listen to them.

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

There's almost no TextChanged activity for the nvim-tree buffer, nor any other buffers.

vim.api.nvim_create_autocmd({ "TextChanged" }, {
  callback = function(ev)
    log.line("dev", [[%-2d %-20s - "%s"]], ev.buf, ev.event, ev.file)
  end,
})
[2023-07-23 17:05:18] [dev] 2  TextChanged          - "/home/alex/src/linux/NvimTree_1"
[2023-07-23 17:05:22] [dev] 2  TextChanged          - "/home/alex/src/linux/NvimTree_1"
[2023-07-23 17:05:24] [dev] 2  TextChanged          - "/home/alex/src/linux/NvimTree_1"

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

I'm clearly not seeing the problem here. These events are very common and will be fired a lot.

@peter-lyr please provide the output of the above three cases.

from nvim-tree.lua.

peter-lyr avatar peter-lyr commented on May 11, 2024

I'm clearly not seeing the problem here. These events are very common and will be fired a lot.

@peter-lyr please provide the output of the above three cases.

@alex-courtis Thank you for answering my question.

After changing my logging to nvim-tree.log, it works nicely too on my Windows 11 PC. It's really a good way to debug this problem using such as vim.v.option_new.

I'd try on my Windows 10 PC tomorrow at work to find the cause of the high CPU usage when tree is open.

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

I'd try on my Windows 10 PC tomorrow at work to find the cause of the high CPU usage when tree is open.

This is a good start. We can see whether it is excessive events or some other issue. nvim-qt vs standard neovim will be a good test.

from nvim-tree.lua.

peter-lyr avatar peter-lyr commented on May 11, 2024

I can reproduce this issue on my Windows 10 now.

Before I run nvim -nu nvt-min.lua, I run set TEMP=D:\Desktop\nv\nvt-min\ and nvim-tree log file change to D:\Desktop\nv\nvt-min\nvim\nvim-tree.log.

  1. D: and cd D:\Desktop\nv\nvt-min
  2. md nvim
  3. nvim -nu nvt-min.lua
  4. :NvimTreeOpen
  5. nvim\nvim-tree.log start to grows.
  6. When I CD devicons or tree, it stops.

Maybe it's becuase tree nodes change and tree is refreshing?

D:\Desktop\nv\nvt-min/..
  devicons
  nvim
    󰌱 nvim-tree.log
  tree
   nvt-min.lua
for name, url in pairs {
  tree = 'https://github.com/nvim-tree/nvim-tree.lua.git',
  devicons = 'https://github.com/nvim-tree/nvim-web-devicons.git',
} do
  local install_path = vim.fn.fnamemodify([[D:\Desktop\nv\nvt-min\]] .. name, ':p') -- TODO: Please change the path here!!!
  if vim.fn.isdirectory(install_path) == 0 then vim.fn.system { 'git', 'clone', '--depth=1', url, install_path } end
  vim.opt.runtimepath:append(install_path)
end

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

require('nvim-tree').setup({
  log = {
    enable = true,
    types = {
      dev = true,
    },
  },
})
print 'Minimal Config Ready!'

local log = require("nvim-tree.log")

pcall(vim.api.nvim_del_autocmd, vim.g.test_au1)

vim.g.test_au1 = vim.api.nvim_create_autocmd({ "CursorMoved", "TextChanged", "OptionSet", }, {
  callback = function(ev)
    log.line("dev", [[%-2d, %-3.3f [%-12s] - [%41s] [%8s] (%8s) %18s: '%31s' -> '%31s']], ev.buf, os.clock(), ev.event,
      string.sub(ev.file, #ev.file - 40, #ev.file), vim.v.option_type, vim.v.option_command, ev.match,
      vim.v.option_old, vim.v.option_new)
  end,
})

nvt-min.log:

[2023-07-24 11:04:35] [dev] 0 , 779.519 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.520 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.520 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.521 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.581 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.582 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.582 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.583 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.645 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.646 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.646 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.647 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.708 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.708 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.709 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.709 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.770 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.771 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.771 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.772 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.833 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.834 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.834 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.835 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.894 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.895 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.895 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.896 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 779.957 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 779.957 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 779.958 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 779.958 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 780.019 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 780.020 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 780.020 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 780.021 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 780.081 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 780.082 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 780.082 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 780.083 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 780.145 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 780.145 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 780.146 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 780.147 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 780.206 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 780.207 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 780.207 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 780.208 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 780.269 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 780.270 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 780.270 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 780.271 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 0 , 780.331 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:35] [dev] 0 , 780.332 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:35] [dev] 3 , 780.332 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:35] [dev] 3 , 780.333 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:36] [dev] 0 , 780.394 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:36] [dev] 0 , 780.394 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:36] [dev] 3 , 780.395 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:36] [dev] 3 , 780.395 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:36] [dev] 0 , 780.457 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:36] [dev] 0 , 780.457 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:36] [dev] 3 , 780.458 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:36] [dev] 3 , 780.458 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:36] [dev] 0 , 780.519 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-24 11:04:36] [dev] 0 , 780.519 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-24 11:04:36] [dev] 3 , 780.519 [CursorMoved ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '
[2023-07-24 11:04:36] [dev] 3 , 780.520 [TextChanged ] - [                                 imTree_1] [        ] (        ) D:/Desktop/nv/nvt-min/NvimTree_1: '                               ' -> '                               '

image

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

Thanks for the detailed digging!

This does seem to be a windows specific issue. I'm seeing logs below once on tree open, then no further OptionSets.

Unfortunately the event passed to the OptionSet callback is not useful as it doesn't indicate which buffer the local option might apply to. It's always a modifiable set/reset.

[2023-07-29 17:09:49] [dev] 0 , 0.041 [OptionSet   ] - [                                         ] [   local] (setlocal)           filetype: '                               ' -> '                       NvimTree'
[2023-07-29 17:09:49] [dev] 0 , 0.041 [OptionSet   ] - [                                         ] [   local] (setlocal)          bufhidden: '                               ' -> '                           wipe'
[2023-07-29 17:09:49] [dev] 0 , 0.041 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-29 17:09:49] [dev] 0 , 0.041 [OptionSet   ] - [                                         ] [   local] (setlocal)           swapfile: '                              1' -> '                              0'
[2023-07-29 17:09:49] [dev] 0 , 0.041 [OptionSet   ] - [                                         ] [   local] (setlocal)            buftype: '                               ' -> '                         nofile'
[2023-07-29 17:09:49] [dev] 0 , 0.041 [OptionSet   ] - [                                         ] [   local] (setlocal)          buflisted: '                              0' -> '                              0'
[2023-07-29 17:09:49] [dev] 0 , 0.045 [OptionSet   ] - [                                         ] [  global] (     set)        eventignore: '                            all' -> '                               '
[2023-07-29 17:09:49] [dev] 0 , 0.047 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              0' -> '                              1'
[2023-07-29 17:09:49] [dev] 0 , 0.048 [OptionSet   ] - [                                         ] [   local] (setlocal)         modifiable: '                              1' -> '                              0'
[2023-07-29 17:10:01] [dev] 0 , 0.065 [OptionSet   ] - [                                         ] [  global] (     set)        eventignore: '                               ' -> '                       BufEnter'
[2023-07-29 17:10:01] [dev] 0 , 0.065 [OptionSet   ] - [                                         ] [  global] (     set)        eventignore: '                       BufEnter' -> '                               '

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

The modifiable set/reset is done when the tree is drawn, which is to be expected, although tree draws are kept to a minimum.

Perhaps the tree is being excessively refreshed following filesystem events.

I'm not really sure how much further I can get with this one.

Suggestions:

  • log.types.watcher = true to see which filesystem events are being seen
  • filesystem_watchers.enable = false as another filesystem watcher experiment
  • use WSL and see if you experience the same issue

from nvim-tree.lua.

alex-courtis avatar alex-courtis commented on May 11, 2024

This isn't affecting functionality and I'm not sure that it's something we can resolve in nvim-tree.

Please comment if you do run into breaking / functionality issues.

from nvim-tree.lua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.