Change directory for a buffer

Hi! :wave:

I’m trying to change the working directory of a buffer using an Autocommand.
My Goal is to change the Working Directory of my Notes.

Eg I’m working on a project at ~/projects/fun/. Then I open a note at ~/notes/remember.md.
Now I’d like to have that buffer (~/notes/remember.md) have the working directory ~/notes, so some lsp plugins like ltex and marksman work properly.

Reading the docs, I found “:cd”, “:lcd” and “:tcd”.

“:lcd” looked correct, but it seems to change the dir of the window.
So when I switch between buffers in the same window the working directories get messed up.
I guess I’d have to remember the set path, before calling lcd, and reset it on bufleave?

Is there an easier, less error-prone, way of doing this?
Or is my whole workflow wrong? :laughing:

Cheers