pub struct LspClient { /* private fields */ }Expand description
LSP 客户端
Implementations§
Source§impl LspClient
impl LspClient
Sourcepub fn with_timeout(self, timeout_ms: u64) -> Self
pub fn with_timeout(self, timeout_ms: u64) -> Self
设置超时时间
Sourcepub async fn get_state(&self, language: &str) -> ConnectionState
pub async fn get_state(&self, language: &str) -> ConnectionState
获取连接状态
Sourcepub async fn is_connected(&self, language: &str) -> bool
pub async fn is_connected(&self, language: &str) -> bool
检查是否已连接
Sourcepub async fn initialize(
&self,
language: &str,
root_path: &Path,
) -> LspResult<InitializeResult>
pub async fn initialize( &self, language: &str, root_path: &Path, ) -> LspResult<InitializeResult>
启动语言服务器并初始化
Sourcepub async fn go_to_definition(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Vec<Location>>
pub async fn go_to_definition( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Vec<Location>>
跳转到定义
Sourcepub async fn find_references(
&self,
language: &str,
file_path: &Path,
position: Position,
include_declaration: bool,
) -> LspResult<Vec<Location>>
pub async fn find_references( &self, language: &str, file_path: &Path, position: Position, include_declaration: bool, ) -> LspResult<Vec<Location>>
查找引用
Sourcepub async fn get_hover(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Option<Hover>>
pub async fn get_hover( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Option<Hover>>
获取 Hover 信息
Sourcepub async fn rename_symbol(
&self,
language: &str,
file_path: &Path,
position: Position,
new_name: &str,
) -> LspResult<Option<WorkspaceEdit>>
pub async fn rename_symbol( &self, language: &str, file_path: &Path, position: Position, new_name: &str, ) -> LspResult<Option<WorkspaceEdit>>
重命名符号
Sourcepub async fn get_document_symbols(
&self,
language: &str,
file_path: &Path,
) -> LspResult<Vec<DocumentSymbol>>
pub async fn get_document_symbols( &self, language: &str, file_path: &Path, ) -> LspResult<Vec<DocumentSymbol>>
获取文档符号
Sourcepub async fn get_workspace_symbols(
&self,
language: &str,
query: &str,
) -> LspResult<Vec<SymbolInformation>>
pub async fn get_workspace_symbols( &self, language: &str, query: &str, ) -> LspResult<Vec<SymbolInformation>>
获取工作区符号
Sourcepub async fn get_code_actions(
&self,
language: &str,
file_path: &Path,
range: Range,
diagnostics: Vec<Diagnostic>,
only: Option<Vec<CodeActionKind>>,
) -> LspResult<Vec<CodeAction>>
pub async fn get_code_actions( &self, language: &str, file_path: &Path, range: Range, diagnostics: Vec<Diagnostic>, only: Option<Vec<CodeActionKind>>, ) -> LspResult<Vec<CodeAction>>
获取代码操作
Sourcepub async fn get_signature_help(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Option<SignatureHelp>>
pub async fn get_signature_help( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Option<SignatureHelp>>
获取签名帮助
Sourcepub async fn get_document_highlights(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Vec<DocumentHighlight>>
pub async fn get_document_highlights( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Vec<DocumentHighlight>>
获取文档高亮
Sourcepub async fn format_document(
&self,
language: &str,
file_path: &Path,
tab_size: u32,
insert_spaces: bool,
) -> LspResult<Vec<TextEdit>>
pub async fn format_document( &self, language: &str, file_path: &Path, tab_size: u32, insert_spaces: bool, ) -> LspResult<Vec<TextEdit>>
格式化文档
Sourcepub async fn get_completions(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Vec<CompletionItem>>
pub async fn get_completions( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Vec<CompletionItem>>
获取代码补全
Sourcepub async fn go_to_implementation(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Vec<Location>>
pub async fn go_to_implementation( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Vec<Location>>
跳转到实现
Sourcepub async fn go_to_type_definition(
&self,
language: &str,
file_path: &Path,
position: Position,
) -> LspResult<Option<Location>>
pub async fn go_to_type_definition( &self, language: &str, file_path: &Path, position: Position, ) -> LspResult<Option<Location>>
跳转到类型定义
Sourcepub async fn shutdown_all(&self) -> LspResult<()>
pub async fn shutdown_all(&self) -> LspResult<()>
关闭所有语言服务器
Sourcepub fn get_language_from_extension(ext: &str) -> Option<&'static str>
pub fn get_language_from_extension(ext: &str) -> Option<&'static str>
根据文件扩展名获取语言
Sourcepub fn manager(&self) -> Arc<LanguageServerManager>
pub fn manager(&self) -> Arc<LanguageServerManager>
获取服务器管理器
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LspClient
impl !RefUnwindSafe for LspClient
impl !UnwindSafe for LspClient
impl Send for LspClient
impl Sync for LspClient
impl Unpin for LspClient
impl UnsafeUnpin for LspClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more