I can use the
finddir function to find a parent folder that contains a
.git folder (project root), like this:
let dir = finddir('.git/..', ';')
However, this only finds project roots that are parent folders of Vim's current working directory, which is usually the directory Vim was started in. I would like to find project roots that are parent folders of the location of the currently active buffer.
Edit: I tried
let dir = finddir('.git/..', expand('%').';')
But this always returns the current directory for some reason.