aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorkyfanc2024-02-13 10:58:53 +0000
committerGitHub2024-02-13 10:58:53 +0000
commitfe869e5dc7a8cd6c2c2e3945816bd890956eef3a (patch)
treead0b899b482df976caf3cc2f079dc7d0d8a3769f /helix-lsp
parent7934ac77143e69068420556b043dde035255340b (diff)
fix lsp config reload (#9415)
`syn_loader` was replaced rather than interior value being replace, old value was still being referenced and not updated after `:config-refresh`. By using `ArcSwap` like for `config`, each `.load()` call will return the most updated value. Co-authored-by: kyfan <kyfan@email>
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/Cargo.toml1
-rw-r--r--helix-lsp/src/lib.rs9
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"))?;