flycheck / flycheck-pos-tip

Flycheck errors display in tooltip
GNU General Public License v3.0
122 stars 10 forks source link

Make a tooltip position configurable according to other menus #17

Open ddovod opened 8 years ago

ddovod commented 8 years ago

Hi. I have some issue with tooltip. Instead of thouthand words please look at the picture http://imgur.com/w2Daspa

Is there any solution? Thank you a lot!

cpitclaudel commented 8 years ago

This is going to be really hard to fix; the other menu is from autocomplete, right? I don't think there's a way for us to autodetect its width, so we'd have to have a special case for every package that displays a menu (company, ac, ...)

Of course, I'm hoping @lunaryorn to prove me wrong :)

swsnr commented 8 years ago

I tend to agree with @cpitclaudel: I don't think that we can easily prevent this sort of thing. I'm inclined to close this issue was "wontfix".

swsnr commented 8 years ago

At best, we could provide an option to adjust tooltip placement, but I'm not firm enough with pos-tip to implement that.

ambihelical commented 8 years ago

I'm having the exact same problem, but since I only manually complete I'd be happy with a way to disable the pos-tip when the completion menu is showing. Any ideas how to accomplish this?

cpitclaudel commented 8 years ago

@ambihelical You can remap the command that starts completion to a defun of your own that would call pos-tip-hide before calling through to the completion function. I can give more details if needed :)

ambihelical commented 8 years ago

I tried it but it doesn't completely solve the problem, as flycheck can cause the tooltip to reappear while the completion menu is still showing. I will probably look into temporarily disabling flycheck next, as there seems to be hooks for completion start and stop.

A potentially simple way to fix this for everyone would be if there was an option to always place the tooltip above the line, and then the two popups shouldn't interfere.

seagle0128 commented 7 years ago

call pos-tip-hide before calling through to the completion function

I think it's a good solution.

ambihelical commented 7 years ago

@seagle0128 Did it work for you? It's been awhile but as I said, it seem to be possible for pos-tip-show to be called again while the completion menu is still active, and I seem to recall this occurring during my experiments.

I ended up doing the following, it has worked so far for me, but requires saving and restoring the flycheck-pos-tip-error-messages function, which seems a bit of a hack to me.

Partial config follows.

(use-package company
  :init
  (add-hook 'company-completion-started-hook #'me:company-started)
  (add-hook 'company-completion-finished-hook #'me:company-ended)
  (add-hook 'company-completion-cancelled-hook #'me:company-ended)
  :config
  (defvar me:flycheck-error-function nil)
  (defun me:company-started (&optional args)
    (when (fboundp 'flycheck-pos-tip-error-messages)
      (setq me:flycheck-error-function (symbol-function 'flycheck-pos-tip-error-messages))
      (fset 'flycheck-pos-tip-error-messages 'ignore)))

  (defun me:company-ended (&optional args)
    (when (fboundp 'flycheck-pos-tip-error-messages)
      (fset 'flycheck-pos-tip-error-messages me:flycheck-error-function))))
seagle0128 commented 7 years ago

@ambihelical Honestly I didn't try this workaround. But it seems your workaround works as well.

cpitclaudel commented 7 years ago

Thanks for sharing that. I think we should have an API to temporarily suspend Flycheck. It turns out that autocomplete already uses advice to override an internal function and disable Flycheck while completing, so that API would be useful there too.