From 7f32de8c49bc86da6cd9126e503cd276cd8fd036 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 30 Jul 2022 21:48:53 +0100 Subject: [PATCH] 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. --- modules/completion/siren-cape.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/completion/siren-cape.el b/modules/completion/siren-cape.el index ba05808..5f303e5 100644 --- a/modules/completion/siren-cape.el +++ b/modules/completion/siren-cape.el @@ -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)