3824: New config names r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-04-02 12:05:46 +00:00 committed by GitHub
commit 3c9e9d3f3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 247 additions and 274 deletions

View file

@ -16,20 +16,33 @@ use serde::Deserialize;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Config { pub struct Config {
pub client_caps: ClientCapsConfig, pub client_caps: ClientCapsConfig,
pub with_sysroot: bool,
pub publish_diagnostics: bool, pub publish_diagnostics: bool,
pub lru_capacity: Option<usize>,
pub proc_macro_srv: Option<String>,
pub files: FilesConfig,
pub notifications: NotificationsConfig, pub notifications: NotificationsConfig,
pub cargo: CargoConfig,
pub rustfmt: RustfmtConfig,
pub check: Option<FlycheckConfig>,
pub inlay_hints: InlayHintsConfig, pub inlay_hints: InlayHintsConfig,
pub completion: CompletionConfig, pub completion: CompletionConfig,
pub call_info_full: bool, pub call_info_full: bool,
pub rustfmt: RustfmtConfig, }
pub check: Option<FlycheckConfig>,
pub vscode_lldb: bool, #[derive(Debug, Clone)]
pub proc_macro_srv: Option<String>, pub struct FilesConfig {
pub lru_capacity: Option<usize>, pub watcher: FilesWatcher,
pub use_client_watching: bool, pub exclude: Vec<String>,
pub exclude_globs: Vec<String>, }
pub cargo: CargoConfig,
pub with_sysroot: bool, #[derive(Debug, Clone)]
pub enum FilesWatcher {
Client,
Notify,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -59,12 +72,26 @@ pub struct ClientCapsConfig {
impl Default for Config { impl Default for Config {
fn default() -> Self { fn default() -> Self {
Config { Config {
client_caps: ClientCapsConfig::default(),
with_sysroot: true,
publish_diagnostics: true, publish_diagnostics: true,
lru_capacity: None,
proc_macro_srv: None,
files: FilesConfig { watcher: FilesWatcher::Notify, exclude: Vec::new() },
notifications: NotificationsConfig { notifications: NotificationsConfig {
workspace_loaded: true, workspace_loaded: true,
cargo_toml_not_found: true, cargo_toml_not_found: true,
}, },
client_caps: ClientCapsConfig::default(),
cargo: CargoConfig::default(),
rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() },
check: Some(FlycheckConfig::CargoCommand {
command: "check".to_string(),
all_targets: true,
extra_args: Vec::new(),
}),
inlay_hints: InlayHintsConfig { inlay_hints: InlayHintsConfig {
type_hints: true, type_hints: true,
parameter_hints: true, parameter_hints: true,
@ -77,19 +104,6 @@ impl Default for Config {
add_call_argument_snippets: true, add_call_argument_snippets: true,
}, },
call_info_full: true, call_info_full: true,
rustfmt: RustfmtConfig::Rustfmt { extra_args: Vec::new() },
check: Some(FlycheckConfig::CargoCommand {
command: "check".to_string(),
all_targets: true,
extra_args: Vec::new(),
}),
vscode_lldb: false,
proc_macro_srv: None,
lru_capacity: None,
use_client_watching: false,
exclude_globs: Vec::new(),
cargo: CargoConfig::default(),
with_sysroot: true,
} }
} }
} }
@ -103,45 +117,44 @@ impl Config {
*self = Default::default(); *self = Default::default();
self.client_caps = client_caps; self.client_caps = client_caps;
set(value, "/excludeGlobs", &mut self.exclude_globs); set(value, "/withSysroot", &mut self.with_sysroot);
set(value, "/useClientWatching", &mut self.use_client_watching); set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics);
set(value, "/lruCapacity", &mut self.lru_capacity); set(value, "/lruCapacity", &mut self.lru_capacity);
if let Some(watcher) = get::<String>(value, "/files/watcher") {
self.files.watcher = match watcher.as_str() {
"client" => FilesWatcher::Client,
"notify"| _ => FilesWatcher::Notify,
}
}
set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded);
set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found);
set(value, "/inlayHintsType", &mut self.inlay_hints.type_hints); set(value, "/cargo/noDefaultFeatures", &mut self.cargo.no_default_features);
set(value, "/inlayHintsParameter", &mut self.inlay_hints.parameter_hints); set(value, "/cargo/allFeatures", &mut self.cargo.all_features);
set(value, "/inlayHintsChaining", &mut self.inlay_hints.chaining_hints); set(value, "/cargo/features", &mut self.cargo.features);
set(value, "/inlayHintsMaxLength", &mut self.inlay_hints.max_length); set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check);
if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
if let Some(false) = get(value, "cargo_watch_enable") { set(value, "/rustfmt/extraArgs", extra_args);
}
if let Some(false) = get(value, "/checkOnSave/enable") {
self.check = None self.check = None
} else { } else {
if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
{ {
set(value, "/cargoWatchArgs", extra_args); set(value, "/checkOnSave/extraArgs", extra_args);
set(value, "/cargoWatchCommand", command); set(value, "/checkOnSave/command", command);
set(value, "/cargoWatchAllTargets", all_targets); set(value, "/checkOnSave/allTargets", all_targets);
} }
}; };
set(value, "/withSysroot", &mut self.with_sysroot); set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints);
if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints);
set(value, "/rustfmtArgs", extra_args); set(value, "/inlayHints/chainingHints", &mut self.inlay_hints.chaining_hints);
} set(value, "/inlayHints/maxLength", &mut self.inlay_hints.max_length);
set(value, "/completion/postfix/enable", &mut self.completion.enable_postfix_completions);
set(value, "/cargoFeatures/noDefaultFeatures", &mut self.cargo.no_default_features); set(value, "/completion/addCallParenthesis", &mut self.completion.add_call_parenthesis);
set(value, "/cargoFeatures/allFeatures", &mut self.cargo.all_features); set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets);
set(value, "/cargoFeatures/features", &mut self.cargo.features); set(value, "/callInfo/full", &mut self.call_info_full);
set(value, "/cargoFeatures/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check);
set(value, "/vscodeLldb", &mut self.vscode_lldb);
set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics);
set(value, "/featureFlags/notifications.workspace-loaded", &mut self.notifications.workspace_loaded);
set(value, "/featureFlags/notifications.cargo-toml-not-found", &mut self.notifications.cargo_toml_not_found);
set(value, "/featureFlags/completion.enable-postfix", &mut self.completion.enable_postfix_completions);
set(value, "/featureFlags/completion.insertion.add-call-parenthesis", &mut self.completion.add_call_parenthesis);
set(value, "/featureFlags/completion.insertion.add-argument-snippets", &mut self.completion.add_call_argument_snippets);
set(value, "/featureFlags/call-info.full", &mut self.call_info_full);
log::info!("Config::update() = {:#?}", self); log::info!("Config::update() = {:#?}", self);

View file

@ -30,7 +30,7 @@ use serde::{de::DeserializeOwned, Serialize};
use threadpool::ThreadPool; use threadpool::ThreadPool;
use crate::{ use crate::{
config::Config, config::{Config, FilesWatcher},
diagnostics::DiagnosticTask, diagnostics::DiagnosticTask,
main_loop::{ main_loop::{
pending_requests::{PendingRequest, PendingRequests}, pending_requests::{PendingRequest, PendingRequests},
@ -40,7 +40,6 @@ use crate::{
world::{WorldSnapshot, WorldState}, world::{WorldSnapshot, WorldState},
Result, Result,
}; };
use req::ConfigurationParams;
#[derive(Debug)] #[derive(Debug)]
pub struct LspError { pub struct LspError {
@ -122,12 +121,13 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
}; };
let globs = config let globs = config
.exclude_globs .files
.exclude
.iter() .iter()
.map(|glob| crate::vfs_glob::Glob::new(glob)) .map(|glob| crate::vfs_glob::Glob::new(glob))
.collect::<std::result::Result<Vec<_>, _>>()?; .collect::<std::result::Result<Vec<_>, _>>()?;
if config.use_client_watching { if let FilesWatcher::Client = config.files.watcher {
let registration_options = req::DidChangeWatchedFilesRegistrationOptions { let registration_options = req::DidChangeWatchedFilesRegistrationOptions {
watchers: workspaces watchers: workspaces
.iter() .iter()
@ -153,7 +153,7 @@ pub fn main_loop(ws_roots: Vec<PathBuf>, config: Config, connection: Connection)
workspaces, workspaces,
config.lru_capacity, config.lru_capacity,
&globs, &globs,
Watch(!config.use_client_watching), Watch(matches!(config.files.watcher, FilesWatcher::Notify)),
config, config,
) )
}; };
@ -607,7 +607,12 @@ fn on_notification(
let request_id = loop_state.next_request_id(); let request_id = loop_state.next_request_id();
let request = request_new::<req::WorkspaceConfiguration>( let request = request_new::<req::WorkspaceConfiguration>(
request_id.clone(), request_id.clone(),
ConfigurationParams::default(), req::ConfigurationParams {
items: vec![req::ConfigurationItem {
scope_uri: None,
section: Some("rust-analyzer".to_string()),
}],
},
); );
msg_sender.send(request.into())?; msg_sender.send(request.into())?;
loop_state.configuration_request_id = Some(request_id); loop_state.configuration_request_id = Some(request_id);
@ -884,10 +889,9 @@ fn update_file_notifications_on_threadpool(
subscriptions: Vec<FileId>, subscriptions: Vec<FileId>,
) { ) {
log::trace!("updating notifications for {:?}", subscriptions); log::trace!("updating notifications for {:?}", subscriptions);
let publish_diagnostics = world.config.publish_diagnostics; if world.config.publish_diagnostics {
pool.execute(move || { pool.execute(move || {
for file_id in subscriptions { for file_id in subscriptions {
if publish_diagnostics {
match handlers::publish_diagnostics(&world, file_id) { match handlers::publish_diagnostics(&world, file_id) {
Err(e) => { Err(e) => {
if !is_canceled(&e) { if !is_canceled(&e) {
@ -899,8 +903,8 @@ fn update_file_notifications_on_threadpool(
} }
} }
} }
})
} }
});
} }
pub fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<Message>) { pub fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<Message>) {

View file

@ -810,7 +810,6 @@ pub fn handle_code_lens(
}; };
lenses.push(lens); lenses.push(lens);
if world.config.vscode_lldb {
if r.args[0] == "run" { if r.args[0] == "run" {
r.args[0] = "build".into(); r.args[0] = "build".into();
} else { } else {
@ -827,7 +826,6 @@ pub fn handle_code_lens(
}; };
lenses.push(debug_lens); lenses.push(debug_lens);
} }
}
// Handle impls // Handle impls
lenses.extend( lenses.extend(

View file

@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize};
pub use lsp_types::{ pub use lsp_types::{
notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
CodeLensParams, CompletionParams, CompletionResponse, ConfigurationParams, DiagnosticTag, CodeLensParams, CompletionParams, CompletionResponse, ConfigurationItem, ConfigurationParams,
DidChangeConfigurationParams, DidChangeWatchedFilesParams, DiagnosticTag, DidChangeConfigurationParams, DidChangeWatchedFilesParams,
DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams, DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams,
DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType, DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType,
PartialResultParams, ProgressParams, ProgressParamsValue, ProgressToken, PartialResultParams, ProgressParams, ProgressParamsValue, ProgressToken,

View file

@ -177,46 +177,149 @@
"type": "object", "type": "object",
"title": "Rust Analyzer", "title": "Rust Analyzer",
"properties": { "properties": {
"rust-analyzer.diagnostics.enable": {
"type": "boolean",
"default": true,
"markdownDescription": "Whether to show native rust-analyzer diagnostics."
},
"rust-analyzer.lruCapacity": {
"type": [
"null",
"integer"
],
"default": null,
"minimum": 0,
"exclusiveMinimum": true,
"description": "Number of syntax trees rust-analyzer keeps in memory."
},
"rust-analyzer.files.watcher": {
"type": "string",
"enum": [
"client",
"notify"
],
"default": "client",
"description": "Controls file watching implementation."
},
"rust-analyzer.files.exclude": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Paths to exclude from analysis."
},
"rust-analyzer.notifications.workspaceLoaded": {
"type": "boolean",
"markdownDescription": "Whether to show `workspace loaded` message."
},
"rust-analyzer.notifications.cargoTomlNotFound": {
"type": "boolean",
"markdownDescription": "Whether to show `can't find Cargo.toml` error message"
},
"rust-analyzer.cargo.noDefaultFeatures": {
"type": "boolean",
"default": false,
"markdownDescription": "Do not activate the `default` feature"
},
"rust-analyzer.cargo.allFeatures": {
"type": "boolean",
"default": true,
"description": "Activate all available features"
},
"rust-analyzer.cargo.features": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of features to activate"
},
"rust-analyzer.cargo.loadOutDirsFromCheck": {
"type": "boolean",
"default": false,
"markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs"
},
"rust-analyzer.rustfmt.extraArgs": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Additional arguments to rustfmt"
},
"rust-analyzer.checkOnSave.enable": {
"type": "boolean",
"default": true,
"markdownDescription": "Run specified `cargo check` command for diagnostics on save"
},
"rust-analyzer.checkOnSave.extraArgs": {
"type": "array",
"items": {
"type": "string"
},
"markdownDescription": "Extra arguments for `cargo check`",
"default": []
},
"rust-analyzer.checkOnSave.command": {
"type": "string",
"default": "check",
"markdownDescription": "Cargo command to use for `cargo check`"
},
"rust-analyzer.checkOnSave.allTargets": {
"type": "boolean",
"default": true,
"markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
},
"rust-analyzer.inlayHints.typeHints": {
"type": "boolean",
"default": true,
"description": "Whether to show inlay type hints"
},
"rust-analyzer.inlayHints.chainingHints": {
"type": "boolean",
"default": true,
"description": "Whether to show inlay type hints for method chains"
},
"rust-analyzer.inlayHints.parameterHints": {
"type": "boolean",
"default": true,
"description": "Whether to show function parameter name inlay hints at the call site"
},
"rust-analyzer.inlayHints.maxLength": {
"type": [
"null",
"integer"
],
"default": 20,
"minimum": 0,
"exclusiveMinimum": true,
"description": "Maximum length for inlay hints"
},
"rust-analyzer.completion.addCallParenthesis": {
"type": "boolean",
"default": true,
"description": "Whether to add parenthesis when completing functions"
},
"rust-analyzer.completion.addCallArgumentSnippets": {
"type": "boolean",
"default": true,
"description": "Whether to add argument snippets when completing functions"
},
"rust-analyzer.completion.postfix.enable": {
"type": "boolean",
"default": true,
"markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
},
"rust-analyzer.callInfo.full": {
"type": "boolean",
"description": "Show function name and docs in parameter hints"
},
"rust-analyzer.highlighting.semanticTokens": { "rust-analyzer.highlighting.semanticTokens": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Use proposed semantic tokens API for syntax highlighting" "description": "Use proposed semantic tokens API for syntax highlighting"
}, },
"rust-analyzer.featureFlags": {
"type": "object",
"default": {},
"description": "Fine grained feature flags to disable annoying features",
"properties": {
"lsp.diagnostics": {
"type": "boolean",
"markdownDescription": "Whether to show diagnostics from `cargo check`"
},
"completion.insertion.add-call-parenthesis": {
"type": "boolean",
"description": "Whether to add parenthesis when completing functions"
},
"completion.insertion.add-argument-snippets": {
"type": "boolean",
"description": "Whether to add argument snippets when completing functions"
},
"completion.enable-postfix": {
"type": "boolean",
"markdownDescription": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc."
},
"call-info.full": {
"type": "boolean",
"description": "Show function name and docs in parameter hints"
},
"notifications.workspace-loaded": {
"type": "boolean",
"markdownDescription": "Whether to show `workspace loaded` message"
},
"notifications.cargo-toml-not-found": {
"type": "boolean",
"markdownDescription": "Whether to show `can't find Cargo.toml` error message"
}
}
},
"rust-analyzer.updates.channel": { "rust-analyzer.updates.channel": {
"type": "string", "type": "string",
"enum": [ "enum": [
@ -243,50 +346,6 @@
"default": null, "default": null,
"description": "Path to rust-analyzer executable (points to bundled binary by default). If this is set, then \"rust-analyzer.updates.channel\" setting is not used" "description": "Path to rust-analyzer executable (points to bundled binary by default). If this is set, then \"rust-analyzer.updates.channel\" setting is not used"
}, },
"rust-analyzer.excludeGlobs": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Paths to exclude from analysis"
},
"rust-analyzer.rustfmtArgs": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "Additional arguments to rustfmt"
},
"rust-analyzer.useClientWatching": {
"type": "boolean",
"default": true,
"description": "client provided file watching instead of notify watching."
},
"rust-analyzer.cargo-watch.enable": {
"type": "boolean",
"default": true,
"markdownDescription": "Run specified `cargo-watch` command for diagnostics on save"
},
"rust-analyzer.cargo-watch.arguments": {
"type": "array",
"items": {
"type": "string"
},
"markdownDescription": "`cargo-watch` arguments. (e.g: `--features=\"shumway,pdf\"` will run as `cargo watch -x \"check --features=\"shumway,pdf\"\"` )",
"default": []
},
"rust-analyzer.cargo-watch.command": {
"type": "string",
"markdownDescription": "`cargo-watch` command. (e.g: `clippy` will run as `cargo watch -x clippy` )",
"default": "check"
},
"rust-analyzer.cargo-watch.allTargets": {
"type": "boolean",
"markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)",
"default": true
},
"rust-analyzer.trace.server": { "rust-analyzer.trace.server": {
"type": "string", "type": "string",
"scope": "window", "scope": "window",
@ -307,64 +366,6 @@
"description": "Enable logging of VS Code extensions itself", "description": "Enable logging of VS Code extensions itself",
"type": "boolean", "type": "boolean",
"default": false "default": false
},
"rust-analyzer.lruCapacity": {
"type": [
"null",
"integer"
],
"default": null,
"minimum": 0,
"exclusiveMinimum": true,
"description": "Number of syntax trees rust-analyzer keeps in memory"
},
"rust-analyzer.inlayHints.typeHints": {
"type": "boolean",
"default": true,
"description": "Whether to show inlay type hints"
},
"rust-analyzer.inlayHints.chainingHints": {
"type": "boolean",
"default": true,
"description": "Whether to show inlay type hints for method chains"
},
"rust-analyzer.inlayHints.parameterHints": {
"type": "boolean",
"default": true,
"description": "Whether to show function parameter name inlay hints at the call site"
},
"rust-analyzer.inlayHints.maxLength": {
"type": [
"null",
"integer"
],
"default": 20,
"minimum": 0,
"exclusiveMinimum": true,
"description": "Maximum length for inlay hints"
},
"rust-analyzer.cargoFeatures.noDefaultFeatures": {
"type": "boolean",
"default": false,
"markdownDescription": "Do not activate the `default` feature"
},
"rust-analyzer.cargoFeatures.allFeatures": {
"type": "boolean",
"default": true,
"description": "Activate all available features"
},
"rust-analyzer.cargoFeatures.features": {
"type": "array",
"items": {
"type": "string"
},
"default": [],
"description": "List of features to activate"
},
"rust-analyzer.cargoFeatures.loadOutDirsFromCheck": {
"type": "boolean",
"default": false,
"markdownDescription": "Run `cargo check` on startup to get the correct value for package OUT_DIRs"
} }
} }
}, },

View file

@ -5,30 +5,6 @@ import { Config } from './config';
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
export function configToServerOptions(config: Config) {
return {
lruCapacity: config.lruCapacity,
inlayHintsType: config.inlayHints.typeHints,
inlayHintsParameter: config.inlayHints.parameterHints,
inlayHintsChaining: config.inlayHints.chainingHints,
inlayHintsMaxLength: config.inlayHints.maxLength,
cargoWatchEnable: config.cargoWatchOptions.enable,
cargoWatchArgs: config.cargoWatchOptions.arguments,
cargoWatchCommand: config.cargoWatchOptions.command,
cargoWatchAllTargets: config.cargoWatchOptions.allTargets,
excludeGlobs: config.excludeGlobs,
useClientWatching: config.useClientWatching,
featureFlags: config.featureFlags,
withSysroot: config.withSysroot,
cargoFeatures: config.cargoFeatures,
rustfmtArgs: config.rustfmtArgs,
vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
};
}
export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> { export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> {
// '.' Is the fallback if no folder is open // '.' Is the fallback if no folder is open
// TODO?: Workspace folders support Uri's (eg: file://test.txt). // TODO?: Workspace folders support Uri's (eg: file://test.txt).
@ -48,7 +24,7 @@ export async function createClient(config: Config, serverPath: string, cwd: stri
const clientOptions: lc.LanguageClientOptions = { const clientOptions: lc.LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'rust' }], documentSelector: [{ scheme: 'file', language: 'rust' }],
initializationOptions: configToServerOptions(config), initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"),
traceOutputChannel, traceOutputChannel,
middleware: { middleware: {
// Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576

View file

@ -66,6 +66,10 @@ export function debugSingle(ctx: Ctx): Cmd {
return async (config: ra.Runnable) => { return async (config: ra.Runnable) => {
const editor = ctx.activeRustEditor; const editor = ctx.activeRustEditor;
if (!editor) return; if (!editor) return;
if (!vscode.extensions.getExtension("vadimcn.vscode-lldb")) {
vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` extension for debugging");
return;
}
const debugConfig = { const debugConfig = {
type: "lldb", type: "lldb",

View file

@ -11,9 +11,8 @@ export class Config {
private readonly rootSection = "rust-analyzer"; private readonly rootSection = "rust-analyzer";
private readonly requiresReloadOpts = [ private readonly requiresReloadOpts = [
"serverPath", "serverPath",
"cargoFeatures", "cargo",
"excludeGlobs", "files",
"useClientWatching",
"highlighting", "highlighting",
"updates.channel", "updates.channel",
] ]
@ -71,17 +70,8 @@ export class Config {
get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; } get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; }
get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; } get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; }
get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; } get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; }
get lruCapacity() { return this.cfg.get<null | number>("lruCapacity")!; }
get excludeGlobs() { return this.cfg.get<string[]>("excludeGlobs")!; }
get useClientWatching() { return this.cfg.get<boolean>("useClientWatching")!; }
get featureFlags() { return this.cfg.get<Record<string, boolean>>("featureFlags")!; }
get rustfmtArgs() { return this.cfg.get<string[]>("rustfmtArgs")!; }
get loadOutDirsFromCheck() { return this.cfg.get<boolean>("loadOutDirsFromCheck")!; }
get traceExtension() { return this.cfg.get<boolean>("trace.extension")!; } get traceExtension() { return this.cfg.get<boolean>("trace.extension")!; }
// for internal use
get withSysroot() { return this.cfg.get<boolean>("withSysroot", true)!; }
get inlayHints() { get inlayHints() {
return { return {
typeHints: this.cfg.get<boolean>("inlayHints.typeHints")!, typeHints: this.cfg.get<boolean>("inlayHints.typeHints")!,
@ -91,21 +81,9 @@ export class Config {
}; };
} }
get cargoWatchOptions() { get checkOnSave() {
return { return {
enable: this.cfg.get<boolean>("cargo-watch.enable")!, command: this.cfg.get<string>("checkOnSave.command")!,
arguments: this.cfg.get<string[]>("cargo-watch.arguments")!,
allTargets: this.cfg.get<boolean>("cargo-watch.allTargets")!,
command: this.cfg.get<string>("cargo-watch.command")!,
};
}
get cargoFeatures() {
return {
noDefaultFeatures: this.cfg.get<boolean>("cargoFeatures.noDefaultFeatures")!,
allFeatures: this.cfg.get<boolean>("cargoFeatures.allFeatures")!,
features: this.cfg.get<string[]>("cargoFeatures.features")!,
loadOutDirsFromCheck: this.cfg.get<boolean>("cargoFeatures.loadOutDirsFromCheck")!,
}; };
} }
} }

View file

@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient'; import * as lc from 'vscode-languageclient';
import { Config } from './config'; import { Config } from './config';
import { createClient, configToServerOptions } from './client'; import { createClient } from './client';
import { isRustEditor, RustEditor } from './util'; import { isRustEditor, RustEditor } from './util';
export class Ctx { export class Ctx {
@ -25,7 +25,6 @@ export class Ctx {
const res = new Ctx(config, extCtx, client, serverPath); const res = new Ctx(config, extCtx, client, serverPath);
res.pushCleanup(client.start()); res.pushCleanup(client.start());
await client.onReady(); await client.onReady();
client.onRequest('workspace/configuration', _ => [configToServerOptions(config)]);
return res; return res;
} }

View file

@ -7,7 +7,7 @@ import { Ctx } from './ctx';
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
export function activateStatusDisplay(ctx: Ctx) { export function activateStatusDisplay(ctx: Ctx) {
const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command); const statusDisplay = new StatusDisplay(ctx.config.checkOnSave.command);
ctx.pushCleanup(statusDisplay); ctx.pushCleanup(statusDisplay);
const client = ctx.client; const client = ctx.client;
if (client != null) { if (client != null) {