I'm using neovim with vim-plug.
I do some webapp testing where I want to see the raw HTML/JS/PHP/etc of a page. This can be done with something like curl example.com > tmp.html; nvim tmp.html
and nvim would load plugins and commands to be used on HTML files. However, I'd rather not save & open files like that for every page.
What I usually do is use python-requests for testing. The python script would GET
/POST
a page and output the HTML and some extra python output. For example:
get.py
#!/usr/bin/python3
import requests
print("testing...")
p = requests.get("http://example.com")
print(p.text)
print("DONE")
terminal
$ ./get.py | nvim -
(It can be as simple as printing some extra text or extra processing with grep
. Non-HTML output is expected.)
When there's non-HTML output, I don't get HTML syntax-highlighting & HTML plugins aren't loaded. These should all be formatted in a temporary buffer for rapid testing.
I can make an augroup
to run some commands but I'm not sure plugins would be loaded. Some plugins may be loaded but certain filetype-specific functions of the plugins don't work (eg Coc's coc-prettier).
How can I "cast" the filetype to HTML/JS/PHP/etc and have nvim load everything that should be loaded when an HTML file is opened?