How to get custom object fields displaying in code completion in VS Code
Autocomplete depends on the metadata cache. To fix this, go to View > Command Palette (Ctrl-Shift-P), and type in "sobject". You should see a command "SFDX: Refresh sobject definitions." After that command runs, you should get autocomplete for all custom objects and fields.
I will answer my own question because I have found the problem (I think).
The autocomplete for custom object depends on the metadata definition, like @sfdcfox said. After updating the sobjects it did not work again. The tricky part is: my org has a namespace, so I should explicitly specify the namespace prefix to the custom object name in the apex code.
It is not necessary to do this in order for the code to work, but it seems to be necessary for the vs code to make the autocompletion work :(
So with a namespace prefix it works, without it not: