diff options
author | Jesus E <heckyel@riseup.net> | 2023-05-13 01:52:06 -0400 |
---|---|---|
committer | Jesus E <heckyel@riseup.net> | 2023-05-13 01:52:06 -0400 |
commit | af5244168e83610f68830184b2d40046e95fc0a4 (patch) | |
tree | c6347e36b884db1e6217e262e0c6c550b61a2f4c | |
parent | 4ee79f3999b5fb03e2bf6431a66d7915adb42170 (diff) | |
download | emacs-personal-af5244168e83610f68830184b2d40046e95fc0a4.tar.lz emacs-personal-af5244168e83610f68830184b2d40046e95fc0a4.tar.xz emacs-personal-af5244168e83610f68830184b2d40046e95fc0a4.zip |
Refactoring code
-rw-r--r-- | modules/init-doom-theme.el | 28 | ||||
-rw-r--r-- | modules/init-js-two.el | 50 |
2 files changed, 37 insertions, 41 deletions
diff --git a/modules/init-doom-theme.el b/modules/init-doom-theme.el index 7eb4af3..581b5af 100644 --- a/modules/init-doom-theme.el +++ b/modules/init-doom-theme.el @@ -7,17 +7,16 @@ :pin "MELPA" :ensure t :bind - ("C-x t d" . dark-theme) - ("C-x t s" . semi-dark-theme) - ("C-x t l" . light-theme) + (("C-x t d" . dark-theme) + ("C-x t s" . semi-dark-theme) + ("C-x t l" . light-theme)) :init (defun light-theme () "Activate light colortheme" (interactive) (load-theme 'doom-one-light) - (delete-selection-mode 1) - ) + (delete-selection-mode 1)) (defun dark-theme () "Activate dark colortheme" @@ -25,8 +24,7 @@ (load-theme 'doom-molokai) (delete-selection-mode 1) ;; Invoke customcolors - (darkcolor) - ) + (darkcolor)) (defun semi-dark-theme () "Activate semi-dark colortheme" @@ -34,11 +32,10 @@ (load-theme 'doom-molokai) (delete-selection-mode 1) ;; Invoke customcolors - (semidarkcolor) - ) + (semidarkcolor)) ;; Invoke theme - (load-theme 'doom-molokai t) ;; global + (load-theme 'doom-molokai t) :config (defun darkcolor () @@ -49,15 +46,14 @@ ;; Modeline (set-face-background 'mode-line "#0C0E10") - (set-face-background 'modeline-inactive "#333333") + (set-face-background 'mode-line-inactive "#333333") ;; (set-face-foreground 'mode-line "#FFFFFF") ;; Fix linum current-line highlight (defface my-linum-hl '((t :background "#0C0E10" :foreground "gold")) "Face for the currently active Line number" - :group 'linum) - ) + :group 'linum)) (defun semidarkcolor () "Simple semidarkcolor for theme." @@ -74,12 +70,10 @@ (defface my-linum-hl '((t :background "gray20" :foreground "gold")) "Face for the currently active Line number" - :group 'linum) - ) + :group 'linum)) ;; Invoke color - (semidarkcolor) ;; default - ) + (semidarkcolor)) (provide 'init-doom-theme) diff --git a/modules/init-js-two.el b/modules/init-js-two.el index 2e88d45..7162eb1 100644 --- a/modules/init-js-two.el +++ b/modules/init-js-two.el @@ -8,23 +8,19 @@ ;; https://github.com/mooz/js2-mode (use-package js2-mode :ensure t - :defer 20 - :hook ((js2-mode . (lambda () - (company-mode)))) - :mode (("\\.js\\'" . js2-mode)) + :pin "MELPA" + :mode ("\\.js'\\'" . js2-mode) + :hook (js2-mode . company-mode) :custom (js2-include-node-externs t) (js2-global-externs '("customElements")) (js2-highlight-level 3) (js2r-prefer-let-over-var t) - (js2r-prefered-quote-type 2) + (js2r-preferred-quote-type 2) (js-indent-align-list-continuation t) - (global-auto-highlight-symbol-mode t) - ;; use eslint_d insetad of eslint for faster linting - (flycheck-javascript-eslint-executable "eslint_d") :config + (setq-default flycheck-javascript-eslint-executable "eslint_d") (setq js-indent-level 2) - ;; patch in basic private field support (advice-add #'js2-identifier-start-p :after-until (lambda (c) (eq c ?#)))) @@ -34,12 +30,13 @@ (use-package js2-refactor :pin "MELPA" :after js2-mode - :bind - (:map js2-mode-map - ("C-k" . js2r-kill) - ("C-c h r" . js2-refactor-hydra/body)) - :hook ((js2-mode . js2-refactor-mode)) - :config (js2r-add-keybindings-with-prefix "C-c C-r") + :hook (js2-mode . js2-refactor-mode) + :config + ;; Add keybindings for js2-refactor with prefix "C-c C-r". + (js2r-add-keybindings-with-prefix "C-c C-r") + ;; Assign keybindings to kill an element in js2 and to open the js2-refactor's hydra menu. + (bind-key "C-k" 'js2r-kill js2-mode-map) + (bind-key "C-c h r" 'js2-refactor-hydra/body js2-mode-map) (defhydra js2-refactor-hydra (:color blue :hint nil) " @@ -82,21 +79,26 @@ ;; json-mode: Major mode for editing JSON files with emacs ;; https://github.com/joshwnj/json-mode -(use-package prettier-js - :pin "MELPA") (use-package json-mode - :pin "MELPA" :ensure t - :defer 20 + :pin "MELPA" + :mode ("\\.json\\'" "\\.jsonld\\'") :custom (json-reformat:indent-width 2) (json-reformat:pretty-string? t) (js-indent-level 2) - :mode "\\.js\\(?:on\\|[hl]int\\(rc\\)?\\)\\'" - :hook ((json-mode . prettier-js-mode)) - :bind (:package json-mode-map - :map json-mode-map - ("C-c <tab>" . json-mode-beautify))) + :hook + (json-mode . (lambda () + (add-hook 'before-save-hook 'json-mode-before-save nil t) + (prettier-js-mode))) + :bind + (:map json-mode-map + ("C-c <tab>" . json-mode-beautify))) + +(use-package prettier-js + :pin "MELPA" + :hook + ((js-mode typescript-mode css-mode scss-mode less-mode web-mode json-mode) . prettier-js-mode)) ;; eslintd-fix: Emacs minor-mode to automatically fix javascript with eslint_d. ;; https://github.com/aaronjensen/eslintd-fix/tree/master |