diff --git a/modules/lang/cc/autoload.el b/modules/lang/cc/autoload.el index 24e5af191..5600c37cf 100644 --- a/modules/lang/cc/autoload.el +++ b/modules/lang/cc/autoload.el @@ -145,17 +145,17 @@ 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) - (doom-project-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) (make-local-variable 'ffap-c++-path) (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))))) diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index 7efcc8635..c250bbd53 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -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,