不幸的是,Pyright 和 Pyls 都没有提供任何诊断解决代码操作,例如 jdtls for java...
我建议在 github 上查看他们各自的存储库以获取更多信息和开发:
pyls,
pyright
要更深入地了解您的语言服务器能够在 vim 中运行以下命令:
:lua print(vim.inspect(vim.lsp.buf_get_clients()[1].resolved_capabilities))
它将在当前缓冲区中输出您附加到的语言服务器的功能。
例如,这是 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
}
}
目前 Pyright 仅支持组织导入代码操作。
请记住,一些 lsp 根本不提供代码操作,但通常它们确实提供了基本需求,例如转到定义/声明、悬停信息、文档、签名帮助、重命名和引用。