fix(cc): make *.c(c|pp) siblings of *.h(h|pp) files

I backported `find-sibling-file` in 198fe82 and included with it some
rudimentary `find-sibling-rules` rules for C++ and others. The C++ rule
made *.h(h|pp) files the siblings of *.c(c|pp) files, but not vice
versa, so users couldn't jump back to the source file with
`find-sibling-file`; a second rule is necessary.

These may be combinable, considering `find-sibling-file` deletes the
current buffer's filename from the list of candidates...

Fix: #7795
Ref: 198fe82b6d49
This commit is contained in:
Henrik Lissner 2024-04-04 13:42:34 -04:00 committed by Yann Esposito (Yogsototh)
parent a37d801a48
commit 5c672b1d0e
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -78,7 +78,8 @@ This is ignored by ccls.")
:return "return"
:yield "#require")
(add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.c\\(c\\|pp\\)\\'" "\\1.\\(h\\|hh\\|hpp\\)"))
(add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.c\\(c\\|pp\\)?\\'" "\\1.h\\(h\\|pp\\)?\\'"))
(add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.h\\(h\\|pp\\)?\\'" "\\1.c\\(c\\|pp\\)?\\'"))
(when (modulep! +tree-sitter)
(add-hook! '(c-mode-local-vars-hook