lang/sh: conform to new hook conventions
This commit is contained in:
parent
4aa577ca3d
commit
b24d7506e6
1 changed files with 18 additions and 18 deletions
|
@ -34,16 +34,16 @@
|
||||||
;; 1. Fontifies variables in double quotes
|
;; 1. Fontifies variables in double quotes
|
||||||
;; 2. Fontify command substitution in double quotes
|
;; 2. Fontify command substitution in double quotes
|
||||||
;; 3. Fontify built-in/common commands (see `+sh-builtin-keywords')
|
;; 3. Fontify built-in/common commands (see `+sh-builtin-keywords')
|
||||||
(defun +sh|init-extra-fontification ()
|
(add-hook 'sh-mode-hook
|
||||||
(font-lock-add-keywords
|
(defun +sh-init-extra-fontification-h ()
|
||||||
nil `((+sh--match-variables-in-quotes
|
(font-lock-add-keywords
|
||||||
(1 'font-lock-constant-face prepend)
|
nil `((+sh--match-variables-in-quotes
|
||||||
(2 'font-lock-variable-name-face prepend))
|
(1 'font-lock-constant-face prepend)
|
||||||
(+sh--match-command-subst-in-quotes
|
(2 'font-lock-variable-name-face prepend))
|
||||||
(1 'sh-quoted-exec prepend))
|
(+sh--match-command-subst-in-quotes
|
||||||
(,(regexp-opt +sh-builtin-keywords 'words)
|
(1 'sh-quoted-exec prepend))
|
||||||
(0 'font-lock-type-face append)))))
|
(,(regexp-opt +sh-builtin-keywords 'words)
|
||||||
(add-hook 'sh-mode-hook #'+sh|init-extra-fontification)
|
(0 'font-lock-type-face append))))))
|
||||||
;; 4. Fontify delimiters by depth
|
;; 4. Fontify delimiters by depth
|
||||||
(add-hook 'sh-mode-hook #'rainbow-delimiters-mode)
|
(add-hook 'sh-mode-hook #'rainbow-delimiters-mode)
|
||||||
|
|
||||||
|
@ -51,14 +51,14 @@
|
||||||
(sp-local-pair 'sh-mode "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p))
|
(sp-local-pair 'sh-mode "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||||
|
|
||||||
;; sh-mode has file extensions checks for other shells, but not zsh, so...
|
;; sh-mode has file extensions checks for other shells, but not zsh, so...
|
||||||
(defun +sh|detect-zsh ()
|
(add-hook 'sh-mode-hook
|
||||||
(when (or (and buffer-file-name
|
(defun +sh-detect-zsh-h ()
|
||||||
(string-match-p "\\.zsh\\'" buffer-file-name))
|
(when (or (and buffer-file-name
|
||||||
(save-excursion
|
(string-match-p "\\.zsh\\'" buffer-file-name))
|
||||||
(goto-char (point-min))
|
(save-excursion
|
||||||
(looking-at-p "^#!.+/zsh[$ ]")))
|
(goto-char (point-min))
|
||||||
(sh-set-shell "zsh")))
|
(looking-at-p "^#!.+/zsh[$ ]")))
|
||||||
(add-hook 'sh-mode-hook #'+sh|detect-zsh))
|
(sh-set-shell "zsh")))))
|
||||||
|
|
||||||
|
|
||||||
(use-package! company-shell
|
(use-package! company-shell
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue