xvzc / chezmoi.nvim

Chezmoi plugin for neovim
MIT License
50 stars 1 forks source link

Chezmoi script support #12

Open kalocsaibotond opened 2 months ago

kalocsaibotond commented 2 months ago

I faced a case, where I was forced to use a chezmoi script. I had to duplicate a config file into multiple places because of the nature of the application. When I edited and saved its config file (using the recommended autocommand), I noticed that chezmoi.nvim did not run the config duplication script that chezmoi would run when chezmoi apply is called.

I do not know whether it is a bug or an intentional.

Sure that the problem can be solved via extending the autocommand to run the chezmoi scripts, but that can become quiclkly ugly, since chezmoi has rich scripting features. (I know my specific case can be solved relatively elegantly with a symlinking script as well.)

Would be it problematic to support chezmoi scripts?

xvzc commented 2 months ago

Hi, Thanks for your opinion, but i didn't understand the purpose of this issue very well. Could please provide more specific example that shows your the case that you are currently struggling with?

kalocsaibotond commented 2 months ago

Hi, Thanks for your opinion, but i didn't understand the purpose of this issue very well. Could please provide more specific example that shows your the case that you are currently struggling with?

Thank you, for your quick response! Your plugin is very nice as it is. I just wondered whether chezmoi script support would make it even better or worth it the effort.

In my specific case, I wanted to include a little VSCodium config into my dotfiles, on windows. My preferred installation method is to use the Scoop package manager, though I want it to work with regular installation as well. Scoop installs VSCodium in portable mode. In portable mode, VSCodium upon first running, looks for the config files in the regular config file location(s), and then copies them into its installation directory. But when I edit the original config file, VSCodium does not update its copy. To remedy the issue, I wrote a little chezmoi ps1 script to copy config files, into the scoop installation directory of VSCodium.

When I edited the config files with Neovim, I realised that the config files in the scoop installation directory are not updated since the chezmoi script did not run. This is how the idea came.

After a little thinking I modified the script to make symbolic link (junction), instead of copying, which solved the problem for me. However, there might be other use cases and problematic applications, where chezmoi scripts comes in handy. Sure, one can extend the plugin's functionality with additional autocommands, or use chezmoi with Watchman to emulate such functionality. However, chezmoi script support would be even nicer.

Nevertheless, If it is too problematic to implement, or such use cases are too niche, then never mind. Your plugin is already superb as it is.

xvzc commented 2 months ago

Thanks for your patience. I could reproduce the issue on my darwin operating system.

I think this is a chezmoi related issue, rather than a lack of the features with this plugin. I wrote an issue in the chezmoi repository, i will get back to you as soon as i get the response.