3rd / image.nvim

🖼️ Bringing images to Neovim.
MIT License
1.17k stars 51 forks source link

[Feature] Add integrations using config file #218

Open dafta opened 2 months ago

dafta commented 2 months ago

It would be great if there was an option to add integrations using your own config, for instance by adding an option to integration options called query_buffer_images, the same way a user can currently override the resolve_image_path function.

The way it would work is, the plugin would check if an integration is enabled, and if an override for the query_buffer_images function exists in the config, it would use that instead of the integration definition in lua/image/integrations. This way, it would be easier to replace the query images function for existing integrations, but more importantly, it would be easier to add custom integrations.

The reason this would be a great addition is for file formats that are rare, or perhaps unique in an environment, and it wouldn't make sense to add a whole new integration and merge it into the plugin when maybe 10 people use it or even know of the format. For instance, we use a custom file format at work that can embed images, and adding support for it using config options is a lot easier than adding a new integration, and then having to update the files that have been changed for it to work every plugin update.

The name of the integration can be inferred from the key used in the integrations dictionary in the options, and the debug variable can be added to the config as well. As for default options, there could be a key for that, but since it's already being defined in the configuration, it might just be easier to define the options using the already existing option keys.

3rd commented 2 months ago

Hey, yep definitely, everything should be plug and play in the end - integrations, image processors and backends. I've been slowly working towards that but didn't have enough time.