Skip to content

Instantly share code, notes, and snippets.

@Nek
Last active January 4, 2018 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nek/14301e726d22caee478c9207a83c1ff0 to your computer and use it in GitHub Desktop.
Save Nek/14301e726d22caee478c9207a83c1ff0 to your computer and use it in GitHub Desktop.
Dot files
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("org" . "http://orgmode.org/elpa/")
("sunrise" . "http://joseito.republika.pl/sunrise-commander/")))
(package-initialize)
(defun package-install-if-not (package)
"Install PACKAGE if it's not installed yet."
(unless (package-installed-p package)
(package-refresh-contents)
(package-install package)))
(package-install-if-not 'use-package)
(setq package-enable-at-startup nil)
(eval-when-compile
(require 'use-package))
(put 'use-package 'lisp-indent-function 1)
(setq use-package-always-ensure t)
;; recent files list by C-x C-r
(recentf-mode 1)
(setq recentf-max-menu-items 11)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
;; CTRL+T create new tab
;; CTRL+TAB switch between tabs
;; CTRL+shift+TAB mac-toggle-tab-group-overview
;; go to file or link by M-RET
(global-set-key (kbd "M-RET") 'find-file-at-point)
;; switch between tabs (mac only fewature)
(global-set-key (kbd "A-<right>") 'mac-next-tab)
(global-set-key (kbd "A-<left>") 'mac-previous-tab)
;; 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)))
;; auto close brackets
(electric-pair-mode 1)
;; make emacs ask for y or n instead of yes or no
(fset 'yes-or-no-p 'y-or-n-p)
;;(global-unset-key (kbd "M-SPC") )
;; prevent passing macos system shortcuts from emacs to the os (f.e. CMD + h)
(setq mac-pass-command-to-system nil)
;; there is no easy way to have some CMD + something shortcuts work
;; I've remapped switch imput source to Alt + SPC
;; and Alfred to Alt + Esc
;; prevent errors with external utils if the default shell isn't sh (I use fish)
(setq shell-file-name "/bin/sh")
;; used to maked modeline less cluttered
;; adds :diminish to use-package
(use-package diminish)
(use-package delight)
;; highlight matching parenthesis
(use-package paren
:init
(setq show-paren-style 'parenthesis)
:config
(show-paren-mode 1))
;; use project specific editor configs
(use-package editorconfig
:delight
:config
(editorconfig-mode 1))
;; used to manage personal key bindings
;; adds :bind to use-package
(use-package bind-key)
;; :quelpa keyword for use-package
(use-package quelpa)
(use-package quelpa-use-package)
;; make package menu awesome
(use-package paradox
:config
(paradox-enable))
;; make M-x much more convinient
(use-package smex
:defines smex-save-file
:config
(setq smex-save-file "~/.cache/emacs/smex-items")
(smex-initialize))
;; expand region by semantic units
(use-package expand-region
:bind
("C-=" . er/expand-region))
;; make help system better
(use-package helpful
:bind
(("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)))
;; give completion superpowers to emacs ui
;; C-c C-r to resume last ivy action
(use-package ivy
:delight
:config
(ivy-mode t)
(setq
ivy-use-virtual-buffers t
ivy-count-format "%d/%d ")
:bind
(("C-c C-r" . ivy-resume)))
;; shorter shortcuts for ivy
(use-package ivy-hydra)
;; ivy completion extras and custom shortcuts
(use-package counsel
:init
(require 'iso-transl)
:bind
(("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)))
;; nice forward search
(use-package counsel-extras
:ensure nil
:quelpa
(counsel-extras :repo "a13/counsel-extras" :fetcher github :version original)
:bind
(("C-s" . counsel-extras-grep-or-isearch-or-swiper)))
;; ivy for regex
(use-package swiper)
;; more friendly interface for ivy
(use-package ivy-rich
:defines ivy-rich-abbreviate-paths ivy-rich-switch-buffer-name-max-length
:config
(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))
;; move around screen by sequence of letters
(use-package avy
:config
(avy-setup-default)
:bind
(("C-:" . avy-goto-char)
("C-'" . avy-goto-char-2)
("M-g M-g" . avy-goto-line)
("M-g w" . avy-goto-word-1)))
;; great git client
(use-package magit)
;; 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)))
;; the silver searcher for emacs
(use-package ag)
;; project management tool
(use-package projectile
:init
(setq projectile-completion-system 'ivy)
:config
(diminish 'projectile-mode '(:eval
(let ((ppn (projectile-project-name)))
(unless (string= ppn "-")
(format " 📂%s" ppn)))))
(projectile-mode))
(use-package counsel-projectile
:config
(counsel-projectile-mode))
;; configurable code snippets ala textmate
(use-package yasnippet
:diminish yas-minor-mode
:config
(yas-reload-all)
(setq yas-prompt-functions '(yas-completing-prompt yas-ido-prompt))
:hook
(prog-mode . yas-minor-mode))
;; advanced syntax checker
;;(use-package flycheck
;; :diminish flycheck-mode
;; :hook
;; (prog-mode . flycheck-mode))
;; hide namespace prefix while editing elisp package
(use-package nameless
:hook
(emacs-lisp-mode . nameless-mode)
:config
(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
:config
(ipretty-mode 1))
;; complete everything, universal completion framework
(use-package company
:delight
:hook
(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
:init
(which-key-mode))
;; Fish shell syntax
(use-package fish-mode)
;; Scheme
(use-package geiser)
;; Clojure
(use-package clojure-mode
:delight "(λ)")
;; Additional syntax highlightning
(use-package clojure-mode-extra-font-locking)
(use-package clojure-snippets)
;; Exhaustive Clojure development package
(use-package cider
:config
;; sadly, we can't use :diminish keyword here, yet
(diminish 'cider-mode
'(:eval (format " 🍏%s" (cider--modeline-info)))))
;; Clojure code style fixer helper
(use-package kibit-helper)
;; JavaScript
(use-package js2-mode
:delight "{js}")
;; React
(use-package rjsx-mode
:delight "{jsx}")
;; Hints and autocompletion for JS
(use-package company-tern
:config
(add-to-list 'company-backends 'company-tern)
:hook
(js2-mode . (lambda ()
(tern-mode)
(company-mode)
(delight 'tern-mode "" 'tern))))
(use-package prettier-js
:diminish (prettier-js-mode . "👸🏻")
:hook
(js2-mode . prettier-js-mode)
(rxjs-mode . prettier-js-mode))
;; dumb goto definition which is actually quite smart
(use-package dumb-jump
:bind
(("M-g j" . dumb-jump-go)
("M-g p" . dumb-jump-back))
:init
(setq dumb-jump-selector 'ivy)
(setq dumb-jump-aggressive nil))
;; Make Emacs dark 🧛🏻‍♀️
(use-package zenburn-theme)
;; Add best font
(set-face-attribute 'default nil :family "Input" :height 160)
(use-package all-the-icons)
(setq initial-buffer-choice (recentf-open-files))
(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.
'(package-selected-packages (quote (quelpa-use-package quelpa diminish use-package)))
'(tramp-syntax (quote default) nil (tramp)))
(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.
)
(provide 'init)
\#*#
*.DS_Store
.DS_Store
*node_modules
*.tern-port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment