-
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
clangd-8 + company + flymake snippets problem #301
Comments
Are you sure that the attached events buffer corresponds to the video? In the video I see a possible completion of "LOG_ALERT", but that text is missing from the events buffer. Or is it because you don't get your completions from the language server? Does the problem still exist if you disable company-clang? |
On Fri, Sep 27, 2019 at 02:33:58AM -0700, Felicián Németh wrote:
Are you sure that the attached events buffer corresponds to the video? In
the video I see a possible completion of "LOG_ALERT", but that text is
missing from the events buffer. Or is it because you don't get your
completions from the language server? Does the problem still exist if you
disable company-clang?
Well, this indeed comes from the company-clang backend. Without it, I get:
log_append void (*)(int, const char *, ...)
log_setmask int (*)(int)
log_free void
log_init void
when typing "log". So no snippets for two of the four functions.
With ccls (still without company-clang) the snippets are proposed, but are
erased a split second after being added when pressing Return; this is getting
stranger and stranger.
|
To go further, I set company-backends to company-capf only, and snippets still malfunction or don't work at all.
Is there something to do to get them to work?
|
Hopefully, there's a solution to this problem, but first we need to understand what's going on. Can you disable company altogether and use the built-in If C-M-i works, then re-enable company with the default settings and with only one back-end (capf). Once again, if it fails, share the events buffer of a "minimal" session. |
Thanks for your help. Here's the input:
Result with clangd: Result with ccls: I think I should mention that I had not installed yasnippets before (but doing so didn't solve my problem). |
In both cases, the client sends (:snippetSupport :json-false), which indicates that yasnippet wasn't enabled when eglot started. The easiest way to overcome this is to execute But then I don't understand how you got snippet like behavior in your original video. The ccls log also shows an eglot bug: it inserted "um(int a, int b) -> int" instead of "um(". Is that right? So, can you repeat your experiment with yasnippet enabled? If that's successful, try to complicate the experiment with snippet completion inside an on-going snippet completion. If that's successful as well, then go back from M-C-i to a very simple company setup. |
On Tue, Oct 01, 2019 at 02:50:56AM -0700, Felicián Németh wrote:
In both cases, the client sends (:snippetSupport :json-false), which indicates that yasnippet wasn't enabled when eglot started. The easiest way to overcome this is to execute `M-x yas-global-mode RET` even before you open any files.
With clangd
I get the full prototype, `intsum(int a, int b)`, but without the functionality allowing you to type on the parameters to erase them (isn't it what snippets are about?).
Even log: https://files.catbox.moe/f2w7ju.txt
With ccls
Still get `intsum(int a, int b) -> int`.
Event log: https://files.catbox.moe/arqvkm.txt
But then I don't understand how you got snippet like behavior in your original video.
Could be company-clang's behaviour, no?
The ccls log also shows an eglot bug: it inserted "um(int a, int b) -> int" instead of "um(". Is that right?
Yes.
However, I thought eglot would automatically detect yasnippet and use it.
|
It does precisely this. But currently, you still must have snippet support enabled globally for the detection and auto-use to take effect. And that's what @nemethf means with However, that could change. I could be convinced to turn on yasnippet automatically with Eglot just as we do with Flymake. @nemethf any thoughts on this? |
This is a new bug you've just discovered (#311). Luckily, this bug doesn't affect completion with company.
And this one is most probably bug #279. So, there are two ways to continue this saga. You can try to avoid #311 with having multiple completion candidates and test whether the "snippet inside snippet" case works with C-M-i and clangd. Or you can try to enable company-mode with its default settings and try to repeat your previous experiment. In the meantime, I try to look into #279. |
I think that will improve newcomers' initial experience. So I'm not against changing the snippet support to an opt-out feature. |
How exactly would one opt out? By not having the |
I just reduced my .emacs to the bare necessities and test company-clang alone. It worked perfectly on a simple example like the previous one:
Config:
(require 'company)
(add-hook 'prog-mode-hook 'company-mode)
(setq company-backends '(company-clang))
Result: https://files.catbox.moe/jzphxh.webm
On the other hand, eglot + company-capf + yasnippets completed but snippets seemed to use a different mechanism (different visuals and second parameter snippets not working):
Config:
(require 'company)
(add-hook 'prog-mode-hook 'company-mode)
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
(add-hook 'c-mode-hook
(lambda ()
(setq company-backends '(company-capf))
(eglot-ensure)
(yas-minor-mode)))
Result: https://files.catbox.moe/k6tqyx.webm
Log (without the #include to make it leaner): https://files.catbox.moe/rubylo.log
Hope this can help make eglot better.
|
Maybe with a new eglot-ignored-client-capabilites defcustom? I think it's important to let the users easily disable this feature. It might help them to debug a server or eglot, or they might just prefer company-clang. Just because yasnippet is installed, it doesn't mean the users want to use it with eglot. (And the same goes for flymake, probably.) |
@q3cpma your videos helped a lot. It seems you go to the next field with Now I'm positive eglot + company-capf + yasnippets works with your last, minimal configuration if you use yasnippet in the intended way. However, you might like the company-clang style better, so it would be good if we could fix that for you. On the bright side, I start to understand your initial bug report. But I cannot dig into the details at the moment. |
On Fri, Oct 04, 2019 at 01:52:39AM -0700, Felicián Németh wrote:
@q3cpma your videos helped a lot. It seems you go to the next field with `right-char` in company-clang, but you need to press `TAB` to jump to the next field in yasnippet. They work differently.
Now I'm positive eglot + company-capf + yasnippets works with your last, minimal configuration if you use yasnippet in the intended way. However, you might like the company-clang style better, so it would be good if we could fix that for you. On the bright side, I start to understand your initial bug report. But I cannot dig into the details at the moment.
Thanks, it works perfectly when using TAB. I still like company-clang's style (flymake not looking at the expanded snippets and movements allowed before editing the next parameter) better, but that's a very minor nitpick.
|
@q3cpma your problem is most likely gone in the latest Eglot, which ensures |
Feel free to reopen if you think this isn't fully solved yet. |
Hello and sorry for vague title,
First, here's a video of the problem: https://files.catbox.moe/71f1jv.webm
This problem only happens with function snippets after overwriting the parameter by typing on it. The only way to describe it is that Flymake's view is desynchronized with what emacs truly has.
I had the same kind of problems with ccls and llvm-7, but it seems gone with llvm-8, so I'll be using it from now.
Here's what the prog-mode section of my config file looks like:
And here are the eglot output buffers:
eglot-events.txt
eglot-stderr.txt
This is with emacs-26.3, eglot-20190910.1347 and company-20190907.1149
The text was updated successfully, but these errors were encountered: