Simple way to store additionnal config in the scope of the actual directory [duplicate]

I have my .vimrc with some global/local configurations, but when I am working in a project, I know that I often create configs (settings, mapping, command, abbreviations, etc.) specifically for this project.

I usually create a session to make them accessible in the directory where I use them with:

:mks!


That create a Session.vim file where my specific configurations are (see :help mksession).

I am asking myself if there is a better/simpler way to do so for my use case (if it's possible, a way to load directly my saved settings when I open a file with vim in the same directory).

Off the top of my head perhaps something like this in your vimrc...

let g:localconffile = '.myvimconf'

let l:fname =  expand('%:p:h') . '/' . g:localconffile
exe "source " . l:fname
endif
endfunc

augroup localconf
autocmd!

VimEnter is going to trigger this only when you first open Vim. If you want this to happen for each file opened we'd use something like BufReadPost.