fix(completion): ensure correct order of completion-at-point-functions

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.
This commit is contained in:
2022-07-30 21:48:53 +01:00
parent bbd8f11719
commit 7f32de8c49

View File

@@ -21,8 +21,11 @@
(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))
(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)