diff --git a/company-coq.el b/company-coq.el index 22e01355..d286996e 100644 --- a/company-coq.el +++ b/company-coq.el @@ -2180,12 +2180,17 @@ to a non-existent file (for an example of such a case, try (file-name-nondirectory (buffer-file-name proof-script-buffer)))))) proof-script-buffer (let* ((lib-name (concat lib-path mod-name)) - (output (company-coq-ask-prover-swallow-errors (format company-coq-locate-lib-cmd lib-name)))) - (or (and output (save-match-data - (when (and (string-match company-coq-locate-lib-output-format output) - (string-match-p company-coq-compiled-regexp (match-string-no-properties 3 output))) - (concat (match-string-no-properties 2 output) ".v")))) - (and fallback-spec (expand-file-name (concat mod-name ".v") (cdr fallback-spec))))))) + (output (company-coq-ask-prover-swallow-errors (format company-coq-locate-lib-cmd lib-name))) + (path (or (and output (save-match-data + (when (and (string-match company-coq-locate-lib-output-format output) + (string-match-p company-coq-compiled-regexp (match-string-no-properties 3 output))) + (concat (match-string-no-properties 2 output) ".v")))) + (and fallback-spec (expand-file-name (concat mod-name ".v") (cdr fallback-spec))))) + (stripped (replace-regexp-in-string "_build/default" "" path nil 'literal))) + (if (file-exists-p stripped) + stripped + path + )))) (defun company-coq--locate-name (name functions) "Find location of NAME using FUNCTIONS.