Skip to content

Instantly share code, notes, and snippets.

@nfaggian
Last active February 9, 2016 22:18
Show Gist options
  • Save nfaggian/aafebbddac59e662ae75 to your computer and use it in GitHub Desktop.
Save nfaggian/aafebbddac59e662ae75 to your computer and use it in GitHub Desktop.
.emacs
;;; emacs.d --- emacs configuration.
;;; Commentary: current configuration (2016)
;;; Code:
(setq user-full-name "Nathan Faggian"
user-mail-address "[email protected]")
;; Packages
;; ============================================================
(load "package")
(setq req-packages '(
color-theme
git
gist
helm-flycheck
flycheck
helm-spotify
helm-swoop
helm
async
highlight-current-line
highlight-indentation
highlight-parentheses
idle-highlight-mode
jedi
auto-complete
epc
ctable
concurrent
magit
git-rebase-mode
git-commit-mode
multiple-cursors
nav
popup
popwin
projectile
pkg-info
epl
dash
python-environment
python-mode
request-deferred
request
deferred
revive
s
scratch
smooth-scrolling
))
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/"))
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/"))
(setq package-archive-enable-alist '(("melpa" deft magit)))
(when (not package-archive-contents)
(package-refresh-contents))
(dolist (pkg req-packages)
(when (and (not (package-installed-p pkg))
(assoc pkg package-archive-contents))
(package-install pkg)))
;; Scratch
;; ============================================================
(autoload 'scratch "scratch" nil t)
;; Backup
;; ============================================================
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq delete-old-versions -1)
(setq version-control t)
(setq vc-make-backup-files t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
;; History
;; ============================================================
(setq savehist-file "~/.emacs.d/savehist")
(savehist-mode 1)
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
'(kill-ring
search-ring
regexp-search-ring))
;; Window
;; ============================================================
(setq custom-safe-themes t)
(load-theme 'leuven)
(when window-system
(tooltip-mode 1)
(tool-bar-mode -1)
(menu-bar-mode 1)
(scroll-bar-mode -1)
(cua-mode 1)
(desktop-save-mode 1)
(setq frame-title-format '(buffer-file-name "%f" ("%b"))))
(when (fboundp 'winner-mode)
(winner-mode 1))
;; Tab and yes/no
;; ============================================================
(setq tab-width 4
indent-tabs-mode nil)
(defalias 'yes-or-no-p 'y-or-n-p)
;; Helm configuration
;; ============================================================
(require 'helm)
(require 'helm-config)
;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z
(when (executable-find "curl")
(setq helm-google-suggest-use-curl-p t))
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
helm-ff-file-name-history-use-recentf t)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(helm-mode 1)
;; Smart mode line
;; ============================================================
(sml/setup)
(setq sml/no-confirm-load-theme t)
;; Undo tree
;; ============================================================
(defalias 'redo 'undo-tree-redo)
(global-set-key (kbd "C-z") 'undo)
;; Font
;; ============================================================
(set-frame-font "Source Code Pro")
;; Aliases
;; ============================================================
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
(global-set-key (kbd "RET") 'newline-and-indent)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-c C-k") 'compile)
(global-set-key (kbd "C-x g") 'magit-status)
(setq magit-last-seen-setup-instructions "1.4.0")
;; Programming - autocomplete
;; ============================================================
(require 'pos-tip)
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
(global-auto-complete-mode t)
(ac-flyspell-workaround)
(ac-linum-workaround)
(setq ac-ignore-case 'smart)
(setq ac-menu-height 5)
(setq ac-auto-show-menu 0.8)
(setq popup-use-optimized-column-computation nil)
(require 'highlight-parentheses)
(require 'highlight-current-line)
(global-hl-line-mode t)
(add-hook 'after-init-hook #'global-flycheck-mode)
;; Delete trailing whitespaces
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(show-paren-mode 1)
(setq visible-bell 1)
(global-linum-mode 1)
(set-face-attribute 'linum nil :height 100)
;; Programming - python
;; ============================================================
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("/work/nfaggian/anaconda/bin/python" . python-mode))
(add-hook 'python-mode-hook (lambda ()
(require 'sphinx-doc)
(sphinx-doc-mode t)))
(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t) ; optional
(setq jedi:complete-on-dot t) ; optional
(eval-after-load "jedi"
'(setq jedi:server-command (list "/work/nfaggian/anaconda/bin/python" jedi:server-script)))
;; Programming - F#
;; ============================================================
(require 'fsharp-mode)
(setq inferior-fsharp-program "/usr/bin/fsharpi")
(setq fsharp-compiler "/usr/bin/fshapc")
;; Programming - javascript
;; ============================================================
(add-hook 'js-mode-hook 'js2-minor-mode)
(add-hook 'js2-mode-hook 'ac-js2-mode)
(setq js2-highlight-level 3)
(require 'flycheck)
(add-hook 'js-mode-hook
(lambda () (flycheck-mode t)))
;; Multiple cursors
;; ============================================================
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-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)
;; Highlight symbol
;; ============================================================
(require 'highlight-symbol)
(global-set-key [(control f3)] 'highlight-symbol)
(global-set-key [f3] 'highlight-symbol-next)
(global-set-key [(shift f3)] 'highlight-symbol-prev)
(global-set-key [(meta f3)] 'highlight-symbol-query-replace)
;; Projectile
;; ============================================================
(projectile-global-mode t)
(setq projectile-completion-system 'helm-comp-read)
;; Magit
;; ============================================================
(setq magit-auto-revert-mode nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment