Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_lsp): rename off by default for vscode #3473

Merged
merged 6 commits into from
Oct 25, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rome_lsp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ rome_flags = { path = "../rome_flags" }
rome_rowan = { path = "../rome_rowan" }
rome_console = { path = "../rome_console" }
rome_text_edit = { path = "../rome_text_edit" }
tokio = { workspace = true, features = ["io-std"] }
tokio = { workspace = true, features = ["rt", "io-std"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rome_lsp was not compiling

tower-lsp = { version = "0.17.0" }
tracing = { workspace = true, features = ["attributes"] }
futures = "0.3"
5 changes: 4 additions & 1 deletion crates/rome_lsp/src/config.rs
Original file line number Diff line number Diff line change
@@ -11,11 +11,14 @@ pub struct WorkspaceSettings {
/// Unstable features enabled
#[serde(default)]
pub unstable: bool,

/// Enable rename capability
pub rename: Option<bool>,
}

#[derive(Debug)]
pub(crate) struct Config {
settings: WorkspaceSettings,
pub(crate) settings: WorkspaceSettings,
}

impl Config {
62 changes: 37 additions & 25 deletions crates/rome_lsp/src/server.rs
Original file line number Diff line number Diff line change
@@ -167,6 +167,30 @@ impl LanguageServer for LSPServer {
Ok(())
}

#[tracing::instrument(level = "trace", skip(self))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just sorted these fns.

async fn did_change_configuration(&self, params: DidChangeConfigurationParams) {
let _ = params;
self.session.fetch_client_configuration().await;
}

async fn did_open(&self, params: DidOpenTextDocumentParams) {
handlers::text_document::did_open(&self.session, params)
.await
.ok();
}

async fn did_change(&self, params: DidChangeTextDocumentParams) {
handlers::text_document::did_change(&self.session, params)
.await
.ok();
}

async fn did_close(&self, params: DidCloseTextDocumentParams) {
handlers::text_document::did_close(&self.session, params)
.await
.ok();
}

async fn code_action(&self, params: CodeActionParams) -> LspResult<Option<CodeActionResponse>> {
handlers::analysis::code_actions(&self.session, params).map_err(into_lsp_error)
}
@@ -192,32 +216,20 @@ impl LanguageServer for LSPServer {
handlers::formatting::format_on_type(&self.session, params).map_err(into_lsp_error)
}

#[tracing::instrument(level = "trace", skip(self))]
async fn did_change_configuration(&self, params: DidChangeConfigurationParams) {
let _ = params;
self.session.fetch_client_configuration().await;
}

async fn did_open(&self, params: DidOpenTextDocumentParams) {
handlers::text_document::did_open(&self.session, params)
.await
.ok();
}

async fn did_change(&self, params: DidChangeTextDocumentParams) {
handlers::text_document::did_change(&self.session, params)
.await
.ok();
}

async fn did_close(&self, params: DidCloseTextDocumentParams) {
handlers::text_document::did_close(&self.session, params)
.await
.ok();
}

async fn rename(&self, params: RenameParams) -> LspResult<Option<WorkspaceEdit>> {
handlers::rename::rename(&self.session, params).map_err(into_lsp_error)
let rename_enabled = self
.session
.config
.read()
.ok()
.and_then(|config| config.settings.rename)
.unwrap_or(false);

if rename_enabled {
handlers::rename::rename(&self.session, params).map_err(into_lsp_error)
} else {
Ok(None)
}
}
}

4 changes: 2 additions & 2 deletions editors/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
@@ -82,6 +82,14 @@
],
"default": null,
"markdownDescription": "The rome lsp server executable. If the path is relative, the workspace folder will be used as base path"
},
"rome.rename": {
"type": [
"boolean",
"null"
],
"default": null,
"markdownDescription": "Enable/Disable Rome handling renames in the workspace. (Experimental)"
}
}
},
@@ -107,7 +115,7 @@
"watch": "npm run compile -- --sourcemap --watch",
"package": "vsce package -o rome_lsp.vsix",
"build": "npm run compile -- --minify && npm run package",
"install-extension": "code --install-extension rome_lsp.vsix",
"install-extension": "code --install-extension rome_lsp.vsix --force",
"format": "cargo run --bin rome format ./src/ ./scripts --write",
"pack:dev": "npm run compile && npm run package && npm run install-extension",
"tsc": "tsc"
6 changes: 6 additions & 0 deletions editors/vscode/src/main.ts
Original file line number Diff line number Diff line change
@@ -31,6 +31,12 @@ export async function activate(context: ExtensionContext) {
const command =
process.env.DEBUG_SERVER_PATH || (await getServerPath(context));

if (process.env.DEBUG_SERVER_PATH) {
window.showInformationMessage(
`Rome DEBUG_SERVER_PATH detected: ${command}`,
);
}

if (!command) {
await window.showErrorMessage(
"The Rome extensions doesn't ship with prebuilt binaries for your platform yet. " +