Skip to main content

ServerInitConfig

Struct ServerInitConfig 

Source
pub struct ServerInitConfig { /* private fields */ }
Expand description

Configuration for LSP server initialization.

Built by Self::new; the fields are private so the effective initialization_options live in exactly one place, the LspServerConfig this was built from.

Implementations§

Source§

impl ServerInitConfig

Source

pub const fn new( server_config: LspServerConfig, workspace_roots: WorkspaceRoots, position_encodings: PositionEncodings, redactions: Arc<Redactions>, ) -> Self

Builds the config a server is spawned from.

server_config must already carry the effective initialization options (for example with the tsserver pin applied): they are sent as they are and are the only copy.

position_encodings is the preference order from crate::config::WorkspaceConfig::position_encodings, sent as capabilities.general.positionEncodings during LspServer::spawn’s initialize handshake. redactions holds the secrets of every configured server, hidden in this server’s output; LspServer::spawn adds the secrets of this server’s own configuration and current environment, so an empty set still hides them, and serve fills it with the secrets of every configured server so a server that echoes another’s secret has it hidden too.

§Examples
use std::sync::Arc;

use mcpls_core::bridge::WorkspaceRoots;
use mcpls_core::config::{LspServerConfig, PositionEncodings};
use mcpls_core::lsp::{ChildWorkingDir, ServerInitConfig};

let config = ServerInitConfig::new(
    LspServerConfig::rust_analyzer(),
    WorkspaceRoots::default(),
    PositionEncodings::DEFAULT,
    Arc::default(),
);
assert_eq!(config.child_working_dir(), &ChildWorkingDir::Inherit);
Source

pub fn with_child_working_dir(self, dir: ChildWorkingDir) -> Self

This config with the child started in dir.

§Examples
use std::path::PathBuf;
use std::sync::Arc;

use mcpls_core::bridge::WorkspaceRoots;
use mcpls_core::config::{LspServerConfig, PositionEncodings};
use mcpls_core::lsp::{ChildWorkingDir, ServerInitConfig};

let dir = ChildWorkingDir::Fixed(PathBuf::from("project"));
let config = ServerInitConfig::new(
    LspServerConfig::rust_analyzer(),
    WorkspaceRoots::default(),
    PositionEncodings::DEFAULT,
    Arc::default(),
)
.with_child_working_dir(dir.clone());
assert_eq!(config.child_working_dir(), &dir);
Source

pub const fn server_config(&self) -> &LspServerConfig

The server’s configuration, carrying the effective initialization options.

Source

pub const fn workspace_roots(&self) -> &WorkspaceRoots

The workspace roots sent as workspaceFolders.

Source

pub const fn position_encodings(&self) -> &PositionEncodings

The position encoding preference order offered to the server.

Source

pub const fn redactions(&self) -> &Arc<Redactions> ⓘ

The secrets hidden in this server’s output.

Source

pub const fn child_working_dir(&self) -> &ChildWorkingDir

Where the child process starts.

Source

pub fn pinned_tsserver(&self) -> Option<PathBuf>

The tsserver this config pins through initialization_options.tsserver.path.

Trait Implementations§

Source§

impl Clone for ServerInitConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerInitConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more