diff --git a/README.md b/README.md
index 6e8052bf..fadaf938 100644
--- a/README.md
+++ b/README.md
@@ -181,10 +181,17 @@ Keybinding | Description
Auto-complete/Company:
-Keybinding | Description
--------------------|-----------------------------------------------------------
-C-. | Force trigger auto-complete/company-complete.
-ESC | Abort auto-complete/company-complete.
+Keybinding | Description
+------------------------------------|------------------------------------------------------------------------------------------
+C-. | Force trigger auto-complete/company-complete.
+ESC | Abort auto-complete/company-complete.
+C-o or C-\\ | Company only: switch to other backend (`company-other-backend`)
+C-M-h | Company only: show doc buffer for current candidate (`company-show-doc-buffer`)
+C-M-v | Company only: scroll doc buffer up (`scroll-other-window`)
+C-M-S-v | Company only: scroll doc buffer down (`scroll-other-window-down`)
+C-h or | Company only: show quick help for current candidate (`company-posframe-quickhelp-toggle`)
+C-S-v or | Company only: scroll quick help up (`company-posframe-quickhelp-scroll-up`)
+M-V or | Company only: scroll quick help down (`company-posframe-quickhelp-scroll-down`)
Tip: if you are looking for a particular key and you know it starts with a
given prefix, type the prefix followed by C-h: Emacs will display
diff --git a/modules/init-company.el b/modules/init-company.el
index 843c4e36..8cb5438f 100644
--- a/modules/init-company.el
+++ b/modules/init-company.el
@@ -2,6 +2,17 @@
;;; Commentary:
;;
+;; ----------------- -------------------------------------------------------
+;; Key Definition
+;; ----------------- -------------------------------------------------------
+;; C-. Force trigger company-complete.
+;; C-o or C-\ Switch to other backend (`company-other-backend').
+;; C-M-h Show doc buffer for current candidate (`company-show-doc-buffer').
+;; C-M-v Scroll doc buffer up (`scroll-other-window').
+;; C-M-S-v Scroll doc buffer down ('scroll-other-window-down').
+;; C-h or Show quick help for current candidate (`company-posframe-quickhelp-toggle').
+;; C-S-v or Scroll quick help up (`company-posframe-quickhelp-scroll-up').
+;; M-V or Scroll quick help down (`company-posframe-quickhelp-scroll-down').
;;; Code:
(eval-when-compile
@@ -11,15 +22,12 @@
(exordium-require 'init-git)
(require 'cl-lib)
-
-(when (version< "29" emacs-version)
- (exordium-require 'init-forge))
+(require 'compat)
(use-package company
:diminish "CA"
:demand t
- :commands (company-other-backend
- company-abort)
+ :commands (company-other-backend)
:custom
(company-idle-delay nil)
(company-files-exclusions '(".git/" ".gitignore" ".gitmodules" ".DS_Store"
@@ -37,7 +45,9 @@
:bind
(("C-." . #'company-complete)
- ("C-c C-\\" . #'company-other-backend)))
+ :map company-active-map
+ ("C-\\" . #'company-other-backend)
+ ("C-o" . #'company-other-backend)))
(use-package company
:diminish "CA"
@@ -46,61 +56,9 @@
:commands (company-begin-backend)
:functions (exordium--company-conventional-commits-type-p)
:init
- (use-package forge-core
- :ensure forge
- :defer t
- :autoload (forge-get-repository))
-
(use-package git-commit
:ensure magit)
- (defun exordium-company-assignees (command &optional arg &rest _ignored)
- "A `company-mode' backend for assigneees in `forge-mode' repository."
- (interactive (list 'interactive))
- (cl-case command
- (interactive (company-begin-backend 'exordium-company-assignees))
- (prefix
- (save-match-data
- (when (and (or (bound-and-true-p git-commit-mode)
- (derived-mode-p 'forge-post-mode
- 'git-commit-elisp-text-mode))
- (forge-get-repository 'full)
- (looking-back
- (rx "@"
- (zero-or-one
- (group alphanumeric
- (repeat 0 38
- (or alphanumeric
- (seq (any "-/") alphanumeric))))))
- (max (- (point) 40)
- (line-beginning-position))))
- ;; IDK how to match end of a 'symbol' that is equal to an "@" or is
- ;; equal to "@foo" in neither `git-commit-mode' nor
- ;; `forge-post-mode'. Hence it's handled manually. The
- ;; `looking-back' above matches an "@" or an "@foo". When it was the
- ;; latter there was a match in group 1. Now, check if this is at
- ;; the very end of the "@" or "@foo". Note that "@@" also
- ;; matches. Probably a few other characters, substituting the second
- ;; "@" in latter pattern, would also give a positive result. Yet, in
- ;; such a case the `match' is "", so that's all fine - all
- ;; candidates will be shown.
- (when (or (save-match-data (looking-at "\\W"))
- (= (point) (point-max)))
- (cons (or (match-string 1) "") t)))))
- (candidates (when-let* ((repo (forge-get-repository :tracked?))
- ((slot-exists-p repo 'assignees))
- ((slot-boundp repo 'assignees))
- (assignees (oref repo assignees)))
- (cl-remove-if-not
- (lambda (assignee)
- (string-prefix-p arg assignee))
- (mapcar (lambda (assignee)
- (propertize (cadr assignee)
- 'full-name (caddr assignee)))
- assignees))))
- (annotation (when-let* ((assignee (get-text-property 0 'full-name arg)))
- (format " [%s]" assignee)))))
-
(defconst exordium--company-conventional-commits-types
(list
;; From Conventional Commits: https://www.conventionalcommits.org
@@ -264,9 +222,18 @@ See https://www.conventionalcommits.org for details."
:config
;; This is block is deferred , so this backed will end up first
- (add-to-list 'company-backends 'exordium-company-assignees)
(add-to-list 'company-backends 'exordium-company-conventional-commits))
+(when (version< "29" emacs-version) ;; Since Emacs-29
+ (use-package company-forge
+ :config
+ (company-forge-icons-mode) ;; Display icons
+ (advice-add #'forge--pull ;; Reset cache after forge pull
+ :filter-args #'company-forge-reset-cache-after-pull)
+ (add-to-list 'company-backends 'company-forge)
+ (add-hook 'completion-at-point-functions
+ #'company-forge-completion-at-point-function)))
+
(use-package company-statistics
:after (company)
:config
@@ -274,6 +241,28 @@ See https://www.conventionalcommits.org for details."
(add-to-list 'company-transformers
'company-sort-by-backend-importance 'append))
+(use-package company-posframe
+ :demand t
+ :diminish
+ :init
+ (use-package company
+ :defer t
+ :commands (company-show-doc-buffer))
+ :commands (company-posframe-quickhelp-toggle
+ company-posframe-quickhelp-scroll-down
+ company-posframe-quickhelp-scroll-up)
+ :bind
+ (:map company-posframe-active-map
+ ("C-h" . #'company-posframe-quickhelp-toggle)
+ ("C-M-h" . #'company-show-doc-buffer)
+ ("C-S-v" . #'company-posframe-quickhelp-scroll-up)
+ ("M-V" . #'company-posframe-quickhelp-scroll-down))
+ :custom
+ (company-posframe-quickhelp-delay 0.2)
+ (company-posframe-quickhelp-x-offset 5)
+ :config
+ (company-posframe-mode 1))
+
(provide 'init-company)
;;; init-company.el ends here
diff --git a/modules/init-desktop.el b/modules/init-desktop.el
index 1e0d0f03..40663d1f 100644
--- a/modules/init-desktop.el
+++ b/modules/init-desktop.el
@@ -9,6 +9,8 @@
(require 'savehist)
(require 'desktop)
+(add-to-list 'desktop-minor-mode-table '(company-posframe-mode nil))
+
(defun exordium--restore-desktop ()
"Restore desktop."
(setq desktop-path (list user-emacs-directory))