added perl5 layer

This commit is contained in:
CeleritasCelery 2017-06-06 16:50:49 -06:00 committed by Eivind Fonn
parent 65f639d8c4
commit af21bf2494
5 changed files with 122 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#+TITLE: Perl5 layer
[[file:img/perl5.png]]
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features]]
- [[#install][Install]]
- [[#layer][Layer]]
* Description
This layer adds support for the Perl5 language.
** Features
- syntactic and semantic checking using [[https://github.com/flycheck/flycheck][flycheck]]
* Install
** Layer
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =perl5= to the existing =dotspacemacs-configuration-layers= list in this
file.

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,98 @@
;;; packages.el --- Perl5 Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; 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
'(
(cperl-mode :location built-in)
smartparens
flycheck
))
(defun perl5/init-cperl-mode ()
(use-package cperl-mode
:defer t
:mode "\\.\\(p[lm]x?\\|P[LM]X?\\)\\'"
:interpreter "perl"
:interpreter "perl5"
:init
(progn
(setq cperl-highlight-variables-indiscriminately t) ;; highlight all scalar variables not just the instantiation
(setq cperl-indent-level 4) ;; 4 spaces is the standard indentation
(setq cperl-close-paren-offset -4) ;; indent the closing paren back four spaces
(setq cperl-continued-statement-offset 4) ;; if a statement continues indent it to four spaces
(setq cperl-indent-parens-as-block t)) ;; parentheses are indented with the block and not with scope
: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
(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)
(font-lock-add-keywords 'cperl-mode
'(("\\_<const\\|croak\\_>" . font-lock-keyword-face)))
(font-lock-add-keywords 'cperl-mode
'(("\\_<say\\|any\\_>" . cperl-nonoverridable-face))))))
(defun perl5/post-init-smartparens ()
;; fixs a bug with electric mode and smartparens https://github.com/syl20bnr/spacemacs/issues/480
(with-eval-after-load "cperl-mode"
(add-hook 'smartparens-enabled-hook (lambda () (define-key cperl-mode-map "{" nil)))
(add-hook 'smartparens-disabled-hook (lambda () (define-key cperl-mode-map "{" 'cperl-electric-lbrace)))))
(defun perl5/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'cperl-mode))

View File

@ -105,6 +105,7 @@
- [[file:+lang/nim/README.org][nim]]
- [[file:+lang/ocaml/README.org][ocaml]]
- [[file:+lang/octave/README.org][octave]]
- [[file:+lang/perl5/README.org][perl5]]
- [[file:+lang/perl6/README.org][perl6]]
- [[file:+lang/php/README.org][php]]
- [[file:+lang/plantuml/README.org][plantuml]]

View File

@ -80,6 +80,8 @@
(configuration-layer/lazy-install 'ocaml :extensions '("\\(\\.ml[ip]?\\'\\|\\.eliomi?\\'\\)" tuareg-mode))
(configuration-layer/lazy-install 'perl5 :extensions '("\\.\\(p[lm]x?\\|P[LM]X?\\)\\'" cperl-mode))
(configuration-layer/lazy-install 'php :extensions '("\\(\\.amk\\'\\|/Amkfile\\'\\|\\.phtml\\'\\|\\.php[s345t]?\\'\\|[^/]\\.\\(module\\|test\\|install\\|profile\\|tpl\\.php\\|theme\\|inc\\)\\'\\|\\.php\\'\\)" php-mode))
(configuration-layer/lazy-install 'purescript :extensions '("\\(\\.purs\\'\\)" purescript-mode))