When reading from stdin with something like
fancy-command | vim -R -, vim does not detect the
set filetype prints
filetype=). When I know the right vim filetype, I can provide it from the command line (or from within vim) with
fancy-command | vim -R +'set ft=cpp' -.
Now, that pipe might be in a shell script e.g. in conjunction with
git show <commit hash>:<path>, such that I don't want to hardcode
cpp as filetype. I have thought about just taking the end of
<path> and provide it to
ft=, but I expect this to fail (
CMakeLists.txt are not identified by their suffix).
So what I'd like to do is run vim's
filetype detect but with a pretended filename when vim is actually reading from stdin.