Comments (11)
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.
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.
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.
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.
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.
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.
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.
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
.
D:
andcd D:\Desktop\nv\nvt-min
md nvim
nvim -nu nvt-min.lua
:NvimTreeOpen
nvim\nvim-tree.log
start to grows.- When I
CD
devicons
ortree
, 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: ' ' -> ' '
from nvim-tree.lua.
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.
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 seenfilesystem_watchers.enable = false
as another filesystem watcher experiment- use WSL and see if you experience the same issue
from nvim-tree.lua.
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)
- neovim 0.10: window picker changes WinBar highlight HOT 19
- it would be great if tree explorer can capture the mouse on opening HOT 3
- Missing some icons HOT 5
- API: tree.resize HOT 2
- `hijack_cursor` with `update_focused_file.enable` does not set cursor on focus/toggle HOT 1
- How to hide root folder? HOT 1
- stack traceback HOT 3
- Don't close floating window when rename or create files using floating `vim.ui.input` window HOT 7
- nvim gets stuck if git option is set in the config HOT 6
- E5108 when calling help with g? HOT 4
- Renaming of file to different case does not work HOT 1
- Opening nvim-tree has a lag delay (1~2s) when root_dir of nvim-tree is different with current buffer HOT 1
- More Fields For sort.sorter Function
- Float view doen't autoclose on opening a file HOT 5
- Nvim Tree does not respect custom theme HOT 1
- Remove View Cached Windows And Buffers
- Allow creating directories when renaming files (behavior like create file) HOT 3
- Hide folders without filter results in live filter HOT 1
- Passing nil as window handle in view.get_winnr
- Modified Icon And Highlight Broken Following Highlight Overhaul
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-tree.lua.