Skip to content

Inconsistent jedi_completion with snippets enabled client (vim-lsp) #619

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

Open
torimus opened this issue Feb 9, 2025 · 2 comments
Open

Comments

@torimus
Copy link

torimus commented Feb 9, 2025

Using Vim 9.1 with latest vim-lsp and UltiSnips integration. I do explicitly enable in pylsp.plugins

  • jedi_completion.enabled to true
  • jedi_completion.include_params to true

When I invoke code completion at symbol, sometimes lsp#complete inserts function including parameters as snippet placeholders

Image

finishing completion inserts selected function with arguments as snippet placeholders:

Image

However in a quite similar case, insertion of function arguments does not happen

Image

results in

Image

Possible bug in jedi_completion plugin? Any other explanation?

@krassowski
Copy link
Member

Currently only an initial set of completion items (by default 25) receive snippets:

if include_params and not is_exception_class(d.name):
snippet = _snippet(d, resolve_label_or_snippet)
completion.update(snippet)

And snippets are not resolved in completionItem/resolve:

@hookimpl
def pylsp_completion_item_resolve(config, completion_item, document):
"""Resolve formatted completion for given non-resolved completion"""
shared_data = document.shared_data["LAST_JEDI_COMPLETIONS"].get(
completion_item["label"]
)
completion_capabilities = config.capabilities.get("textDocument", {}).get(
"completion", {}
)
item_capabilities = completion_capabilities.get("completionItem", {})
supported_markup_kinds = item_capabilities.get("documentationFormat", ["markdown"])
preferred_markup_kind = _utils.choose_markup_kind(supported_markup_kinds)
if shared_data:
completion, data = shared_data
return _resolve_completion(completion, data, markup_kind=preferred_markup_kind)
return completion_item

This might explain it.

@krassowski
Copy link
Member

The specification forbids changing insertText in resolution phase unless completionItem#resolveSupport lists it:

By default the request can only delay the computation of the detail and documentation properties. Since 3.16.0 the client can signal that it can resolve more properties lazily. This is done using the completionItem#resolveSupport client capability which lists all properties that can be filled in during a ‘completionItem/resolve’ request. All other properties (usually sortText, filterText, insertText and textEdit) must be provided in the textDocument/completion response and must not be changed during resolve

So it will only work for clients which do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants