Refactor lang/php

This commit is contained in:
Henrik Lissner 2018-07-18 19:27:13 +02:00
parent a4c14108c7
commit f6f74efdee
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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,7 +66,7 @@
(unless (file-exists-p (concat php-extras-eldoc-functions-file ".el"))
(message "Generating PHP eldoc files...")
(require 'async)
(async-start `(lambda ()
(async-start (lambda ()
,(async-inject-variables "\\`\\(load-path\\|php-extras-eldoc-functions-file\\)$")
(require 'php-extras-gen-eldoc)
(php-extras-generate-eldoc-1 t))
@ -71,20 +75,12 @@
(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/")))