I am trying to persist some state about my buffers, specifically terminal buffers, over vim sessions with :mksession through the plugin 'vim-session' by xolox.
The goal is to assign labels to the terminal buffers (for usage with the terminal JSON API, implementing a source/sink based dynamic coupling), but for the future, I would like to have arbitrary data coupled tightly with my buffers. Terminals already restore nicely over sessions if their invocation command captures all behavior. It would maybe be possible to capture a label in those commands, but I don't like that as a system as it only solves the issue for terminals, but not for buffers in general.
The buffer number does not stay constant over session instances, so a global variable that I may persist to index the buffers (the xolox session-plugin allows this) is out of the question.
I have scoured the :opt list of buffer options for something that is designed to store some arbitrary data, but found none.
How would I go about achieving that goal of attaching metadata to a buffer for permanent identification? Thanks!