mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-30 17:01:02 -05:00
fix(cc): ffap in C modes (and ts-modes)
This commit is contained in:
@@ -145,8 +145,8 @@ the children of class at point."
|
||||
"Takes the local project include paths and registers them with ffap.
|
||||
This way, `find-file-at-point' (and `+lookup/file') will know where to find most
|
||||
header files."
|
||||
(when-let (project-root (and (featurep 'lsp)
|
||||
(or (lsp-workspace-root)
|
||||
(when-let* ((project-root (or (and (fboundp 'lsp-workspace-root)
|
||||
(lsp-workspace-root))
|
||||
(doom-project-root))))
|
||||
(require 'ffap)
|
||||
(make-local-variable 'ffap-c-path)
|
||||
@@ -154,8 +154,8 @@ header files."
|
||||
(cl-loop for dir in (or (cdr (assoc project-root +cc--project-includes-alist))
|
||||
(+cc-resolve-include-paths))
|
||||
do (add-to-list (pcase major-mode
|
||||
(`c-mode 'ffap-c-path)
|
||||
(`c++-mode 'ffap-c++-path))
|
||||
((or `c-mode `c-ts-mode) 'ffap-c-path)
|
||||
((or `c++-mode `c++-ts-mode) 'ffap-c++-path))
|
||||
(expand-file-name dir project-root)))))
|
||||
|
||||
|
||||
|
@@ -35,6 +35,12 @@ This is ignored by ccls.")
|
||||
(set-tree-sitter! 'c++-mode 'c++-ts-mode
|
||||
'((cpp :url "https://github.com/tree-sitter/tree-sitter-cpp"
|
||||
:rev "v0.23.4"))))
|
||||
|
||||
(after! ffap
|
||||
(add-to-list 'ffap-alist '(c-mode . ffap-c-mode))
|
||||
(add-to-list 'ffap-alist '(c-ts-mode . ffap-c-mode))
|
||||
(add-to-list 'ffap-alist '(c++-ts-mode . ffap-c++-mode)))
|
||||
|
||||
:config
|
||||
;; HACK: cc-mode adds null entries to `major-mode-remap-defaults', which
|
||||
;; overrides our tree-sitter remappings, causing the first remap to succeed,
|
||||
|
Reference in New Issue
Block a user