doomemacs/modules/module-php.el

77 lines
3.1 KiB
EmacsLisp
Raw Normal View History

2015-06-15 15:06:10 +08:00
;;; module-php.el
(use-package php-mode
:mode "\\.\\(php\\|inc\\)$"
:init
2016-02-21 04:30:30 +08:00
(define-docset! php-mode "php,laravel")
(define-company-backend! php-mode '(php-extras-company))
(add-hook! php-mode 'flycheck-mode)
(setq php-template-compatibility nil
2016-03-27 12:49:52 +08:00
php-extras-eldoc-functions-file (concat narf-temp-dir "/php-extras-eldoc-functions"))
2015-06-15 15:06:10 +08:00
:config
(require 'php-extras)
2015-12-27 15:51:49 +08:00
(defun php-extras-company-setup ()) ;; company will set up itself
2015-06-15 15:06:10 +08:00
2016-02-26 13:08:41 +08:00
;; Generate php-extras documentation and completion asynchronously
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
(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 "<? " " ?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC") ("| " "=")))
(sp-local-pair "<?php " " ?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
(sp-local-pair "<?" "?>" :when '(("RET")) :post-handlers '("||\n[i]"))
(sp-local-pair "<?php" "?>" :when '(("RET")) :post-handlers '("||\n[i]")))
(use-package php-refactor-mode
:init
(add-hook! php-mode '(turn-on-eldoc-mode emr-initialize php-refactor-mode))
:config
(require 'emr)
(mapc (lambda (x)
(let ((command-name (car x))
(title (cadr x))
(region-p (caddr x))
predicate)
(setq predicate (cond ((eq region-p 'both) nil)
(t (if region-p
(lambda () (use-region-p))
(lambda () (not (use-region-p)))))))
(emr-declare-command (intern (format "php-refactor--%s" (symbol-name command-name)))
:title title :modes 'php-mode :predicate predicate)))
'((convert-local-to-instance-variable "convert local var to instance var" nil)
(optimize-use "optimize FQNs in file" nil)
(extract-method "extract method" t)
(rename-local-variable "rename local variable" nil)))))
2015-06-15 15:06:10 +08:00
2016-02-26 13:08:41 +08:00
;; PHP Repl
2015-12-09 14:54:30 +08:00
(use-package php-boris :defer t
:init
(define-repl! php-mode php-boris)
:config
2016-02-26 13:08:41 +08:00
(evil-set-initial-state 'php-boris-mode 'emacs))
2015-11-25 19:00:49 +08:00
2016-02-26 13:08:41 +08:00
;; Support for Facebook's version of PHP
2015-10-10 06:00:39 +08:00
(use-package hack-mode :mode "\\.hh$")
2016-02-05 07:53:08 +08:00
(define-minor-mode php-laravel-mode
""
:init-value nil
:lighter " Laravel"
:keymap (make-sparse-keymap)
(add-yas-minor-mode! 'php-laravel-mode))
(associate! php-laravel-mode
:in (php-mode json-mode yaml-mode web-mode nxml-mode js2-mode scss-mode)
:files ("artisan" "server.php"))
2015-06-15 15:06:10 +08:00
(provide 'module-php)
;;; module-php.el ends here