emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.75k stars 869 forks source link

[Feature] commitCharactersSupport #1484

Open yyoncho opened 4 years ago

yyoncho commented 4 years ago

This is something that we are missing from 3.14 support. When declared, each CompletionItem will have a list of chars which once pressed will insert the item. I was unable to find something in company-mode that corresponds directly to that feature(cc @dgutov), but potentially the feature might be implemented in the upstream and wired in lsp-mode.

cc @kiennq

dgutov commented 4 years ago

That sounds like company-auto-complete-chars (which can be set to a function).

But since you intend to go the c-a-p-f route, direct integration with company seems ill-advised. So maybe that should be some extra property on the list returned by the completion function. That would need some thought.

dvzubarev commented 4 years ago

I use company-show-numbers all the time: If enabled, show quick-access numbers for the first ten candidates. Although you need to press Alt-<num> instead of some char.

yyoncho commented 4 years ago

@kiennq company-auto-complete-chars does not work on our side. The issue is that when the completion is over we restore the initial state of the buffer(at the time of completion request) which deletes the trigger character.

Some potential fixes:

  1. Handle auto-complete-chars on our side.
  2. company somehow to alert us for this case?
  3. ?

I think this is a very useful feature, especially when auto-complete chars are provided by context-aware service.