Skip to content

Instantly share code, notes, and snippets.



Last active Mar 26, 2018
What would you like to do?
(require 'package)
(setq package-archives '(("gnu" . "")
("melpa" . "")
("marmalade" . "")
("org" . "")
("sunrise" . "")))
(defun package-install-if-not (package)
"Install PACKAGE if it's not installed yet."
(unless (package-installed-p package)
(package-install package)))
(package-install-if-not 'use-package)
(setq package-enable-at-startup nil)
(require 'use-package))
(put 'use-package 'lisp-indent-function 1)
(setq use-package-always-ensure t)
;; :quelpa keyword for use-I.
;; package-enable-at-need startup it to use packages directly from git repos.
(use-package quelpa)
(use-package quelpa-use-package)
;; Add :diminish and :delight to make mode-line less cluttered
(use-package diminish)
(use-package delight)
;; Add :bind to easily add package specific key bindings
(use-package bind-key)
(use-package exec-path-from-shell
:ensure t
:if (memq window-system '(mac ns x))
(setq exec-path-from-shell-variables '("PATH"))
;; Better list-packages
(use-package paradox
;; Fix some annoyances
;; Store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;; Disable lock files (they prevent simultaneous editing)
(setq create-lockfiles nil)
;; Set Emacs default shell
;; This prevents errors if you use a shell different from /bin/sh (I use fish)
(setq shell-file-name "/bin/sh")
;; Prevent passing MacOs system shortcuts from Emacs to the OS (f.e. CMD + h)
;; I couldn't make CMD+SPC work and had to remap "switch input source"
;; command to ALT+SPC
(setq mac-pass-command-to-system nil)
;; Make emacs ask for y or n instead of yes or no
(fset 'yes-or-no-p 'y-or-n-p)
;; Configure built-in features
;; Go to file or link by M-RET
(global-set-key (kbd "M-RET") 'find-file-at-point)
;; Auto close brackets
(electric-pair-mode 1)
(use-package treemacs)
;; M-x all-the-icons-install-fonts
(use-package all-the-icons)
(use-package all-the-icons-dired
(defun rg/all-the-icons-dired-hook ()
(setq-local all-the-icons-dired-displayed nil)
(define-minor-mode rg/all-the-icons-dired-mode
"Display all-the-icons icon for each files in a dired buffer."
:lighter " rg/all-the-icons-dired-mode"
(if (and (display-graphic-p) rg/all-the-icons-dired-mode)
(add-hook 'dired-after-readin-hook 'rg/all-the-icons-dired-hook t t)
(when (derived-mode-p 'dired-mode)
(remove-hook 'dired-after-readin-hook 'rg/all-the-icons-dired-hook t)
(dired-mode . rg/all-the-icons-dired-mode))
(use-package flycheck
:delight "")
;; List of recent files and projects on startup screen
(use-package dashboard
:diminish page-break-lines-mode
(setq dashboard-startup-banner "~/.emacs.d/acid.png")
(setq dashboard-banner-logo-title "🔥👹Welcome to Madness!👹🔥")
(setq dashboard-items '((recents . 7)
(projects . 7)))
;; Highlight matching parenthesis
(use-package paren
(setq show-paren-style 'parenthesis)
(show-paren-mode 1))
;; use project specific editor configs
(use-package editorconfig
(editorconfig-mode 1))
;; Add autocompletion to M-x
(use-package smex
:defines smex-save-file
(setq smex-save-file "~/.cache/emacs/smex-items")
;; Expand region by semantic units
(use-package expand-region
("C-=" . er/expand-region))
;; Make help system better
(use-package helpful
(("C-h f" . helpful-callable)
("C-h v" . helpful-variable)
("C-h k" . helpful-key)
("C-c C-d" . helpful-at-point)
("C-h F" . helpful-function)
("C-h C" . helpful-command)))
;; Completion for Emacs minibuffers
;; C-c C-r to resume last ivy action
(use-package ivy
(ivy-mode t)
ivy-use-virtual-buffers t
ivy-count-format "(%d/%d) ")
(("C-c C-r" . ivy-resume)))
;; Shorter shortcuts for ivy
(use-package ivy-hydra)
;; Ivy completion extras and custom shortcuts
(use-package counsel
(require 'iso-transl)
(("M-x" . counsel-M-x)
("M-y" . counsel-yank-pop)
("C-x C-f" . counsel-find-file)
("C-c C-SPC" . counsel-mark-ring)
("<f10>" . counsel-tmm)
:map iso-transl-ctl-x-8-map
("RET" . counsel-unicode-char)
:map help-map
("f" . counsel-describe-function)
("v" . counsel-describe-variable)
("b" . counsel-descbinds)))
;; Better search in buffer
(use-package counsel-extras
:ensure nil
(counsel-extras :repo "a13/counsel-extras" :fetcher github :version original)
(("C-s" . counsel-extras-grep-or-isearch-or-swiper)))
;; Ivy for regex
(use-package swiper)
;; Better interface for ivy
(use-package ivy-rich
:defines ivy-rich-abbreviate-paths ivy-rich-switch-buffer-name-max-length
(setq ivy-rich-abbreviate-paths t)
(setq ivy-rich-switch-buffer-name-max-length 45)
(ivy-set-display-transformer 'ivy-switch-buffer 'ivy-rich-switch-buffer-transformer))
;; Undo tree
(use-package undo-tree)
;; Git client
(use-package magit
("C-c g b" . magit-blame)
("C-c g m" . magit))
(use-package git-gutter
(global-git-gutter-mode +1)
'(git-gutter:update-interval 2)
'(git-gutter:modified-sign "*")
'(git-gutter:added-sign "+")
'(git-gutter:deleted-sign "-")
'(git-gutter:hide-gutter nil))
;; Highlight uncommitted changes
;; (use-package diff-hl
;; :hook
;; ((magit-post-refresh . diff-hl-magit-post-refresh)
;; (prog-mode . diff-hl-mode)
;; (dired-mode . diff-hl-dired-mode)))
(use-package git-link
("C-c g l" . git-link))
;; The silver searcher for emacs
(use-package ag)
;; Project management tool
(use-package projectile
(setq projectile-completion-system 'ivy)
(diminish 'projectile-mode '(:eval
(let ((ppn (projectile-project-name)))
(unless (string= ppn "-")
(format "%s " ppn)))))
(use-package counsel-projectile
("M-p" . counsel-projectile)
;; Configurable code snippets ala textmate
(use-package yasnippet
:diminish yas-minor-mode
(setq yas-prompt-functions '(yas-completing-prompt yas-ido-prompt))
(prog-mode . yas-minor-mode))
;; Hide namespace prefix while editing elisp package
(use-package nameless
(emacs-lisp-mode . nameless-mode)
(setq nameless-private-prefix t))
;; A tool that suggests elisp function by provided input and output
(use-package suggest)
;; Pretty print the result of the last evaluated elisp expression
(use-package ipretty
(ipretty-mode 1))
;; complete everything, universal completion framework
(use-package company
(after-init . global-company-mode)
;; Emojis for in Emacs! :cactus: -> 🌵
;; (use-package company-emoji
;; :config
;; (add-to-list 'company-backends 'company-emoji)
;; (set-fontset-font t 'symbol
;; (font-spec :family
;; (if (eq system-type 'darwin)
;; "Apple Color Emoji"
;; "Symbola"))
;; nil 'prepend))
;; Show keybindings for incomplete command
(use-package which-key
:diminish which-key-mode
(use-package htmlize)
;; Folding
;; (use-package hideshow
;; :hook
;; (prog-mode . hs-minor-mode)
;; :bind
;; ("C-<return>" . hs-toggle-hiding))
(use-package lisp-mode
:ensure nil
:delight ""
;; Fish shell syntax
(use-package fish-mode)
;; Scheme
(use-package geiser)
;; Clojure
(use-package clojure-mode
:delight "")
(use-package clojurescript-mode
:delight "")
;; Additional syntax highlightning
(use-package clojure-mode-extra-font-locking)
(use-package clojure-snippets)
;; Exhaustive Clojure development package
;; it formats buffer and attempts to return to original position.
(defun cider-format-buffer-back () (interactive)
(let (p)
(setq p (point))
(goto-char p)))
(defun add-clj-format-before-save () (interactive)
(add-hook 'before-save-hook
t t))
;; (add-hook 'clojure-mode-hook
;; 'add-clj-format-before-save)
(use-package cider
(setq cider-cljs-lein-repl
"(do (require 'figwheel-sidecar.repl-api)
;; sadly, we can't use :diminish keyword here, yet
(diminish 'cider-mode
'(:eval (format " 🍏%s " (cider--modeline-info))))
;; :hook
;; (clojure-mode . add-clj-format-before-save)
;; Clojure code style fixer helper
(use-package kibit-helper)
(use-package smartparens
(("C-c <right>" . sp-forward-slurp-sexp)
("C-c <left>" . sp-forward-barf-sexp))
(require 'smartparens-config)
(prog-mode . smartparens-mode))
(insert (all-the-icons-icon-for-file "eee.jsx"))
;; JavaScript
(use-package js2-mode
:delight ""
:diminish hs-mode
;; Disable js2 mode linting
(setq js2-mode-show-strict-warnings nil)
(setq js2-mode-show-parse-errors nil)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)))
;; (use-package js2-refactor
;; :diminish
;; :hook
;; (js2-mode . js2-refactor-mode)
;; )
(use-package indium
:diminish indium-interaction-mode
(js2-mode . indium-interaction-mode))
;; React
(use-package rjsx-mode
:delight ""
:diminish js2-mode
(add-to-list 'auto-mode-alist '("containers\\/.*\\.js\\'" . rjsx-mode)))
;;(insert (all-the-icons-icon-for-file "foo.html"))
;;(insert (all-the-icons-icon-for-file "foo.txt"))
;;(insert (all-the-icons-icon-for-file "foo.yaml"))
(use-package eldoc
:delight "")
(defun setup-tide-mode ()
"Set up Tide mode."
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save-mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
(company-mode +1))
(use-package tide
:ensure t
(setq tide-tsserver-executable "/usr/local/bin/tsserver")
(setq company-tooltip-align-annotations t)
(setq tide-sort-completions-by-kind t)
(setq tide-completion-detailed t)
(setq tide-hl-identifier-idle-time 0)
;; (add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'js2-mode-hook #'setup-tide-mode)
(flycheck-add-next-checker 'javascript-eslint 'javascript-tide 'append)
;; (add-hook 'web-mode-hook
;; (lambda ()
;; (when (string-equal "jsx" (file-name-extension buffer-file-name))
;; (setup-tide-mode))))
(flycheck-add-mode 'javascript-eslint 'web-mode)
(flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)
;; Code formatter
;; (use-package prettier-js
;; :diminish (prettier-js-mode . "👸🏻")
;; :hook
;; (js2-mode . prettier-js-mode)
;; (rjsx-mode . prettier-js-mode))
;; Go to a definition of anything and back
(use-package dumb-jump
(("M-g j" . dumb-jump-go)
("M-g p" . dumb-jump-back))
(setq dumb-jump-selector 'ivy)
(setq dumb-jump-aggressive nil))
;; Get rid of UI noise
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;; Make sortcuts work in cyrillic layout
(use-package reverse-im
(reverse-im-activate "russian-computer"))
;; Make Emacs dark
(use-package plan9-theme)
;; Set custom font
(set-face-attribute 'default nil :family "Input" :height 160)
"(do (require 'figwheel-sidecar.repl-api)
(figwheel-sidecar.repl-api/cljs-repl))") :diminish
;; 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.
"/Applications/Google Chrome Chrome Canary")
"(do (require 'figwheel-sidecar.repl-api)
'(git-gutter:added-sign "+")
'(git-gutter:deleted-sign "-")
'(git-gutter:hide-gutter nil)
'(git-gutter:modified-sign "*")
'(git-gutter:update-interval 2)
(indium quelpa-use-package quelpa diminish use-package)))
(".idea" ".ensime_cache" ".eunit" ".git" ".hg" ".fslckout" "_FOSSIL_" ".bzr" "_darcs" ".tox" ".svn" ".stack-work" "node_modules" "build" "config" "public" "scripts")))
'(tramp-syntax (quote default) nil (tramp)))
;; 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.
(provide 'init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.