-
Notifications
You must be signed in to change notification settings - Fork 200
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
Completion with non-prefix candidates #181
Comments
Ok, this is very interesting. I have since something similar for Sly recently and indeed I do miss it in Eglot. I recently added special support for this kind of stuff in |
Can you confirm it's something like https://github.com/joaotavora/sly/blob/master/doc/animations/company-flex-completion.gif you are after? |
It would also be useful for example with clangd, which, for some candidates, prepends a special prefix to completion label - the character
|
@joaotavora Yes, something like the linked gif would do the job. |
I don't know about that (I am using clangd-8). The code says it's "A visual indicator to prepend to the completion label to indicate whether completion result would trigger an #include insertion or not". Maybe you need to build clangd index to enable it, since I'm doing that. |
I'm using this one. It is certainly easy to run, and I can implement the citation fuzzy matching soon for another interesting test case. On the downside, it's mostly a sketch at this point, and I have tested it only with Eglot. It would be better to make sure first that my server plays well with clients that already do non-prefix matching; unfortunately it doesn't seem so easy to just run your own server on the "reference client", if you would call VS Code so. |
Oh it looks very good. I wish I had this when I was recently writing my master thesis
❤️ Unfortunately, on debian buster/sid, luarocks complains that it only finds lua 5.1. I installed lua 5.3 and and even added it to the alternatives, but I still can't install your server :-(. Any help? |
It's funny how the dependencies work on Debian, but the following works for me (on Ubuntu 18.04): |
Looks line "funny" == "broken" in this case. Anyway, I did what you suggested and it worked. So got it working. I'll let you know once I come up with something. |
@astoff for this to work correctly we need support from the LSP specification. Here's a preamble, that you might want to skip. Basically, completions in LSP are very client agnostic: they work like "Here's a document, here's point, optionally here's what's been pressed recently, now give me the completions", whereas Emacs normally works like "here's a substring and some minimal context, give me strings that complete the substring". It's not easy to judge what is better, and we sure aren't going to change the basic workings of the LSP approach, but it makes it difficult for Emacs to guess exactly what string the LSP server is completing. But this doesn't necessarily matter here. For this to work, the server has to provide the regions of each completion that it thinks are the parts of that that are already set down. So the user requests completion after the word Well, long story short, we need a new field for the Of course, I'll create an issue in the LSP github page. |
I've just reread the original issue description and I think there's a different (easier) solution to the problem. I think the culprit is that eglot does not follow closely the lsp standard when it comes to filterText properties. However, I believe a workaround can be implemented in the server. I haven't tested it, but if the server sends "document" as label instead of "begin{document}", then eglot inserts the newText property ("begin{document}") correctly. Obviously, the correct solution is to support filterText in eglot. I made a half-baked attempt to do that in #235, but it might not solve this issue. Having said that, flex matching would be awesome. |
Although I won't have time to review it anytime soon, please explain exactly how, or open a new issue. In case #235 is already that issue, disregard this. |
After a long time — thanks for looking into this and also bringing up the issue with the LSP people. I guess it will just take a while for the specs to mature and resolve this question completely. In any case, would you like to set up eglot to work out of the box with digestif? I think it does the basic stuff well enough by now. It should be enabled in |
In version 1.5, flex matching works when filterText is appropriately set, so I'll close this. |
It would be nice to support non-prefix matches for completion candidates. Currently, it seems that all non-prefix matches returned by the server are discarded, when using either company or completion-at-point.
In latex, for instance, completions after
\doc
should include\documentclass
and\begin{document}
. Even if the response from the server (attached below) includes both, with the propertyfilterText
appropriately set, eglot suggests only\documentclass
.There is at least one further use case for this feature in latex: completing
\cite{label
could suggest not only bibtex entries whose identifier starts withlabel
, but also any entries fuzzy-matching 'label`. This would allow using bibtex entries with non-mnemonic labels, like those one can download from indexing services.The text was updated successfully, but these errors were encountered: