Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix: use community maintained fork of tower-lsp (#1316)
Jeremy Fleischmane594a60d433b
diff --git a/Cargo.lock b/Cargo.lockindex 26e8d660f..3fe55e449 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -144,28 +144,6 @@ dependencies = ["yansi",]-[[package]]-name = "async-trait"-version = "0.1.85"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056"-dependencies = [- "proc-macro2",- "quote",- "syn",-]--[[package]]-name = "auto_impl"-version = "1.2.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73"-dependencies = [- "proc-macro2",- "quote",- "syn",-]-[[package]]name = "autocfg"version = "1.4.0"@@ -516,11 +494,12 @@ dependencies = [[[package]]name = "dashmap"-version = "5.5.3"+version = "6.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"+checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf"dependencies = ["cfg-if",+ "crossbeam-utils","hashbrown 0.14.5","lock_api","once_cell",@@ -625,6 +604,15 @@ version = "1.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"+[[package]]+name = "fluent-uri"+version = "0.1.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d"+dependencies = [+ "bitflags 1.3.2",+]+[[package]]name = "fnv"version = "1.0.7"@@ -932,7 +920,7 @@ dependencies = ["serde","serde_json","tokio",- "tower-lsp",+ "tower-lsp-server","tracing","tracing-subscriber",]@@ -1450,15 +1438,15 @@ dependencies = [[[package]]name = "lsp-types"-version = "0.94.1"+version = "0.97.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "c66bfd44a06ae10647fe3f8214762e9369fd4248df1350924b4ef9e770a85ea1"+checksum = "53353550a17c04ac46c585feb189c2db82154fc84b79c7a66c96c2c644f66071"dependencies = ["bitflags 1.3.2",+ "fluent-uri","serde","serde_json","serde_repr",- "url",][[package]]@@ -1700,26 +1688,6 @@ dependencies = ["siphasher",]-[[package]]-name = "pin-project"-version = "1.1.8"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916"-dependencies = [- "pin-project-internal",-]--[[package]]-name = "pin-project-internal"-version = "1.1.8"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb"-dependencies = [- "proc-macro2",- "quote",- "syn",-]-[[package]]name = "pin-project-lite"version = "0.2.16"@@ -2015,7 +1983,7 @@ dependencies = ["sync_wrapper","tokio","tokio-rustls",- "tower 0.5.2",+ "tower","tower-service","url","wasm-bindgen",@@ -2527,20 +2495,6 @@ dependencies = ["winnow",]-[[package]]-name = "tower"-version = "0.4.13"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"-dependencies = [- "futures-core",- "futures-util",- "pin-project",- "pin-project-lite",- "tower-layer",- "tower-service",-]-[[package]]name = "tower"version = "0.5.2"@@ -2563,13 +2517,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"[[package]]-name = "tower-lsp"-version = "0.20.0"+name = "tower-lsp-server"+version = "0.21.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d4ba052b54a6627628d9b3c34c176e7eda8359b7da9acd497b9f20998d118508"+checksum = "5fade4c658b63d11b623ddfa80821901e943a2923a010ae4a038661de42bd377"dependencies = [- "async-trait",- "auto_impl","bytes","dashmap","futures",@@ -2580,22 +2532,10 @@ dependencies = ["serde_json","tokio","tokio-util",- "tower 0.4.13",- "tower-lsp-macros",+ "tower","tracing",]-[[package]]-name = "tower-lsp-macros"-version = "0.9.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa"-dependencies = [- "proc-macro2",- "quote",- "syn",-]-[[package]]name = "tower-service"version = "0.3.3"@@ -3018,7 +2958,6 @@ dependencies = ["form_urlencoded","idna","percent-encoding",- "serde",][[package]]diff --git a/harper-ls/Cargo.toml b/harper-ls/Cargo.tomlindex 928c81808..f4b338f39 100644--- a/harper-ls/Cargo.toml+++ b/harper-ls/Cargo.toml@@ -14,7 +14,7 @@ harper-core = { path = "../harper-core", version = "0.38.0", features = ["concurharper-comments = { path = "../harper-comments", version = "0.38.0" }harper-typst = { path = "../harper-typst", version = "0.38.0" }harper-html = { path = "../harper-html", version = "0.38.0" }-tower-lsp = "0.20.0"+tower-lsp-server = "0.21.1"tokio = { version = "1.45.0", features = ["fs", "rt", "rt-multi-thread", "macros", "io-std", "io-util", "net"] }clap = { version = "4.5.38", features = ["derive"] }once_cell = "1.21.3"diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rsindex 702e5013e..109c233b4 100644--- a/harper-ls/src/backend.rs+++ b/harper-ls/src/backend.rs@@ -18,9 +18,9 @@ use harper_literate_haskell::LiterateHaskellParser;use harper_typst::Typst;use serde_json::Value;use tokio::sync::{Mutex, RwLock};-use tower_lsp::jsonrpc::Result as JsonResult;-use tower_lsp::lsp_types::notification::PublishDiagnostics;-use tower_lsp::lsp_types::{+use tower_lsp_server::jsonrpc::Result as JsonResult;+use tower_lsp_server::lsp_types::notification::PublishDiagnostics;+use tower_lsp_server::lsp_types::{CodeActionOrCommand, CodeActionParams, CodeActionProviderCapability, CodeActionResponse,ConfigurationItem, Diagnostic, DidChangeConfigurationParams, DidChangeTextDocumentParams,DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions,@@ -28,9 +28,9 @@ use tower_lsp::lsp_types::{ExecuteCommandOptions, ExecuteCommandParams, FileChangeType, FileSystemWatcher, GlobPattern,InitializeParams, InitializeResult, InitializedParams, MessageType, PublishDiagnosticsParams,Range, Registration, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind,- TextDocumentSyncOptions, TextDocumentSyncSaveOptions, Url, WatchKind,+ TextDocumentSyncOptions, TextDocumentSyncSaveOptions, Uri, WatchKind,};-use tower_lsp::{Client, LanguageServer};+use tower_lsp_server::{Client, LanguageServer, UriExt};use tracing::{error, info, warn};use crate::config::Config;@@ -45,7 +45,7 @@ pub struct Backend {client: Client,config: RwLock<Config>,stats: RwLock<Stats>,- doc_state: Mutex<HashMap<Url, DocumentState>>,+ doc_state: Mutex<HashMap<Uri, DocumentState>>,}impl Backend {@@ -59,14 +59,17 @@ impl Backend {}/// Load a specific file's dictionary- async fn load_file_dictionary(&self, url: &Url) -> anyhow::Result<MutableDictionary> {+ async fn load_file_dictionary(&self, uri: &Uri) -> anyhow::Result<MutableDictionary> {// VS Code's unsaved documents have "untitled" scheme- if url.scheme() == "untitled" {+ if uri+ .scheme()+ .is_some_and(|scheme| scheme.eq_lowercase("untitled"))+ {return Ok(MutableDictionary::new());}let path = self- .get_file_dict_path(url)+ .get_file_dict_path(uri).await.context("Unable to get the file path.")?;@@ -77,15 +80,15 @@ impl Backend {}/// Compute the location of the ignored lint's store.- async fn get_ignored_lints_path(&self, url: &Url) -> anyhow::Result<PathBuf> {+ async fn get_ignored_lints_path(&self, uri: &Uri) -> anyhow::Result<PathBuf> {let config = self.config.read().await;- Ok(config.ignored_lints_path.join(fileify_path(url)?))+ Ok(config.ignored_lints_path.join(fileify_path(uri)?))}- async fn save_ignored_lints(&self, url: &Url, ignored_lints: &IgnoredLints) -> Result<()> {+ async fn save_ignored_lints(&self, uri: &Uri, ignored_lints: &IgnoredLints) -> Result<()> {save_ignored_lints(- self.get_ignored_lints_path(url)+ self.get_ignored_lints_path(uri).await.context("Unable to get ignored lints path.")?,ignored_lints,@@ -94,9 +97,9 @@ impl Backend {.context("Unable to save ignored lints to path.")}- async fn load_ignored_lints(&self, url: &Url) -> Result<IgnoredLints> {+ async fn load_ignored_lints(&self, uri: &Uri) -> Result<IgnoredLints> {Ok(load_ignored_lints(- self.get_ignored_lints_path(url)+ self.get_ignored_lints_path(uri).await.context("Unable to get ignored lints path.")?,)@@ -106,15 +109,15 @@ impl Backend {}/// Compute the location of the file's specific dictionary- async fn get_file_dict_path(&self, url: &Url) -> anyhow::Result<PathBuf> {+ async fn get_file_dict_path(&self, uri: &Uri) -> anyhow::Result<PathBuf> {let config = self.config.read().await;- Ok(config.file_dict_path.join(fileify_path(url)?))+ Ok(config.file_dict_path.join(fileify_path(uri)?))}- async fn save_file_dictionary(&self, url: &Url, dict: impl Dictionary) -> Result<()> {+ async fn save_file_dictionary(&self, uri: &Uri, dict: impl Dictionary) -> Result<()> {save_dict(- self.get_file_dict_path(url)+ self.get_file_dict_path(uri).await.context("Unable to get the file path.")?,dict,@@ -168,10 +171,10 @@ impl Backend {Ok(dict)}- async fn generate_file_dictionary(&self, url: &Url) -> Result<MergedDictionary> {+ async fn generate_file_dictionary(&self, uri: &Uri) -> Result<MergedDictionary> {let (global_dictionary, file_dictionary) = tokio::join!(self.generate_global_dictionary(),- self.load_file_dictionary(url)+ self.load_file_dictionary(uri));let mut global_dictionary =@@ -183,20 +186,20 @@ impl Backend {Ok(global_dictionary)}- async fn update_document_from_file(&self, url: &Url, language_id: Option<&str>) -> Result<()> {+ async fn update_document_from_file(&self, uri: &Uri, language_id: Option<&str>) -> Result<()> {let content = tokio::fs::read_to_string(- url.to_file_path()- .map_err(|_| anyhow!("Unable to convert URL to file path."))?,+ uri.to_file_path()+ .ok_or_else(|| anyhow!("Unable to convert URL to file path."))?,).await- .with_context(|| format!("Unable to read from file {:?}", url))?;+ .with_context(|| format!("Unable to read from file {:?}", uri))?;- self.update_document(url, &content, language_id).await+ self.update_document(uri, &content, language_id).await}async fn update_document(&self,- url: &Url,+ uri: &Uri,text: &str,language_id: Option<&str>,) -> Result<()> {@@ -214,15 +217,15 @@ impl Backend {};let dict = Arc::new(- self.generate_file_dictionary(url)+ self.generate_file_dictionary(uri).await.context("Unable to generate the file dictionary.")?,);let mut doc_lock = self.doc_state.lock().await;- let ignored_lints = self.load_ignored_lints(url).await.unwrap_or_default();+ let ignored_lints = self.load_ignored_lints(uri).await.unwrap_or_default();- let doc_state = doc_lock.entry(url.clone()).or_insert_with(|| {+ let doc_state = doc_lock.entry(uri.clone()).or_insert_with(|| {info!("Constructing new LintGroup for new document.");DocumentState {@@ -231,7 +234,7 @@ impl Backend {.with_lint_config(lint_config.clone()),language_id: language_id.map(|v| v.to_string()),dict: dict.clone(),- url: url.clone(),+ uri: uri.clone(),..Default::default()}});@@ -244,7 +247,7 @@ impl Backend {}let Some(language_id) = &doc_state.language_id else {- doc_lock.remove(url);+ doc_lock.remove(uri);return Ok(());};@@ -252,7 +255,7 @@ impl Backend {backend: &'a Backend,new_dict: Arc<MutableDictionary>,parser: impl Parser + 'static,- url: &'a Url,+ uri: &'a Uri,doc_state: &'a mut DocumentState,lint_config: &LintGroupConfig,dialect: Dialect,@@ -261,7 +264,7 @@ impl Backend {info!("Constructing new linter because of modified ident dictionary.");doc_state.ident_dict = new_dict.clone();- let mut merged = backend.generate_file_dictionary(url).await?;+ let mut merged = backend.generate_file_dictionary(uri).await?;merged.add_dictionary(new_dict);let merged = Arc::new(merged);@@ -288,7 +291,7 @@ impl Backend {self,Arc::new(new_dict),ts_parser,- url,+ uri,doc_state,&lint_config,dialect,@@ -310,7 +313,7 @@ impl Backend {self,Arc::new(new_dict),parser,- url,+ uri,doc_state,&lint_config,dialect,@@ -333,7 +336,7 @@ impl Backend {match parser {None => {- doc_lock.remove(url);+ doc_lock.remove(uri);}Some(mut parser) => {if isolate_english {@@ -353,18 +356,18 @@ impl Backend {async fn generate_code_actions(&self,- url: &Url,+ uri: &Uri,range: Range,) -> JsonResult<Vec<CodeActionOrCommand>> {let (config, mut doc_states) = tokio::join!(self.config.read(), self.doc_state.lock());- let Some(doc_state) = doc_states.get_mut(url) else {+ let Some(doc_state) = doc_states.get_mut(uri) else {return Ok(Vec::new());};Ok(doc_state.generate_code_actions(range, &config.code_action_config))}- async fn generate_diagnostics(&self, url: &Url) -> Vec<Diagnostic> {+ async fn generate_diagnostics(&self, uri: &Uri) -> Vec<Diagnostic> {// Copy necessary configuration to avoid holding lock.let diagnostic_severity = {let config = self.config.read().await;@@ -372,18 +375,18 @@ impl Backend {};let mut doc_states = self.doc_state.lock().await;- let Some(doc_state) = doc_states.get_mut(url) else {+ let Some(doc_state) = doc_states.get_mut(uri) else {return Vec::new();};doc_state.generate_diagnostics(diagnostic_severity)}- async fn publish_diagnostics(&self, url: &Url) {- let diagnostics = self.generate_diagnostics(url).await;+ async fn publish_diagnostics(&self, uri: &Uri) {+ let diagnostics = self.generate_diagnostics(uri).await;let result = PublishDiagnosticsParams {- uri: url.clone(),+ uri: uri.clone(),diagnostics,version: None,};@@ -418,7 +421,6 @@ impl Backend {}}-#[tower_lsp::async_trait]impl LanguageServer for Backend {async fn initialize(&self, _: InitializeParams) -> JsonResult<InitializeResult> {Ok(InitializeResult {@@ -516,13 +518,13 @@ impl LanguageServer for Backend {}async fn did_close(&self, _params: DidCloseTextDocumentParams) {- let url = _params.text_document.uri;+ let uri = _params.text_document.uri;let mut doc_lock = self.doc_state.lock().await;- doc_lock.remove(&url);+ doc_lock.remove(&uri);self.client.send_notification::<PublishDiagnostics>(PublishDiagnosticsParams {- uri: url.clone(),+ uri: uri.clone(),diagnostics: vec![],version: None,})@@ -531,29 +533,29 @@ impl LanguageServer for Backend {async fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) {let mut doc_lock = self.doc_state.lock().await;- let mut urls_to_clear = Vec::new();+ let mut uris_to_clear = Vec::new();for change in ¶ms.changes {if change.typ != FileChangeType::DELETED {continue;}- doc_lock.retain(|url, _| {+ doc_lock.retain(|uri, _| {// `change.uri` could be a directory so use `starts_with` instead of `==`.- let to_remove = url.as_str().starts_with(change.uri.as_str());+ let to_remove = uri.as_str().starts_with(change.uri.as_str());if to_remove {- urls_to_clear.push(url.clone());+ uris_to_clear.push(uri.clone());}!to_remove});}- for url in &urls_to_clear {+ for uri in &uris_to_clear {self.client.send_notification::<PublishDiagnostics>(PublishDiagnosticsParams {- uri: url.clone(),+ uri: uri.clone(),diagnostics: vec![],version: None,})@@ -592,7 +594,7 @@ impl LanguageServer for Backend {return Ok(None);};- let file_url = second.parse().unwrap();+ let file_uri = second.parse().unwrap();let mut dict = self.load_user_dictionary().await;dict.append_word(word, WordMetadata::default());@@ -600,11 +602,11 @@ impl LanguageServer for Backend {.await.map_err(|err| error!("{err}")).err();- self.update_document_from_file(&file_url, None)+ self.update_document_from_file(&file_uri, None).await.map_err(|err| error!("{err}")).err();- self.publish_diagnostics(&file_url).await;+ self.publish_diagnostics(&file_uri).await;}"HarperAddToFileDict" => {let word = &first.chars().collect::<Vec<_>>();@@ -613,10 +615,10 @@ impl LanguageServer for Backend {return Ok(None);};- let file_url = second.parse().unwrap();+ let file_uri = second.parse().unwrap();let mut dict = match self- .load_file_dictionary(&file_url)+ .load_file_dictionary(&file_uri).await.map_err(|err| error!("{err}")){@@ -627,15 +629,15 @@ impl LanguageServer for Backend {};dict.append_word(word, WordMetadata::default());- self.save_file_dictionary(&file_url, dict)+ self.save_file_dictionary(&file_uri, dict).await.map_err(|err| error!("{err}")).err();- self.update_document_from_file(&file_url, None)+ self.update_document_from_file(&file_uri, None).await.map_err(|err| error!("{err}")).err();- self.publish_diagnostics(&file_url).await;+ self.publish_diagnostics(&file_uri).await;}"HarperOpen" => match open::that(&first) {Ok(()) => {@@ -653,7 +655,7 @@ impl LanguageServer for Backend {}},"HarperIgnoreLint" => {- let Ok(url) = Url::parse(&first) else {+ let Ok(uri) = first.parse() else {error!("Unable to parse URL from command: {first}");return Ok(None);};@@ -669,14 +671,14 @@ impl LanguageServer for Backend {};let mut doc_lock = self.doc_state.lock().await;- let Some(doc_state) = doc_lock.get_mut(&url) else {+ let Some(doc_state) = doc_lock.get_mut(&uri) else {error!("Requested document has not been loaded.");return Ok(None);};doc_state.ignore_lint(&lint);if let Err(_err) = self- .save_ignored_lints(&url, &doc_state.ignored_lints)+ .save_ignored_lints(&uri, &doc_state.ignored_lints).await{error!("Unable to save ignored lints.");@@ -685,7 +687,7 @@ impl LanguageServer for Backend {drop(doc_lock);- self.publish_diagnostics(&url).await;+ self.publish_diagnostics(&uri).await;}_ => (),}@@ -696,7 +698,7 @@ impl LanguageServer for Backend {async fn did_change_configuration(&self, params: DidChangeConfigurationParams) {self.update_config_from_obj(params.settings).await;- let urls: Vec<Url> = {+ let uris: Vec<Uri> = {let mut doc_lock = self.doc_state.lock().await;let config_lock = self.config.read().await;@@ -709,12 +711,12 @@ impl LanguageServer for Backend {doc_lock.keys().cloned().collect()};- for url in urls {- self.update_document_from_file(&url, None)+ for uri in uris {+ self.update_document_from_file(&uri, None).await.map_err(|err| error!("{err}")).err();- self.publish_diagnostics(&url).await;+ self.publish_diagnostics(&uri).await;}}@@ -733,9 +735,9 @@ impl LanguageServer for Backend {let doc_states = self.doc_state.lock().await;// Clears the diagnostics for open buffers.- for url in doc_states.keys() {+ for uri in doc_states.keys() {let result = PublishDiagnosticsParams {- uri: url.clone(),+ uri: uri.clone(),diagnostics: vec![],version: None,};diff --git a/harper-ls/src/config.rs b/harper-ls/src/config.rsindex 83151418b..23eb32485 100644--- a/harper-ls/src/config.rs+++ b/harper-ls/src/config.rs@@ -18,14 +18,14 @@ pub enum DiagnosticSeverity {impl DiagnosticSeverity {/// Converts `self` to the equivalent LSP type.- pub fn to_lsp(self) -> tower_lsp::lsp_types::DiagnosticSeverity {+ pub fn to_lsp(self) -> tower_lsp_server::lsp_types::DiagnosticSeverity {match self {- DiagnosticSeverity::Error => tower_lsp::lsp_types::DiagnosticSeverity::ERROR,- DiagnosticSeverity::Warning => tower_lsp::lsp_types::DiagnosticSeverity::WARNING,+ DiagnosticSeverity::Error => tower_lsp_server::lsp_types::DiagnosticSeverity::ERROR,+ DiagnosticSeverity::Warning => tower_lsp_server::lsp_types::DiagnosticSeverity::WARNING,DiagnosticSeverity::Information => {- tower_lsp::lsp_types::DiagnosticSeverity::INFORMATION+ tower_lsp_server::lsp_types::DiagnosticSeverity::INFORMATION}- DiagnosticSeverity::Hint => tower_lsp::lsp_types::DiagnosticSeverity::HINT,+ DiagnosticSeverity::Hint => tower_lsp_server::lsp_types::DiagnosticSeverity::HINT,}}}diff --git a/harper-ls/src/diagnostics.rs b/harper-ls/src/diagnostics.rsindex 93296524c..08639829f 100644--- a/harper-ls/src/diagnostics.rs+++ b/harper-ls/src/diagnostics.rs@@ -4,8 +4,8 @@ use harper_core::linting::{Lint, Suggestion};use harper_core::{CharStringExt, Document};use harper_stats::RecordKind;use serde_json::Value;-use tower_lsp::lsp_types::{- CodeAction, CodeActionKind, CodeActionOrCommand, Command, Diagnostic, TextEdit, Url,+use tower_lsp_server::lsp_types::{+ CodeAction, CodeActionKind, CodeActionOrCommand, Command, Diagnostic, TextEdit, Uri,WorkspaceEdit,};@@ -25,7 +25,7 @@ pub fn lints_to_diagnostics(pub fn lint_to_code_actions<'a>(lint: &'a Lint,- url: &'a Url,+ uri: &'a Uri,document: &Document,config: &CodeActionConfig,) -> Vec<CodeActionOrCommand> {@@ -54,7 +54,7 @@ pub fn lint_to_code_actions<'a>(diagnostics: None,edit: Some(WorkspaceEdit {changes: Some(HashMap::from([(- url.clone(),+ uri.clone(),vec![TextEdit {range,new_text: replace_string,@@ -82,7 +82,7 @@ pub fn lint_to_code_actions<'a>(title: "Ignore Harper error.".to_owned(),command: "HarperIgnoreLint".to_owned(),arguments: Some(vec![- serde_json::Value::String(url.to_string()),+ serde_json::Value::String(uri.to_string()),serde_json::to_value(lint).unwrap(),]),}));@@ -93,13 +93,13 @@ pub fn lint_to_code_actions<'a>(results.push(CodeActionOrCommand::Command(Command::new(format!("Add \"{}\" to the global dictionary.", orig),"HarperAddToUserDict".to_string(),- Some(vec![orig.clone().into(), url.to_string().into()]),+ Some(vec![orig.clone().into(), uri.to_string().into()]),)));results.push(CodeActionOrCommand::Command(Command::new(format!("Add \"{}\" to the file dictionary.", orig),"HarperAddToFileDict".to_string(),- Some(vec![orig.into(), url.to_string().into()]),+ Some(vec![orig.into(), uri.to_string().into()]),)));}diff --git a/harper-ls/src/document_state.rs b/harper-ls/src/document_state.rsindex 7dfa113a3..626dfc020 100644--- a/harper-ls/src/document_state.rs+++ b/harper-ls/src/document_state.rs@@ -4,7 +4,7 @@ use crate::pos_conv::range_to_span;use harper_core::linting::{Lint, LintGroup, Linter};use harper_core::{Document, IgnoredLints, MergedDictionary, MutableDictionary, TokenKind};use harper_core::{Lrc, Token};-use tower_lsp::lsp_types::{CodeActionOrCommand, Command, Diagnostic, Range, Url};+use tower_lsp_server::lsp_types::{CodeActionOrCommand, Command, Diagnostic, Range, Uri};pub struct DocumentState {pub document: Document,@@ -13,7 +13,7 @@ pub struct DocumentState {pub linter: LintGroup,pub language_id: Option<String>,pub ignored_lints: IgnoredLints,- pub url: Url,+ pub uri: Uri,}impl DocumentState {@@ -62,7 +62,7 @@ impl DocumentState {.into_iter().filter(|lint| lint.span.overlaps_with(span)).flat_map(|lint| {- lint_to_code_actions(&lint, &self.url, &self.document, code_action_config)+ lint_to_code_actions(&lint, &self.uri, &self.document, code_action_config)}).collect();@@ -92,7 +92,7 @@ impl Default for DocumentState {linter: Default::default(),language_id: Default::default(),ignored_lints: Default::default(),- url: Url::parse("https://example.net").unwrap(),+ uri: "https://example.net".parse().unwrap(),}}}diff --git a/harper-ls/src/io_utils.rs b/harper-ls/src/io_utils.rsindex 3ddd1a846..269dcb874 100644--- a/harper-ls/src/io_utils.rs+++ b/harper-ls/src/io_utils.rs@@ -1,17 +1,17 @@use anyhow::anyhow;use std::path::{Component, PathBuf};-use tower_lsp::lsp_types::Url;+use tower_lsp_server::{UriExt, lsp_types::Uri};/// Rewrites a path to a filename using the same conventions as/// [Neovim's undo-files](https://neovim.io/doc/user/options.html#'undodir').-pub fn fileify_path(url: &Url) -> anyhow::Result<PathBuf> {+pub fn fileify_path(uri: &Uri) -> anyhow::Result<PathBuf> {let mut rewritten = String::new();// We assume all URLs are local files and have a base.- for seg in url+ for seg in uri.to_file_path()- .map_err(|_| anyhow!("Unable to convert URL to file path."))?+ .ok_or_else(|| anyhow!("Unable to convert URI to file path."))?.components(){if !matches!(seg, Component::RootDir) {diff --git a/harper-ls/src/main.rs b/harper-ls/src/main.rsindex 7b0fd7b5c..468d743bb 100644--- a/harper-ls/src/main.rs+++ b/harper-ls/src/main.rs@@ -16,7 +16,7 @@ mod pos_conv;use backend::Backend;use clap::Parser;-use tower_lsp::{LspService, Server};+use tower_lsp_server::{LspService, Server};use tracing::{Level, error, info};use tracing_subscriber::FmtSubscriber;diff --git a/harper-ls/src/pos_conv.rs b/harper-ls/src/pos_conv.rsindex 6a2fb3d00..783efc796 100644--- a/harper-ls/src/pos_conv.rs+++ b/harper-ls/src/pos_conv.rs@@ -2,7 +2,7 @@//! Harper uses, and the Ranges that the LSP uses.use harper_core::Span;-use tower_lsp::lsp_types::{Position, Range};+use tower_lsp_server::lsp_types::{Position, Range};pub fn span_to_range(source: &[char], span: Span) -> Range {let start = index_to_position(source, span.start);@@ -85,7 +85,7 @@ pub fn range_to_span(source: &[char], range: Range) -> Span {#[cfg(test)]mod tests {- use tower_lsp::lsp_types::{Position, Range};+ use tower_lsp_server::lsp_types::{Position, Range};use super::{index_to_position, position_to_index, range_to_span};