forked from FG42/FG42
155 lines
6.0 KiB
EmacsLisp
155 lines
6.0 KiB
EmacsLisp
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
|
;;
|
|
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
|
;;
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
|
;; URL: https://devheroes.codes/FG42/FG42
|
|
;; Version: 4.0.0
|
|
;;
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
;;
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
;;
|
|
;;; Commentary:
|
|
;;; Code:
|
|
(eval-when-compile
|
|
(require 'fpkg)
|
|
(require 'fg42/config))
|
|
|
|
(config-when "completion-backend" "company"
|
|
(use! company
|
|
"Company is a modular text completion framework for GNU Emacs."
|
|
:hook (emacs-startup . global-company-mode)
|
|
:bind (:map company-active-map
|
|
("M-n" . company-select-next)
|
|
("M-p" . company-select-previous)
|
|
("TAB" . company-complete-common-or-cycle)
|
|
("M-d" . company-show-doc-buffer))
|
|
|
|
:init
|
|
;; Use Company for completion
|
|
(setq company-show-numbers t)
|
|
(setq company-idle-delay 0)
|
|
(setq company-tooltip-limit 20)
|
|
(setq company-echo-delay 0)
|
|
(setq company-tooltip-align-annotations t)
|
|
(setq company-dabbrev-downcase nil)
|
|
|
|
:config
|
|
(setq-default company-backends
|
|
'(company-capf (company-keywords :separate) company-files))
|
|
(bind-key [remap completion-at-point] #'company-complete company-mode-map))
|
|
|
|
|
|
(use! company-box
|
|
"A company front-end with icons."
|
|
:after company
|
|
:hook (company-mode . company-box-mode)))
|
|
|
|
|
|
(config-when "completion-backend" "corfu"
|
|
(use! corfu
|
|
"Corfu enhances in-buffer completion with a small completion popup.
|
|
The current candidates are shown in a popup below or above the point. The candidates
|
|
can be selected by moving up and down. Corfu is the minimalistic in-buffer completion
|
|
counterpart of the Vertico minibuffer UI."
|
|
:custom
|
|
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
|
|
(corfu-auto t) ;; Enable auto completion
|
|
(corfu-separator ?*) ;; Orderless field separator
|
|
(corfu-quit-no-match 'separator)
|
|
(corfu-quit-at-boundary 'separator)
|
|
(corfu-quit-no-match t)
|
|
(corfu-preview-current 'insert) ;; Disable current candidate preview
|
|
(corfu-preselect 'first) ;; Preselect the prompt
|
|
(corfu-on-exact-match 'insert) ;; Configure handling of exact matches
|
|
(corfu-scroll-margin 5) ;; Use scroll margin
|
|
(corfu-left-margin-width 2.0)
|
|
(corfu-right-margin-width 2.0)
|
|
|
|
:bind
|
|
(:map corfu-map ("<escape>" . corfu-quit))
|
|
(:map corfu-map ("M-SPC" . corfu-insert-separator))
|
|
:hook
|
|
(emacs-startup . global-corfu-mode)
|
|
(corfu-mode . (lambda ()
|
|
(require 'corfu-popupinfo)
|
|
(require 'corfu-indexed)
|
|
|
|
(corfu-popupinfo-mode)
|
|
(corfu-indexed-mode)
|
|
(dotimes (i 10)
|
|
(define-key corfu-mode-map
|
|
(kbd (format "M-%s" i))
|
|
(kbd (format "C-%s <tab>" i)))))))
|
|
|
|
(use! cape
|
|
"Cape provides Completion At Point Extensions which can be used
|
|
in combination with Corfu, Company or the default completion UI."
|
|
:bind (("C-c p p" . completion-at-point) ;; capf
|
|
("C-c p t" . complete-tag) ;; etags
|
|
("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
|
|
("C-c p h" . cape-history)
|
|
("C-c p f" . cape-file)
|
|
("C-c p k" . cape-keyword)
|
|
("C-c p s" . cape-elisp-symbol)
|
|
("C-c p e" . cape-elisp-block)
|
|
("C-c p a" . cape-abbrev)
|
|
("C-c p l" . cape-line)
|
|
("C-c p w" . cape-dict)
|
|
("C-c p :" . cape-emoji)
|
|
("C-c p \\" . cape-tex)
|
|
("C-c p _" . cape-tex)
|
|
("C-c p ^" . cape-tex)
|
|
("C-c p &" . cape-sgml)
|
|
("C-c p r" . cape-rfc1345))
|
|
:init
|
|
;; Add to the global default value of `completion-at-point-functions' which is
|
|
;; used by `completion-at-point'. The order of the functions matters, the
|
|
;; first function returning a result wins. Note that the list of buffer-local
|
|
;; completion functions takes precedence over the global list.
|
|
;;(add-to-list 'completion-at-point-functions #'cape-history)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-keyword)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-tex)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-sgml)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-dict)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
|
|
;;(add-to-list 'completion-at-point-functions #'cape-line)
|
|
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
|
|
(add-to-list 'completion-at-point-functions #'cape-file)
|
|
(add-to-list 'completion-at-point-functions #'cape-elisp-block))
|
|
|
|
(with-config "graphics"
|
|
(use! nerd-icons-corfu
|
|
"Nerd icon integration with corfu."
|
|
:after corfu
|
|
:config
|
|
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))))
|
|
|
|
|
|
;;;###autoload
|
|
(defun fg42/setup-completion ()
|
|
"Initialize FG42's completion system.
|
|
This function is meant to be used with hooks."
|
|
;; Why? because if we end up with more auto completion alternatives
|
|
;; to corfu or company mode, then we can setup them here rather than walking
|
|
;; around fixing downstream modules.
|
|
(interactive)
|
|
(config-when "completion-backend" "company"
|
|
(company-mode t)))
|
|
|
|
|
|
(provide 'fg42/completion)
|
|
;;; completion.el ends here
|