Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A neovim client should tell that it supports specific editor commands #875

Open
Myriad-Dreamin opened this issue Nov 21, 2024 · 1 comment · May be fixed by #993
Open

A neovim client should tell that it supports specific editor commands #875

Myriad-Dreamin opened this issue Nov 21, 2024 · 1 comment · May be fixed by #993
Labels
editor-integration Features about editor integrations enhancement New feature or request

Comments

@Myriad-Dreamin
Copy link
Owner

Myriad-Dreamin commented Nov 21, 2024

The client must tell whether it supports several editor commands to callback after lsp completion.

  • editor.action.triggerSuggest, which is known to be supported by vscode 1.0+ and neovim 0.9.1+
  • editor.action.triggerParameterHints, which is known to be supported by vscode 1.0+ and neovim 0.9.1+
  • tinymist.triggerSuggestAndParameterHints, supported by the vscode's client-side extension.

Since the two editor.action.* builtin commands are only known to be supported in neovim, we can only focus on fix this issue on neovim clients first.

Related issues:

Why not trigger these commands by default?

If server yields a not existing command, users might keep receiving command not found errors. Related issue: #697

Example Workflow

  1. client add configuration items when initializing the server:

config.triggerSuggest = true;
config.triggerSuggestAndParameterHints = true;
config.triggerParameterHints = true;
config.supportHtmlInMarkdown = true;

  1. The configuration items are parsed and held in the tinymist_query crate's global object.

/// Whether to trigger suggest completion, a.k.a. auto-completion.
pub trigger_suggest: bool,
/// Whether to trigger named parameter completion.
pub trigger_named_completion: bool,
/// Whether to trigger parameter hint, a.k.a. signature help.
pub trigger_parameter_hints: bool,

  1. The tinymist_query crate reads command to use when performing lsp-based completion.

/// Get configured trigger parameter hints command.
pub fn trigger_parameter_hints(&self, context: bool) -> Option<&'static str> {
(self.completion_feat.trigger_parameter_hints && context)
.then_some("editor.action.triggerParameterHints")
}
/// Get configured trigger after snippet command.
///
/// > 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
pub fn trigger_on_snippet(&self, context: bool) -> Option<&'static str> {
if !self.completion_feat.trigger_on_snippet_placeholders {
return None;
}
(self.completion_feat.trigger_suggest && context).then_some("editor.action.triggerSuggest")
}
/// Get configured trigger on positional parameter hints command.
pub fn trigger_on_snippet_with_param_hint(&self, context: bool) -> Option<&'static str> {
if !self.completion_feat.trigger_on_snippet_placeholders {
return self.trigger_parameter_hints(context);
}
(self.completion_feat.trigger_suggest_and_parameter_hints && context)
.then_some("tinymist.triggerSuggestAndParameterHints")
}

Possible Workflow in Neovim

  1. If the neovim client finds commands are supported, it adds related configuration items when initializing the server in mason-lsp-config. As mentioned, they are only supported since neovim 0.9.1+.
  2. same as that in vscode.
  3. same as that in vscode.
@Myriad-Dreamin Myriad-Dreamin changed the title Neovim clients should tell that it supports specific editor commands A neovim client should tell that it supports specific editor commands Nov 21, 2024
@Myriad-Dreamin
Copy link
Owner Author

@Myriad-Dreamin Myriad-Dreamin added enhancement New feature or request editor-integration Features about editor integrations labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-integration Features about editor integrations enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant