2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/php/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
;; (def-package! hack-mode
|
2017-02-19 18:57:16 -05:00
|
|
|
;; :mode "\\.hh$"
|
|
|
|
;; :config
|
2018-06-15 02:58:12 +02:00
|
|
|
;; (set-company-backend! 'hack-mode '(company-capf)))
|
2016-04-19 02:45:28 -04:00
|
|
|
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! php-mode
|
2017-12-08 22:33:12 -05:00
|
|
|
:mode "\\.php[s345]?$"
|
|
|
|
:mode "\\.inc$"
|
2016-04-10 18:50:28 -04:00
|
|
|
:interpreter "php"
|
2015-06-15 09:06:10 +02:00
|
|
|
:config
|
2017-12-08 22:33:12 -05:00
|
|
|
(add-hook! php-mode #'(ac-php-core-eldoc-setup flycheck-mode))
|
2017-05-23 21:33:03 +02:00
|
|
|
|
2018-01-28 21:36:42 -05:00
|
|
|
;; Disable HTML compatibility in php-mode. `web-mode' has superior support for
|
|
|
|
;; php+html. Use the .phtml
|
2017-02-19 18:57:16 -05:00
|
|
|
(setq php-template-compatibility nil)
|
2016-05-01 01:10:30 -04:00
|
|
|
|
2018-06-15 16:07:24 +02:00
|
|
|
(set-repl-handler! 'php-mode #'php-boris)
|
2018-06-15 17:27:48 +02:00
|
|
|
(set-lookup-handlers! 'php-mode :documentation #'php-search-documentation)
|
2017-03-19 22:47:50 -04:00
|
|
|
|
2017-05-23 21:33:03 +02:00
|
|
|
;; ac-php provides custom autocompletion, php-extras provides autocompletion
|
|
|
|
;; for built-in libraries
|
2018-06-15 02:58:12 +02:00
|
|
|
(set-company-backend! 'php-mode '(company-ac-php-backend php-extras-company))
|
2017-05-23 21:33:03 +02:00
|
|
|
|
2017-04-08 01:36:11 -04:00
|
|
|
;; default is 10; this optimizes `smartparens' performance, but limits sp
|
|
|
|
;; pairs to 6 characters.
|
2018-05-07 22:37:19 +02:00
|
|
|
(setq-hook! 'php-mode-hook sp-max-pair-length 6)
|
2016-10-05 12:50:02 +02:00
|
|
|
|
2016-04-23 22:08:46 -04:00
|
|
|
(sp-with-modes '(php-mode)
|
2017-04-03 03:12:49 -04:00
|
|
|
(sp-local-pair "/* " "*/" :post-handlers '(("||\n[i] " "RET") ("| " "SPC")))
|
2016-04-23 22:08:46 -04:00
|
|
|
(sp-local-pair "<? " " ?>")
|
|
|
|
(sp-local-pair "<?php " " ?>")
|
|
|
|
(sp-local-pair "<?=" " ?>")
|
|
|
|
(sp-local-pair "<?" "?>" :when '(("RET")) :post-handlers '("||\n[i]"))
|
2017-02-19 18:57:16 -05:00
|
|
|
(sp-local-pair "<?php" "?>" :when '(("RET")) :post-handlers '("||\n[i]")))
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(map! :map php-mode-map
|
2017-02-19 18:57:16 -05:00
|
|
|
:localleader
|
2017-02-28 12:11:18 -05:00
|
|
|
(:prefix "r"
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "cv" #'php-refactor--convert-local-to-instance-variable
|
|
|
|
:n "u" #'php-refactor--optimize-use
|
|
|
|
:v "xm" #'php-refactor--extract-method
|
|
|
|
:n "rv" #'php-refactor--rename-local-variable)
|
2017-02-28 12:11:18 -05:00
|
|
|
(:prefix "t"
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "r" #'phpunit-current-project
|
|
|
|
:n "a" #'phpunit-current-class
|
|
|
|
:n "s" #'phpunit-current-test)))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! php-extras
|
2016-04-23 22:08:46 -04:00
|
|
|
:after php-mode
|
2017-02-19 18:57:16 -05:00
|
|
|
:init
|
|
|
|
;; company will set up itself
|
2017-04-17 02:17:10 -04:00
|
|
|
(advice-add #'php-extras-company-setup :override #'ignore)
|
2017-05-23 21:33:03 +02:00
|
|
|
:config
|
2017-06-08 11:47:56 +02:00
|
|
|
(setq php-extras-eldoc-functions-file
|
|
|
|
(concat doom-etc-dir "php-extras-eldoc-functions"))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
;; Make expensive php-extras generation async
|
2015-11-17 02:09:34 -05:00
|
|
|
(unless (file-exists-p (concat php-extras-eldoc-functions-file ".el"))
|
2017-05-23 21:33:03 +02:00
|
|
|
(message "Generating PHP eldoc files...")
|
2018-01-06 17:02:57 -05:00
|
|
|
(require 'async)
|
2015-11-17 02:09:34 -05:00
|
|
|
(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"))
|
2016-04-23 22:08:46 -04:00
|
|
|
(message "PHP eldoc updated!")))))
|
2016-03-28 21:39:13 -04:00
|
|
|
|
2016-05-19 03:18:57 -04:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! php-refactor-mode
|
2017-12-08 22:33:12 -05:00
|
|
|
:hook php-mode)
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! phpunit
|
2017-02-19 18:57:16 -05:00
|
|
|
:commands (phpunit-current-test phpunit-current-class phpunit-current-project))
|
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! php-boris :commands php-boris)
|
2015-11-25 06:00:49 -05:00
|
|
|
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-05-23 21:33:03 +02:00
|
|
|
(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)
|
2018-01-28 21:36:42 -05:00
|
|
|
:config (setq ac-php-tags-path (concat doom-cache-dir "ac-php/")))
|
2017-05-23 21:33:03 +02:00
|
|
|
|
|
|
|
|
2017-02-19 18:57:16 -05:00
|
|
|
;;
|
|
|
|
;; Projects
|
2016-04-16 21:36:24 -04:00
|
|
|
;;
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-03-02 18:20:46 -05:00
|
|
|
(def-project-mode! +php-laravel-mode
|
|
|
|
:modes (php-mode yaml-mode web-mode nxml-mode js2-mode scss-mode)
|
|
|
|
:files (and "artisan" "server.php"))
|
|
|
|
|
|
|
|
(def-project-mode! +php-composer-mode
|
|
|
|
:modes (web-mode php-mode)
|
2018-06-01 02:20:00 +02:00
|
|
|
:files ("composer.json"))
|
2017-02-19 18:57:16 -05:00
|
|
|
|