Skip to content

lsp-try-completion: make it pass-through so the basic style works #2405

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

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

kiennq
Copy link
Member

@kiennq kiennq commented Dec 14, 2020

Make the try-completion of completion function become pass through so basic completion style of lsp-capf works.
Also if there's only one completion result, return that value as common prefix.
Fix #2404

Also make the completion function of lsp-mode to return nil if the action flag doesn't match to predefined one.

Copy link
Member

@yyoncho yyoncho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@@ -470,12 +470,15 @@ The MARKERS and PREFIX value will be attached to each candidate."
;; boundaries
((equal (car-safe action) 'boundaries) nil)
;; try-completion
((null action) (cl-first (member probe (funcall candidates))))
((null action)
(when-let ((cands (funcall candidates)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you use (not (cl-rest collection)) instead of comparing lenght to 1. I know that we have that on a few places but it is no the correct elisp.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyoncho as a side note, cl-rest or cdr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since cl-rest is alias of cdr and more expressive at the same time, IMO cl-rest is a clear winner here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, both convey the same meaning. To me, cdr is more intuitive, IMHO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favour of cl-rest (or even rest if it was not deprecated). car/cdr/etc are archaisms kept only for historical reasons and IMHO they should be deprecated even in core code.

@kiennq kiennq force-pushed the bug/try-completion-pt branch from 80a9e1d to 9c0eef0 Compare December 14, 2020 08:36
@kiennq kiennq merged commit 7d22a49 into emacs-lsp:master Dec 14, 2020
@kiennq kiennq deleted the bug/try-completion-pt branch January 2, 2021 01:16
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

Successfully merging this pull request may close these issues.

Completion error: completion--some: Internal error: ChatHistoryEntry doesn’t match \`E
3 participants