I have some zsh function files that I should not add extensions to for the convenience of calling, i.e. my_func instead of my_func.zsh. But this causes an issue that Neovim cannot detect their filetypes since I also use nvim-treesitter that does :syntax off/:filetype off by default.

So, is it possible to have a local setting file located in a folder so that those files at the same level will all be set to the specified filetype?

  • If there's no good answer, there's a workaround. I have a similar problem with *.py files that I want to display in a web browser; the server executes them instead. What I did is create matching *.code files for references in the HTML. The trick is to have one of each pair be a symbolic link to the other (hard links are even better, but you have to occasionally check to make sure they haven't become unlinked). Commented Mar 16, 2023 at 13:04

2 Answers 2


If you are talking about autoload functions or just scripts, putting a zsh shebang or #compdef at the beginning should work fine for filetype detection. Otherwise, # vim: ft=zsh near the beginning or end (:help modeline).


First of all, nvim-treesitter does not call :filetype off by default.

Secondly, :filetype on is enabled by default(:h nvim-defaults).

Finally, you can use vim.filetype.add (:h lua-filetype).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.