Skip to content

Instantly share code, notes, and snippets.

@davidpdrsn
Created December 15, 2015 18:51
Show Gist options
  • Select an option

  • Save davidpdrsn/64f0159f62d5f2c0af49 to your computer and use it in GitHub Desktop.

Select an option

Save davidpdrsn/64f0159f62d5f2c0af49 to your computer and use it in GitHub Desktop.
(load-file "~/.emacs.d/sensible-defaults.el")
(sensible-defaults/use-all-settings)
;;; Load emacs builtin package manager
;;; Load packages both from marmalade and melpa
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(setq package-enable-at-startup nil)
(package-initialize)
(defun ensure-package-installed (&rest packages)
"Assure every package is installed, ask for installation if it’s not.
Return a list of installed packages or nil for every skipped package."
(mapcar
(lambda (package)
(if (package-installed-p package)
nil
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package)
package)))
packages))
;; Make sure to have downloaded archive description.
(or (file-exists-p package-user-dir) (package-refresh-contents))
(package-initialize)
;; Dependencies
(ensure-package-installed 'evil
'evil-commentary
'evil-leader
'evil-surround
'helm
'helm-flx
'helm-fuzzier
'helm-projectile
'linum-relative
'projectile
'evil-magit
'projectile-rails
'ujelly-theme
'evil-jumper
'magit)
;;; Load evil mode
(require 'evil)
(global-evil-leader-mode)
(evil-leader/set-leader "<SPC>")
(evil-mode 1)
(require 'evil-surround)
(global-evil-surround-mode 1)
(setq evil-motion-state-modes (append evil-emacs-state-modes evil-motion-state-modes))
(setq evil-emacs-state-modes nil)
(require 'evil-jumper)
(evil-jumper-mode t)
(require 'magit)
(require 'evil-magit)
;;; Misc functions
(defun find-user-init-file ()
"Edit the `user-init-file', in another window."
(interactive)
(find-file-other-window user-init-file))
(defun reload-user-init-file ()
"Reload `user-init-file'."
(interactive)
(load-file user-init-file))
(defun normal-mode-and-save ()
"Enter normal mode and save buffer"
(interactive)
(evil-force-normal-state)
(save-buffer))
;;; Don't use tabs for indenting
(setq-default indent-tabs-mode nil)
;;; Leader keys
(evil-leader/set-key
"ev" 'find-user-init-file
"sv" 'reload-user-init-file
"x" 'execute-extended-command
;; "hf" 'describe-function
;; "hk" 'describe-key
"g" 'magit-status
"f" 'helm-projectile)
;;; Hide the toolbar
(menu-bar-mode -1)
(toggle-scroll-bar -1)
(tool-bar-mode -1)
;;; Color theme
(load-theme 'ujelly t)
;;; Key maps
(define-key evil-normal-state-map (kbd "C-u") 'evil-scroll-up)
(define-key evil-visual-state-map (kbd "C-u") 'evil-scroll-up)
;;; More natural movement between splits
;; (define-key evil-normal-state-map (kbd "C-h") 'evil-window-left)
;; (define-key evil-normal-state-map (kbd "C-l") 'evil-window-right)
;; (define-key evil-normal-state-map (kbd "C-j") 'evil-window-down)
;; (define-key evil-normal-state-map (kbd "C-k") 'evil-window-up)
(global-set-key (kbd "C-s") 'normal-mode-and-save)
;;; Projectile
(require 'projectile)
(require 'helm-projectile)
(projectile-global-mode)
(add-hook 'projectile-mode-hook 'projectile-rails-on)
(setq projectile-enable-caching t)
(setq projectile-switch-project-action 'projectile-dired)
(setq projectile-remember-window-configs t)
(setq projectile-completion-system 'helm)
(setq projectile-switch-project-action 'helm-projectile)
(helm-projectile-on)
;;; Helm
(require 'helm)
(helm-mode 1)
(helm-flx-mode +1)
(require 'helm-fuzzier)
(helm-fuzzier-mode 1)
(setq helm-M-x-fuzzy-match t
helm-bookmark-show-location t
helm-buffers-fuzzy-matching t
helm-completion-in-region-fuzzy-match t
helm-file-cache-fuzzy-match t
helm-imenu-fuzzy-match t
helm-mode-fuzzy-match t
helm-locate-fuzzy-match t
helm-quick-update t
helm-recentf-fuzzy-match t
helm-semantic-fuzzy-match t)
;;; Relative line numbers
(require 'linum-relative)
(linum-relative-global-mode)
;;; Commentary
(evil-commentary-mode)
;;; disable all alarms
(setq ring-bell-function 'ignore)
(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.
'(magit-commit-arguments nil))
(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.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment