mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
This applies especially in lsp-mode. Yasnippet snippets now show as completion candidates if the word at point exactly matches a snippet keyword, otherwise it'll fallback to normal lsp backed completion. And it also supports completing file/directory names now too while lsp-mode is active. All this is done by modifying completion-at-point-functions after lsp-mode has done it's trickery with it. Along with a dirty hack to company-yasnippet to make it only activate on exact matches. Without this hack, lsp backed completion rarely activates as snippets would have higher priority if there's any partial matches.
37 lines
959 B
EmacsLisp
37 lines
959 B
EmacsLisp
;;; siren-cape.el --- jimeh's Emacs Siren: cape configuration.
|
|
|
|
;;; Commentary:
|
|
|
|
;; Basic configuration for cape. Auto completion on steroids.
|
|
|
|
;;; Code:
|
|
|
|
(require 'siren-company)
|
|
|
|
(use-package cape
|
|
:hook
|
|
(lsp-completion-mode . siren-cape-capf-lsp-mode-setup)
|
|
|
|
:preface
|
|
(defalias 'siren-yasnippet-capf
|
|
(cape-company-to-capf 'company-yasnippet))
|
|
|
|
(defun siren-cape-capf-lsp-mode-setup ()
|
|
(siren-cape-capf-add-hooks t))
|
|
|
|
(defun siren-cape-capf-add-hooks (&optional local)
|
|
(add-hook 'completion-at-point-functions
|
|
'siren-yasnippet-capf -65 local)
|
|
(add-hook 'completion-at-point-functions 'cape-file -10 local))
|
|
|
|
(defun siren-cape-capf-remove-hooks (&optional local)
|
|
(remove-hook 'completion-at-point-functions
|
|
'siren-yasnippet-capf local)
|
|
(remove-hook 'completion-at-point-functions 'cape-file local))
|
|
|
|
:init
|
|
(siren-cape-capf-add-hooks))
|
|
|
|
(provide 'siren-cape)
|
|
;;; siren-cape.el ends here
|