Rosettea / Hilbish

🌓 The Moon-powered shell! A comfy and extensible shell for Lua fans! 🌺 ✨
https://rosettea.github.io/Hilbish/
MIT License
496 stars 21 forks source link

feat: configuration options could be stored in regular table #286

Closed sleeptightAnsiC closed 4 months ago

sleeptightAnsiC commented 4 months ago

Per our discussion on discord, configuration options are currently being set with __newindex metamethod which means that following code does NOT work:

hilbish.opts.fuzzy = true -- OK, I can see this working
print(hilbish.opts.fuzzy) -- OK, prints: 'true'
for k,v in pairs(hilbish.opts) do print(tostring(k).." = "..tostring(v)) end -- FAIL! does nothing, like if the 'hilbish.opts' was empty

This is super confusing because most Lua projects (e.g. Neovim plugins) rarely use such approach when dealing with configurations. Instead, the default configuration options are usually stored in the regular table and said table gets merged/overwritten with/by user-defined options.

This is probably also an issue with other things like hooks, API functions, etc.

OS: Arch Linux x86_64 (6.8.2-arch2-1) Hilbish version: https://github.com/Rosettea/Hilbish/commit/11fc1edd9455d83fde3b28e8ad3afbaf0fe5c99d

sleeptightAnsiC commented 4 months ago

Fixed confirmed in https://github.com/Rosettea/Hilbish/pull/287/commits/f11e0e7533e4769e442cf4cf19de0d0ce4333075

image