-
-
Notifications
You must be signed in to change notification settings - Fork 626
chore: refacto setup part 1 #603
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
Conversation
Have noticed some slow downs, running with tree.setup {
auto_close = true,
update_focused_file = {
enable = true,
},
} gives rally slow startup times:
The same file with
(which is still super long) but it does not properly initialise nvim-tree on that branch. So setup is mandatory now I assume? With removed setup those are the lines that contribute to those ~50ms: local tree = require 'nvim-tree'
local tree_callback = require('nvim-tree.config').nvim_tree_callback |
@gegoune could not reproduce the slowdown, on basic folders (10 to 500 folder/files), it opens in under 20ms in my machine (i debugged the setup part specifically with |
Just to be sure, I am not talking about opening nvim-tree window but time it takes to run |
i understand what you said before, but i could definitely not reproduce, on my machine it's really fast, opening the tree or not during setup does not change thing much, because well:
not sure where this happens, i'm going to make some more debugging |
@gegoune could you try this profiler to see if nvim-tree really is that slow compared to other plugins ? If so, could you send me your complete config for nvim-tree for the setup ? |
343843f
to
55f6342
Compare
I will try with the profiler in a minute, although I have no idea how to use it. From your output, isn't 15ms still quite a lot? Does nvim-tree actually retrieves directory's content on setup? I don't think it should do anything other than configure itself and only read directory when its window gets opened. |
it does initialize the tree with basic content. This code is quite old 😄 |
doc/nvim-tree-lua.txt
Outdated
type: `boolean` | ||
default: `true` | ||
|
||
- |open_on_setup|: will automatically the tree when running setup if current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed 'open' after 'automatically'.
doc/nvim-tree-lua.txt
Outdated
type: `boolean` | ||
default: `false` | ||
|
||
- |tab_open|: opens the tree automatically when switching tabpage or opening a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open_on_setup
and tab_open
are very different, perhaps they should both start with open_
and for example be like open_on_startup|setup
and open_on_tab
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what i told mysefl while writing the docs, thanks for confirming this!
doc/nvim-tree-lua.txt
Outdated
type: `boolean` | ||
default: `false` | ||
|
||
- |tab_open|: opens the tree automatically when switching tabpage or opening a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even
auto_open = {
startup = bool,
tab = bool,
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are not really related. auto_open will open on startup automatically, tab will only keep the window open as if it was the same screen. I guess i'd like to rename the tab_open one because it's not really explicit.
Have also noticed that nvim-tree doesn't change directory ( Does not work properly:
File opens, but after opening nvim-tree its root is still in Does work properly:
nvim-tree's root nicely updates to repositories root. Works as expected. @ibhagwan, do you think it might be caused by fzf-lua somehow? Although if I open another file using fzf-lua's oldfiles after second scenario then directory in nvim-tree updates nicely. after/plugin/nvim-tree.lualocal tree = require 'nvim-tree'
local tree_callback = require('nvim-tree.config').nvim_tree_callback
vim.g.nvim_tree_bindings = {
{ key = '<C-s>', cb = tree_callback 'split' },
{ key = '<C-x>', cb = '' },
{ key = 'h', cb = tree_callback 'close_node' },
{ key = { '<CR>', 'l' }, cb = tree_callback 'edit' },
}
require('nvim-tree.view').View.winopts.cursorline = true
tree.setup {
auto_close = true,
update_cwd = true,
update_focused_file = {
enable = true,
update_cwd = true, -- ?
},
} plugin/nvim-tree.lualocal g = vim.g
local bar = '▍'
-- g.nvim_tree_auto_close = 1
-- g.nvim_tree_follow = 1
g.nvim_tree_git_hl = 1
g.nvim_tree_group_empty = 1
g.nvim_tree_highlight_opened_files = 2
-- g.nvim_tree_hijack_cursor = 0
g.nvim_tree_icons = {
git = {
unstaged = 'M',
staged = 'S',
unmerged = 'U',
renamed = 'R',
untracked = '?',
deleted = 'D',
ignored = 'I',
},
folder = {
default = '+',
open = '-',
empty = '+',
empty_open = '-',
symlink = '+',
symlink_open = '-',
},
lsp = {
error = bar,
warning = bar,
info = bar,
hint = bar,
},
}
g.nvim_tree_ignore = { '.git', 'node_modules', '.cache' }
g.nvim_tree_lsp_diagnostics = 1
g.nvim_tree_root_folder_modifier = ':t:r'
g.nvim_tree_show_icons = {
files = 0,
folders = 1,
git = 1,
}
g.nvim_tree_special_files = {}
g.nvim_tree_width = 40 |
@kyazdani42 I have also tried to get profiler working but couldn't. Do you mind showing me how to do that when you get a sec, please? |
@gegoune, I don't think so, all |
Ah, of course, didn't think of testing it like that. Case you described above does not update nvim-tree's root, so it's not fzf-lua's problem, forgive me for mentioning you for no good reason. |
ebfb6e4
to
9492936
Compare
@gegoune maybe this is caused by EDIT: was the same before actually i don't think its related. I'm not sure but i don't think your root cwd updates as expected ? Also i've noted that rooter.nvim implemented special logic for nvim-tree so that's why it might not be working anymore. |
Oh, maybe, do you see anything wrong with their logic? Just checked |
just did some debugging, the |
I have tried replacing rooter with ahmedkhalf/project.nvim and it doesn't work in the same way so probably rooter isn't at blame here. |
Did not understand your last comment. If you mean Ok, just found out... the rooter.nvim only run |
Yes, sorry, meant exactly what you assumed, that it fails the same way. Didn't try vim-rooter, might have some time later tonight. But if rooter.nvim requires that var and project.nvim also doesn't work does it mean that there is some other issue at play here since rooter.ncim has no |
ok so, tested with a very minimal init.lua: vim.cmd "set rtp+=~/project.nvim"
require'project_nvim'.setup {
manual_mode = false,
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" },
silent_chdir = false,
}
vim.cmd 'au DirChanged * lua print(2)' and it does change the directory as expected, but does not trigger the |
or maybe because autocmd cannot be nested ? |
Fixed, sorry for the long wait. |
refacto setup for code entrypoint following options switched boolean values as options to the setup function: - `nvim_tree_disable_netrw` -> `disable_netrw` - `nvim_tree_hijack_netrw` -> `hijack_netrw` - `nvim_tree_auto_open` -> `open_on_setup` - `nvim_tree_auto_close` -> `auto_close` - `nvim_tree_tab_open` -> `tab_open` - `nvim-tree-update-cwd` -> `update_cwd` - `nvim_tree_hijack_cursor` -> `hijack_cursor` - `nvim_tree_system_open_command` -> `system_open.cmd` - `nvim_tree_system_open_command_args` -> `system_open.args` - `nvim_tree_follow` -> `update_focused_file.enable` - `nvim_tree_follow_update_path` -> `update_focused_file.update_cwd` Also added new option `update_focused_file.ignore_list` which will ignore filepath or filetypes that matches one entry of the list when updating the path if update_cwd is true.
9492936
to
83a238a
Compare
* chore: refacto setup part 1 refacto setup for code entrypoint following options switched boolean values as options to the setup function: - `nvim_tree_disable_netrw` -> `disable_netrw` - `nvim_tree_hijack_netrw` -> `hijack_netrw` - `nvim_tree_auto_open` -> `open_on_setup` - `nvim_tree_auto_close` -> `auto_close` - `nvim_tree_tab_open` -> `tab_open` - `nvim-tree-update-cwd` -> `update_cwd` - `nvim_tree_hijack_cursor` -> `hijack_cursor` - `nvim_tree_system_open_command` -> `system_open.cmd` - `nvim_tree_system_open_command_args` -> `system_open.args` - `nvim_tree_follow` -> `update_focused_file.enable` - `nvim_tree_follow_update_path` -> `update_focused_file.update_cwd` Also added new option `update_focused_file.ignore_list` which will ignore filepath or filetypes that matches one entry of the list when updating the path if update_cwd is true. * add deprecation warning * update readme * schedule on enter to avoid running before vim first buffer has loaded * update docs * correct typo * rename tab open -> open on tab
* chore: refacto setup part 1 refacto setup for code entrypoint following options switched boolean values as options to the setup function: - `nvim_tree_disable_netrw` -> `disable_netrw` - `nvim_tree_hijack_netrw` -> `hijack_netrw` - `nvim_tree_auto_open` -> `open_on_setup` - `nvim_tree_auto_close` -> `auto_close` - `nvim_tree_tab_open` -> `tab_open` - `nvim-tree-update-cwd` -> `update_cwd` - `nvim_tree_hijack_cursor` -> `hijack_cursor` - `nvim_tree_system_open_command` -> `system_open.cmd` - `nvim_tree_system_open_command_args` -> `system_open.args` - `nvim_tree_follow` -> `update_focused_file.enable` - `nvim_tree_follow_update_path` -> `update_focused_file.update_cwd` Also added new option `update_focused_file.ignore_list` which will ignore filepath or filetypes that matches one entry of the list when updating the path if update_cwd is true. * add deprecation warning * update readme * schedule on enter to avoid running before vim first buffer has loaded * update docs * correct typo * rename tab open -> open on tab
refacto setup for code entrypoint
following options switched to boolean values as options to the setup function:
nvim_tree_disable_netrw
->disable_netrw
nvim_tree_hijack_netrw
->hijack_netrw
nvim_tree_auto_open
->open_on_setup
nvim_tree_auto_close
->auto_close
nvim_tree_tab_open
->tab_open
nvim-tree-update-cwd
->update_cwd
nvim_tree_hijack_cursor
->hijack_cursor
nvim_tree_system_open_command
->system_open.cmd
nvim_tree_system_open_command_args
->system_open.args
nvim_tree_follow
->update_focused_file.enable
nvim_tree_follow_update_path
->update_focused_file.update_cwd
Also added new option
update_focused_file.ignore_list
which willignore filepath or filetypes that matches one entry of the list when
updating the path if update_cwd is true.
After a few try of refactoring the setup in one go, i decided to move options bit by bit to the setup because it was too too complexe to do it in one go.
I'll do a step by step refactoring to remove all the
g:
options.I'll leave this open for a week or so, so user can test this before merging to make sure nothing was broken.
This PR should enable lazy loading. All the others
g:
options should be set BEFORE runningnvim-tree.setup
TODO:
man
hijack issue.should fix: #515 #184 #93
and maybe more but i'm not sure