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: 198fe82b6d
This commit is contained in:
Henrik Lissner 2024-04-04 13:42:34 -04:00
parent 38a3adcf0e
commit 19e27764ea
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

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