lsp/server: protect lsp state modifications with mutex
So far the LSP server has a strict 1-to-1 relationship with a connection
to an editor. Consequently no locking has been needed because all
requests come from the same source, and due to the way the JSON RPC
connection is configured, there's been no possibility of concurrent
requests being sent to any server.
But this is about to change and so a single server will have to deal
with having to do work for more than one client. To make this safe, we
add a mutex, and make sure it's held for every implemented LSP method.
Signed-off-by: Matthew Sackman <matthew@cue.works>
Change-Id: I75a8ffc3a50bcd120d4edfeea03b29a0c56bdea0
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1232174
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>