stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.55k stars 76 forks source link

Question #335

Closed yyy33 closed 6 months ago

yyy33 commented 6 months ago

hello, I was just reading the code. Is there one ! missing here https://github.com/stevearc/aerial.nvim/blob/ef08437108247d8805ae388f2699537eac2fd810/lua/aerial/init.lua#L231

stevearc commented 6 months ago

Nope! This is a bit needlessly complex because of the extra-lazy loading logic that I don't think is really required anymore. setup() is split into two parts: there's the initial call to setup() which does as little work as possible (for startup time). It creates commands and autocmds, and stores the config options for later. Only at some future point when we're actually using aerial (we run a command, call an API function, etc) do we perform the second half, do_setup() which creates highlight groups, more autocmds, and some other work. It also sets initialized = true.

So coming back to this line, when you call setup(), if-and-only-if we have already completed this second step of running do_setup once before, call it again now. If we haven't called do_setup before, don't do it right now because we want to put that work off for as long as possible.