pub struct LspClient { /* private fields */ }Expand description
LSP Client for a single language server
Implementations§
Source§impl LspClient
impl LspClient
Sourcepub async fn new(config: LspConfig) -> Result<Self>
pub async fn new(config: LspConfig) -> Result<Self>
Create a new LSP client with the given configuration
Sourcepub async fn for_language(
language: &str,
root_uri: Option<String>,
) -> Result<Self>
pub async fn for_language( language: &str, root_uri: Option<String>, ) -> Result<Self>
Create an LSP client for a specific language
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Initialize the language server
Sourcepub async fn open_document(&self, path: &Path, content: &str) -> Result<()>
pub async fn open_document(&self, path: &Path, content: &str) -> Result<()>
Open a text document
Sourcepub async fn close_document(&self, path: &Path) -> Result<()>
pub async fn close_document(&self, path: &Path) -> Result<()>
Close a text document
Sourcepub async fn change_document(&self, path: &Path, content: &str) -> Result<()>
pub async fn change_document(&self, path: &Path, content: &str) -> Result<()>
Update a text document
Sourcepub async fn go_to_definition(
&self,
path: &Path,
line: u32,
character: u32,
) -> Result<LspActionResult>
pub async fn go_to_definition( &self, path: &Path, line: u32, character: u32, ) -> Result<LspActionResult>
Go to definition
Sourcepub async fn find_references(
&self,
path: &Path,
line: u32,
character: u32,
include_declaration: bool,
) -> Result<LspActionResult>
pub async fn find_references( &self, path: &Path, line: u32, character: u32, include_declaration: bool, ) -> Result<LspActionResult>
Find references
Sourcepub async fn hover(
&self,
path: &Path,
line: u32,
character: u32,
) -> Result<LspActionResult>
pub async fn hover( &self, path: &Path, line: u32, character: u32, ) -> Result<LspActionResult>
Get hover information
Sourcepub async fn document_symbols(&self, path: &Path) -> Result<LspActionResult>
pub async fn document_symbols(&self, path: &Path) -> Result<LspActionResult>
Get document symbols
Sourcepub async fn workspace_symbols(&self, query: &str) -> Result<LspActionResult>
pub async fn workspace_symbols(&self, query: &str) -> Result<LspActionResult>
Search workspace symbols
Sourcepub async fn go_to_implementation(
&self,
path: &Path,
line: u32,
character: u32,
) -> Result<LspActionResult>
pub async fn go_to_implementation( &self, path: &Path, line: u32, character: u32, ) -> Result<LspActionResult>
Go to implementation
Sourcepub async fn completion(
&self,
path: &Path,
line: u32,
character: u32,
) -> Result<LspActionResult>
pub async fn completion( &self, path: &Path, line: u32, character: u32, ) -> Result<LspActionResult>
Get code completions
Sourcepub async fn diagnostics(&self, path: &Path) -> Result<LspActionResult>
pub async fn diagnostics(&self, path: &Path) -> Result<LspActionResult>
Return the most recent LSP diagnostics for a file after ensuring the document is open.
This always syncs the current on-disk content to the server via a
textDocument/didChange (or didOpen the first time), then waits for
a fresh publishDiagnostics from the server. Without this, edits made
by file-writing tools would be invisible to the LSP’s in-memory buffer
and callers would see stale pre-edit diagnostics.
Sourcepub async fn capabilities(&self) -> Option<ServerCapabilities>
pub async fn capabilities(&self) -> Option<ServerCapabilities>
Get the server capabilities
Sourcepub fn handles_file(&self, path: &Path) -> bool
pub fn handles_file(&self, path: &Path) -> bool
Check if this client handles the given file extension
Sourcepub fn handles_language(&self, language: &str) -> bool
pub fn handles_language(&self, language: &str) -> bool
Check if this client handles a language by name
Auto Trait Implementations§
impl !Freeze for LspClient
impl !RefUnwindSafe for LspClient
impl Send for LspClient
impl Sync for LspClient
impl Unpin for LspClient
impl UnsafeUnpin for LspClient
impl !UnwindSafe 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
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request