mod config;
mod manager;
mod position;
mod protocol;
mod session;
use std::error::Error;
use std::fmt::{self, Display, Formatter};
pub use config::{LspConfig, LspConfigError, ServerProfile};
pub use manager::LspManager;
pub(crate) use manager::WireNavigationTarget;
pub(crate) use position::from_lsp_character;
pub use position::{PositionEncoding, display_column, next_byte_column, previous_byte_column};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct LspOperationId(u64);
impl LspOperationId {
pub(crate) const fn new(value: u64) -> Self {
Self(value)
}
pub(crate) const fn value(self) -> u64 {
self.0
}
}
#[non_exhaustive]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum LspError {
Disabled(String),
AmbiguousProfile(String),
InvalidDocument(String),
Process(String),
Protocol(String),
RequestFailed(String),
ContentModified,
Timeout(String),
Unsupported(String),
}
impl Display for LspError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::Disabled(detail)
| Self::AmbiguousProfile(detail)
| Self::InvalidDocument(detail)
| Self::Process(detail)
| Self::Protocol(detail)
| Self::RequestFailed(detail)
| Self::Timeout(detail)
| Self::Unsupported(detail) => formatter.write_str(detail),
Self::ContentModified => {
formatter.write_str("language server content changed while resolving the request")
}
}
}
}
impl Error for LspError {}