I'm looking for a way to set
filetype on load, a loading phase via
Right now I can open the files inside a given directory via some utility function that I wrote, and during the opening phase, I'm setting a
filetype and it works.
Now what I want to achieve is that no matter where or how I open something of that kind, I would like to have a
ftdetect rule, that matches the correct
Let's say I have a variable as
let g:special_dir = '/path/to/dir', and that directory has an arbitrarily deep file tree.
I would like that whenever I open
/path/to/dir/deep/route/file, I set one
filetype, but If I open
/path/to/dir/deep/route/directory I set another.
I have being reading, it's not clear to me If I can set a variable to be the matching criteria for the
autocommand that does the setting, but at least if I can parametrize the glob expression that it's used there, I can instead of setting the file type plain and simple, I could call a function that does that.
In other words, I would like to find a way to do something like
function SpecialFileTypeResolver(filename) " Logic" endfun let g:special_dir = '/path/to/dir' au BufNewFile,BufRead g:special_dir :call SpecialFileTypeResolver(<filename>)
Now I know that you can set file type to directories,
nerdtree do something similar, but honestly I haven't had a deep jump in to the code, I've only tried and
grep out the file where that condition is coded, but no luck there.