Automatically refresh the location list

Hi all,

I was wondering if it was possible to have the location list be refreshed automatically.
I have a mapping to open the location list (i.e. lua vim.diagnostic.setloclist()) but even when I fix the error I have to re-open the location list for the error/warning to disappear.

Is there anyway to achieve this?
Thanks