Files
emacs-personal/modules/init-web-mode.el
Astounds fa9b2a92c2
All checks were successful
git-sync-with-mirror / test (push) Successful in 3m18s
git-sync-with-mirror / git-sync (push) Successful in 15s
ci: add test workflow and fix code quality issues
- Add CI test job with Emacs batch load and byte-compile
- Fix settings-file variable check in init.el
- Fix extra parenthesis in init-neotree.el
- Add missing projectile dependencies in neotree and web-mode
- Fix add-hook usage in init-icons.el
- Add hydra dependency in init-ivy.el
- Standardize header style in init-company.el
2026-02-27 23:34:18 -05:00

77 lines
2.5 KiB
EmacsLisp

;;; init-web-mode.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package web-mode
:after projectile
:pin "MELPA"
:mode (("\\.html?\\'" . web-mode)
("\\.djhtml\\'" . web-mode)
("\\.blade.php\\'" . web-mode)
("\\.tpl\\'" . web-mode)
("\\.twig\\'" . web-mode)
("\\.jsp\\'" . web-mode)
("\\.gsp\\'" . web-mode)
("\\.scss\\'" . web-mode)
("\\.tsx\\'" . web-mode)
("\\.ctp\\'" . web-mode))
:config
;; web-modeの設定
(setq web-mode-enable-current-element-highlight t)
(set-face-background 'web-mode-current-element-highlight-face "#616161")
;; Fix smarty
(setq web-mode-engines-alist
'(("smarty" . "\\.tpl\\'")))
;; Django hook
;; require projectile
(defun my-django-mode ()
(when (and (require 'web-mode nil t)
(fboundp 'web-mode-set-engine))
(if (projectile-project-p)
(when (file-exists-p (concat (projectile-project-root) "manage.py"))
(web-mode-set-engine "django")
;; HTML auto functions
(setq web-mode-enable-auto-opening t)
(setq web-mode-enable-auto-closing t)
(setq web-mode-enable-auto-quoting t)
(setq web-mode-enable-auto-expanding t)
;; Auto-pairing
(require 'smartparens)
(sp-pair "{% " " %}")
(sp-pair "{{ " " }}")
(sp-pair "{# " " #}")
(sp-pair "{" nil :actions :rem)
(sp-pair "<" ">")
(setq web-mode-enable-auto-pairing nil)))))
;; Pelican hook
(defun my-pelican-mode ()
(when (and (require 'web-mode nil t)
(fboundp 'web-mode-set-engine))
(if (projectile-project-p)
(when (file-exists-p (concat (projectile-project-root) "pelicanconf.py"))
(web-mode-set-engine "django")
;; HTML auto functions
(setq web-mode-enable-auto-opening t)
(setq web-mode-enable-auto-closing t)
(setq web-mode-enable-auto-quoting t)
(setq web-mode-enable-auto-expanding t)
;; Auto-pairing
(require 'smartparens)
(sp-pair "{% " " %}")
(sp-pair "{" nil :actions :rem)
(sp-pair "<" ">")
(setq web-mode-enable-auto-pairing nil)))))
:hook
(web-mode . my-django-mode)
(web-mode . my-pelican-mode))
(provide 'init-web-mode)
;;; init-web-mode.el ends here