evantayloryates / .hammerspoon

A set of custom Lua scripts using the Hammerspoon API to provide highly granular MacOS windows management
MIT License
0 stars 0 forks source link

Move meta.lua to it's own top-level location #1

Open evantayloryates opened 2 years ago

evantayloryates commented 2 years ago

Since meta.lua is currently within the Utils folder, other Utils can't use a lot of the helper functions I've made. This is because meta.lua is loaded before everything else so. that it can double check that importing is happening is happening for all non-exluded files. Side effect of loading meta first is that I also load all of the Utils folder (is this true?? may need to check) so if a utils file calls, for example my ltp function (alias for listTableProps), it will throw a global 'ltp' is not callable (a nil value) error

evantayloryates commented 2 years ago

This issue actually has more to do with import ordering after further inspection. The task here is to create a declarative way of specifying import orders. For instance, I will want my print functions and associated aliases to import before everything else so that those aliases will be available for use by all files imported after.

evantayloryates commented 2 years ago

I could see a simple labeling system being sufficient for my purposes:

  1. Root
  2. Debug
  3. Development
  4. Production

Not married to this list, but something to this effect would be helpful. This system should effectively decouple the file structure from the import order. Then, if I am working in a file that is typically a root or debug kind of file, I could temporarily set it's type to 'Development' to allow access to other util-like functions that it normally would not have access to.

evantayloryates commented 2 years ago

There's also the approach of importing files without executing them. This would have more to do with how I write my scripts generally. A heavier focus on OOP would probably give this to me for free.

Dependency injection might also be nice here. I haven't looked into how this would be done in Lua, but I imagine it would be straightforward. I could even see a master table where aliases are mapped to table keys, and then the functions associated with those keys are filled in later/lazily