Skip to content

Instantly share code, notes, and snippets.

@kingscott
Last active November 28, 2019 21:02
Show Gist options
  • Save kingscott/5aedb1c7b35f24b9815363885f3d107a to your computer and use it in GitHub Desktop.
Save kingscott/5aedb1c7b35f24b9815363885f3d107a to your computer and use it in GitHub Desktop.
;;; package --- Summary
;;; Commentary:
(require 'package)
;; Required packages:
;; - neotree
;; add MELPA and MARMALADE to archives
;;; Code:
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
;; Kill *Messages* buffer
(setq message-log-max nil)
(kill-buffer "*Messages*")
;; Kill toolbar
(tool-bar-mode 0)
;; Remove scroll bar
(scroll-bar-mode 0)
;; Shut off the damn bell
(setq ring-bell-function 'ignore)
(setq visible-bell nil)
;; Don't use tabs
(setq-default indent-tabs-mode nil)
;; Turn off autosaving
(setq auto-save-default nil)
;; Make cursor not blink
(blink-cursor-mode 0)
;; Remove startup messages
(setq initial-scratch-message ";; Scratch")
(setq inhibit-startup-screen nil)
(setq initial-buffer-choice t)
;; Don't use backup files
(setq make-backup-files nil)
;; Don't generate buffer change files
;; The files that are: .#something.rb
(setq create-lockfiles nil)
(setq backup-directory-alist '(("." . "~/.Trash"))
backup-by-copying t ; Don't delink hardlinks
version-control t ; Use version numbers on backups
delete-old-versions t ; Automatically delete excess backups
kept-new-versions 20 ; how many of the newest versions to keep
kept-old-versions 5 ; and how many of the old
)
;; Move backup files somewhere else
(setq backup-directory-alist
`((".*" . ,"~/.Trash")))
(setq auto-save-file-name-transforms
`((".*" ,"~/.Trash" t)))
(setq-default line-spacing 3)
;;; Editor pane specific stuff
;; Add line numbers to all programming modes
(add-hook 'prog-mode-hook 'linum-mode)
(add-hook 'prog-mode-hook 'column-number-mode)
;; Remove trailing whitespace upon save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Show hidden files in neotree
(setq-default neo-show-hidden-files t)
(add-to-list 'load-path "~/.emacs.d/lisp")
(defun add-to-path (dir)
"Add DIR to PATH environment variable and Emacs' `exec-path' list."
(setenv "PATH" (concat dir ":" (getenv "PATH")))
(push dir exec-path))
(add-to-path "/usr/local/bin")
;; Start js2-mode on every .js file
(add-to-list 'auto-mode-alist '("\\.js\\'" . rjsx-mode))
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.hbs\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.scss\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
(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.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(ansi-color-names-vector
["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
'(compilation-message-face (quote default))
'(cua-global-mark-cursor-color "#2aa198")
'(cua-normal-cursor-color "#839496")
'(cua-overwrite-cursor-color "#b58900")
'(cua-read-only-cursor-color "#859900")
'(custom-safe-themes
(quote
("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" "6dd2b995238b4943431af56c5c9c0c825258c2de87b6c936ee88d6bb1e577cb9" default)))
'(fci-rule-color "#3E4451")
'(highlight-changes-colors (quote ("#d33682" "#6c71c4")))
'(highlight-symbol-colors
(--map
(solarized-color-blend it "#002b36" 0.25)
(quote
("#b58900" "#2aa198" "#dc322f" "#6c71c4" "#859900" "#cb4b16" "#268bd2"))))
'(highlight-symbol-foreground-color "#93a1a1")
'(highlight-tail-colors
(quote
(("#073642" . 0)
("#546E00" . 20)
("#00736F" . 30)
("#00629D" . 50)
("#7B6000" . 60)
("#8B2C02" . 70)
("#93115C" . 85)
("#073642" . 100))))
'(hl-bg-colors
(quote
("#7B6000" "#8B2C02" "#990A1B" "#93115C" "#3F4D91" "#00629D" "#00736F" "#546E00")))
'(hl-fg-colors
(quote
("#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36")))
'(hl-paren-colors (quote ("#2aa198" "#b58900" "#268bd2" "#6c71c4" "#859900")))
'(magit-diff-use-overlays nil)
'(nrepl-message-colors
(quote
("#dc322f" "#cb4b16" "#b58900" "#546E00" "#B4C342" "#00629D" "#2aa198" "#d33682" "#6c71c4")))
'(package-selected-packages
(quote
(php-mode alchemist elixir-mode scala-mode helm-rg helm add-node-modules-path prettier-js solarized-theme multiple-cursors flycheck rjsx-mode web-mode neotree atom-one-dark-theme)))
'(pos-tip-background-color "#073642")
'(pos-tip-foreground-color "#93a1a1")
'(prettier-js-args nil)
'(prettier-js-show-errors (quote buffer))
'(smartrep-mode-line-active-bg (solarized-color-blend "#859900" "#073642" 0.2))
'(standard-indent 2)
'(term-default-bg-color "#002b36")
'(term-default-fg-color "#839496")
'(vc-annotate-background nil)
'(vc-annotate-background-mode nil)
'(vc-annotate-color-map
(quote
((20 . "#dc322f")
(40 . "#c85d17")
(60 . "#be730b")
(80 . "#b58900")
(100 . "#a58e00")
(120 . "#9d9100")
(140 . "#959300")
(160 . "#8d9600")
(180 . "#859900")
(200 . "#669b32")
(220 . "#579d4c")
(240 . "#489e65")
(260 . "#399f7e")
(280 . "#2aa198")
(300 . "#2898af")
(320 . "#2793ba")
(340 . "#268fc6")
(360 . "#268bd2"))))
'(vc-annotate-very-old-color nil)
'(weechat-color-list
(quote
(unspecified "#002b36" "#073642" "#990A1B" "#dc322f" "#546E00" "#859900" "#7B6000" "#b58900" "#00629D" "#268bd2" "#93115C" "#d33682" "#00736F" "#2aa198" "#839496" "#657b83")))
'(xterm-color-names
["#073642" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#eee8d5"])
'(xterm-color-names-bright
["#002b36" "#cb4b16" "#586e75" "#657b83" "#839496" "#6c71c4" "#93a1a1" "#fdf6e3"]))
;; Setup standard .js file indent
(setq-default js-indent-level 2)
(setq-default js2-indent-level 2)
(setq-default rjsx-indent-level 2)
(setq-default js2-strict-trailing-comma-warning nil)
(defun my-web-mode-hook ()
"Hooks for Web mode. Adjust indents"
;;; http://web-mode.org/
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-attr-indent-offset 2)
)
(add-hook 'web-mode-hook 'my-web-mode-hook)
;; Set theme
(load-theme 'atom-one-dark t)
;; Fira Code
(when (window-system)
(set-frame-font "Fira Code Retina 12"))
(let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
(35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
(36 . ".\\(?:>\\)")
(37 . ".\\(?:\\(?:%%\\)\\|%\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
(45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
;; (46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=-]\\)")
(47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
(48 . ".\\(?:x[a-zA-Z]\\)")
;; (58 . ".\\(?:::\\|[:=]\\)")
(59 . ".\\(?:;;\\|;\\)")
(60 . ".\\(?:\\(?:!--\\)\\|\\(?:~~\\|->\\|\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[*$+~/<=>|-]\\)")
(61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
(62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
(63 . ".\\(?:\\(\\?\\?\\)\\|[:=?]\\)")
(91 . ".\\(?:]\\)")
(92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
(94 . ".\\(?:=\\)")
(119 . ".\\(?:ww\\)")
(123 . ".\\(?:-\\)")
(124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
(126 . ".\\(?:~>\\|~~\\|[>=@~-]\\)")
)
))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
;; Add Cmd+\ to toggle neotree
(global-set-key (kbd "s-\\") 'neotree-toggle)
;; Add toggle for comments
(global-set-key (kbd "s-/") 'comment-or-uncomment-region)
;; For multiple cursors
(global-set-key (kbd "C-c m c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
;; HELM STUFF ;;
(global-set-key (kbd "M-x") #'helm-M-x)
;; (global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
;; helm-rg
(global-set-key (kbd "C-h C-r") #'helm-rg)
; open helm buffer inside current window, not occupy whole other window
(setq helm-split-window-in-side-p t)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
;; Enable helm mode
(helm-mode 1)
;;; .emacs ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment