mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
internal: Make exclude characters for typing assists configurable, default to None
Signed-off-by: Tarek <tareknaser360@gmail.com>
This commit is contained in:
parent
e6276c8b64
commit
d6b701e251
5 changed files with 37 additions and 2 deletions
|
@ -411,6 +411,7 @@ impl Analysis {
|
|||
position: FilePosition,
|
||||
char_typed: char,
|
||||
autoclose: bool,
|
||||
chars_to_exclude: Option<String>,
|
||||
) -> Cancellable<Option<SourceChange>> {
|
||||
// Fast path to not even parse the file.
|
||||
if !typing::TRIGGER_CHARS.contains(char_typed) {
|
||||
|
@ -419,6 +420,11 @@ impl Analysis {
|
|||
if char_typed == '<' && !autoclose {
|
||||
return Ok(None);
|
||||
}
|
||||
if let Some(chars_to_exclude) = chars_to_exclude {
|
||||
if chars_to_exclude.contains(char_typed) {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
|
||||
self.with_db(|db| typing::on_char_typed(db, position, char_typed))
|
||||
}
|
||||
|
|
|
@ -310,6 +310,8 @@ config_data! {
|
|||
|
||||
/// Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
|
||||
typing_autoClosingAngleBrackets_enable: bool = false,
|
||||
/// Specify the characters to exclude from triggering typing assists. The default trigger characters are `.`, `=`, `<`, `>`, `{`, and `(`. Setting this to a string will disable typing assists for the specified characters.
|
||||
typing_excludeChars: Option<String> = None,
|
||||
|
||||
|
||||
/// Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`].
|
||||
|
@ -2160,6 +2162,10 @@ impl Config {
|
|||
*self.typing_autoClosingAngleBrackets_enable()
|
||||
}
|
||||
|
||||
pub fn typing_exclude_chars(&self) -> Option<String> {
|
||||
self.typing_excludeChars().clone()
|
||||
}
|
||||
|
||||
// VSCode is our reference implementation, so we allow ourselves to work around issues by
|
||||
// special casing certain versions
|
||||
pub fn visual_studio_code_version(&self) -> Option<&Version> {
|
||||
|
|
|
@ -459,9 +459,14 @@ pub(crate) fn handle_on_type_formatting(
|
|||
if char_typed == '>' {
|
||||
return Ok(None);
|
||||
}
|
||||
let chars_to_exclude = snap.config.typing_exclude_chars();
|
||||
|
||||
let edit =
|
||||
snap.analysis.on_char_typed(position, char_typed, snap.config.typing_autoclose_angle())?;
|
||||
let edit = snap.analysis.on_char_typed(
|
||||
position,
|
||||
char_typed,
|
||||
snap.config.typing_autoclose_angle(),
|
||||
chars_to_exclude,
|
||||
)?;
|
||||
let edit = match edit {
|
||||
Some(it) => it,
|
||||
None => return Ok(None),
|
||||
|
|
|
@ -997,6 +997,11 @@ Show documentation.
|
|||
--
|
||||
Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
|
||||
--
|
||||
[[rust-analyzer.typing.excludeChars]]rust-analyzer.typing.excludeChars (default: `null`)::
|
||||
+
|
||||
--
|
||||
Specify the characters to exclude from triggering typing assists. The default trigger characters are `.`, `=`, `<`, `>`, `{`, and `(`. Setting this to a string will disable typing assists for the specified characters.
|
||||
--
|
||||
[[rust-analyzer.workspace.discoverConfig]]rust-analyzer.workspace.discoverConfig (default: `null`)::
|
||||
+
|
||||
--
|
||||
|
|
|
@ -2612,6 +2612,19 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "typing",
|
||||
"properties": {
|
||||
"rust-analyzer.typing.excludeChars": {
|
||||
"markdownDescription": "Specify the characters to exclude from triggering typing assists. The default trigger characters are `.`, `=`, `<`, `>`, `{`, and `(`. Setting this to a string will disable typing assists for the specified characters.",
|
||||
"default": null,
|
||||
"type": [
|
||||
"null",
|
||||
"string"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "workspace",
|
||||
"properties": {
|
||||
|
|
Loading…
Reference in a new issue