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
impl ServerInitConfig
Sourcepub const fn new(
server_config: LspServerConfig,
workspace_roots: WorkspaceRoots,
position_encodings: PositionEncodings,
redactions: Arc<Redactions>,
) -> Self
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);Sourcepub fn with_child_working_dir(self, dir: ChildWorkingDir) -> Self
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);Sourcepub const fn server_config(&self) -> &LspServerConfig
pub const fn server_config(&self) -> &LspServerConfig
The server’s configuration, carrying the effective initialization options.
Sourcepub const fn workspace_roots(&self) -> &WorkspaceRoots
pub const fn workspace_roots(&self) -> &WorkspaceRoots
The workspace roots sent as workspaceFolders.
Sourcepub const fn position_encodings(&self) -> &PositionEncodings
pub const fn position_encodings(&self) -> &PositionEncodings
The position encoding preference order offered to the server.
Sourcepub const fn redactions(&self) -> &Arc<Redactions> ⓘ
pub const fn redactions(&self) -> &Arc<Redactions> ⓘ
The secrets hidden in this server’s output.
Sourcepub const fn child_working_dir(&self) -> &ChildWorkingDir
pub const fn child_working_dir(&self) -> &ChildWorkingDir
Where the child process starts.
Sourcepub fn pinned_tsserver(&self) -> Option<PathBuf>
pub fn pinned_tsserver(&self) -> Option<PathBuf>
The tsserver this config pins through initialization_options.tsserver.path.