From 9c0a9df549d118148cefb4a640f386586972c760 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Mon, 15 Jul 2024 17:50:25 -0700 Subject: [PATCH] Change to company --- disabled.el | 38 +++++++++++++++++++++++++++++ init.el | 69 +++++++++++++++++++++++++---------------------------- 2 files changed, 71 insertions(+), 36 deletions(-) diff --git a/disabled.el b/disabled.el index 39b265f..11aa953 100644 --- a/disabled.el +++ b/disabled.el @@ -140,3 +140,41 @@ ;; (setq inferior-lisp-program "/usr/bin/sbcl") ;; :config ;; (sly-symbol-completion-mode -1)) + +;; corfu (autocomplete) +;; (use-package corfu +;; :bind (("M-" . completion-at-point) +;; :map corfu-map +;; ("M-SPC" . corfu-insert-separator) +;; ("M-m" . my/corfu-move-to-minibuffer)) +;; :init +;; (defun my/corfu-move-to-minibuffer () +;; (interactive) +;; (when completion-in-region--data +;; (let ((completion-extra-properties corfu--extra) +;; completion-cycle-threshold completion-cycling) +;; (apply #'consult-completion-in-region completion-in-region--data)))) +;; (setq corfu-cycle t +;; corfu-auto t +;; corfu-on-exact-match nil +;; completion-cycle-threshold nil) +;; (global-corfu-mode 1) +;; (corfu-popupinfo-mode 1) +;; :config +;; (add-to-list 'corfu-continue-commands #'my/corfu-move-to-minibuffer)) +;; (use-package corfu-terminal +;; :init +;; (corfu-terminal-mode 1)) + +;; ;; cape (a bunch of capfs!) +;; (use-package cape +;; :bind (("C-c p" . cape-dabbrev) +;; ([remap dabbrev-expand] . cape-dabbrev) +;; ("C-c P" . cape-line) +;; ("C-c f" . cape-file)) +;; :hook (text-mode . my/-cape-setup-text-mode) +;; :init +;; (defun my/-cape-setup-text-mode () +;; (setq-local completion-at-point-functions +;; '(cape-dict cape-dabbrev) +;; corfu-auto nil))) diff --git a/init.el b/init.el index 0225c1d..4cb9970 100644 --- a/init.el +++ b/init.el @@ -427,43 +427,40 @@ visual states." (use-package embark-consult :hook (embark-collect-mode . consult-preview-at-point-mode)) -;; corfu (autocomplete) -(use-package corfu - :bind (("M-" . completion-at-point) - :map corfu-map - ("M-SPC" . corfu-insert-separator) - ("M-m" . my/corfu-move-to-minibuffer)) - :init - (defun my/corfu-move-to-minibuffer () - (interactive) - (when completion-in-region--data - (let ((completion-extra-properties corfu--extra) - completion-cycle-threshold completion-cycling) - (apply #'consult-completion-in-region completion-in-region--data)))) - (setq corfu-cycle t - corfu-auto t - corfu-on-exact-match nil - completion-cycle-threshold nil) - (global-corfu-mode 1) - (corfu-popupinfo-mode 1) +;; company (in buffer auto-complete) +(use-package company + :defer nil + :bind (("M-TAB" . company-complete) + ("M-" . company-complete) + ("C-c f" . company-files) + ([remap dabbrev-expand] . company-dabbrev) + :map prog-mode-map + ([remap company-dabbrev] . company-dabbrev-code)) + :hook ((company-search-mode . my/-company-search-mode-add-lighter) + (sh-mode . my/-company-setup-shell-mode)) :config - (add-to-list 'corfu-continue-commands #'my/corfu-move-to-minibuffer)) -(use-package corfu-terminal - :init - (corfu-terminal-mode 1)) - -;; cape (a bunch of capfs!) -(use-package cape - :bind (("C-c p" . cape-dabbrev) - ([remap dabbrev-expand] . cape-dabbrev) - ("C-c P" . cape-line) - ("C-c f" . cape-file)) - :hook (text-mode . my/-cape-setup-text-mode) - :init - (defun my/-cape-setup-text-mode () - (setq-local completion-at-point-functions - '(cape-dict cape-dabbrev) - corfu-auto nil))) + (defun my/-company-setup-shell-mode () + (setq-local company-backends '(company-files company-keywords + company-dabbrev-code))) + (defun my/-company-search-mode-add-lighter () + (if company-search-mode + (cl-pushnew company-search-lighter global-mode-string :test 'equal) + (setq global-mode-string + (cl-delete company-search-lighter global-mode-string :test 'equal)))) + (defun my/-company-set-completion-styles (oldfun &rest args) + (let ((completion-styles '(basic emacs21 flex))) + (apply oldfun args))) + (advice-add 'company-capf :around 'my/-company-set-completion-styles) + (setopt company-format-margin-function #'company-text-icons-margin) + (setq company-transformers '(company-sort-by-occurrence)) + (global-company-mode 1)) +(use-package company-quickhelp + :bind (:map company-active-map + ("M-h" . company-quickhelp-manual-begin)) + :after company + :config + (company-quickhelp-mode 1) + (setopt company-quickhelp-delay nil)) ;; xref (use-package xref