add prettier support

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2023-01-25 10:39:58 -05:00
parent b67eb916d9
commit 1cb5489db5
2 changed files with 34 additions and 0 deletions

View File

@ -440,6 +440,34 @@ in {
'';
};
add-node-modules-path = {
enable = true;
config = ''
(eval-after-load 'js2-mode
'(add-hook 'js2-mode-hook #'add-node-modules-path))
(eval-after-load 'typescript-mode
'(add-hook 'typescript-mode-hook #'add-node-modules-path))
(eval-after-load 'web-mode
'(add-hook 'web-mode-hook #'add-node-modules-path))
'';
};
prettier-js = {
enable = true;
after = [ "xe-tools" ];
config = ''
(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook #'(lambda ()
(xe/enable-minor-mode
'("\\.jsx?\\'" . prettier-js-mode))))
(add-hook 'web-mode-hook #'(lambda ()
(xe/enable-minor-mode
'("\\.tsx?\\'" . prettier-js-mode))))
'';
};
deno-fmt = {
enable = true;
config = ''

View File

@ -10,4 +10,10 @@
(interactive)
(insert "ಠ_ಠ"))
(defun xe/enable-minor-mode (my-pair)
"Enable minor mode if filename match the regexp. MY-PAIR is a cons cell (regexp . minor-mode)."
(if (buffer-file-name)
(if (string-match (car my-pair) buffer-file-name)
(funcall (cdr my-pair)))))
(provide 'xe-tools)