Show informations on the side
This library provides the frontend UI to display information either on the left/right side of the buffer window.
P.S. The implementation is extracted and modified from lsp-ui-sideline
Table of Contents
Instead of hard-coded information, we extracted it to multiple different backends. It allows us to customize the displayed information we want, which is more flexible and configurable.
(use-package sideline
:init
(setq sideline-backends-skip-current-line t ; don't display on current line
sideline-order-left 'down ; or 'up
sideline-order-right 'up ; or 'down
sideline-format-left "%s " ; format for left aligment
sideline-format-right " %s" ; format for right aligment
sideline-priority 100 ; overlays' priority
sideline-display-backend-name t)) ; display the backend name
The most basic way to set up the backends for sideline.
(use-package sideline
:init
(setq sideline-backends-left '(sideline-flycheck)
sideline-backends-right '(sideline-lsp)))
Alternatively, you could set it to cons cell with the search order.
(use-package sideline
:init
(setq sideline-backends-right '((sideline-lsp . up)
(sideline-flycheck . down))))
Following is an example code to define your own sideline backend:
(defun my-backend (command)
"Example backend."
(cl-case command
(`candidates '("info 1" "info 2" "info 3")) ; required
(`action (lambda (candidate &rest _) ; optional
(message "Execute command for `%s`!" candidate)))))
or define it asynchronously:
(defun my-backend-async (command)
"Example async backend."
(cl-case command
(`candidates (cons :async (lambda (callback &rest _)
(funcall callback '("info 1" "info 2" "info 3")))))
(`action ...)))
then you can tell your user to...
(setq sideline-backends-left '(my-backend)) ; use `sideline-backends-right' for right alignment
Here is a list of supported commands:
candidates
- list of strings to display; accept async functionaction
- (optional) callback function after the mouse clickface
- (optional) face overrides the default sideline facename
- (optional) backend name to display
If you would like to contribute to this project, you may either clone and make pull requests to this repository. Or you can clone the project and establish your own branch of this tool. Any methods are welcome!