2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/php/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-07-18 19:27:13 +02:00
|
|
|
(defvar +php--company-backends nil)
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! php-mode
|
2018-07-18 19:27:13 +02:00
|
|
|
:mode "\\.inc\\'"
|
2015-06-15 09:06:10 +02:00
|
|
|
:config
|
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-07-18 19:27:13 +02:00
|
|
|
(when +php--company-backends
|
|
|
|
(set-company-backend! 'php-mode +php--company-backends))
|
2017-05-23 21:33:03 +02:00
|
|
|
|
2018-07-18 19:27:13 +02:00
|
|
|
;; Use the smallest `sp-max-pair-length' for optimum `smartparens' performance
|
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)
|
2018-07-18 19:58:33 +02:00
|
|
|
(sp-local-pair "<?" "?>" :post-handlers '(("| " "SPC" "=") ("||\n[i]" "RET") ("[d2]" "p")))
|
|
|
|
(sp-local-pair "<?php" "?>" :post-handlers '(("| " "SPC") ("||\n[i]" "RET"))))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
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
|
|
|
|
2018-07-29 02:46:18 +02:00
|
|
|
(def-package! hack-mode
|
|
|
|
:when (featurep! +hack)
|
|
|
|
:mode "\\.hh$")
|
|
|
|
|
|
|
|
|
2018-07-18 19:27:13 +02:00
|
|
|
(def-package! php-refactor-mode
|
|
|
|
:hook php-mode)
|
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! php-extras
|
2016-04-23 22:08:46 -04:00
|
|
|
:after php-mode
|
2018-07-29 20:59:49 +02:00
|
|
|
:preface (advice-add #'php-extras-company-setup :override #'ignore)
|
|
|
|
:init (add-to-list '+php--company-backends 'php-extras-company nil #'eq)
|
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)
|
2018-07-18 19:27:13 +02: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))
|
2015-11-17 02:09:34 -05:00
|
|
|
(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-05-23 21:33:03 +02:00
|
|
|
(def-package! company-php
|
|
|
|
:when (featurep! :completion company)
|
2018-07-18 19:27:13 +02:00
|
|
|
:commands (ac-php-remake-tags ac-php-remake-tags-all)
|
|
|
|
:init
|
|
|
|
(add-to-list '+php--company-backends 'company-ac-php-backend nil #'eq)
|
2018-07-27 01:31:53 +02:00
|
|
|
(add-hook 'php-mode-hook #'+php|init-ac-php-core-eldoc)
|
|
|
|
(setq ac-php-tags-path (concat doom-cache-dir "ac-php/"))
|
2018-08-01 18:15:11 +02:00
|
|
|
;; loaded by `company-php'
|
|
|
|
(after! ac-php-core
|
|
|
|
(when (equal ac-php-ctags-executable
|
|
|
|
(concat ac-php-root-directory "phpctags"))
|
|
|
|
;; prioritize phpctags in PATH
|
|
|
|
(setq ac-php-ctags-executable
|
|
|
|
(or (executable-find "phpctags")
|
|
|
|
ac-php-ctags-executable)))))
|
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
|
|
|
|