pub struct LspClient { /* private fields */ }Expand description
LSP Client
Manages a single LSP server connection and provides high-level API for common LSP operations like hover, definition, references, and diagnostics.
Implementations§
Source§impl LspClient
impl LspClient
Sourcepub fn new(
language: impl Into<String>,
server_name: impl Into<String>,
project_root: PathBuf,
) -> Self
pub fn new( language: impl Into<String>, server_name: impl Into<String>, project_root: PathBuf, ) -> Self
Create a new LSP client
Sourcepub fn from_config(config: &LspServerConfig, project_root: PathBuf) -> Self
pub fn from_config(config: &LspServerConfig, project_root: PathBuf) -> Self
Create LSP client from config
Sourcepub async fn spawn(&self, config: &LspServerConfig) -> Result<()>
pub async fn spawn(&self, config: &LspServerConfig) -> Result<()>
Spawn and initialize the LSP server
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Send LSP initialize request
Sourcepub async fn initialized(&self) -> Result<()>
pub async fn initialized(&self) -> Result<()>
Send initialized notification
Sourcepub async fn open_file(&self, uri: &Url, content: &str) -> Result<()>
pub async fn open_file(&self, uri: &Url, content: &str) -> Result<()>
Open a file in the LSP server
Sourcepub async fn hover(
&self,
uri: &Url,
position: Position,
) -> Result<Option<HoverResult>>
pub async fn hover( &self, uri: &Url, position: Position, ) -> Result<Option<HoverResult>>
Get hover information at a position
Sourcepub async fn definition(
&self,
uri: &Url,
position: Position,
) -> Result<Vec<Location>>
pub async fn definition( &self, uri: &Url, position: Position, ) -> Result<Vec<Location>>
Get definition locations at a position
Sourcepub async fn references(
&self,
uri: &Url,
position: Position,
include_declaration: bool,
) -> Result<Vec<Location>>
pub async fn references( &self, uri: &Url, position: Position, include_declaration: bool, ) -> Result<Vec<Location>>
Get reference locations at a position
Sourcepub async fn diagnostics(&self, uri: &Url) -> Result<Vec<Diagnostic>>
pub async fn diagnostics(&self, uri: &Url) -> Result<Vec<Diagnostic>>
Get diagnostics for a file from cache
Sourcepub async fn update_diagnostics(&self, uri: Url, diagnostics: Vec<Diagnostic>)
pub async fn update_diagnostics(&self, uri: Url, diagnostics: Vec<Diagnostic>)
Update diagnostics cache (called when receiving publishDiagnostics notification)
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if the client is connected
Sourcepub fn server_name(&self) -> &str
pub fn server_name(&self) -> &str
Get the server name
Sourcepub fn project_root(&self) -> &PathBuf
pub fn project_root(&self) -> &PathBuf
Get the project root
Sourcepub async fn capabilities(&self) -> Option<ServerCapabilities>
pub async fn capabilities(&self) -> Option<ServerCapabilities>
Get server capabilities
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
Mutably borrows from an owned value. Read more