HakonHarnes / img-clip.nvim

Effortlessly embed images into any markup language, like LaTeX, Markdown or Typst
MIT License
443 stars 7 forks source link

feat: project specific config files #34

Closed HakonHarnes closed 7 months ago

HakonHarnes commented 7 months ago

Related issue

Closes #31.

Summary of changes

Added a get_config() method which returns a table of config options. The configuration can either be defined:

  1. Like a "normal" neovim configuration, e.g. using the opts in lazy.nvim
  2. Through custom .img-clip.lua files, which mimicks the opts field in lazy.nvim

The get_config method will search for the nearest .img-clip.lua, execute it, and if valid, use it as the configuration. Otherwise, it defaults back to the normal neovim configuration. This behaviour is cached in the M.configs table (key is current dir of file) to reduce overhead. Tests have been adjusted such that they are not affected by .img-clip.lua files. They always use M.opts.

Also added the ability to pass nested options through the API.