Skip to content

Instantly share code, notes, and snippets.

@coetry
Created November 7, 2018 18:54
Show Gist options
  • Save coetry/28595366c3d765f073e707c392dca6e2 to your computer and use it in GitHub Desktop.
Save coetry/28595366c3d765f073e707c392dca6e2 to your computer and use it in GitHub Desktop.
emacs config
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(initial-scratch-message ";; bismilLah
")
'(package-selected-packages
(quote
(emmet-mode prettier-js add-node-modules-path flycheck-color-mode-line web-mode slime evil))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(require 'package)
(require 'prettier-js)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'auto-mode-alist '("\\.jsx?$" . web-mode)) ;; auto-enable for .js/.jsx files
(setq web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'")))
(defun web-mode-init-hook ()
"Hooks for Web mode. Adjust indent."
(setq web-mode-markup-indent-offset 2)
(funcall emmet-mode))
(add-hook 'web-mode-hook 'web-mode-init-hook)
(add-hook 'web-mode-hook 'emmet-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
(setq prettier-js-args '(
"--trailing-comma" "none"
"--no-semi"
"--bracket-spacing" "false"
"--single-quote"
"--jsx-single-quote"
))
(defun 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)))))
(add-hook 'web-mode-hook #'(lambda ()
(enable-minor-mode
'("\\.jsx?\\'" . prettier-js-mode))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment