Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- function stamp_input() {
- while IFS= read -r string; do
- printf '%s\n' "$string"
- printf 'Input: [%s] %s\n' $(date +%s.%4N) "$string" 1>&2
- done
- }
- function stamp_output() {
- while IFS= read -r string; do
- printf '[%s] %s\n' $(date +%s.%4N) "$string"
- done
- }
- 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": ""}}}'
- 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'
- 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": {}}'
- cat <(echo -en $LSP_INIT_CMDS) \
- <(sleep 2 && echo -en $LSP_BODY_CMDS | stamp_input | head -c -1) \
- <(sleep 3 && echo -en $LSP_SHUTDOWN_CMDS | head -c -2) \
- | coq-lsp | stamp_output | grep "goals"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement