GithubHelp home page GithubHelp logo

flycheck-posframe's Introduction

flycheck-posframe

License GPL 3 MELPA Build Status

Display flycheck error messages via posframe.

flycheck-posframe screenshot

Installation

MELPA

The preferred way to install flycheck-posframe is via MELPA - then you can just M-x package-install RET flycheck-posframe RET

To enable then simply add the following to your init file:

(with-eval-after-load 'flycheck
  (require 'flycheck-posframe)
  (add-hook 'flycheck-mode-hook #'flycheck-posframe-mode))

We recommend to use use-package to make this automatic:

(use-package flycheck-posframe
  :ensure t
  :after flycheck
  :config (add-hook 'flycheck-mode-hook #'flycheck-posframe-mode))

Manual

If you would like to install the package manually, download or clone it and place within Emacs' load-path, then you can require it in your init file like this:

(require 'flycheck-posframe)
(add-hook 'flycheck-mode-hook #'flycheck-posframe-mode)

NOTE: This will also require the manual installation of flycheck if you have not done so already.

Configuration

Default Pretty Configuration

Calling (flycheck-posframe-configure-pretty-defaults) will configure flycheck-posframe to show warnings and errors with nicer faces (inheriting from warning and error respectively), and set the prefix for each to nicer unicode characters.

Manual Configuration

There are a few settings which can be configured to customise the display of error messages. These include the faces which are used to show the error messages flycheck-posframe-info-face, flycheck-posframe-warning-face and flycheck-posframe-error-face and a string which is used as the prefix for each message flycheck-posframe-info-prefix``flycheck-posframe-warning-prefix and flycheck-posframe-error-prefix. The background colour can be specified as the background attribute of the flycheck-posframe-background-face face. The position, as well as the border width and colour can also be customised via the flycheck-posframe-position, flycheck-posframe-border-widthandflycheck-posframe-border-color` variables respectively.

flycheck-posframe-LEVEL-face

By default each of flycheck-posframe-LEVEL-face inherits from the default face so should appear like the rest of the text in the buffer. If however you want to ensure error messages stand-out you could configure them to inherit from the error face:

(set-face-attribute 'flycheck-posframe-error-face nil :inherit 'error)

flycheck-posframe-LEVEL-prefix

By default flycheck-posframe-LEVEL-prefix is set to "➤ ". If however you wanted to show each warning message prefixed with the unicode WARNING SIGN symbol (U+26A0) "⚠ " you could configure it as follows:

(setq flycheck-posframe-warning-prefix "\u26a0 ")

flycheck-posframe-background-face

By default flycheck-posframe-background-face inherits from the default face, so the background colour should be the same as the standard window frame background colour. This can be customised like any other face (ie. by using customize-face or manually setting the :background face attribute)

flycheck-posframe-border-face

By default flycheck-posframe-border-face inherits from the default face, so the background colour should be the same as the standard foreground colour. This can be customised like any other face (ie. by using customize-face or manually setting the :foreground face attribute)

flycheck-posframe-border-use-error-face

By default flycheck-posframe-border-use-error-face is nil. When non-nil, it will override flycheck-posframe-border-face with the foreground of the face for the highest error level that is shown by posframe.

flycheck-posframe-border-width

By default flycheck-posframe-border-width is zero but this can be set to an integer number of pixels to specify the width of the border.

flycheck-posframe-position

By default flycheck-posframe-position is set to point-bottom-left-corner so that errors are shown just below point. This can be customised to any of the existing positions supported by posframe. For example, to display errors at the bottom-left of the window:

(setq flycheck-posframe-position 'window-bottom-left-corner)

License

Copyright © 2019 Alex Murray

Distributed under GNU GPL, version 3.

flycheck-posframe's People

Contributors

alexmurray avatar anonimitoraf avatar divvycr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flycheck-posframe's Issues

Rendering of a posframe moves pointer to first line of frame

Any time a new posframe is created, regardless of where it is on the screen, my pointer goes to the space just to the left of the first line in my existing buffer. I have no idea if this is a problem with this package or posframe itself.

Let me know what you need from me. Thanks!

Reuse frame instead of deleting and recreating

Hi, thanks again for flycheck-posframe. I'm wondering if it can be reworked slightly to reuse the posframe similar to how company-childframe does it. Every time a frame is created on macOS it causes a flicker in the top left of the parent frame. It's also slow, and worst of all, destroying the frame makes it far more likely to run into bug#30800 which just outright crashes emacs when it happens.

Posframe doesn't hide automatically on moving the point out of the error line

This might be an issue in recent updates of posframe but flycheck-posframe has stopped hiding automatically once moved out of the error line. It stays open until I hover on it with my mouse or change my focus to the minibuffer.

I have solved it by running the flycheck posframe hide on post-command-hook.

(add-hook 'post-command-hook #'flycheck-posframe-hide-posframe)

Allow configuration of background

I'm not sure how, but it'd be great if we could customize the background color of the posframe. It currently matches the frame it is showing over, which makes it a bit harder to read.

If I customize the error/warning faces, I get this:

cloudapp annotation 2018-03-11 at 10 01 20 am png

Add an option to match `-posframe-border-face` to highest error level.

I want the posframe border colour to reflect the severity of the error(s).

With my limited experience, I was thinking of adding the following function:

(defun flycheck-posframe-highest-error-level-face (errs)
  "Return the face corresponding to the highest error level from ERRS."
  (flycheck-posframe-get-face-for-error (cl-reduce
					 (lambda (err1 err2) (if (flycheck-error-level-< err1 err2) err2 err1))
					 errs)))

To apply for the border colour, based on the option flycheck-posframe-border-use-error-face:

(defun flycheck-posframe-show-posframe (errors)
  "Display ERRORS, using posframe.el library."
  (posframe-hide flycheck-posframe-buffer)
  (when (and errors
             (not (run-hook-with-args-until-success 'flycheck-posframe-inhibit-functions)))
    (let ((poshandler (intern (format "posframe-poshandler-%s" flycheck-posframe-position))))
      (unless (functionp poshandler)
        (setq poshandler nil))
      (flycheck-posframe-check-position)
      (posframe-show
       flycheck-posframe-buffer
       :string (flycheck-posframe-format-errors errors)
       :background-color (face-background 'flycheck-posframe-background-face nil t)
       :position (point)
       :internal-border-width flycheck-posframe-border-width
-      :internal-border-color (face-foreground 'flycheck-posframe-border-face nil t)
+      :internal-border-color (face-foreground (if flycheck-posframe-border-use-error-face
+						   (flycheck-posframe-highest-error-level-face errors)
+						 'flycheck-posframe-border-face) nil t)
       :poshandler poshandler
       :hidehandler #'flycheck-posframe-hidehandler))))

Examples from my local implementation:

Missing the last char of the error message

Thanks for the great package.

There's a bit small thing that may be improved as illustrated in the following image

screen shot 2018-12-21 at 22 17 13

As compared to the pos-tip version, the ] is missing!

How to set color

Hi i am a vimer but now new come to emacs, got problem with set flycheck-posframe color,need help

    (setq  flycheck-posframe-warning-prefix "😅"
           flycheck-posframe-error-prefix "😡"
           flycheck-posframe-border-width 5
           flycheck-posframe-error-face '(:foreground "red")
           flycheck-posframe-warning-face '(:foreground "orange")
           flycheck-posframe-info-face '(:foreground "blue")
           flycheck-posframe-border-face  '(:foreground "#dc752f")))

Don't show while auto-completion

Thanks for the great package!

I have an issue while input with company. When auto-completion popup, the flycheck-posframe still popups, which overrides the company prompts. I think it should not display while auto-completion popups.

image

Position of the message

Greetings great job,

You can put some option to configure the position where the message will be displayed, for example on the sideline similar to lsp-ui

Thanks

Thank you!

I have been looking for this functionality for a long time.

Hugely helpful in TIDE where flycheck errors obfuscate type signatures in the mini buffer.

Now I can keep the signature and see Flycheck errors in frame. Thanks! 🎉

Package ‘emacs-26’ is unavailable

Hi,

I'm using the following configuration to setup the package.

(use-package flycheck-posframe     
  :ensure t
  :after flycheck
  :config (add-hook 'flycheck-mode-hook #'flycheck-posframe-mode))

Unfortunately, the following message is depicted:
"Package ‘emacs-26’ is unavailable"

I checked M-x package-list-packages and the package is marked as incompat, see bellow:
image

System Information:

  • GNU Emacs 25.3.1 (x86_64-w64-mingw32) of 2018-03-05
  • OS: Windows 10

Feature request: Custom appearance of the posframe

It would be nice to have the following things customizable:

  1. The appearance of the posframe, e.g. border.

  2. The position of the posframe, some thing like lsp-ui place the error message on the right side of the window is nice.

Feature request: padding/margin for frames

The border feature is awesome, but sadly looks very cramped for me:

image

Is it possible to set a padding and/or margin for each frame? I can't seem to find the option :(.

P.S. I have seen #11 but it doesn't seem to solve the spacing issue.

Thanks in advance!

Disable mode if `lsp-ui-mode` is active?

I was wondering if it might be a good idea for flycheck-posframe-mode to not enable itself when lsp-ui-mode is active in a buffer, because lsp-ui-mode shows the same info.

I enable flycheck-posframe-mode in prog-mode-hook, so it's available in all programming modes, but I prefer to disable it when using LSP. Disabling it in lsp-ui-mode-hook doesn't work because (I assume) that hook is called before prog-mode-hook.

I defined my own function jk-maybe-flycheck-posframe-mode which enables flycheck-posframe-mode unless lsp-ui-mode is active, but perhaps that's something flycheck-posframe-mode should do itself?

Posframe does not show up when using flycheck-next-error

When using flycheck-next-error (bound to M-n), flycheck-posframe doesn't show up, I have to move the cursor somewhere else then back on the error/warning area (without using flycheck-next-error or M-n) to get posframe to show up.

Here is a small config to reproduce it:

;;; init --- Emacs configuration -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:

;; flycheck
(eval-when-compile (defvar flycheck-mode-map))
(autoload 'flycheck-next-error     "flycheck")
(autoload 'flycheck-previous-error "flycheck")
(add-hook 'flycheck-mode-hook
 (lambda ()
  (define-key flycheck-mode-map (kbd "M-n") #'flycheck-next-error)
  (define-key flycheck-mode-map (kbd "M-p") #'flycheck-previous-error)))

(add-hook 'prog-mode-hook #'flycheck-mode)

;; flycheck-posframe
(add-hook 'flycheck-mode-hook #'flycheck-posframe-mode)

(provide 'init)
;;; init ends here

requires Emacs 26

Is there any specific reason this needs Emacs 26?
Don't want to compile my own so stuck with 25.3 T_T

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.