I can get autocompletion with corfu to work with txt files, but not when I enable lsp. Here is a MWE which I use as init.el.

(setq straight-build-dir (format "build/%d%s%d"
      straight-use-package-by-default t)

(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
         'silent 'inhibit-cookies)
      (goto-char (point-max))
  (load bootstrap-file nil 'nomessage))

(setq use-package-hook-name-suffix nil)
(straight-use-package 'use-package)

(use-package vertico
  :hook (after-init-hook . vertico-mode)
  (:map vertico-map
   ("C-M-j" . vertico-exit-input)
   ("<tab>" . vertico-insert)))

(use-package corfu
  :hook (after-init-hook . global-corfu-mode)
  (corfu-auto t "Enable auto completion")
  (corfu-auto-prefix 3)
  (:map corfu-map
        ("[tab]" . corfu-next)
        ("C-n" . corfu-next)
        ("[backtab]" . corfu-previous)
        ("C-p" . corfu-previous)
        ("<escape>" . corfu-quit)))

(use-package cape
  :after corfu
  :demand t
  :commands (cape-history ; Complete from Eshell, Comint or minibuffer history
             cape-keyword ; Complete programming language keyword
             cape-tex ; Complete unicode char from TeX command, e.g. \hbar.
             cape-abbrev ; Complete abbreviation at point
             cape-dict ; Complete word from dictionary at point
             cape-line ; Complete current line from other lines in buffer
             cape-symbol ; Elisp symbol
             cape-ispell ; Complete word at point with Ispell
             ;; Complete with Dabbrev at point
  (cape-dabbrev-min-length 3)
  (add-hook 'text-mode-hook
            (lambda ()
              (setq-local completion-at-point-functions
                          (list (cape-super-capf #'cape-dabbrev #'cape-file #'cape-history #'cape-ispell #'cape-dict))))))

(use-package lsp-mode
  (lsp-completion-provider :none)
  (lsp-lens-enable nil)
  (lsp-log-io nil))

(use-package lsp-ltex
  (text-mode-hook . (lambda ()
                      (require 'lsp-ltex)
  (setq lsp-ltex-check-frequency "save"
        lsp-ltex-java-path "/usr/lib/jvm/java-11-openjdk-amd64"
        lsp-ltex-version "15.2.0"))

The value of completion-at-point-functions is

Its value is (lsp-completion-at-point)
Local in buffer testing.txt; global value is 

I tried the following with text-mode-hook, but it did not resolve the problem.

(setq-local completion-at-point-functions
                           (list (cape-capf-properties #'lsp-completion-at-point :exclusive 'no)))

I raised an issue but the proposed Wiki entries do not help. As a result, I am having to fall back to company for .txt files with ltex. Corfu popups work great with programming modes and lsp.

1 Answer 1


I have solved this problem partially with the following snippet to disable lsp-mode integration with capf.

(add-hook 'text-mode-hook (lambda ()
                        (setq-local lsp-completion-enable nil)))

Corfu and cape autocompletion now work with text-mode and lsp-ltex. However, this disables capf completions using a language server like Texlab.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.