2015-06-15 09:06:10 +02:00
|
|
|
;;; module-php.el
|
|
|
|
|
2016-04-19 02:45:28 -04:00
|
|
|
(use-package hack-mode
|
|
|
|
:mode "\\.hh$"
|
|
|
|
:config (define-company-backend! hack-mode (capf)))
|
|
|
|
|
2015-06-15 09:06:10 +02:00
|
|
|
(use-package php-mode
|
2016-04-10 18:50:28 -04:00
|
|
|
:mode ("\\.php[s345]?$" "\\.inc$" )
|
|
|
|
:interpreter "php"
|
2015-06-15 09:06:10 +02:00
|
|
|
:init
|
2016-02-20 15:30:30 -05:00
|
|
|
(define-docset! php-mode "php,laravel")
|
|
|
|
(define-company-backend! php-mode '(php-extras-company))
|
|
|
|
|
2016-04-08 14:07:16 -04:00
|
|
|
(add-hook 'php-mode-hook 'flycheck-mode)
|
2015-06-25 23:47:03 +02:00
|
|
|
(setq php-template-compatibility nil
|
2016-03-27 00:49:52 -04:00
|
|
|
php-extras-eldoc-functions-file (concat narf-temp-dir "/php-extras-eldoc-functions"))
|
2015-06-15 09:06:10 +02:00
|
|
|
:config
|
|
|
|
(require 'php-extras)
|
2015-12-27 02:51:49 -05:00
|
|
|
(defun php-extras-company-setup ()) ;; company will set up itself
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2016-03-29 23:49:41 -04:00
|
|
|
(map! :map php-mode-map
|
2016-04-16 21:27:59 -04:00
|
|
|
(:localleader :nv ";" 'narf/append-semicolon)
|
|
|
|
:n "gd" 'ac-php-find-symbol-at-point
|
|
|
|
:n "gD" 'ac-php-location-stack-back)
|
2016-03-29 23:49:41 -04:00
|
|
|
|
2016-02-26 00:08:41 -05:00
|
|
|
;; Generate php-extras documentation and completion asynchronously
|
2015-11-17 02:09:34 -05: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-28 21:39:13 -04:00
|
|
|
(sp-with-modes '(php-mode)
|
2016-04-19 03:17:49 -04:00
|
|
|
(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 " " ?>")
|
2016-03-29 23:49:54 -04:00
|
|
|
(sp-local-pair "<?=" " ?>")
|
2016-03-28 21:39:13 -04:00
|
|
|
(sp-local-pair "<?" "?>" :when '(("RET")) :post-handlers '("||\n[i]"))
|
|
|
|
(sp-local-pair "<?php" "?>" :when '(("RET")) :post-handlers '("||\n[i]")))
|
|
|
|
|
2016-02-26 09:43:29 -05:00
|
|
|
(use-package php-refactor-mode
|
2016-04-16 21:27:59 -04:00
|
|
|
:init (add-hook! php-mode '(turn-on-eldoc-mode emr-initialize php-refactor-mode))
|
2016-02-26 09:43:29 -05:00
|
|
|
:config
|
|
|
|
(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 09:06:10 +02:00
|
|
|
|
2016-02-26 00:08:41 -05:00
|
|
|
;; PHP Repl
|
2015-12-09 01:54:30 -05:00
|
|
|
(use-package php-boris :defer t
|
2016-04-16 21:27:59 -04:00
|
|
|
:init (define-repl! php-mode php-boris)
|
|
|
|
:config (evil-set-initial-state 'php-boris-mode 'emacs))
|
2015-11-25 06:00:49 -05:00
|
|
|
|
2016-04-16 21:36:24 -04:00
|
|
|
;;
|
|
|
|
(define-project-type! laravel "laravel"
|
2016-04-19 03:18:01 -04:00
|
|
|
:modes (php-mode yaml-mode web-mode nxml-mode js2-mode scss-mode)
|
2016-02-04 18:53:08 -05:00
|
|
|
:files ("artisan" "server.php"))
|
|
|
|
|
2015-06-15 09:06:10 +02:00
|
|
|
(provide 'module-php)
|
|
|
|
;;; module-php.el ends here
|