au BufNewFile,BufRead *requirements.{txt,in} set ft=requirements
au BufNewFile,BufRead *requirements/*.{txt,in} set ft=requirements

" vim: et sw=4 ts=4 sts=4:

function! s:isRequirementsFile()
    let l:filename = expand("%:p")

    if l:filename =~# '\v.*requirements\.(txt|in)'
        return 1
    endif

    if l:filename =~# '\v.requirements/.*\.(txt|in)'
        return 1
    endif

    return 0
endfunction

au BufNewFile,BufRead *.{txt,in} if s:isRequirementsFile() | set ft=requirements

" vim: et sw=4 ts=4 sts=4:

Use regular expression at filetype detection
Use regular expression at filetype detection

raimon49/requirements.txt.vim