Open abitrolly opened 3 years ago
Debugging with httpie
fails, because it sends HTTP headers and expects HTTP headers. It should be patched (or extended with TransportPlugin
to just send Content-Length
and expect Content-Length
in return.
The plugin in turn is requests
Transport Adapter.
http -v 127.0.0.1:9084 method=initialize id=1 --debug --traceback --stream
/spent 10h
requests
only needs to implement one method - send()
- https://docs.python-requests.org/en/latest/_modules/requests/adapters/
The requests
API is tied to Session
, but it is not possible to add own methods to it without monkeypatching. So users will need to use standard .get()
(or .post()
) calls with JSON-RPC method names added to passed JSON.
import requests
from requests_lsp import LSPAdapter
session = requests.Session()
session.mount("lsp://", LSPAdapter())
response = session.get("lsp://127.0.0.1:9084", json={"id":"1", "method": "initialize"})
print(response.json())
Adapter should save connection between calls, provide Content-Length
header and JSON-RPC ids if they are not set.
Working proof of concept for requests
adapter is done - https://github.com/abitrolly/requests-lsp
/spent 20h
I need to troubleshoot failing tests for my Ruby project in GitLab.
Write LSIF indexer that uses existing LSP server
The server on port 9084 silently exits after the first wrong request. Maybe it needs some debug params.
initialize
request. LSP uses JSON-RPC protocol withContent-length
headers and without HTTP methods.lsp://
Transport Plugin tohttpie
(requests
Transport Adapter) for easier debugging from command line*.rb
files usingtextDocument/didOpen
(textDocumentItem)[https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentItem]