Skip to content

Instantly share code, notes, and snippets.

@thomasfaingnaert
Last active July 5, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasfaingnaert/6006fe12473a2b452c35ffea3197d461 to your computer and use it in GitHub Desktop.
Save thomasfaingnaert/6006fe12473a2b452c35ffea3197d461 to your computer and use it in GitHub Desktop.
Control LSP server from Bash
#!/usr/bin/env bash
send()
{
local length=${#1}
printf "Content-Length: $length\r\n" >pipe
printf '\r\n' >pipe
printf ${1//\\/\\\\} >pipe
}
rm -rf pipe
mkfifo pipe
language-server <pipe &
exec 3>pipe
# initialize
send '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{...}}'
sleep 1
# initialized
send '{"jsonrpc":"2.0","method":"initialized","params":{}}'
sleep 1
# ...
exec 3>&-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment