Working corfu setup without company

This commit is contained in:
Maciej 2025-01-07 14:25:33 +02:00
parent b9559eabe0
commit a0500746f4
Signed by: maciej
GPG key ID: 41D62D42D3B0D765
11 changed files with 255 additions and 314 deletions

File diff suppressed because it is too large Load diff

View file

@ -8,8 +8,8 @@
;; These packages are foundational dependency and possibly can be blocking.
;;; Code:
;; Nice menus
(use-package transient :ensure t)
(use-package company :ensure t)
;; Finally, wait for installation of these four packages.
(if (fboundp 'elpaca-wait)

View file

@ -1,97 +0,0 @@
;;; icejam-company-yasnippet.el -- summary -*- lexical-binding: t; -*-
;;; Commentary:
;;; Company completion framework configuration
;;; Code:
(require 'icejam-blocking)
(use-package yasnippet :ensure t :defer t
:hook ((elpaca-after-init . yas-global-mode))
:config
(unbind-key "C-c & C-n" yas-minor-mode-map)
(unbind-key "C-c & C-s" yas-minor-mode-map)
(unbind-key "C-c & C-v" yas-minor-mode-map))
(use-package yasnippet-snippets :ensure t :after (yasnippet))
(use-package kind-icon
:ensure t
:after company
:config
(let* ((kind-func (lambda (candidate) (company-call-backend 'kind candidate)))
(formatter (kind-icon-margin-formatter `((company-kind . ,kind-func)))))
(defun icejam-company-kind-icon-margin (candidate _selected)
(funcall formatter candidate))
(setopt company-format-margin-function #'icejam-company-kind-icon-margin)))
(with-eval-after-load 'company
(global-company-mode t)
;; Hacks for orderless
(defun just-one-face (fn &rest args)
(let ((orderless-match-faces [completions-common-part]))
(apply fn args)))
(advice-add 'company-capf--candidates :around #'just-one-face)
(defun company-completion-styles (capf-fn &rest args)
(let ((completion-styles '(partial-completion basic)))
(apply capf-fn args)))
(advice-add 'company-capf :around #'company-completion-styles)
(setq-default
company-minimum-prefix-length 3 ;; minimum prefix character number for auto complete.
company-idle-delay 0.1
company-require-match nil
company-echo-delay 0 ;;;; company-show-numbers t
company-tooltip-align-annotations t ;; align annotations to the right tooltip border.
company-tooltip-flip-when-above t
company-tooltip-limit 10 ;; tooltip candidates max limit.
company-tooltip-minimum 2 ;; minimum candidates limit.
company-tooltip-minimum-width 10 ;; The minimum width of the tooltip's inner area.
;; This doesn't include the margins and the scroll bar.
company-tooltip-margin 2 ;; width of margin columns to show around the tooltip
company-tooltip-offset-display 'lines ;; 'lines - how to show tooltip unshown candidates number.
company-show-numbers nil ;; t: show quick-access numbers for the first ten candidates.
company-selection-wrap-around t ;; loop over candidates
company-dabbrev-other-buffers t ;; Only offer dabbrev from the same major mode
company-dabbrev-downcase nil ;; Preserve case of candidates
company-format-margin-function nil
;; company-async-wait 0.03
;; company-async-timeout 2
)
;; Absolute defaults for company mode
(setopt company-backends
'((company-files ; files & directory
company-keywords ; keywords
company-capf)
(company-dabbrev company-abbrev)
))
;; Use standard emacs next and previous bindings for navigating company
;; suggestions
(define-key company-active-map (kbd "C-p") 'company-select-previous-or-abort)
(define-key company-active-map (kbd "C-n") 'company-select-next-or-abort)
(defun icejam-insert-space-and-complete ()
"Insert space before trying to complete a section."
(interactive)
(save-excursion
(insert " "))
(company-indent-or-complete-common))
;; Only use RETURN for completion in company
(unbind-key "TAB" company-active-map)
;; Yasnippet configuration
(define-key prog-mode-map (kbd "C-c y") 'company-yasnippet)
(define-key prog-mode-map (kbd "<f13>") 'icejam-insert-space-and-complete)
(define-key prog-mode-map (kbd "TAB") 'company-indent-or-complete-common)
(define-key text-mode-map (kbd "C-c y") 'company-yasnippet)
(define-key text-mode-map (kbd "<f13>") 'icejam-insert-space-and-complete)
(define-key text-mode-map (kbd "TAB") 'company-indent-or-complete-common))
(provide 'icejam-company-yasnippet)
;;; icejam-company-yasnippet.el ends here

View file

@ -0,0 +1,55 @@
;;; icejam-complete-at-point.el -- summary -*- lexical-binding: t; -*-
;;; Commentary:
;;; Company completion framework configuration
;;; Code:
(require 'icejam-blocking)
(use-package yasnippet :ensure t :defer t
:hook ((elpaca-after-init . yas-global-mode))
:config
(unbind-key "C-c & C-n" yas-minor-mode-map)
(unbind-key "C-c & C-s" yas-minor-mode-map)
(unbind-key "C-c & C-v" yas-minor-mode-map))
(use-package yasnippet-snippets :ensure t :after (yasnippet))
(use-package corfu :ensure t :defer t
:hook ((elpaca-after-init . global-corfu-mode)
(global-corfu-mode . corfu-popupinfo-mode))
:config
(setopt corfu-auto-delay 0.2)
(setopt corfu-popupinfo-delay '(0.4 . 0.2))
(setopt corfu-auto t)
(setopt corfu-quit-no-match 'separator))
(use-package corfu-terminal :ensure t :defer t
:unless (display-graphic-p)
:hook ((elpaca-after-init . corfu-terminal-mode)))
(use-package cape :ensure t :after corfu
:commands (cape-dabbrev cape-file cape-elisp-symbol)
:init
(add-hook 'prog-mode-hook
(lambda ()
(progn
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
(add-hook 'completion-at-point-functions #'cape-elisp-symbol)))))
(use-package yasnippet-capf :ensure t
:after corfu
:commands (yasnippet-capf)
:config (setopt yasnippet-capf-lookup-by 'name)
:init
(add-hook 'prog-mode-hook
(lambda () (add-hook 'completion-at-point-functions #'yasnippet-capf))))
(use-package kind-icon
:ensure t
:after corfu
:config
(declare-function kind-icon-margin-formatter kind-icon)
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
(provide 'icejam-complete-at-point)
;;; icejam-complete-at-point.el ends here

View file

@ -94,7 +94,7 @@
(require 'icejam-avy)
(require 'icejam-transient)
(require 'icejam-prog-mode)
(require 'icejam-company-yasnippet)
(require 'icejam-complete-at-point)
(require 'icejam-copilot)
(require 'icejam-flycheck)
(require 'icejam-ispell)

View file

@ -71,8 +71,7 @@ in `icejam-set-font-to-screen`.")
"Set font to FAMILY and its HEIGHT to X.
Not all faces will be set to this value. Some of them look better with being
slightly smaller than the default face, by 1 point. Those are: `tooltip',
`company-tooltip', `company-tooltip-annotation', `company-tooltip-mouse'.
slightly smaller than the default face, by 1 point. Those are: `tooltip'.
Modeline faces (`mode-line' and `mode-line-inactive') look better if they are
two points smaller."
@ -87,10 +86,7 @@ two points smaller."
(* 10)))
;; Some font faces look better when they are 1 point smaller.
(dolist (face '(tooltip
company-tooltip
company-tooltip-annotation
company-tooltip-mouse))
(dolist (face '(tooltip))
(set-face-attribute face nil :height (-> height
(- 1)
(* 10))))

View file

@ -44,8 +44,6 @@
("r" "Replace" vr/replace)
("i" "Indent" indent-region)]
["Complete"
("y" "Snippet" company-yasnippet)
("m" "Any (Company)" company-complete)
("g" "Ask GPT" gptel-menu)
("a" "Aider" aider-transient-menu)
("e" "Refactor (Elysium)" elysium-query)]

View file

@ -19,10 +19,7 @@
(if (boundp 'c-default-style)
(setq-local c-default-style "bsd")
(defvar c-default-style "bsd"))
(add-to-list (make-local-variable 'company-backends)
'(company-etags company-yasnippet)))
(defvar c-default-style "bsd")))
(add-hook 'c-mode-hook 'icejam-lang-activate-clang-mode)

View file

@ -9,7 +9,7 @@
;;; Code:
(require 'icejam-prog-mode)
(require 'icejam-company-yasnippet)
(require 'icejam-complete-at-point)
(use-package slime :ensure t)
(use-package slime-company :ensure t

View file

@ -2,16 +2,20 @@
;;; Commentary:
;;; Code:
(require 'icejam-blocking)
(require 'icejam-prog-mode)
(require 'icejam-transient)
;; Dash is a package that creates terse and more natural to me functions to
;; do basic things in Elisp.
(use-package dash :ensure t :defer t)
(use-package lispy :ensure t :defer t)
(use-package aggressive-indent :ensure t :defer t)
;; ;; Dash is a package that creates terse and more natural to me functions to
;; ;; do basic things in Elisp.
(declare-function elpaca-installed-p "elpaca")
(unless (elpaca-installed-p 'dash)
(use-package dash :ensure t :defer t))
;; ;; Adds pseudomodal editing for lisp.
(unless (elpaca-installed-p 'lispy)
(use-package lispy :ensure t :defer t))
(declare-function aggressive-indent-mode "aggressive-indent")
(declare-function column-enforce-n "column-enforce-mode" (number))
(add-to-list 'auto-mode-alist '("/Eask\\'" . emacs-lisp-mode))
@ -35,13 +39,14 @@
(icejam-set-indent 2) ;; Default indentation of 2 characters
(column-enforce-n 80)
(dash-fontify-mode t) ;; Fontify dash variables
(lispy-mode t) ;; Pseudomodal editing for lisp code
(aggressive-indent-mode) ;; Indent lisp automatically
(dash-fontify-mode t)
(lispy-mode t)
;; Company list override
(add-to-list (make-local-variable 'company-backends)
'(company-yasnippet company-capf)))
(setq-local completion-at-point-functions '(yasnippet-capf
elisp-completion-at-point
cape-dabbrev
cape-file
cape-elisp-symbol)))
(add-hook 'emacs-lisp-mode-hook 'icejam-activate-emacs-lisp-mode)

View file

@ -22,11 +22,7 @@
(column-enforce-n 99)
;; Run LSP
(lsp-deferred)
;; Company list override
(add-to-list (make-local-variable 'company-backends)
'(company-capf company-yasnippet)))
(lsp-deferred))
(add-hook 'rust-mode-hook 'icejam-activate-rust-mode)
(add-hook 'rust-mode-hook 'flycheck-rust-setup)