vec*_*cin 7 neovim language-server-protocol pyright python-language-server nvim-lspconfig
当我打开 python 文件时,诊断似乎工作正常。然后,我导航到出现诊断错误的行,按快捷方式调用代码操作(在我的例子中为“<space>ca”),然后收到一条消息“没有可用的代码操作”。我尝试运行它以解决不同的错误,例如以下错误:
b =1 #E225 missing whitespace around operator
from jinja2 import StrictUndefined #'jinja2.StricUndefined' imported but unused
import jjj # import-error: Unable to import 'jjj'
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经尝试了两个 LSP 服务器:pyright 和 pylsp,两者都给了我相同的“没有可用的代码操作”
我见过类似的问题,但 JavaScript在这里询问,它建议安装一个插件,但这对我不起作用。
Sag*_*age 11
不幸的是,Pyright 和 Pyls 都不提供任何诊断解决代码操作,例如 java 的 jdtls...
我建议查看它们在 github 上的个人存储库以获取更多信息和开发:
pyright、
pyright
要更深入地了解您的语言服务器的功能,请在 vim 中运行以下命令:
:lua print(vim.inspect(vim.lsp.buf_get_clients()[1].resolved_capabilities))
Run Code Online (Sandbox Code Playgroud)
它将在当前缓冲区中输出您所附加的语言服务器的功能。
例如,这是没有特殊配置的 Pyright 的输出:
{
call_hierarchy = true,
code_action = {
codeActionKinds = { "quickfix", "source.organizeImports" },
workDoneProgress = true
},
code_lens = false,
code_lens_resolve = false,
completion = true,
declaration = false,
document_formatting = false,
document_highlight = {
workDoneProgress = true
},
document_range_formatting = false,
document_symbol = {
workDoneProgress = true
},
execute_command = true,
find_references = {
workDoneProgress = true
},
goto_definition = {
workDoneProgress = true
},
hover = {
workDoneProgress = true
},
implementation = false,
rename = true,
signature_help = true,
signature_help_trigger_characters = { "(", ",", ")" },
text_document_did_change = 2,
text_document_open_close = true,
text_document_save = true,
text_document_save_include_text = false,
text_document_will_save = false,
text_document_will_save_wait_until = false,
type_definition = false,
workspace_folder_properties = {
changeNotifications = false,
supported = false
},
workspace_symbol = {
workDoneProgress = true
}
}
Run Code Online (Sandbox Code Playgroud)
目前 Pyright 仅支持组织导入代码操作。
请记住,某些 lsp 根本不提供代码操作,但通常它们确实提供基本需求,例如转到定义/声明、悬停信息、文档、签名帮助、重命名和引用。
| 归档时间: |
|
| 查看次数: |
9385 次 |
| 最近记录: |