Reworked important parts of eglot-completion-at-point.
One of the tasks was to cleanup the nomenclature so it's easier to
spot how LSP and Emacs's views of completion techniques differ. When
reading this rather long function, remember an "item" is a plist
representing the LSP completionItem object, and "proxy" is a
propertized string that Emacs's frontends will use to represent that
completion. When the completion is close to done, the :exit-function
is called, to potentially rework the inserted text so that the final
result might be quite different from the proxy (it might be a snippet,
or even a suprising text edit).
The most important change in this commit reworks the way the
completion "bounds" are calculated in the buffer. This is the region
that Emacs needs to know that is being targeted for the completion. A
server can specify this region by using textEdit-based completions all
consistently pointing to the same range. If it does so, Emacs will
use that region instead of its own understanding of symbol
boundaries (provided by thingatpt.el and syntax tables).
To implement server-side completion filtering, the server can also
provide a filterText "cookie" in each completion, which, when
prefix-matched to the intended region, selects or rejects the
completion. Given the feedback in
https://github.com/microsoft/language-server-protocol/issues/651, we
have no choice but to play along with that inneficient and grotesque
strategy to implement flex-style matching. Like ever in LSP, we do so
while being backward-compatible to all previously supported behaviour.
* eglot.el (eglot-completion-at-point): rework.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/235