나는 LSP 주위에서 놀고 있는데 첫 단계를 지나칠 수 없습니다. 작업이 간단하기 때문에 Python을 클라이언트 언어로 사용하고 있습니다. 내가하는 일은 :
나는 내가 할 수있는 모든 것을 시도했고 내가 찾을 수있는 것을 읽었지만 성공하지 못했습니다. LSP에 더 정통한 사람이 내가 뭘 잘못하고 있는지 지적하는 데 도움이되기를 바랍니다.
다음은 내 Python 코드입니다. 나는 PHP 언어 서버로 시도했지만 사용되는 서버의 종류는 중요하지 않습니다.
import socket
import sys
initReq = """
{
"jsonrpc": "2.0",
"id": 1,
"method": " initialize",
"params": {
"processId": null,
"rootPath": "/Users/stefano/Testing/PHPSources",
"rootUri": "file:///Users/stefano/Testing/PHPSources",
"capabilities": {
"workspace": {
"applyEdit": true,
"workspaceEdit": {
"documentChanges": true,
"resourceOperations": [
"create",
"rename",
"delete"
],
"failureHandling": "textOnlyTransactional"
},
"didChangeConfiguration": {
"dynamicRegistration": true
},
"didChangeWatchedFiles": {
"dynamicRegistration": true
},
"symbol": {
"dynamicRegistration": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
}
},
"executeCommand": {
"dynamicRegistration": true
},
"configuration": true,
"workspaceFolders": true
},
"textDocument": {
"publishDiagnostics": {
"relatedInformation": true,
"tagSupport": true
},
"synchronization": {
"dynamicRegistration": true,
"willSave": true,
"willSaveWaitUntil": true,
"didSave": true
},
"completion": {
"dynamicRegistration": true,
"contextSupport": true,
"completionItem": {
"snippetSupport": true,
"commitCharactersSupport": true,
"documentationFormat": [
"markdown",
"plaintext"
],
"deprecatedSupport": true,
"preselectSupport": true
},
"completionItemKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
]
}
},
"hover": {
"dynamicRegistration": true,
"contentFormat": [
"markdown",
"plaintext"
]
},
"signatureHelp": {
"dynamicRegistration": true,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
],
"parameterInformation": {
"labelOffsetSupport": true
}
}
},
"definition": {
"dynamicRegistration": true,
"linkSupport": true
},
"references": {
"dynamicRegistration": true
},
"documentHighlight": {
"dynamicRegistration": true
},
"documentSymbol": {
"dynamicRegistration": true,
"symbolKind": {
"valueSet": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
]
},
"hierarchicalDocumentSymbolSupport": true
},
"codeAction": {
"dynamicRegistration": true,
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
}
},
"codeLens": {
"dynamicRegistration": true
},
"formatting": {
"dynamicRegistration": true
},
"rangeFormatting": {
"dynamicRegistration": true
},
"onTypeFormatting": {
"dynamicRegistration": true
},
"rename": {
"dynamicRegistration": true,
"prepareSupport": true
},
"documentLink": {
"dynamicRegistration": true
},
"typeDefinition": {
"dynamicRegistration": true,
"linkSupport": true
},
"implementation": {
"dynamicRegistration": true,
"linkSupport": true
},
"colorProvider": {
"dynamicRegistration": true
},
"foldingRange": {
"dynamicRegistration": true,
"rangeLimit": 5000,
"lineFoldingOnly": true
},
"declaration": {
"dynamicRegistration": true,
"linkSupport": true
}
}
},
"initializationOptions": {
"storagePath": "/Users/hosanna/Library/Application Support/Code/User/workspaceStorage/30bd6a399166f4f329c9f383d63b74ca/bmewburn.vscode-intelephense-client",
"clearCache": false
},
"trace": "verbose",
"workspaceFolders": [
{
"uri": "file:///Users/stefano/Testing/PHPSources",
"name": "TransportationApp"
}
]
}
}
"""
host = '127.0.0.1'
port = 8088
# create socket
print('# Creating socket')
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error:
print('Failed to create socket')
sys.exit()
# Connect to remote server
print('# Connecting to server, ' + host)
s.connect((host , port))
# Send data to remote server
print('# Sending data to server')
try:
s.sendall(initReq.encode('utf-8'))
except socket.error:
print('Send failed')
sys.exit()
# Receive data
print('# Receive data from server')
reply = s.recv(4096)
print(reply)
헤더 부분과 각각의 새 줄이 누락되었습니다. Github 에 도움 을 주신 rcjsuen 에게 감사드립니다.
참조 형식은 다음과 같아야합니다.
Content-Length: <length>\r\n
\r\n
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/didOpen",
"params": {
...
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다