Open brucestephens opened 5 years ago
Right, I also had a similar issue. A quick fix, which I have now, is to add the following hack into your init file.
(eval-after-load "cquery"
'(defun cquery--get-init-params ()
`(,@cquery-extra-init-params
:cacheDirectory ,(file-name-as-directory
(funcall cquery-cache-dir-function (lsp--suggest-project-root)))
:highlight (:enabled ,(or (and cquery-sem-highlight-method t) :json-false))
:emitInactiveRegions ,(or cquery-enable-inactive-region :json-false))))
Before the very recent change (to use the new lsp API),
.cquery_cached_index
was put in the project root. Now it ends up in the directory containing the first file you edit, which is surely unintended (though will work OK if you have all source files in one directory).(The problem is presumably
cquery--get-init-params
usingdefault-directory
. I can get my expected behaviour by settingcquery-cache-dir-function
to a suitable find-project-root function.)
Can you share your workaround?
Can you share your workaround?
Something like this:
(defun cquery-root ()
(let ((root (cquery--get-root))
(isroot nil))
(cond (root
(dolist (f '("compile_commands.json" "build/compile_commands.json"))
(setq isroot (or isroot (file-exists-p (expand-file-name f root)))))))
(if isroot
root
nil)))
(defun cquery-cache-dir (dir)
(expand-file-name cquery-cache-dir (cquery-root)))
(setq cquery-cache-dir-function #'cquery-cache-dir)
Before the very recent change (to use the new lsp API),
.cquery_cached_index
was put in the project root. Now it ends up in the directory containing the first file you edit, which is surely unintended (though will work OK if you have all source files in one directory).(The problem is presumably
cquery--get-init-params
usingdefault-directory
. I can get my expected behaviour by settingcquery-cache-dir-function
to a suitable find-project-root function.)