Refactoring code

This commit is contained in:
Jesus E 2023-05-13 01:52:06 -04:00
parent 4ee79f3999
commit af5244168e
No known key found for this signature in database
GPG Key ID: 159C8F8BC9AED8B6
2 changed files with 37 additions and 41 deletions

View File

@ -7,17 +7,16 @@
:pin "MELPA" :pin "MELPA"
:ensure t :ensure t
:bind :bind
("C-x t d" . dark-theme) (("C-x t d" . dark-theme)
("C-x t s" . semi-dark-theme) ("C-x t s" . semi-dark-theme)
("C-x t l" . light-theme) ("C-x t l" . light-theme))
:init :init
(defun light-theme () (defun light-theme ()
"Activate light colortheme" "Activate light colortheme"
(interactive) (interactive)
(load-theme 'doom-one-light) (load-theme 'doom-one-light)
(delete-selection-mode 1) (delete-selection-mode 1))
)
(defun dark-theme () (defun dark-theme ()
"Activate dark colortheme" "Activate dark colortheme"
@ -25,8 +24,7 @@
(load-theme 'doom-molokai) (load-theme 'doom-molokai)
(delete-selection-mode 1) (delete-selection-mode 1)
;; Invoke customcolors ;; Invoke customcolors
(darkcolor) (darkcolor))
)
(defun semi-dark-theme () (defun semi-dark-theme ()
"Activate semi-dark colortheme" "Activate semi-dark colortheme"
@ -34,11 +32,10 @@
(load-theme 'doom-molokai) (load-theme 'doom-molokai)
(delete-selection-mode 1) (delete-selection-mode 1)
;; Invoke customcolors ;; Invoke customcolors
(semidarkcolor) (semidarkcolor))
)
;; Invoke theme ;; Invoke theme
(load-theme 'doom-molokai t) ;; global (load-theme 'doom-molokai t)
:config :config
(defun darkcolor () (defun darkcolor ()
@ -49,15 +46,14 @@
;; Modeline ;; Modeline
(set-face-background 'mode-line "#0C0E10") (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") ;; (set-face-foreground 'mode-line "#FFFFFF")
;; Fix linum current-line highlight ;; Fix linum current-line highlight
(defface my-linum-hl (defface my-linum-hl
'((t :background "#0C0E10" :foreground "gold")) '((t :background "#0C0E10" :foreground "gold"))
"Face for the currently active Line number" "Face for the currently active Line number"
:group 'linum) :group 'linum))
)
(defun semidarkcolor () (defun semidarkcolor ()
"Simple semidarkcolor for theme." "Simple semidarkcolor for theme."
@ -74,12 +70,10 @@
(defface my-linum-hl (defface my-linum-hl
'((t :background "gray20" :foreground "gold")) '((t :background "gray20" :foreground "gold"))
"Face for the currently active Line number" "Face for the currently active Line number"
:group 'linum) :group 'linum))
)
;; Invoke color ;; Invoke color
(semidarkcolor) ;; default (semidarkcolor))
)
(provide 'init-doom-theme) (provide 'init-doom-theme)

View File

@ -8,23 +8,19 @@
;; https://github.com/mooz/js2-mode ;; https://github.com/mooz/js2-mode
(use-package js2-mode (use-package js2-mode
:ensure t :ensure t
:defer 20 :pin "MELPA"
:hook ((js2-mode . (lambda () :mode ("\\.js'\\'" . js2-mode)
(company-mode)))) :hook (js2-mode . company-mode)
:mode (("\\.js\\'" . js2-mode))
:custom :custom
(js2-include-node-externs t) (js2-include-node-externs t)
(js2-global-externs '("customElements")) (js2-global-externs '("customElements"))
(js2-highlight-level 3) (js2-highlight-level 3)
(js2r-prefer-let-over-var t) (js2r-prefer-let-over-var t)
(js2r-prefered-quote-type 2) (js2r-preferred-quote-type 2)
(js-indent-align-list-continuation t) (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 :config
(setq-default flycheck-javascript-eslint-executable "eslint_d")
(setq js-indent-level 2) (setq js-indent-level 2)
;; patch in basic private field support
(advice-add #'js2-identifier-start-p (advice-add #'js2-identifier-start-p
:after-until :after-until
(lambda (c) (eq c ?#)))) (lambda (c) (eq c ?#))))
@ -34,12 +30,13 @@
(use-package js2-refactor (use-package js2-refactor
:pin "MELPA" :pin "MELPA"
:after js2-mode :after js2-mode
:bind :hook (js2-mode . js2-refactor-mode)
(:map js2-mode-map :config
("C-k" . js2r-kill) ;; Add keybindings for js2-refactor with prefix "C-c C-r".
("C-c h r" . js2-refactor-hydra/body)) (js2r-add-keybindings-with-prefix "C-c C-r")
:hook ((js2-mode . js2-refactor-mode)) ;; Assign keybindings to kill an element in js2 and to open the js2-refactor's hydra menu.
:config (js2r-add-keybindings-with-prefix "C-c C-r") (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) (defhydra js2-refactor-hydra (:color blue :hint nil)
" "
@ -82,22 +79,27 @@
;; json-mode: Major mode for editing JSON files with emacs ;; json-mode: Major mode for editing JSON files with emacs
;; https://github.com/joshwnj/json-mode ;; https://github.com/joshwnj/json-mode
(use-package prettier-js
:pin "MELPA")
(use-package json-mode (use-package json-mode
:pin "MELPA"
:ensure t :ensure t
:defer 20 :pin "MELPA"
:mode ("\\.json\\'" "\\.jsonld\\'")
:custom :custom
(json-reformat:indent-width 2) (json-reformat:indent-width 2)
(json-reformat:pretty-string? t) (json-reformat:pretty-string? t)
(js-indent-level 2) (js-indent-level 2)
:mode "\\.js\\(?:on\\|[hl]int\\(rc\\)?\\)\\'" :hook
:hook ((json-mode . prettier-js-mode)) (json-mode . (lambda ()
:bind (:package json-mode-map (add-hook 'before-save-hook 'json-mode-before-save nil t)
:map json-mode-map (prettier-js-mode)))
:bind
(:map json-mode-map
("C-c <tab>" . json-mode-beautify))) ("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. ;; eslintd-fix: Emacs minor-mode to automatically fix javascript with eslint_d.
;; https://github.com/aaronjensen/eslintd-fix/tree/master ;; https://github.com/aaronjensen/eslintd-fix/tree/master
(use-package eslintd-fix) (use-package eslintd-fix)