 ;;; lang/php/config.el -*- lexical-binding: t; -*-
+
+(defvar +php--company-backends nil)
 
 ;; (def-package! hack-mode
 ;;   :mode "\\.hh$"



(def-package! php-mode
  :mode "\\.php[s345]?$"
  :mode "\\.inc$"
  :interpreter "php"
  :config
  (add-hook 'php-mode-hook #'ac-php-core-eldoc-setup)

  ;; Disable HTML compatibility in php-mode. `web-mode' has superior support for
  ;; php+html. Use the .phtml
  (setq php-template-compatibility nil)

  (unless (file-exists-p (concat php-extras-eldoc-functions-file ".el"))
    (message "Generating PHP eldoc files...")
    (require 'async)
    (async-start (lambda ()
                   ,(async-inject-variables "\\`\\(load-path\\|php-extras-eldoc-functions-file\\)$")
                   (require 'php-extras-gen-eldoc)
                   (php-extras-generate-eldoc-1 t))
                 (lambda (_)
                   (load (concat php-extras-eldoc-functions-file ".el"))
                   (message "PHP eldoc updated!")))))


(def-package! company-php
  :when (featurep! :completion company)
  :commands (ac-php-remake-tags ac-php-remake-tags-all)
  :hook (php-mode . ac-php-core-eldoc-setup)
  :init
  (add-to-list '+php--company-backends 'company-ac-php-backend nil #'eq)
  :config (setq ac-php-tags-path (concat doom-cache-dir "ac-php/")))


