Out of the box, Neovim knows to treat files containing #!/usr/bin/env nodejs as Javascript, but for some reason, it doesn't treat files with #!/usr/bin/env pypy3 as Python.
Until Neovim can get this sorted out, you can change your own neovim config to do it anyway, by putting something like:
" au BufEnter * if getline(1) =~ "^#!.*pypy.*$" | set filetype=python | finish | endif
if getline(1) =~ "^#!.*pypy.*$"
set filetype=python
finish
" elseif getline(1) =~ "whatever""
" set filetype=whatever
endif
...in your ~/.config/nvim/scripts.vim file.
vim.filetype.add {
pattern = {
[".*"] = function(_, bufnr)
local first_line = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false)[1] or ""
if first_line:match "^#!.*pypy.*$" then return "python" end
-- if nothing is returned, it uses the default filetype
end,
},
}
HTH.
You can e-mail the author with questions or comments: