From f6f74efdee2a7bc27357537ff60ff5776c0ee8d1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 18 Jul 2018 19:27:13 +0200 Subject: [PATCH] Refactor lang/php --- modules/lang/php/config.el | 42 +++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/modules/lang/php/config.el b/modules/lang/php/config.el index e435067de..6e0136d73 100644 --- a/modules/lang/php/config.el +++ b/modules/lang/php/config.el @@ -1,5 +1,7 @@ ;;; lang/php/config.el -*- lexical-binding: t; -*- +(defvar +php--company-backends nil) + ;; (def-package! hack-mode ;; :mode "\\.hh$" ;; :config @@ -7,12 +9,9 @@ (def-package! php-mode - :mode "\\.php[s345]?$" - :mode "\\.inc$" + :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) @@ -22,10 +21,10 @@ ;; ac-php provides custom autocompletion, php-extras provides autocompletion ;; for built-in libraries - (set-company-backend! 'php-mode '(company-ac-php-backend php-extras-company)) + (when +php--company-backends + (set-company-backend! 'php-mode +php--company-backends)) - ;; default is 10; this optimizes `smartparens' performance, but limits sp - ;; pairs to 6 characters. + ;; Use the smallest `sp-max-pair-length' for optimum `smartparens' performance (setq-hook! 'php-mode-hook sp-max-pair-length 6) (sp-with-modes '(php-mode) @@ -49,11 +48,16 @@ :n "s" #'phpunit-current-test))) +(def-package! php-refactor-mode + :hook php-mode) + + (def-package! php-extras :after php-mode :init ;; company will set up itself (advice-add #'php-extras-company-setup :override #'ignore) + (add-to-list '+php--company-backends 'php-extras-company nil #'eq) :config (setq php-extras-eldoc-functions-file (concat doom-etc-dir "php-extras-eldoc-functions")) @@ -62,29 +66,21 @@ (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)) + (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! php-refactor-mode - :hook php-mode) - - -(def-package! phpunit - :commands (phpunit-current-test phpunit-current-class phpunit-current-project)) - - -(def-package! php-boris :commands php-boris) - - (def-package! company-php :when (featurep! :completion company) - :commands (company-ac-php-backend ac-php-remake-tags ac-php-remake-tags-all ac-php-core-eldoc-setup) + :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/")))