twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
13.51k stars 494 forks source link

Open editor with appropiate file extension when using template files #3938

Closed BrayanLope5 closed 2 months ago

BrayanLope5 commented 2 months ago

What exactly are you trying to do?

I am not sure this is the best place to add this but I was wondering if there is any way to give an editor the appropriate file extension when using chezmoi templates with the tmpl extension. For example, if I open my hyprland config with chezmoi edit, it has no syntax highlighting because the file has the extension for chezmoi templates. I use the helix editor on the terminal by the way.

What have you tried so far?

I've had to assign the appropriate language to each file I open that is a chezmoi template.

Where else have you checked for solutions?

Output of any commands you've tried with --verbose flag

$ chezmoi --verbose edit FILE/PATH

Just opens the tmpl file with no syntax highlighting.

Output of chezmoi doctor

~ ❯ chezmoi doctor RESULT CHECK MESSAGE warning version v2.52.2, built at 2024-09-10T06:56:59Z ok latest-version v2.52.2 ok os-arch linux/amd64 (EndeavourOS) ok uname Linux hplaptop 6.10.9-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 10 Sep 2024 14:37:32 +0000 x86_64 GNU/Linux ok go-version go1.23.1 (gc) ok executable /usr/bin/chezmoi ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2024-09-11T 17:05:51-07:00 ok source-dir ~/.local/share/chezmoi is a git working tree (clean) ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a git working tree (clean) ok dest-dir ~ is a directory ok umask 022 ok cd-command found /usr/bin/fish ok cd-args /usr/bin/fish info diff-command not set ok edit-command found /usr/bin/helix ok edit-args /usr/bin/helix ok git-command found /usr/bin/git, version 2.46.0 warning merge-command vimdiff not found in $PATH ok shell-command found /usr/bin/fish ok shell-args /usr/bin/fish info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.4.5 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info bitwarden-secrets-command bws not found in $PATH info dashlane-command dcli not found in $PATH info doppler-command doppler not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info rbw-command rbw not found in $PATH info vault-command vault not found in $PATH info vlt-command vlt not found in $PATH info secret-command not set ~ ❯

Additional context

None.

halostatue commented 2 months ago

This really isn't something that Chezmoi can do, but some editors have user-contributed extensions that can assist with this. I personally use alker0/chezmoi.vim and it works quite well. If you use emacs, there appears to be a solid extension available for that.

There is nothing currently available in the VS Code marketplace, and I doubt there is anything for Helix, Zed, or the Jetbrains family of editors.