nathom / filetype.nvim

A faster version of filetype.vim
564 stars 35 forks source link

Wrong filetype detection for files/paths containing "mak", "mk" and possibly some others #77

Open nagua opened 2 years ago

nagua commented 2 years ago

Hello everyone,

first off: thank you for your great plugin! It really is a good effort and much easier to read than vimscript.

I'm getting some strange filedetections lately and I wanted to investigate that. The situation:

I created a bash script called 'build_cmake' that uses a shebang at the top of the file. 'filetype.nvim' reports this file as a makefile. I investigated how that could happen and I found that it matches the complex regex with absolute path check:

https://github.com/nathom/filetype.nvim/blob/25b5f7e5314d5e7739be726860253c67f7e513bf/lua/filetype/init.lua#L179-L181

This happens to be the case because build_c[mak]e contains the string mak. This could also happen if you have the string mak or mk or dsp in your absolute path. So I would argue that matching on the absolute path should be done after matching a shebang. What do you think about that?

Have a great day! Nagua

fragov commented 1 year ago

Yes, I confirm. I use Oil.nvim, and there is 'mak' in my home directory name. If I open anything in the home directory with Oil.nvim, the plugin set the file type to 'make'. And it breaks work of the Oil.nvim plugin.