Advertisement
Guest User

time_lsp.sh

a guest
Mar 15th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.61 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. function stamp_input() {
  3.     while IFS= read -r string; do
  4.         printf '%s\n' "$string"
  5.         printf 'Input: [%s] %s\n' $(date +%s.%4N) "$string" 1>&2
  6.     done
  7. }
  8. function stamp_output() {
  9.     while IFS= read -r string; do
  10.         printf '[%s] %s\n' $(date +%s.%4N) "$string"
  11.     done
  12. }
  13. LSP_INIT_CMDS='Content-Length: 240\r\n\r\n{"jsonrpc": "2.0", "id": 0, "method": "initialize", "params": {"processId": 3994151, "rootPath": ".", "rootUri": ".", "initializationOptions": null, "capabilities": {}, "trace": "off", "workspaceFolders": [{"name": "coq-lsp", "uri": "."}]}}Content-Length: 57\r\n\r\n{"jsonrpc": "2.0", "method": "initialized", "params": {}}Content-Length: 148\r\n\r\n{"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"uri": "local1.v", "languageId": "Coq", "version": 1, "text": ""}}}'
  14. LSP_BODY_CMDS='Content-Length: 167\r\n\r\n{"jsonrpc": "2.0", "method": "textDocument/didChange", "params": {"textDocument": {"uri": "local1.v", "version": 2}, "contentChanges": [{"text": "Variable x: nat."}]}}Content-Length: 143\r\n\r\n{"jsonrpc": "2.0", "id": 1, "method": "proof/goals", "params": {"textDocument": {"uri": "local1.v"}, "position": {"line": 0, "character": 16}}}\n'
  15. LSP_SHUTDOWN_CMDS='Content-Length: 63\r\n\r\n{"jsonrpc": "2.0", "id": 3, "method": "shutdown", "params": {}}Content-Length: 50\r\n\r\n{"jsonrpc": "2.0", "method": "exit", "params": {}}'
  16. cat <(echo -en $LSP_INIT_CMDS) \
  17.     <(sleep 2 && echo -en $LSP_BODY_CMDS | stamp_input | head -c -1) \
  18.     <(sleep 3 && echo -en $LSP_SHUTDOWN_CMDS | head -c -2) \
  19.     | coq-lsp | stamp_output | grep "goals"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement