diff options
Diffstat (limited to 'helix-lsp')
-rw-r--r-- | helix-lsp/Cargo.toml | 1 | ||||
-rw-r--r-- | helix-lsp/src/lib.rs | 9 |
2 files changed, 6 insertions, 4 deletions
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml index 2bdd5cfc..4284b052 100644 --- a/helix-lsp/Cargo.toml +++ b/helix-lsp/Cargo.toml @@ -30,3 +30,4 @@ thiserror = "1.0" tokio = { version = "1.36", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] } tokio-stream = "0.1.14" parking_lot = "0.12.1" +arc-swap = "1" diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 05764418..c58d967b 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -5,6 +5,7 @@ pub mod jsonrpc; pub mod snippet; mod transport; +use arc_swap::ArcSwap; pub use client::Client; pub use futures_executor::block_on; pub use jsonrpc::Call; @@ -640,14 +641,14 @@ impl Notification { #[derive(Debug)] pub struct Registry { inner: HashMap<LanguageServerName, Vec<Arc<Client>>>, - syn_loader: Arc<helix_core::syntax::Loader>, + syn_loader: Arc<ArcSwap<helix_core::syntax::Loader>>, counter: usize, pub incoming: SelectAll<UnboundedReceiverStream<(usize, Call)>>, pub file_event_handler: file_event::Handler, } impl Registry { - pub fn new(syn_loader: Arc<helix_core::syntax::Loader>) -> Self { + pub fn new(syn_loader: Arc<ArcSwap<helix_core::syntax::Loader>>) -> Self { Self { inner: HashMap::new(), syn_loader, @@ -681,8 +682,8 @@ impl Registry { root_dirs: &[PathBuf], enable_snippets: bool, ) -> Result<Option<Arc<Client>>> { - let config = self - .syn_loader + let syn_loader = self.syn_loader.load(); + let config = syn_loader .language_server_configs() .get(&name) .ok_or_else(|| anyhow::anyhow!("Language server '{name}' not defined"))?; |