From 87f4197f234ef838843f0df175d0c5834e58b76e Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 17 Sep 2022 18:05:15 -0700 Subject: ref(completion): add more packages for completion Get LSP to work with cape and corfu for the completion. Change-Id: Id8f01b1dee77957ff5ba27ed471707b7b9c7dc93 --- emacs/custom/my-completion.el | 22 ++++++++++++++++------ emacs/custom/my-lsp.el | 9 +++++++++ emacs/custom/my-packages.el | 3 +++ emacs/custom/my-settings.el | 2 -- emacs/custom/my-text.el | 4 ---- 5 files changed, 28 insertions(+), 12 deletions(-) (limited to 'emacs/custom') diff --git a/emacs/custom/my-completion.el b/emacs/custom/my-completion.el index 818355b..ecc5adb 100644 --- a/emacs/custom/my-completion.el +++ b/emacs/custom/my-completion.el @@ -9,6 +9,11 @@ (require 'marginalia) (require 'corfu) (require 'consult) +(require 'savehist) +(require 'cape) +(require 'tempel) + +(savehist-mode t) (setq vertico-multiform-categories '((consult-grep buffer))) @@ -22,13 +27,18 @@ (setq completion-styles '(orderless basic)) (setq completion-category-defaults nil) -(setq corfu-cycle t) ;; Enable cycling for `corfu-next/previous' -(setq corfu-auto t) ;; Enable auto completion +(setq corfu-cycle t) ;; Enable cycling for `corfu-next/previous' +(setq corfu-auto t) ;; Enable auto completion +(setq corfu-max-width 80) ;; Default is 100 and is too wide + +(vertico-mode t) ;; Enable vertico globally +(vertico-multiform-mode t) ;; Enable vertico globally +(marginalia-mode t) ;; Enable marginalia globally +(global-corfu-mode) ;; Enable corfu globally -(vertico-mode) -(vertico-multiform-mode 1) -(marginalia-mode) -(global-corfu-mode) +(add-to-list 'completion-at-point-functions #'cape-file) +(add-to-list 'completion-at-point-functions #'cape-abbrev) +(add-to-list 'completion-at-point-functions #'cape-ispell) (global-set-key (kbd "C-c m") 'consult-mode-command) (global-set-key (kbd "C-x b") 'consult-buffer) diff --git a/emacs/custom/my-lsp.el b/emacs/custom/my-lsp.el index 0cb62bd..98c061a 100644 --- a/emacs/custom/my-lsp.el +++ b/emacs/custom/my-lsp.el @@ -22,6 +22,15 @@ (add-hook 'lsp-mode-hook #'lsp-ui-mode) +(require 'consult-lsp) +(define-key lsp-mode-map [remap xref-find-apropos] #'consult-lsp-symbols) + +(require 'lsp-completion) +(setq lsp-completion-provider :none) ;; I use corfu +(add-hook 'lsp-completion-mode-hook + (lambda () + (setf (alist-get 'lsp-capf completion-category-defaults) '((styles . (orderless flex)))))) + (provide 'my-lsp) ;;; my-lsp.el ends here diff --git a/emacs/custom/my-packages.el b/emacs/custom/my-packages.el index 67bb510..569fb40 100644 --- a/emacs/custom/my-packages.el +++ b/emacs/custom/my-packages.el @@ -60,10 +60,13 @@ (straight-use-package 'tree-sitter-langs) ;; packages for navigation +(straight-use-package 'cape) (straight-use-package 'consult) +(straight-use-package 'consult-lsp) (straight-use-package 'corfu) (straight-use-package 'marginalia) (straight-use-package 'orderless) +(straight-use-package 'tempel) (straight-use-package 'vertico) (straight-use-package 'which-key) diff --git a/emacs/custom/my-settings.el b/emacs/custom/my-settings.el index e6c1ce9..39140a3 100644 --- a/emacs/custom/my-settings.el +++ b/emacs/custom/my-settings.el @@ -45,8 +45,6 @@ (customize-set-variable 'history-length 1000) (customize-set-variable 'history-delete-duplicates t) -(customize-set-variable 'savehist-save-minibuffer-history t) -(add-hook 'after-init-hook #'savehist-mode) (add-hook 'after-init-hook 'midnight-mode) diff --git a/emacs/custom/my-text.el b/emacs/custom/my-text.el index 0c99ba6..99961d8 100644 --- a/emacs/custom/my-text.el +++ b/emacs/custom/my-text.el @@ -20,10 +20,6 @@ (when (executable-find "pandoc") (customize-set-variable 'markdown-command "pandoc -f markdown -t html")) -;; https://www.masteringemacs.org/article/text-expansion-hippie-expand -;; replace default keybinding for `dabbrev' with `hippie-expand' -(global-set-key (kbd "M-/") 'hippie-expand) - (setq only-global-abbrevs nil) (eval-after-load 'abbrev (let ((table text-mode-abbrev-table)) -- cgit 1.4.1