Skip to content

Conversation

@Olical
Copy link
Owner

@Olical Olical commented Apr 21, 2025

#48

This finds files that match your Lua file glob patterns in .nfnl.fnl and checks a few things:

  • Do they have a [nfnl] header that indicates that this file was compiled by nfnl?
  • If it does, get the path to the source file from that header (which I recently simplified)
  • Does that source Fennel file exist?
  • If it doesn't, prompt to delete the Lua file since the file it was compiled from is no longer there.

I've tried to make this as efficient as I can, there's a risk that all this fs access on each write will be slow for some users. So we should run it in another thread / off of the main UI thread somehow and make it controllable so the user can turn it off per project.

It only reads the first line from each file and only the files that match the patterns in the configuration. Hopefully this should keep slowdowns to a minimum.

Try it!

Use :NfnlFindOrphans and then if you're happy, :NfnlDeleteOrphans. I'll automate it next with config options to turn it off.

To Do

  • Have it actually prompt to delete the orphaned files whenever we compile something or compile all files (only run this once if we compile all files!)
  • Add a section to the config so you can manually exclude some files from this deletion system. I doubt people will need this, but I want to provide it.
  • Add a flag to turn the GC system on and off.
  • Have a command users can invoke manually if they turn off the auto cleanup.

@Olical Olical force-pushed the orphan-lua-file-gc branch from 8646b5b to ffe322f Compare April 21, 2025 17:01
@Olical
Copy link
Owner Author

Olical commented Apr 26, 2025

The check on write and config seems to be working for me now. Just need to have it handle the old style of header comment too, right now it thinks ALL of Conjure's lua files are orphans which isn't right.

Now works with old and new header styles.
@Olical
Copy link
Owner Author

Olical commented Apr 26, 2025

Cool, fixed that issue! It supports the old header style now. It is however trying to delete the embedded nfnl files because I just copied the .lua files over into Conjure, not the .fnl source. So now we need an ignore list of some kind.

@Olical Olical merged commit cddf641 into main Apr 26, 2025
4 checks passed
@Olical Olical deleted the orphan-lua-file-gc branch April 26, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants