2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/php/autoload.el -*- lexical-binding: t; -*-
|
2017-03-02 18:20:46 -05:00
|
|
|
|
|
|
|
(defvar +php-composer-conf (make-hash-table :test 'equal))
|
|
|
|
|
2018-08-13 18:12:50 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defun +php-company-backend (command &optional arg &rest _ignored)
|
|
|
|
"A delegating company-backend that uses `company-phpactor' if phpactor is
|
|
|
|
available and installed, or `php-extras-company' otherwise."
|
|
|
|
(cond ((and (require 'company-phpactor nil t)
|
|
|
|
(ignore-errors (phpactor-find-executable)))
|
|
|
|
(company-phpactor command arg))
|
|
|
|
((and (require 'php-extras nil t)
|
|
|
|
(file-exists-p (concat php-extras-eldoc-functions-file ".el")))
|
|
|
|
(php-extras-company command arg))))
|
|
|
|
|
2017-03-02 18:20:46 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun +php-composer-conf (&optional project-root refresh-p)
|
|
|
|
"Retrieve the contents of composer.json as an alist. If REFRESH-P is non-nil
|
|
|
|
ignore the cache."
|
|
|
|
(let ((project-root (or project-root (doom-project-root))))
|
|
|
|
(or (and (not refresh-p) (gethash project-root +php-composer-conf))
|
|
|
|
(let ((package-file (expand-file-name "composer.json" project-root)))
|
2019-06-25 21:38:16 +02:00
|
|
|
(when-let (data (and (file-exists-p package-file)
|
|
|
|
(require 'json)
|
|
|
|
(json-read-file package-file)))
|
2017-03-02 18:20:46 -05:00
|
|
|
(puthash project-root data +php-composer-conf))))))
|
2018-07-27 01:31:53 +02:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +php|init-ac-php-core-eldoc ()
|
|
|
|
"Initialize eldoc support for `php-mode' with `ac-php-core'. Fails gracefully
|
|
|
|
if phpctags isn't installed."
|
2018-08-01 18:15:11 +02:00
|
|
|
(require 'ac-php-core)
|
|
|
|
(cond ((not ac-php-ctags-executable))
|
|
|
|
((not (file-exists-p ac-php-ctags-executable))
|
|
|
|
(message "Could not find phpctags executable, eldoc support is disabled")
|
|
|
|
(message "To disable these warnings, set ac-php-ctags-executable to nil"))
|
|
|
|
((ac-php-core-eldoc-setup))))
|