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
New "Open At Startup" Mechanisms #1669
Comments
Draft: on_start = {
open = {
always = false,
directory = true,
unnamed = false,
empty = false,
file = true,
ignore_filetype = {
"gitcommit"
},
},
focus_tree = {
always = true,
unnamed = false,
empty = false,
file = false,
},
} unnamed is a buffer with empty empty is a buffer with a name but The new configuration could go in an alternate |
LunarVim must be notified prior to release so that they may refactor ignore_ft: https://github.com/LunarVim/LunarVim/blob/36c8bdee9ff59a0a63c1edfc445b5eb2886cf246/lua/lvim/core/nvimtree.lua#L9 |
Allow Users may take their own startup actions on |
There are some difficulties here:
A pragmatic solution may be to remove this functionality and provide startup recipes. The user can control their own startup order and deal with netrw. We successfully removed the close-on-quit functionality as it was equally problematic. I am beginning to see why NerdTree never provided this functionality, only recipes. Your wisdom would be gratefully appreciated @gegoune Some recipes that users can mix and match: vim.api.nvim_create_autocmd({ "VimEnter" }, { group = group, callback = M.startup })
-- open_on_setup unnamed
function M.startup0(data)
-- ordinary buffers with no name only
if vim.bo[data.buf].buftype == "" and data.file == "" then
api.tree.open()
end
end
-- open_on_setup_file, ignore_ft_on_setup
function M.startup1(data)
-- only files
if vim.fn.filereadable(data.file) ~= 1 then
return
end
-- do nothing for git commit messages
if vim.bo[data.buf].ft == "gitcommit" then
return
end
-- open the tree
api.tree.open()
end
-- open_on_setup_file, focus buffer
function M.startup2(data)
-- window of the startup buffer
local winid = vim.fn.bufwinid(data.buf)
-- open the tree
api.tree.open()
-- restore focus
vim.api.nvim_set_current_win(winid)
end
-- open_on_setup (directory) hijack disabled
function M.startup3(data)
-- only open for directories
if vim.fn.isdirectory(data.file) == 0 then
return
end
-- window of the startup buffer
local winid = vim.fn.bufwinid(data.buf)
-- open the tree
api.tree.open()
-- restore focus
vim.api.nvim_set_current_win(winid)
-- wipe the directory buffer
vim.cmd.bw(data.buf)
end
|
I am in favour of removal given enough API is provided for users to implement their own automation. I am bit biased though - never had that option enabled. |
The only interesting bits remaining are:
|
#1918 would be useful, allowing the user to replace the startup buffer. |
@alex-courtis Thanks for pointing me from #176 This is the use case I was hoping to solve with the old When I open a file through |
Unfortunately nothing is complete and documented yet. It's time to pull the trigger on this and make it official via wiki / help. You could do something like the above VimEnter examples: function M.startup1(data)
-- only files
if vim.fn.filereadable(data.file) ~= 1 then
return
end
-- do nothing for undesirable file paths
if data.file starts with /var/tmp then
return
end
-- OR do nothing for undesirable directories
if vim.fn.getcwd() == "/var/tmp" then
return
end
-- open the tree
api.tree.open()
end |
More preparation: #1946 |
Wiki: Open At Startup Deprecation PR: #1951 |
RELATED: <nvim-tree/nvim-tree.lua#1669> REF: <https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup> Signed-off-by: Gaoyang Zhang <gy@blurgy.xyz>
Can we somehow disable the |
Please have a look at https://github.com/nvim-tree/nvim-tree.lua/pull/2122/files and remove those options from your configuration. |
open_on_setup
.* have been deprecated in favour of self serve mechanisms: Open At Startup. Please start a Discussion if you have an questions or concerns.The existing startup mechanisms such an
open_on_setup
are problematic, with recent changes resulting in many regressions #1668.The options are nonatomic and difficult (sometimes impossible) to configure for each use case.
There are often race conditions around startup and events with vim itself and other plugins.
A new mechanisms to specify startup behaviour with more granularity is under way.
The existing mechanism will be retained if an original configuration options such as
open_on_setup
is specified, however the user will be notified of the new mechanism on startup and pointed to a wiki page to explain migration to the new.Update 20230109: the new mechanism will be a set of recipes for the user to control behaviour programatically, along with the events to allow this.
Update 20230129: existing configuration will be deprecated in favour of a self serve mechanism: Open At Startup
The text was updated successfully, but these errors were encountered: