Skip to content

Startup Autocommands #1893

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
alex-courtis opened this issue Jan 7, 2023 · 7 comments · Fixed by #1912
Closed

Startup Autocommands #1893

alex-courtis opened this issue Jan 7, 2023 · 7 comments · Fixed by #1912
Labels

Comments

@alex-courtis
Copy link
Member

It is necessary for the user to determine the loaded/setup status of nvim-tree. See #1869 (comment) for use case.

  1. au for nvim-tree required
  2. au for nvim-tree setup
  3. require("nvim-tree").is_setup()

3 is not strictly necessary due to Event.Ready however is cheap and may be useful.

/cc @mrjones2014

@alex-courtis
Copy link
Member Author

alex-courtis commented Jan 10, 2023

@mrjones2014 please review #1912

I've not added an is_started "API" as I'm struggling to see a use case: for those interested in startup the two aus should be sufficient. Happy to add it...

@mrjones2014
Copy link
Collaborator

I'm struggling to see a use case

If nvim-tree loads before legendary.nvim then I won't get the autocmd. Could you just set something like vim.g.nvim_tree_attached = true?

@mrjones2014
Copy link
Collaborator

This otherwise looks good. But I need a way to tell if the autocmds have already happened before I try to attach to them.

@alex-courtis
Copy link
Member Author

I'm struggling to see a use case

If nvim-tree loads before legendary.nvim then I won't get the autocmd. Could you just set something like vim.g.nvim_tree_attached = true?

That makes good sense. I was thinking in terms of lua methods which did not feel right.

vim.g pairs well with each autocommand. They are outside of regular lua plugin operations which is necessary for this case.

Perhaps other lua plugins should do this. Perhaps some do already.

@alex-courtis
Copy link
Member Author

Added #1912

@mrjones2014
Copy link
Collaborator

Perhaps other lua plugins should do this. Perhaps some do already.

Many plugins use this pattern. Often in a plugin/plugin_name.lua file you’ll see something like

if vim.g.plugin_name_loaded == true then
  return
end

vim.g.plugin_name_loaded = true

@alex-courtis
Copy link
Member Author

👍 merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants