mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-02 14:53:38 -05:00
I removed the grammar recipes in3b58741
to avoid redundancy with the upstream recipes, but didn't realize that those upstream recipes weren't added until Emacs 31, so users on 30 and older would get errors when trying to install any missing grammars. This also establishes a hard dependency between :lang (php +tree-sitter) and :lang ({javascript,web} +tree-sitter). Amend:3b58741522
85 lines
2.7 KiB
EmacsLisp
85 lines
2.7 KiB
EmacsLisp
;;; lang/web/+css.el -*- lexical-binding: t; -*-
|
|
|
|
(defvar +web-continue-block-comments t
|
|
"If non-nil, newlines in block comments are continued with a leading *.
|
|
|
|
This also indirectly means the asterisks in the opening /* and closing */ will
|
|
be aligned.
|
|
|
|
If set to `nil', disable all the above behaviors.")
|
|
|
|
(add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.\\(\\(s[ac]\\|le\\)ss\\|styl\\)\\'" "\\1\\.css\\'"))
|
|
(add-to-list 'find-sibling-rules '("/\\([^/]+\\)\\.css\\'" "\\1\\.\\(\\(s[ac]\\|le\\)ss\\|styl\\)\\'"))
|
|
|
|
|
|
;;
|
|
;;; Major modes
|
|
|
|
(setq-hook! 'css-mode-hook
|
|
;; Correctly continue /* and // comments on newline-and-indent
|
|
comment-line-break-function #'+css/comment-indent-new-line
|
|
;; Fix `fill-paragraph' not conjoining line comments in CSS modes correctly.
|
|
adaptive-fill-function #'+css-adaptive-fill-fn
|
|
;; Fix filled lines not being auto-prefixed with a * when needed.
|
|
adaptive-fill-first-line-regexp "\\'[ \t]*\\(?:\\* *\\)?\\'")
|
|
|
|
(after! (:any css-mode sass-mode)
|
|
(set-docsets! '(css-mode scss-mode sass-mode)
|
|
"CSS" "HTML" "Bourbon" "Compass"
|
|
["Sass" (memq major-mode '(scss-mode sass-mode))]))
|
|
|
|
(add-hook! '(css-mode-hook sass-mode-hook stylus-mode-hook)
|
|
#'rainbow-mode)
|
|
|
|
;; built-in. Contains both css-mode & scss-mode
|
|
(after! css-mode
|
|
;; css-mode hooks apply to scss and less-css modes
|
|
(map! :localleader
|
|
:map scss-mode-map
|
|
"b" #'+css/scss-build
|
|
:map (css-mode-map scss-mode-map less-css-mode-map)
|
|
"rb" #'+css/toggle-inline-or-block)
|
|
|
|
(use-package! counsel-css
|
|
:when (modulep! :completion ivy)
|
|
:hook (css-mode . counsel-css-imenu-setup)
|
|
:init
|
|
(map! :map (css-mode-map scss-mode-map less-css-mode-map)
|
|
:localleader ";" #'counsel-css))
|
|
|
|
(use-package! helm-css-scss
|
|
:when (modulep! :completion helm)
|
|
:defer t
|
|
:init
|
|
(map! :map (css-mode-map scss-mode-map less-css-mode-map)
|
|
:localleader ";" #'helm-css-scss)
|
|
:config
|
|
(setq helm-css-scss-split-direction #'split-window-vertically
|
|
helm-css-scss-split-with-multiple-windows t)))
|
|
|
|
|
|
(after! sass-mode
|
|
(set-company-backend! 'sass-mode 'company-css)
|
|
(map! :map sass-mode-map :localleader "b" #'+css/sass-build))
|
|
|
|
|
|
;;
|
|
;;; Tools
|
|
|
|
(when (modulep! +lsp)
|
|
(add-hook! '(css-mode-local-vars-hook
|
|
scss-mode-local-vars-hook
|
|
sass-mode-local-vars-hook
|
|
less-css-mode-local-vars-hook)
|
|
:append #'lsp!))
|
|
|
|
|
|
(use-package! css-ts-mode ; 29.1+ only
|
|
:when (modulep! +tree-sitter)
|
|
:defer t
|
|
:init
|
|
(set-tree-sitter! 'css-mode 'css-ts-mode
|
|
'((css :url "https://github.com/tree-sitter/tree-sitter-css"
|
|
:rev "v0.23.0"
|
|
:commit "6a442a3cf461b0ce275339e5afa178693484c927"))))
|