I use nvim as my main editor, and I run services using systemd. When I edit a unit file directly, there is a built in filetype for systemd, which is great.
However, when I edit a service file with
systemctl edit my-service.service
systemd copies the file to a temporary file named something like .#my-service.servicee18f4d3ef193cd58 and opens it as a buffer, and the filetype isn't detected because of the filename, so I have to manually set it with set ft=systemd in nvim.
I read about the SYSTEMD_EDITOR environment variable, and tried setting it in my zshrc like so:
export SYSTEMD_EDITOR='nvim -c "set ft=systemd"'
but that results in nvim being launched with two buffers named ft=systemd" and .#my-service.servicee18f4d3ef193cd58 when I issue systemctl edit --full my-service.service
How can I correctly set that environment variable? or, alternatively, how can I expand vim's ft detection to include files of this naming pattern?