-//! FIXME: write short doc here
+//! Config used by the language server.
+//!
+//! We currently get this config from `initialize` LSP request, which is not the
+//! best way to do it, but was the simplest thing we could implement.
+//!
+//! Of particular interest is the `feature_flags` hash map: while other fields
+//! configure the server itself, feature flags are passed into analysis, and
+//! tweak things like automatic insertion of `()` in completions.
use rustc_hash::FxHashMap;
assert_eq!(default, serde_json::from_str(r#"{}"#).unwrap());
assert_eq!(
default,
- serde_json::from_str(
- r#"{"publishDecorations":null, "showWorkspaceLoaded":null, "lruCapacity":null}"#
- )
- .unwrap()
+ serde_json::from_str(r#"{"publishDecorations":null, "lruCapacity":null}"#).unwrap()
);
}
}
### Settings
* `rust-analyzer.highlightingOn`: enables experimental syntax highlighting
-* `rust-analyzer.showWorkspaceLoadedNotification`: to ease troubleshooting, a
- notification is shown by default when a workspace is loaded
* `rust-analyzer.enableEnhancedTyping`: by default, rust-analyzer intercepts
`Enter` key to make it easier to continue comments. Note that it may conflict with VIM emulation plugin.
* `rust-analyzer.raLspServerPath`: path to `ra_lsp_server` executable
* `rust-analyzer.trace.server`: enables internal logging
* `rust-analyzer.trace.cargo-watch`: enables cargo-watch logging
* `RUST_SRC_PATH`: environment variable that overwrites the sysroot
+* `rust-analyzer.featureFlags` -- a JSON object to tweak fine-grained behavior:
+ ```js
+ {
+ // Show diagnostics produced by rust-analyzer itself.
+ "lsp.diagnostics": true,
+ // Automatically insert `()` and `<>` when completing functions and types.
+ "completion.insertion.add-call-parenthesis": true,
+ // Show notification when workspace is fully loaded
+ "notifications.workspace-loaded": true,
+ }
+ ```
## Emacs
"description": "A list of patterns for cargo-watch to ignore (will be passed as `--ignore`)",
"default": []
},
- "rust-analyzer.showWorkspaceLoadedNotification": {
- "type": "boolean",
- "description": "Controls whether rust-analyzer displays a notification when a project is loaded.",
- "default": false
- },
"rust-analyzer.trace.server": {
"type": "string",
"scope": "window",
public rainbowHighlightingOn = false;
public enableEnhancedTyping = true;
public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server';
- public showWorkspaceLoadedNotification = true;
public lruCapacity: null | number = null;
public displayInlayHints = true;
public maxInlayHintLength: null | number = null;
) as boolean;
}
- if (config.has('showWorkspaceLoadedNotification')) {
- this.showWorkspaceLoadedNotification = config.get(
- 'showWorkspaceLoadedNotification'
- ) as boolean;
- }
-
if (!this.highlightingOn && Server) {
Server.highlighter.removeHighlights();
}
documentSelector: [{ scheme: 'file', language: 'rust' }],
initializationOptions: {
publishDecorations: true,
- showWorkspaceLoaded:
- Server.config.showWorkspaceLoadedNotification,
lruCapacity: Server.config.lruCapacity,
excludeGlobs: Server.config.excludeGlobs,
useClientWatching: Server.config.useClientWatching,