[feature] How about detect shebang to set filetype?
That is if a file's first line is
#!/usr/bin/env -S pip install -r
or
#!/usr/bin/env -S pip-compile
We set this file's filetype is requirements.
Thanks!
Take a look at $VIMRUNTIME/autoload/dist/script.vim for reference on detecting filetypes based on first line.
Interesting idea, But I don't have the practice of writing shebang on the first line of the requirements file. Would this be used often?
Would this be used often?
For Unix user, detect filetype by shebang should be some convention :smile:
Disagree. Not everything needs to be an executable (hence not everything needs such a shebang line). But probably no harm in supporting it.
Not everything needs to be an executable
Although I usually do this thing (add shebang for many program's input files: jq/sed/parallel/other programs which can accept a file) :smile:
probably no harm in supporting it.
Agree :smile:
Take a look at
$VIMRUNTIME/autoload/dist/script.vimfor reference on detecting filetypes based on first line.
In neovim, it is $VIMRUNTIME/scripts.vim.
let s:line1 = getline(1)
if s:line1 =~# "^#!"
" ...