feat(lsp): add settings for diagnostics and actions
MODIFY
crates/rome_lsp/src/config.rs
crates/rome_lsp/src/config.rs
@@ -12,6 +12,16 @@ pub struct FormatterWorkspaceSettings {
pub format_with_syntax_errors: bool,
}
+#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)]
+#[serde(rename_all = "camelCase")]
+/// Settings for Rome Analysis
+pub struct AnalysisWorkspaceSettings {
+ /// Allows rome to compute and publish diagnostics
+ pub enable_diagnostics: bool,
+ /// Allows rome to compute and provide code actions
+ pub enable_code_actions: bool,
+}
+
#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
/// The settings applied to the workspace by the LSP
@@ -19,6 +29,10 @@ pub struct WorkspaceSettings {
/// Formatter settings
#[serde(default)]
pub formatter: FormatterWorkspaceSettings,
+
+ /// Analysis settings
+ #[serde(default)]
+ pub analysis: AnalysisWorkspaceSettings,
}
#[derive(Debug)]

MODIFY
crates/rome_lsp/src/server.rs
crates/rome_lsp/src/server.rs
@@ -90,6 +90,10 @@ impl LanguageServer for LSPServer {
}
async fn code_action(&self, params: CodeActionParams) -> LspResult<Option<CodeActionResponse>> {
+ let workspace_settings = self.session.config.read().get_workspace_settings();
+ if !workspace_settings.analysis.enable_code_actions {
+ return Ok(None);
+ }
let url = params.text_document.uri.clone();
let doc = self.session.document(&url)?;

MODIFY
crates/rome_lsp/src/session.rs
crates/rome_lsp/src/session.rs
@@ -104,6 +104,10 @@ impl Session {
/// them to the client. Called from [`handlers::text_document`] when a file's
/// contents changes.
pub(crate) async fn update_diagnostics(&self, url: lsp::Url) -> anyhow::Result<()> {
+ let workspace_settings = self.config.read().get_workspace_settings();
+ if !workspace_settings.analysis.enable_diagnostics {
+ return Ok(());
+ }
let doc = self.document(&url)?;
let file_id = doc.file_id();

MODIFY
editors/vscode/package.json
editors/vscode/package.json
true,
false
]
+ },
+ "rome.analysis.enableDiagnostics": {
+ "type": "boolean",
+ "default": false,
+ "markdownDescription": "Allows rome to compute and publish diagnostics"
+ },
+ "rome.analysis.enableCodeActions": {
+ "type": "boolean",
+ "default": false,
+ "markdownDescription": "Allows rome to compute and provide code actions"
}
}
}

feat(lsp): add settings for diagnostics and actions (#2222)