minad / corfu

:desert_island: corfu.el - COmpletion in Region FUnction
GNU General Public License v3.0
1.15k stars 43 forks source link

How to avoid number completion in SQL mode ? #337

Closed zhangjie2012 closed 1 year ago

zhangjie2012 commented 1 year ago

like this:

image

btw: sql mode corfu very slow. My config:

(use-package cape
  :ensure t
  :init
  (add-to-list 'completion-at-point-functions #'cape-file)
  (add-to-list 'completion-at-point-functions #'cape-history)
  (add-to-list 'completion-at-point-functions #'cape-dabbrev))

(use-package corfu
  :ensure t
  :hook (prog-mode . corfu-mode)
  :bind (:map corfu-map
              ("M-SPC" . corfu-insert-separator)
              ("C-n" . corfu-next)
              ("C-p" . corfu-previous))
  :config
  (setq corfu-auto t
        corfu-auto-prefix 1
        corfu-auto-delay 0.1
        corfu-quit-no-match t
        corfu-quit-at-boundary t)
  (add-hook 'multiple-cursors-mode-enabled-hook (lambda () (corfu-mode -1)))
  (add-hook 'multiple-cursors-mode-disabled-hook (lambda () (corfu-mode 1))))
minad commented 1 year ago

You could set a :predicate function in cape--dabbrev-properties which filters out numeric candidates. Alternatively you could modify cape-dabbrev (or wrap it) to return nil if the matching word is undesired.

minad commented 1 year ago

I added support for dabbrev-abbrev-char-regexp, see https://github.com/minad/cape/commit/e503d9a6f86b05962fe4b638f49d8d0110891570. You can adjust this variable if you don't want to treat digits as word characters.