lucky
lucky copied to clipboard
Allow setting editor for `lucky exec` using a yml file
We already have a setting for this https://github.com/luckyframework/lucky/blob/b6f68bdc78b0b6831e801cac3ba0c97f83159e81/tasks/exec.cr#L8 What if we just add it to the config on new apps?
The problem is the task is precompiled so there’s no way to override it ;(
Just for more info on this issue, we have a setting that allows you to override this https://github.com/luckyframework/lucky/blob/b6f68bdc78b0b6831e801cac3ba0c97f83159e81/tasks/exec.cr#L15-L18
But since this task is precompiled, https://github.com/luckyframework/lucky/blob/b6f68bdc78b0b6831e801cac3ba0c97f83159e81/shard.yml#L10-L11 you wouldn't have a way to override this setting. You'd have to somehow tell the Lucky shard to rebuild its exec task or not make it precompiled (which means longer build times).
There already exist a few ways to solve this problem, and I'm not sure something added to Lucky is the right place to solve this. Unfortunately this is one of those problems that it seems like every software package must inevitably solve - git has core.editor for example.
In Linux, /usr/bin/editor is designed to solve this problem. So is /etc/alternatives/editor, which I think is an addition made by Ubuntu(?). It's not uncommon for me to have /usr/bin/editor symlinked to /etc/alternatives/editor symlinked to /usr/bin/vim. There's also a vaguely cemented though now borderline archaic sense that $EDITOR should be defined and point to something relevant.
On macOS the open command is supposed to sort this out for you, using the system database of file types and acceptable software to edit those types of files, and you're allowed to override the "open" behavior on a per-file or per-file type basis. Windows has a similar database.
In any case, the really tricky thing about this setting is that it's not actually related to the application at all. It's a developer setting. So if you have the setting in a yml file and multiple developers working on the system, you're going to get a fight about what editor should be in the file.
I don't think lucky has a precedent for "developer specific overrides" for this kind of thing, which is probably for the best. Are there other settings like this? Would this type of thing indicate that a system wide ~/.config/lucky file attempt to be read on machines before spawning the editor?
I thought about doing a ~/.config/lucky, but as far as I can tell, this would be the only setting to go in there... If we have any other settings though, then doing something like that might totally be worth it.