stevearc / resession.nvim

A replacement for mksession with a better API
MIT License
175 stars 13 forks source link

fix: don't load plugin if extension data is empty #28

Closed Subjective closed 9 months ago

Subjective commented 10 months ago

I have the overseer extension enabled, and it was causing overseer to alway loading on startup, adding about 100ms to startup time even when there were no tasks set for the current session.

This prevents any plugin associated with the extension from loading if the data is empty.

stevearc commented 9 months ago

I think I'd prefer to solve this from the other direction instead: making the overseer extension only save data if any tasks are present https://github.com/stevearc/overseer.nvim/commit/8a830905c10d929033aa0fefa318fb6d9e18f5b8

Side note, how are you getting that timing information? The only thing the extension should do with empty data is require("overseer") https://github.com/stevearc/overseer.nvim/blob/8a830905c10d929033aa0fefa318fb6d9e18f5b8/lua/resession/extensions/overseer.lua#L22 That won't even run the setup() function and it doesn't require any other modules, so the only work really is two requires: one for the extension file and one for overseer itself. I don't think it's possible for that to take 100ms, so either there's something wrong with the measurement or there's some mystery work happening that I missed.

Subjective commented 9 months ago

Side note, how are you getting that timing information?

My bad, it seems overseer was loading nvim-dap, which contributed to the additional 100ms startup time. Maybe it would be a good idea to make the nvim-dap integration optional?

image
stevearc commented 9 months ago

I've just exposed the method for patching nvim-dap https://github.com/stevearc/overseer.nvim/commit/c1ef281a078d2f815ec669f4b1af358d5624ccda

You can pass in dap = false to overseer.setup(), and then manually run require("overseer").patch_dap(true) later when nvim-dap is loaded.