First we’re going to add melpa as a source for packages
(require 'package)
(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 '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
Make sure use-package is available, if it’s not we install it.
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(setq use-package-ensure-all t)
(require 'use-package)
(setq custom-file "~/.emacs.d/.emacs-customize.el")
(load custom-file)
(setq backup-directory-alist
`(("." . ,(concat user-emacs-directory "backups"))))
(fset 'yes-or-no-p 'y-or-n-p)
(use-package windmove
:ensure nil
:bind
(("C-M-<left>". windmove-left)
("C-M-<right>". windmove-right)
("C-M-<up>". windmove-up)
("C-M-<down>". windmove-down)))
(global-unset-key [mouse-2])
(recentf-mode 1)
(setq recentf-max-saved-items 200)
(setq recentf-max-menu-items 50)
(setq recentf-exclude '("^/var/folders\\.*"
"COMMIT_EDITMSG\\'"
".*-autoloads\\.el\\'"
"[/\\]\\.elpa/"
))
Show path to file and, if available, the project name. Set titlebar style
(defun frame-title-format ()
"Return frame title with current project name, where applicable."
(concat
"emacs - "
(when (and (bound-and-true-p projectile-mode)
(projectile-project-p))
(format "[%s] - " (projectile-project-name)))
(let ((file buffer-file-name))
(if file
(abbreviate-file-name file)
"%b"))))
(setq-default frame-title-format '((:eval (frame-title-format))))
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))
(scroll-bar-mode 0)
(tool-bar-mode 0)
(menu-bar-mode 0)
(delete-selection-mode 1)
(global-auto-revert-mode 1)
(line-number-mode 1)
(column-number-mode 1)
(show-paren-mode 1)
(setq show-paren-style 'parenthesis)
(global-hl-line-mode 1)
(eldoc-mode 1)
(setq max-lisp-eval-depth 10000)
(add-hook 'prog-mode-hook (lambda () (interactive)(hs-minor-mode 1)))
(winner-mode 1)
(setq inhibit-startup-screen t)
(setq ring-bell-function 'ignore)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)
(global-set-key [remap dabbrev-expand] 'hippie-expand)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8-unix)
(defun dos2unix ()
"Replace DOS eolns CR LF with Unix eolns CR"
(interactive)
(goto-char (point-min))
(while (search-forward "\r" nil t) (replace-match "")))
(add-hook 'focus-out-hook (lambda () (interactive)(save-some-buffers t)))
;; save when frame is closed
(add-hook 'delete-frame-functions (lambda () (interactive)(save-some-buffers t)))
(defun back-to-indentation-or-beginning ()
"Replace jump-to-beginning with jump-to-indentation."
(interactive)
(if (= (point) (progn (back-to-indentation) (point)))
(beginning-of-line)))
(global-set-key (kbd "C-a") 'back-to-indentation-or-beginning)
(defun kill-dired-buffers ()
"Kill all dired buffers."
(interactive)
(mapc (lambda (buffer)
(when (eq 'dired-mode (buffer-local-value 'major-mode buffer))
(kill-buffer buffer)))
(buffer-list)))
(defun kill-other-buffers ()
"Kill all other buffers."
(interactive)
(mapc 'kill-buffer (delq (current-buffer) (buffer-list))))
(when (eq system-type 'darwin)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil))
;; load package
(require 'ansi-color)
;; function for colorizing
(defun colorize-buffer ()
(interactive)
(toggle-read-only)
(ansi-color-apply-on-region (point-min) (point-max))
(toggle-read-only))
;; add hook to apply the function when magit mode is enabled
(add-hook 'magit-mode-hook 'colorize-buffer)
We don’t want that annoying floating frame that ediff uses by default.
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(use-package monokai-theme
:ensure t
:config
(load-theme 'monokai t))
(use-package golden-ratio-scroll-screen
:ensure t
:bind(([remap scroll-down-command] . golden-ratio-scroll-screen-down)
([remap scroll-up-command] . golden-ratio-scroll-screen-up)))
(use-package undo-tree
:ensure t
:diminish undo-tree-mode
:demand
:config
(global-undo-tree-mode)
:bind(("C-z" . undo-tree-undo)
("C-M-z" . undo-tree-redo)))
(use-package dired-subtree
:ensure t)
(use-package hydra
:ensure t)
(use-package nyan-mode
:ensure t
:config
(nyan-mode)
(nyan-start-animation))
(use-package dired-sidebar
:ensure t)
(use-package ibuffer
:bind( "C-x C-b" . ibuffer))
(use-package ibuffer-sidebar
:after (ibuffer)
:ensure t)
(use-package editorconfig
:ensure t
:config
(editorconfig-mode 1))
(use-package wgrep
:ensure t)
(use-package smex
:ensure t)
(use-package dedicated
:ensure t)
(use-package htmlize
:ensure t)
(use-package ace-window
:ensure t
:bind([remap other-window] . ace-window)
:init
(setq aw-dispatch-always t)
:config
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0))))))
(use-package multiple-cursors
:ensure t
:bind("C-c m" . hydra-multiple-cursors/body))
(defhydra hydra-multiple-cursors (:hint nil)
"
^Up^ ^Down^ ^Miscellaneous^
----------------------------------------------
[_p_] Next [_n_] Next [_l_] Edit lines
[_P_] Skip [_N_] Skip [_a_] Mark all
[_M-p_] Unmark [_M-n_] Unmark [_q_] Quit"
("l" mc/edit-lines :exit t)
("a" mc/mark-all-like-this :exit t)
("n" mc/mark-next-like-this)
("N" mc/skip-to-next-like-this)
("M-n" mc/unmark-next-like-this)
("p" mc/mark-previous-like-this)
("P" mc/skip-to-previous-like-this)
("M-p" mc/unmark-previous-like-this)
("q" nil))
(use-package switch-buffer-functions
:ensure t
:init
(add-hook 'switch-buffer-functions (lambda (prev cur)
(interactive)
(save-some-buffers t))))
(use-package flycheck
:ensure t
:defer 1
:diminish (flycheck-mode . "Fly")
:config
(add-to-list 'flycheck-checkers 'lsp-ui)
:hook
(after-init . global-flycheck-mode))
(use-package adaptive-wrap
:ensure t)
(use-package yasnippet
:ensure t
:diminish yas-minor-mode
:hook
(prog-mode . yas-minor-mode)
:config
(yas-reload-all))
(use-package duplicate-thing
:ensure t
:bind(("C-c C-d" . duplicate-thing)))
(use-package exec-path-from-shell
:if (memq window-system '(mac ns x))
:ensure t
:config
(exec-path-from-shell-initialize))
(use-package visual-regexp
:ensure t)
(use-package smartparens
:ensure t
:init
(require 'smartparens-config)
:config
(sp-use-smartparens-bindings)
:hook (prog-mode . smartparens-mode))
(use-package projectile
:ensure t
:demand
:bind (:map projectile-mode-map
("C-c p" . projectile-command-map))
:init
(setq projectile-switch-project-action 'projectile-vc)
(setq projectile-mode-line
'(:eval
(format " Pr[%s]"
(projectile-project-name))))
:config
(projectile-mode))
(use-package expand-region
:ensure t
:bind(("C-=" . er/expand-region)
("C--" . er/contract-region)))
(use-package diminish
:ensure t
:config
(diminish 'auto-revert-mode))
;; (use-package rainbow-delimiters
;; :ensure t
;; :init
;; (add-hook 'prog-mode-hook 'rainbow-delimiters-mode-enable))
(use-package graphql-mode
:ensure t)
(use-package restclient
:ensure t
:mode ("\\.rest\\'" . restclient-mode))
(use-package company-restclient
:ensure t
:hook (restclient-mode . (lambda ()
(add-to-list 'company-backends 'company-restclient))))
(use-package vterm
:ensure t
:init
(defalias 'ansi-term (lambda (&rest _) (call-interactively #'vterm)))
(defalias 'term (lambda (&rest _) (call-interactively #'vterm))))
(use-package olivetti
:ensure t
:init
(setq olivetti-body-width 80))
(use-package helm
:ensure t
:demand
:diminish helm-mode
:init
:bind(("C-x f" . helm-recentf)
("C-x b" . helm-mini)
("C-c s" . helm-occur)
("C-c S" . helm-moccur)
("C-x C-b" . helm-buffers-list)
("C-x C-f" . helm-find-files)
("C-x C-r" . helm-resume))
:config
(helm-mode 1))
(use-package helm-swoop
:after (helm)
:ensure t
:bind
(("M-i" . helm-swoop)
("C-c M-i" . helm-multi-swoop)
("M-I" . helm-swoop-back-to-last-point)
("C-x M-i" . helm-multi-swoop-all)))
(use-package helm-smex
:ensure t
:after (helm smex)
:init
(setq helm-smex-show-bindings t)
:bind(([remap execute-extended-command] . helm-smex)
("M-X" . helm-smex-major-mode-commands)))
(use-package helm-projectile
:ensure t
:after (projectile helm)
:config
(helm-projectile-on))
(use-package helm-flx
:ensure t
:after (helm)
:config
(helm-flx-mode +1))
(use-package helm-fuzzier
:ensure t
:after (helm)
:config
(helm-fuzzier-mode +1))
(use-package helm-ag
:ensure t
:after (helm))
(use-package helm-dash
:ensure t
:after (helm))
(use-package helm-company
:ensure t
:after (helm company)
:bind (:map company-mode-map ("C-:" . helm-company)
:map company-active-map ("C-:" . helm-company)))
(use-package magit
:ensure t
:init
(setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1 )
:bind("C-x g" . magit-status)
:config
(magit-define-popup-switch 'magit-push-popup
?t "Follow tags" "--follow-tags")
;; Protect against accident pushes to upstream
(defadvice magit-push-current-to-upstream
(around my-protect-accidental-magit-push-current-to-upstream)
"Protect against accidental push to upstream.
Causes `magit-git-push' to ask the user for confirmation first."
(let ((my-magit-ask-before-push t))
ad-do-it))
(defadvice magit-git-push (around my-protect-accidental-magit-git-push)
"Maybe ask the user for confirmation before pushing.
Advice to `magit-push-current-to-upstream' triggers this query."
(if (bound-and-true-p my-magit-ask-before-push)
;; Arglist is (BRANCH TARGET ARGS)
(if (yes-or-no-p (format "Push %s branch upstream to %s? "
(ad-get-arg 0) (ad-get-arg 1)))
ad-do-it
(error "Push to upstream aborted by user"))
ad-do-it))
(ad-activate 'magit-push-current-to-upstream)
(ad-activate 'magit-git-push))
(use-package forge
:ensure t
:after magit)
(use-package git-link
:ensure t)
(use-package gitignore-mode
:ensure t)
(use-package diff-hl
:ensure t
:config
(global-diff-hl-mode))
(use-package org
:ensure t
:init
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
(setq org-confirm-babel-evaluate nil)
(setq org-src-window-setup 'current-window)
(setq org-startup-folded nil)
(setq org-edit-src-content-indentation 0)
(setq org-startup-indented t)
(setq org-fontify-whole-heading-line t)
(setq org-agenda-files (list "~/Dropbox/org/notes.org"
"~/Dropbox/org/personal.org"))
(setq org-plantuml-jar-path
(expand-file-name "~/Dropbox/jars/plantuml.jar"))
(setq org-ditaa-jar-path
(expand-file-name "~/Dropbox/jars/ditaa0_6b.jar"))
(setq org-ditaa-eps-jar-path
(expand-file-name "~/Dropbox/jars/DitaaEps.jar"))
:bind
(("C-c l" . 'org-store-link)
("C-c a" . 'org-agenda))
:config
(setenv "NODE_PATH"
(concat
(getenv "HOME") "/code/js-parser-test/node_modules" ":"
(getenv "NODE_PATH")))
(org-babel-do-load-languages
'org-babel-load-languages
'((restclient . t)
(browser . t)
(shell . t)
(scheme . t)
(gnuplot . t)
(plantuml . t)
(js . t))))
(use-package org-protocol)
(use-package ob-restclient
:ensure t)
(use-package ob-browser
:ensure t)
(use-package toc-org
:ensure t
:after org
:hook (org-mode . toc-org-enable))
(use-package gnuplot
:ensure t)
(use-package gnuplot-mode
:ensure t)
(use-package company
:ensure t
:diminish company-mode
:demand
:init
(setq company-idle-delay nil)
:config
(global-company-mode))
(use-package company-quickhelp
:ensure t
:after (company)
:config
(company-quickhelp-mode))
;; (use-package company-box
;; :ensure t
;; :hook (company-mode . company-box-mode))
Lsp allows us to utilize the same interface to multiple languages
(use-package lsp-mode
:ensure t
:commands lsp
:hook (js-mode . lsp))
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode)
(use-package company-lsp
:ensure t
:commands company-lsp
:config
(push 'company-lsp company-backends))
(setq js-switch-indent-offset 2)
(setq js-indent-level 2)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js-mode))
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . js-mode))
(add-to-list 'auto-mode-alist '("\\.ts\\'" . js-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . js-mode))
(use-package js2-mode
:ensure t
:init
(setq js2-mode-show-parse-errors nil)
(setq js2-mode-show-strict-warnings nil)
:hook
(js-mode . js2-minor-mode))
(use-package eslint-fix
:ensure t)
(use-package js2-refactor
:ensure t
:hook (js-mode . js2-refactor-mode)
:config
(js2r-add-keybindings-with-prefix "C-c C-m"))
(use-package add-node-modules-path
:ensure t
:hook (js-mode . add-node-modules-path))
(use-package indium
:ensure t
:diminish (indium-interaction-mode . "In" )
:hook (js-mode . indium-interaction-mode))
(use-package prettier-js
:ensure t
:after add-node-modules-path
:hook (js-mode . prettier-js-mode))
;;JSON
(use-package json-mode
:ensure t
:mode (("\\.json\\'" . json-mode)
("\\manifest.webapp\\'" . json-mode )
("\\.tern-project\\'" . json-mode)))
(use-package web-mode
:ensure t
:mode (("\\.phtml\\'" . web-mode)
("\\.tpl\\.php\\'" . web-mode)
("\\.blade\\.php\\'" . web-mode)
("\\.jsp\\'" . web-mode)
("\\.as[cp]x\\'" . web-mode)
("\\.erb\\'" . web-mode)
("\\.html?\\'" . web-mode)
("\\.ejs\\'" . web-mode)
("\\.php\\'" . web-mode)
("\\.mustache\\'" . web-mode)
("/\\(views\\|html\\|theme\\|templates\\)/.*\\.php\\'" . web-mode))
:init
(setq web-mode-markup-indent-offset 2)
(setq web-mode-attr-indent-offset 2)
(setq web-mode-attr-value-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-enable-auto-closing t)
(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-comment-keywords t)
(setq web-mode-enable-current-element-highlight t))
(use-package company-web
:ensure t
:hook (web-mode . (lambda ()
(add-to-list 'company-backends 'company-web-html)
(add-to-list 'company-backends 'company-web-jade)
(add-to-list 'company-backends 'company-web-slim))))
(use-package emmet-mode
:ensure t
:hook (web-mode sgml-mode html-mode css-mode))
(use-package rainbow-mode
:ensure t
:pin gnu
:hook css-mode)
(use-package simple-httpd
:ensure t)
(use-package impatient-mode
:ensure t)
(use-package python-mode
:ensure t)
(use-package company-jedi
:ensure t
:init
(add-hook 'python-mode-hook (add-to-list 'company-backends 'company-jedi)))
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init
(setq markdown-command "multimarkdown")
(setq markdown-header-scaling t))
(use-package geiser
:ensure t
:init
(setq geiser-chez-binary "chez")
(setq geiser-active-implementations '(chez)))
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
(use-package lua-mode
:ensure t
:mode ("\\.lua\\'" . lua-mode))
(use-package company-lua
:ensure t
:init
(add-hook 'lua-mode-hook (lambda ()
(add-to-list 'company-backends 'company-lua))))
(use-package fountain-mode
:ensure t)
(use-package cider
:ensure t)
(use-package yaml-mode
:ensure t)
This is an issue with Emacs 27 on Mac OS
(delete-file "~/Library/Colors/Emacs.clr")