doomemacs/modules/lang/php/config.el

94 lines
2.7 KiB
EmacsLisp
Raw Normal View History

2017-02-20 07:57:16 +08:00
;;; lang/php/config.el
2015-06-15 15:06:10 +08:00
;; (def-package! hack-mode
2017-02-20 07:57:16 +08:00
;; :mode "\\.hh$"
;; :config
;; (set! :company-backend 'hack-mode '(company-capf)))
2016-04-19 14:45:28 +08:00
2017-02-20 07:57:16 +08:00
(def-package! php-mode
2017-02-20 07:57:16 +08:00
:mode ("\\.php[s345]?$" "\\.inc$")
2016-04-11 06:50:28 +08:00
:interpreter "php"
2015-06-15 15:06:10 +08:00
:init
2016-04-09 02:07:16 +08:00
(add-hook 'php-mode-hook 'flycheck-mode)
2015-06-15 15:06:10 +08:00
:config
2017-02-20 07:57:16 +08:00
(setq php-template-compatibility nil)
(set! :repl 'php-mode 'php-boris)
(add-hook! php-mode (setq-local sp-max-pair-length 6))
(sp-with-modes '(php-mode)
(sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
(sp-local-pair "<? " " ?>")
(sp-local-pair "<?php " " ?>")
(sp-local-pair "<?=" " ?>")
(sp-local-pair "<?" "?>" :when '(("RET")) :post-handlers '("||\n[i]"))
2017-02-20 07:57:16 +08:00
(sp-local-pair "<?php" "?>" :when '(("RET")) :post-handlers '("||\n[i]")))
(map! :map php-mode-map
2017-02-20 07:57:16 +08:00
:localleader
:nv ";" 'doom/append-semicolon
(:prefix "r"
: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-20 07:57:16 +08:00
(:prefix "t"
:n "r" 'phpunit-current-project
:n "a" 'phpunit-current-class
:n "s" 'phpunit-current-test)))
2017-02-20 07:57:16 +08:00
2015-06-15 15:06:10 +08:00
(def-package! php-extras
:after php-mode
2017-02-20 07:57:16 +08:00
:init
(add-hook 'php-mode-hook 'eldoc-mode)
:config
(setq php-extras-eldoc-functions-file (concat doom-etc-dir "php-extras-eldoc-functions"))
2017-02-20 07:57:16 +08:00
(set! :company-bakend 'php-mode '(php-extras-company company-yasnippet))
2017-02-20 07:57:16 +08:00
;; company will set up itself
(advice-add 'php-extras-company-setup :override 'ignore)
;; Make expensive php-extras generation async
2015-11-17 15:09:34 +08:00
(unless (file-exists-p (concat php-extras-eldoc-functions-file ".el"))
(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!")))))
2016-03-29 09:39:13 +08:00
2016-05-19 15:18:57 +08:00
(def-package! php-refactor-mode
2017-02-20 07:57:16 +08:00
:commands php-refactor-mode
:init (add-hook 'php-mode-hook 'php-refactor-mode))
(def-package! phpunit
2017-02-20 07:57:16 +08:00
:commands (phpunit-current-test phpunit-current-class phpunit-current-project))
(def-package! php-boris :commands php-boris)
2015-11-25 19:00:49 +08:00
2017-02-20 07:57:16 +08:00
;;
;; Projects
2016-04-17 09:36:24 +08:00
;;
2017-02-20 07:57:16 +08:00
2017-03-03 07:20:46 +08: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)
:files "composer.json")
2017-02-20 07:57:16 +08:00