pub struct LanguageServer {
pub output_done_rx: UnboundedReceiver<String>,
/* private fields */
}Fields§
§output_done_rx: UnboundedReceiver<String>Implementations§
Source§impl LanguageServer
impl LanguageServer
Sourcepub fn new(
binary: LanguageServerBinary,
id: i32,
root_path: &Path,
capture: Arc<Mutex<Option<String>>>,
code_action_kind: Option<Vec<CodeActionKind>>,
) -> Result<Self>
pub fn new( binary: LanguageServerBinary, id: i32, root_path: &Path, capture: Arc<Mutex<Option<String>>>, code_action_kind: Option<Vec<CodeActionKind>>, ) -> Result<Self>
Start a new language server process A process is construct by one io_listener and one listener_loop When sending something to the process, the request will be handled by background task keeping the process lock-free
§Usage
let binary: LanguageServerBinary = LanguageServerBinary { ... };
let root_path = Path::new("your-root");
// Stderr capture will take every stderr response receivered
// usefull for logging
let stderr_capture = Arc::new(Mutex::new(...))
let server =
LanguageServerProcess::new(binary, 1, root_path, stderr_capture, None)?;binary: See LanguageServerBinaryid: id for the serverroot_path: Root path for the lsp, useful for discovering workspacescapture: Stderr capturercode_action_kind: List of code action kinds that will be registered during startup
Sourcepub async fn request<T: Request>(&self, params: T::Params) -> Result<T::Result>
pub async fn request<T: Request>(&self, params: T::Params) -> Result<T::Result>
Send a request to the server and get the response back T must be type of request::Request. We had re-exported the module
§Usage
use chan_rs::lsp_types::request::Initialize;
let init_params = IntializeParams::default();
let response = server.request::<Initialize>(init_params)?;params: Parameters for the request
Sourcepub async fn notify<T: Notification>(&self, params: T::Params) -> Result<()>
pub async fn notify<T: Notification>(&self, params: T::Params) -> Result<()>
Send a notify to the server, notify requests don’t send response back T must be type of notification::Notification. We had re-exported the module
§Usage
use chan_rs::lsp_types::notification::Initialized;
let initialized = IntializedParams::default();
server.notify::<Initialized>(initialized)?;params: Parameters for the notification
Sourcepub fn on_request<T: Request, F, Fut>(&self, f: F) -> Subscription
pub fn on_request<T: Request, F, Fut>(&self, f: F) -> Subscription
Register a handler to handle incoming request You can only register on handler for one method
Sourcepub fn on_notification<T: Notification, F>(&self, f: F) -> Subscription
pub fn on_notification<T: Notification, F>(&self, f: F) -> Subscription
Register a handler to handle incoming notification You can only register one handler for one method
Sourcepub fn on_io<F>(&self, f: F) -> Subscription
pub fn on_io<F>(&self, f: F) -> Subscription
Register a handler to handle stdio You can re-regsiter the handler
Sourcepub fn working_dir(&self) -> &PathBuf
pub fn working_dir(&self) -> &PathBuf
Working dir of the workspace
Sourcepub fn capabilities(&self) -> ServerCapabilities
pub fn capabilities(&self) -> ServerCapabilities
List of capablilities
Sourcepub fn update_capabilities(&self, update: impl FnOnce(&mut ServerCapabilities))
pub fn update_capabilities(&self, update: impl FnOnce(&mut ServerCapabilities))
Update the server capabilities
Sourcepub fn code_action_kinds(&self) -> Option<Vec<CodeActionKind>>
pub fn code_action_kinds(&self) -> Option<Vec<CodeActionKind>>
List code action kinds