mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
When lsp-mode is active, it tries to ensure it's own lsp-completion-at-point function is listed before any other functions in completion-at-point-functions. This however prevents completions for yasnippet snippets and files/folders from working, as completion never moved on beyond lsp-completion-at-point. Previously I had managed to fix this by using the DEPTH option of add-hook to get siren-yasnippet-capf and cape-file to run before lsp-completion-at-point. But it seems lsp-mode has changed from using add-hook to a more custom method of always ensuring lsp-completion-at-point is always first on the list. Hence we need to the same using the new siren-prepend macro I recently added.
39 lines
1.1 KiB
EmacsLisp
39 lines
1.1 KiB
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
|
|
:after company
|
|
: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)
|
|
(if local (make-local-variable 'completion-at-point-functions))
|
|
;; Use `siren-prepend' function instead of `add-hook' to ensure our custom
|
|
;; completion functions are listed before `lsp-completion-at-point'.
|
|
(siren-prepend completion-at-point-functions 'cape-file)
|
|
(siren-prepend completion-at-point-functions 'siren-yasnippet-capf))
|
|
|
|
(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
|