2017-06-06 22:50:49 +00:00
|
|
|
;;; packages.el --- Perl5 Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2017-06-06 22:50:49 +00:00
|
|
|
;;
|
|
|
|
;; Author: Troy Hinckley <troyhinckley@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq perl5-packages
|
|
|
|
'(
|
2017-10-15 14:04:45 +00:00
|
|
|
(company-plsense :requires company)
|
2017-06-06 22:50:49 +00:00
|
|
|
(cperl-mode :location built-in)
|
|
|
|
flycheck
|
2017-10-15 14:04:45 +00:00
|
|
|
smartparens
|
2017-06-06 22:50:49 +00:00
|
|
|
))
|
|
|
|
|
2017-10-15 14:04:45 +00:00
|
|
|
(defun perl5/init-company-plsense ()
|
|
|
|
(use-package company-plsense
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-10-15 14:04:45 +00:00
|
|
|
:init
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-plsense
|
|
|
|
:modes cperl-mode)))
|
|
|
|
|
2017-06-06 22:50:49 +00:00
|
|
|
(defun perl5/init-cperl-mode ()
|
|
|
|
(use-package cperl-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-06-06 22:50:49 +00:00
|
|
|
:mode "\\.\\(p[lm]x?\\|P[LM]X?\\)\\'"
|
|
|
|
:interpreter "perl"
|
|
|
|
:interpreter "perl5"
|
|
|
|
|
|
|
|
:init
|
|
|
|
(progn
|
2017-06-08 07:12:35 +00:00
|
|
|
(setq
|
|
|
|
;; highlight all scalar variables not just the instantiation
|
|
|
|
cperl-highlight-variables-indiscriminately t
|
|
|
|
cperl-indent-level 4 ; 4 spaces is the standard indentation
|
|
|
|
cperl-close-paren-offset -4 ; indent the closing paren back four spaces
|
|
|
|
cperl-continued-statement-offset 4 ; if a statement continues indent it to four spaces
|
|
|
|
cperl-indent-parens-as-block t)) ; parentheses are indented with the block and not with scope
|
2017-06-06 22:50:49 +00:00
|
|
|
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; Don't highlight arrays and hashes in comments
|
|
|
|
(font-lock-remove-keywords
|
|
|
|
'cperl-mode
|
|
|
|
'(("\\(\\([@%]\\|\\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
|
|
|
|
(if (eq (char-after (match-beginning 2)) 37)
|
|
|
|
'cperl-hash-face 'cperl-array-face) t)
|
|
|
|
("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)" 1
|
|
|
|
(if (= (- (match-end 2) (match-beginning 2)) 1)
|
|
|
|
(if (eq (char-after (match-beginning 3)) 123)
|
|
|
|
'cperl-hash-face 'cperl-array-face)
|
|
|
|
font-lock-variable-name-face) t)
|
|
|
|
("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
|
|
|
|
(2 font-lock-string-face t)
|
|
|
|
("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" nil nil
|
|
|
|
(1 font-lock-string-face t)))
|
|
|
|
("[[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1 font-lock-string-face t)))
|
|
|
|
|
|
|
|
(font-lock-add-keywords
|
|
|
|
'cperl-mode
|
|
|
|
'(("\\(\\([@%]\\|\\$#\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)" 1
|
|
|
|
(if (nth 4 (syntax-ppss))
|
|
|
|
'font-lock-comment-face
|
|
|
|
(if (eq (char-after (match-beginning 2)) ?%)
|
|
|
|
'cperl-hash-face
|
|
|
|
'cperl-array-face)) t)
|
|
|
|
("\\(\\([$@]+\\)[a-zA-Z_:][a-zA-Z0-9_:]*\\)[ \t]*\\([[{]\\)" 1
|
|
|
|
(if (nth 4 (syntax-ppss))
|
|
|
|
'font-lock-comment-face
|
|
|
|
(if (= (- (match-end 2) (match-beginning 2)) 1)
|
|
|
|
(if (eq (char-after (match-beginning 3)) ?{)
|
|
|
|
'cperl-hash-face
|
|
|
|
'cperl-array-face)
|
|
|
|
font-lock-variable-name-face)) t)
|
|
|
|
("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
|
|
|
|
(2 (if (nth 4 (syntax-ppss))
|
|
|
|
'font-lock-comment-face
|
|
|
|
'font-lock-string-face) t)
|
|
|
|
("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" nil nil
|
|
|
|
(1 (if (nth 4 (syntax-ppss))
|
|
|
|
'font-lock-comment-face
|
|
|
|
'font-lock-string-face) t)))
|
|
|
|
("[[ \t{,(]\\(-?[a-zA-Z0-9_:]+\\)[ \t]*=>" 1
|
|
|
|
(if (nth 4 (syntax-ppss))
|
|
|
|
'font-lock-comment-face
|
|
|
|
'font-lock-string-face) t)))
|
|
|
|
|
|
|
|
;; Use less horrible colors for cperl arrays and hashes
|
2017-06-08 07:12:35 +00:00
|
|
|
(set-face-attribute 'cperl-array-face nil
|
|
|
|
:foreground "#DD7D0A"
|
|
|
|
:background 'unspecified
|
|
|
|
:weight 'unspecified)
|
|
|
|
(set-face-attribute 'cperl-hash-face nil
|
|
|
|
:foreground "OrangeRed3"
|
|
|
|
:background 'unspecified
|
|
|
|
:weight 'unspecified)
|
2017-06-06 22:50:49 +00:00
|
|
|
|
2017-06-24 21:17:56 +00:00
|
|
|
;; tab key will ident all marked code when tab key is pressed
|
|
|
|
(add-hook 'cperl-mode-hook
|
|
|
|
(lambda () (local-set-key (kbd "<tab>") 'indent-for-tab-command)))
|
|
|
|
|
2017-10-02 18:17:50 +00:00
|
|
|
(spacemacs/declare-prefix "m=" "format")
|
|
|
|
(spacemacs/declare-prefix "mg" "find-symbol")
|
2017-10-15 14:04:45 +00:00
|
|
|
(spacemacs/declare-prefix "mh" "perldoc")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'cperl-mode
|
|
|
|
"==" 'spacemacs/perltidy-format
|
|
|
|
"=b" 'spacemacs/perltidy-format-buffer
|
|
|
|
"=f" 'spacemacs/perltidy-format-function
|
|
|
|
"hh" 'cperl-perldoc-at-point
|
|
|
|
"hd" 'cperl-perldoc
|
|
|
|
"v" 'cperl-select-this-pod-or-here-doc)
|
2017-06-24 21:17:56 +00:00
|
|
|
|
2017-06-06 22:50:49 +00:00
|
|
|
(font-lock-add-keywords 'cperl-mode
|
2017-10-02 18:17:50 +00:00
|
|
|
'(("\\_<say\\_>" . cperl-nonoverridable-face))))))
|
2017-06-06 22:50:49 +00:00
|
|
|
|
2017-10-15 14:04:45 +00:00
|
|
|
(defun perl5/post-init-flycheck ()
|
|
|
|
(spacemacs/enable-flycheck 'cperl-mode))
|
|
|
|
|
2017-06-06 22:50:49 +00:00
|
|
|
(defun perl5/post-init-smartparens ()
|
|
|
|
;; fixs a bug with electric mode and smartparens https://github.com/syl20bnr/spacemacs/issues/480
|
2017-06-08 07:12:35 +00:00
|
|
|
(with-eval-after-load 'cperl-mode
|
|
|
|
(add-hook 'smartparens-enabled-hook 'spacemacs//perl5-smartparens-enable)
|
|
|
|
(add-hook 'smartparens-disabled-hook 'spacemacs//perl5-spartparens-disable)))
|