Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs and company autocompletion. Add a header directory globally

I'm trying to add a header files path to company-mode but I can't do it. I did it with flycheck as follow:

(defun include-paths ()
   (setq flycheck-clang-include-path (list (expand-file-name "../include"))))

(add-hook 'c++-mode-hook 'include-paths)

Is there a similar way to do it with company-mode?

like image 428
class_OpenGL Avatar asked Oct 19 '25 20:10

class_OpenGL


1 Answers

I'm assuming you're using company-c-headers.

Almost verbatim from their README file, you can use M-x customize-groups, company-c-headers to modify the search directories.

Alternatively, you can bind the company-c-headers-path-system and company-c-headers-path-user variables to functions which return the corresponding paths. For example, if you are using EDE, you can use the following:

(defun ede-object-system-include-path ()
  "Return the system include path for the current buffer."
  (when ede-object
    (ede-system-include-path ede-object)))

(setq company-c-headers-path-system 'ede-object-system-include-path)

Source

like image 85
Tim Miller Avatar answered Oct 22 '25 13:10

Tim Miller