feat: trigger parameter hints instead of suggest on pos args (#243)

* dev: disable aggressive positional arguments completion

* feat: trigger parameter hints instead of suggest on pos args

* dev: update snapshot
This commit is contained in:
Myriad-Dreamin 2024-05-05 23:40:29 +08:00 committed by GitHub
parent 64c8be64d3
commit d8c3a97f24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 16 deletions

View file

@ -1029,7 +1029,9 @@ impl<'a, 'w> CompletionContext<'a, 'w> {
// command on a suggestion to "manually" retrigger suggest after inserting one
//
// todo: only vscode and neovim (0.9.1) support this
command: Some("editor.action.triggerSuggest"),
command: snippet
.contains("${")
.then_some("editor.action.triggerSuggest"),
..Completion::default()
});
}
@ -1181,7 +1183,7 @@ impl<'a, 'w> CompletionContext<'a, 'w> {
let mut command = None;
if parens && matches!(value, Value::Func(_)) {
if let Value::Func(func) = value {
command = Some("editor.action.triggerSuggest");
command = Some("editor.action.triggerParameterHints");
if func
.params()
.is_some_and(|params| params.iter().all(|param| param.name == "self"))

View file

@ -313,7 +313,7 @@ impl<'a, 'w> CompletionContext<'a, 'w> {
kind: kind.clone(),
label_detail: ty_detail,
// todo: only vscode and neovim (0.9.1) support this
command: Some("editor.action.triggerSuggest"),
command: Some("editor.action.triggerParameterHints"),
..Default::default()
};
@ -641,13 +641,7 @@ pub fn param_completions<'a>(
apply: Some(eco_format!("{}: ${{}}", param.name)),
detail: Some(plain_docs_sentence(&param.docs)),
label_detail: None,
// todo: only vscode and neovim (0.9.1) support this
//
// VS Code doesn't do that... Auto triggering suggestion only happens on typing
// (word starts or trigger characters). However, you can use
// editor.action.triggerSuggest as command on a suggestion to
// "manually" retrigger suggest after inserting one
command: Some("editor.action.triggerSuggest"),
command: Some("tinymist.triggerNamedCompletion"),
..Completion::default()
};
match param.infer_type {
@ -742,8 +736,7 @@ fn type_completion(
label: f.clone(),
apply: Some(eco_format!("{}: ${{}}", f)),
detail: docs.map(Into::into),
// todo: only vscode and neovim (0.9.1) support this
command: Some("editor.action.triggerSuggest"),
command: Some("tinymist.triggerNamedCompletion"),
..Completion::default()
});
}