Commit e8f88bb4 authored by Fangrui Song's avatar Fangrui Song

Add cquery-project-root-function

parent 0e4910d2
......@@ -49,11 +49,14 @@
(cl-defun cquery--get-root ()
"Return the root directory of a cquery project."
(when cquery-project-root-function
(-when-let (root (funcall cquery-project-root-function))
(cl-return-from cquery--get-root root)))
(cl-loop for root in cquery-project-roots do
(when (string-prefix-p (expand-file-name root) buffer-file-name)
(cl-return-from cquery--get-root root)))
(and (require 'projectile nil t) (projectile-project-root))
(and (require 'projectile nil t) (ignore-errors (projectile-project-root)))
(expand-file-name (or (locate-dominating-file default-directory "compile_commands.json")
(locate-dominating-file default-directory ".cquery")
(user-error "Could not find cquery project root")))))
......@@ -71,6 +71,19 @@ Relative to the project root directory."
:type '(repeat string)
:group 'cquery)
(defcustom cquery-project-root-function
"A function used to find the project root.
The following methods are applied in order to get the project root.
* `cquery-project-root-function'
* `cquery-project-roots'
* projectile
* `.cquery' or `compile_commands.json'
:type 'function
:group 'cquery)
(defcustom cquery-project-roots
"A list of project roots that will be matched against the source filename first
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment