Skip to content

Commit

Permalink
Switch from company to corfu for completion
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Jul 22, 2022
1 parent b484cad commit 5ed2eee
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 71 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ in the approximate order of how much I use them, from most to least:
* Erlang

In particular, there's a nice config for *autocompletion* with
[company](https://company-mode.github.io/), and
[corfu](https://github.com/minad/corfu), and
`flymake` (re-using backends from [flycheck](http://www.flycheck.org))
is used to immediately highlight syntax errors in Ruby, Python,
Javascript, Haskell and a number of other languages.
Expand Down
2 changes: 1 addition & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
(require 'init-recentf)
(require 'init-minibuffer)
(require 'init-hippie-expand)
(require 'init-company)
(require 'init-corfu)
(require 'init-windows)
(require 'init-sessions)
(require 'init-mmm)
Expand Down
31 changes: 0 additions & 31 deletions lisp/init-company.el

This file was deleted.

31 changes: 31 additions & 0 deletions lisp/init-corfu.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;;; init-corfu.el --- Interactive completion in buffers -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

;; WAITING: haskell-mode sets tags-table-list globally, breaks tags-completion-at-point-function
;; TODO Default sort order should place [a-z] before punctuation

(setq tab-always-indent 'complete)
(require-package 'orderless)
(with-eval-after-load 'vertico
(require 'orderless))
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides nil)
(setq completion-cycle-threshold 4)

(when (maybe-require-package 'corfu)
(setq-default corfu-auto t)
(setq-default corfu-quit-no-match 'separator)
(add-hook 'after-init-hook 'global-corfu-mode)

(when (maybe-require-package 'corfu-doc)
(with-eval-after-load 'corfu
(add-hook 'corfu-mode-hook #'corfu-doc-mode)))

;; TODO: https://github.com/jdtsmith/kind-icon
)


(provide 'init-corfu)
;;; init-corfu.el ends here
14 changes: 2 additions & 12 deletions lisp/init-nix.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@
(maybe-require-package 'nix-buffer)

(when (maybe-require-package 'nixos-options)
(when (maybe-require-package 'company-nixos-options)
(with-eval-after-load 'company
(with-eval-after-load 'nix-mode
;; Patch pending https://github.com/travisbhartwell/nix-emacs/pull/46
(with-eval-after-load 'company-nixos-options
(defun company-nixos--in-nix-context-p ()
(unless (executable-find "nix-build")
(or (derived-mode-p 'nix-mode 'nix-repl-mode)
(let ((file-name (buffer-file-name (current-buffer))))
(and file-name (equal "nix" (file-name-extension file-name))))))))

(add-to-list 'company-backends 'company-nixos-options))))))
;; TODO: write a CAPF backend based on company-nixos-options
))


(provide 'init-nix)
Expand Down
6 changes: 1 addition & 5 deletions lisp/init-php.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
;;; Code:

(when (maybe-require-package 'php-mode)
(maybe-require-package 'smarty-mode)

(when (maybe-require-package 'company-php)
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-ac-php-backend))))
(maybe-require-package 'smarty-mode))

(provide 'init-php)
;;; init-php.el ends here
5 changes: 1 addition & 4 deletions lisp/init-ruby.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@
;;; Robe
(when (maybe-require-package 'robe)
(with-eval-after-load 'ruby-mode
(add-hook 'ruby-mode-hook 'robe-mode))
(with-eval-after-load 'robe
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-robe))))
(add-hook 'ruby-mode-hook 'robe-mode)))



Expand Down
8 changes: 0 additions & 8 deletions lisp/init-slime.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@
(require-package 'slime)
(push (expand-file-name "contrib" (file-name-directory (locate-library "slime"))) load-path)

(when (maybe-require-package 'slime-company)
(setq slime-company-completion 'fuzzy
slime-company-after-completion 'slime-company-just-one-space)
(with-eval-after-load 'slime-company
(add-to-list 'company-backends 'company-slime)))


;;; Lisp buffers

(with-eval-after-load 'slime
(setq slime-protocol-version 'ignore)
(setq slime-net-coding-system 'utf-8-unix)
(let ((features '(slime-fancy slime-repl slime-fuzzy)))
(when (require 'slime-company nil t)
(push 'slime-company features))
(slime-setup features)) )


Expand Down
16 changes: 7 additions & 9 deletions lisp/init-terraform.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
;;; Terraform

(when (maybe-require-package 'terraform-mode)
(when (maybe-require-package 'company-terraform)
(with-eval-after-load 'terraform-mode
(company-terraform-init)

;; I find formatters based on "reformatter" to be more reliable
;; so I redefine `terraform-format-on-save-mode' here.
(when (maybe-require-package 'reformatter)
(reformatter-define terraform-format
:program "terraform" :args '("fmt" "-"))))))
;; TODO: find/write a replacement for company-terraform
(with-eval-after-load 'terraform-mode
;; I find formatters based on "reformatter" to be more reliable
;; so I redefine `terraform-format-on-save-mode' here.
(when (maybe-require-package 'reformatter)
(reformatter-define terraform-format
:program "terraform" :args '("fmt" "-")))))

(provide 'init-terraform)
;;; init-terraform.el ends here
Expand Down

0 comments on commit 5ed2eee

Please sign in to comment.