Closed K-gihu closed 2 years ago
I can't reproduce your problem, my jedi-language-server --version
is 0.36.1
打开 lsp-bridge-enable-log 之后,进行与上面相同的操作,*lsp-bridge*
显示:
Eval in Emacs: (lsp-bridge--first-start '58243)
Eval in Emacs: (message '"[LSP-Bridge] Start LSP server (jedi) for /home/klu/test.py...")
Handlers: [<class 'core.handler.completion.Completion'>,
<class 'core.handler.completion_item.CompletionItem'>,
<class 'core.handler.find_define.FindDefine'>,
<class 'core.handler.find_implementation.FindImplementation'>,
<class 'core.handler.find_references.FindReferences'>,
<class 'core.handler.hover.Hover'>,
<class 'core.handler.signature_help.SignatureHelp'>,
<class 'core.handler.prepare_rename.PrepareRename'>,
<class 'core.handler.rename.Rename'>,
<class 'core.handler.jdt_uri_resolver.JDTUriResolver'>,
<class 'core.handler.deno_uri_resolver.DenoUriResolver'>,
<class 'core.handler.code_action.CodeAction'>,
<class 'core.handler.formatting.Formatting'>,
<class 'core.handler.execute_command.ExecuteCommand'>,
<class 'core.handler.workspace_symbol.WorkspaceSymbol'>]
--- Send initialize for /home/klu/test.py (jedi)
--- Send (25015): initialize
{
"id": 25015,
"method": "initialize",
"params": {
"processId": 191312,
"rootPath": "/home/klu/test.py",
"clientInfo": {
"name": "emacs",
"version": "GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)\n of 2022-10-25"
},
"rootUri": "file:///home/klu/test.py",
"capabilities": {
"workspace": {
"configuration": true,
"symbol": {
"resolveSupport": {
"properties": []
}
}
},
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": false,
"deprecatedSupport": true,
"tagSupport": {
"valueSet": [
1
]
}
}
},
"codeAction": {
"dynamicRegistration": false,
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
},
"isPreferredSupport": true
}
}
},
"initializationOptions": {}
},
"jsonrpc": "2.0"
}
--- Recv response jedi (25015)
{
"jsonrpc": "2.0",
"id": 25015,
"result": {
"capabilities": {
"textDocumentSync": {
"openClose": true,
"change": 2,
"willSave": null,
"willSaveWaitUntil": null,
"save": true
},
"completionProvider": {
"triggerCharacters": [
".",
"'",
"\""
],
"resolveProvider": true
},
"hoverProvider": true,
"signatureHelpProvider": {
"triggerCharacters": [
"(",
","
]
},
"definitionProvider": true,
"typeDefinitionProvider": {},
"referencesProvider": true,
"documentHighlightProvider": true,
"documentSymbolProvider": true,
"codeActionProvider": {
"codeActionKinds": [
"refactor.inline",
"refactor.extract"
]
},
"renameProvider": true,
"executeCommandProvider": {
"commands": []
},
"workspaceSymbolProvider": true,
"workspace": {
"workspaceFolders": {
"supported": true,
"changeNotifications": true
},
"fileOperations": {}
}
}
}
}
Eval in Emacs: (message '"[LSP-Bridge] Start LSP server (jedi) for /home/klu/test.py with 'single-file' mode, enjoy hacking!")
--- Send (notification): initialized
{
"method": "initialized",
"params": {},
"jsonrpc": "2.0"
}
--- Send (notification): workspace/didChangeConfiguration
{
"method": "workspace/didChangeConfiguration",
"params": {
"settings": {}
},
"jsonrpc": "2.0"
}
--- Send (notification): textDocument/didOpen
{
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///home/klu/test.py",
"languageId": "python",
"version": 0,
"text": "a = 3\n"
}
},
"jsonrpc": "2.0"
}
--- Send (22040): textDocument/definition
{
"id": 22040,
"method": "textDocument/definition",
"params": {
"position": {
"line": 0,
"character": 0
},
"textDocument": {
"uri": "file:///home/klu/test.py"
}
},
"jsonrpc": "2.0"
}
--- Recv notification: textDocument/publishDiagnostics
{
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
"uri": "file:///home/klu/test.py",
"diagnostics": []
}
}
ERROR:pygls.protocol:Failed to handle request 22040 textDocument/definition work_done_token=None text_document=TextDocumentIdentifier(uri='file:///home/klu/test.py') position=0:0
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/pygls/protocol.py", line 331, in _handle_request
self._execute_request(msg_id, handler, params)
File "/usr/lib/python3.10/site-packages/pygls/protocol.py", line 260, in _execute_request
method_name, method_type, msg_id, handler(params))
File "/usr/lib/python3.10/site-packages/jedi_language_server/server.py", line 306, in definition
definitions = [
File "/usr/lib/python3.10/site-packages/jedi_language_server/server.py", line 306, in <listcomp>
definitions = [
File "/usr/lib/python3.10/site-packages/jedi_language_server/server.py", line 308, in <genexpr>
for definition in (jedi_utils.lsp_location(name) for name in names)
File "/usr/lib/python3.10/site-packages/jedi_language_server/jedi_utils.py", line 107, in lsp_location
return Location(uri=module_path.as_uri(), range=lsp)
AttributeError: 'str' object has no attribute 'as_uri'
--- Recv message (error):
{
"jsonrpc": "2.0",
"id": 22040,
"error": {
"code": -32602,
"message": "AttributeError: 'str' object has no attribute 'as_uri'",
"data": "{'traceback': [' File \"/usr/lib/python3.10/site-packages/pygls/protocol.py\", line 331, in _handle_request\\n self._execute_request(msg_id, handler, params)\\n', ' File \"/usr/lib/python3.10/site-packages/pygls/protocol.py\", line 260, in _execute_request\\n method_name, method_type, msg_id, handler(params))\\n', ' File \"/usr/lib/python3.10/site-packages/jedi_language_server/server.py\", line 306, in definition\\n definitions = [\\n', ' File \"/usr/lib/python3.10/site-packages/jedi_language_server/server.py\", line 306, in <listcomp>\\n definitions = [\\n', ' File \"/usr/lib/python3.10/site-packages/jedi_language_server/server.py\", line 308, in <genexpr>\\n for definition in (jedi_utils.lsp_location(name) for name in names)\\n', ' File \"/usr/lib/python3.10/site-packages/jedi_language_server/jedi_utils.py\", line 107, in lsp_location\\n return Location(uri=module_path.as_uri(), range=lsp)\\n']}"
}
}
Eval in Emacs: (message '"[LSP-Bridge] AttributeError: 'str' object has no attribute 'as_uri'")
Eval in Emacs: (lsp-bridge-diagnostic--render '"/home/klu/test.py" '())
--- Send (33658): textDocument/signatureHelp
{
"id": 33658,
"method": "textDocument/signatureHelp",
"params": {
"position": {
"line": 0,
"character": 0
},
"textDocument": {
"uri": "file:///home/klu/test.py"
}
},
"jsonrpc": "2.0"
}
--- Recv response jedi (33658): textDocument/signatureHelp
{
"jsonrpc": "2.0",
"id": 33658,
"result": null
}
--- Send (6143): textDocument/signatureHelp
{
"id": 6143,
"method": "textDocument/signatureHelp",
"params": {
"position": {
"line": 0,
"character": 0
},
"textDocument": {
"uri": "file:///home/klu/test.py"
}
},
"jsonrpc": "2.0"
}
--- Recv response jedi (6143): textDocument/signatureHelp
{
"jsonrpc": "2.0",
"id": 6143,
"result": null
}
--- Send (15734): textDocument/signatureHelp
{
"id": 15734,
"method": "textDocument/signatureHelp",
"params": {
"position": {
"line": 0,
"character": 0
},
"textDocument": {
"uri": "file:///home/klu/test.py"
}
},
"jsonrpc": "2.0"
}
--- Recv response jedi (15734): textDocument/signatureHelp
{
"jsonrpc": "2.0",
"id": 15734,
"result": null
}
--- Send (32487): textDocument/signatureHelp
{
"id": 32487,
"method": "textDocument/signatureHelp",
"params": {
"position": {
"line": 0,
"character": 0
},
"textDocument": {
"uri": "file:///home/klu/test.py"
}
},
"jsonrpc": "2.0"
}
--- Recv response jedi (32487): textDocument/signatureHelp
{
"jsonrpc": "2.0",
"id": 32487,
"result": null
}
--- Send (notification): textDocument/didClose
{
"method": "textDocument/didClose",
"params": {
"textDocument": {
"uri": "file:///home/klu/test.py"
}
},
"jsonrpc": "2.0"
}
--- Send (14501): shutdown
{
"id": 14501,
"method": "shutdown",
"params": {},
"jsonrpc": "2.0"
}
--- Send (notification): exit
{
"method": "exit",
"params": {},
"jsonrpc": "2.0"
}
Exit server: /home/klu/test.py#jedi
--- Lsp server exited, exit code: -9
b''
使用 arch linux 系统,几个包的版本是:
% pacman -Q python-jedi jedi-language-server emacs-git
python-jedi 0.18.1-1
jedi-language-server 0.37.0-2
emacs-git 29.0.50.161406-1
lsp-bridge 用最新的。
把你的 test.py 附件发上来看看吧
test.py 实际上只有一行,就是这个
a = 3
然后把光标放在 a 上执行 lsp-bridge-find-def
之后就会出现上面的错误
我怀疑这可能是 jedi 服务器配置的问题?我还是第一次用 jedi,请问您用了什么样的配置文件呢?
我怀疑这可能是 jedi 服务器配置的问题?我还是第一次用 jedi,请问您用了什么样的配置文件呢?
我用pyright
我没有配置 jedi , 请排查一下自己的配置吧。
To reproduce, open emacs with:
test.el:
Then open a test python file
~/test.py
, in which:Place the cursor on
a
,and pressC-7
, error occurs in*lsp-bridge*
buffer: