summaryrefslogtreecommitdiff
path: root/emacs.d/init.el
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2017-04-27 09:51:29 -0700
committerFranck Cuny <franck.cuny@gmail.com>2017-04-27 09:51:29 -0700
commita862e0bbdecc9c3a5eae8ab60181eeaff5ab1699 (patch)
treeda8c484f28d85c1265900f706815c705c5c341ca /emacs.d/init.el
parent[Emacs] fix a comment (diff)
downloademacs.d-a862e0bbdecc9c3a5eae8ab60181eeaff5ab1699.tar.gz
[Emacs] Move packages configuration to a new file.
Keep `init.el` as small as possible, and move all the packages to their own configuration file.
Diffstat (limited to '')
-rw-r--r--emacs.d/init.el470
1 files changed, 12 insertions, 458 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el
index cfff32d..440a879 100644
--- a/emacs.d/init.el
+++ b/emacs.d/init.el
@@ -1,460 +1,14 @@
-;; setup packages
-(require 'package)
-(setq package-user-dir (expand-file-name "var/elpa" user-emacs-directory)
- package-enable-at-startup nil
- package-archives (append package-archives
- '(("melpa" . "https://melpa.milkbox.net/packages/"))))
-
-(package-initialize)
-
-(unless package-archive-contents
- (message "Refreshing ELPA package archives...")
- (package-refresh-contents))
-
-;; install the package 'use-package' unless it's already installed
-(unless (package-installed-p 'use-package)
- (progn
- (package-install 'use-package)))
-
-;; ... and load 'use-package'
-(require 'use-package)
-
-(use-package settings
- :load-path (lambda () (expand-file-name "lib" user-emacs-directory)))
-
-(use-package funcs
- ;; Contains some functions
- :load-path (lambda () (expand-file-name "lib" user-emacs-directory))
- :commands (fc/load-time)
- :bind (("s-=" . fc/scale-up-font)
- ("s--" . fc/scale-down-font)
- ("s-0" . fc/reset-font-size)))
-
-(use-package bindings
- ;; my own custom bindings
- :load-path (lambda () (expand-file-name "lib" user-emacs-directory)))
-
-(use-package server
- ;; start emacs server if not already running
- :config
- (unless (server-running-p) (server-start)))
-
-(use-package diminish
- ;; remove clutter from the mode line
- :ensure t)
-
-(use-package ag
- ;; interface to the 'ag' tool
- :ensure t
- :commands (counsel-ag ag)
- :bind (:map ag-mode-map
- ("p" . compilation-previous-error)
- ("n" . compilation-next-error)
- ("N" . compilation-next-file)
- ("P" . compilation-previous-file))
- :config
- (setq ag-highlight-search t
- ag-reuse-buffers t
- ag-reuse-window t))
-
-(use-package autorevert
- ;; automatically revert the buffer if the content changed on disk
- :diminish auto-revert-mode)
-
-(use-package company
- ;; provide completion
- :ensure t
- :config
- (global-company-mode))
-
-(use-package company-go
- :ensure t
- ;; completion for golang
- :init (with-eval-after-load 'company
- (add-to-list 'company-backends 'company-go)))
-
-(use-package counsel
- ;; completion functions for ivy
- :ensure t
-
- :bind*
- (("M-x" . counsel-M-x)
- ("C-s" . counsel-grep-or-swiper)
- ("C-x C-f" . counsel-find-file)
- ("C-x C-r" . counsel-recentf)
- ("C-c f" . counsel-git)
- ("C-c s" . counsel-git-grep)
- ("C-c /" . counsel-ag))
-
- :config
- (setq counsel-find-file-at-point t))
-
-(use-package dired
- ;; configuration for dired
- :bind ("C-x C-d" . dired)
-
- :config
- (let ((gls "/opt/twitter/bin/gls"))
- (if (file-exists-p gls)
- (setq insert-directory-program gls
- dired-listing-switches "-aBhl --group-directories-first")))
- (use-package dired-x
- :init
- (add-hook 'dired-load-hook (lambda () (load "dired-x")))
- :config
- (add-hook 'dired-mode-hook #'dired-omit-mode)
- (setq dired-omit-verbose nil)
- (setq dired-omit-files
- (concat dired-omit-files "\\|^.DS_Store$\\|^.projectile$\\|^.git$"))))
-
-(use-package dockerfile-mode
- ;; support for dockerfile mode
- :ensure t)
-
-(use-package lisp-mode
- ;; simple configuration for various lisp mode
- :config
- (add-hook 'emacs-lisp-mode-hook
- (lambda()
- (setq mode-name "λ"))))
-
-(use-package eldoc
- ;; documentation with eldoc
- :ensure t
-
- :commands eldoc-mode
-
- :diminish ""
-
- :init
- (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
- (add-hook 'lisp-interaction-mode-hook 'eldoc-mode))
-
-(use-package exec-path-from-shell
- ;; environment fixup for macOS.
- :ensure t
-
- :if (and (eq system-type 'darwin) (display-graphic-p))
-
- :init
- (setq exec-path-from-shell-check-startup-files nil)
-
- :config
- (progn
- (setq exec-path-from-shell-debug t)
- (exec-path-from-shell-initialize)))
-
-(use-package flycheck
- ;; check syntax
- :ensure t
-
- :config
- (progn
-
- (add-hook 'prog-mode-hook 'flycheck-mode)
-
- (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))
- (setq flycheck-highlighting-mode 'lines)
- (setq flycheck-check-syntax-automatically '(mode-enabled save))))
-
-(use-package flyspell
- ;; check the spelling
- :ensure t
-
- :init
- (progn
- (setq ispell-program-name "aspell"
- ispell-list-command "--list")
- (add-hook 'text-mode-hook 'flyspell-mode))
-
- :config
- (use-package flyspell-popup
- :ensure t
- :bind ("C-:" . flyspell-popup-correct)))
-
-(use-package geiser
- ;; to work with various schemes
- :ensure t
-
- :config
- (progn
- (setq geiser-default-implementation 'racket
- geiser-racket-binary "~/src/devbox/racket/racket-repl.sh")))
-
-(use-package go-mode
- ;; support for go
- :mode (("\\.go\\'" . go-mode))
-
- :ensure t
-
- :config
- (progn
- (when (memq window-system '(mac ns x))
- (dolist (var '("GOPATH"))
- (unless (getenv var)
- (exec-path-from-shell-copy-env var))))
-
- (use-package go-eldoc
- :ensure t
- :config
- (add-hook 'go-mode-hook 'go-eldoc-setup))
-
- (use-package gotest
- :ensure t)
-
- (use-package go-guru
- :ensure t)
-
- (defun fc/my-go-hook ()
- (set (make-local-variable 'compile-command)
- "go build -v && go test -v && go vet")
- (setq-local tab-width 4)
- (make-variable-buffer-local 'whitespace-style)
- (setq whitespace-style (delq 'tabs whitespace-style)))
-
- (add-hook 'before-save-hook 'gofmt-before-save)
- (add-hook 'go-mode-hook 'fc/my-go-hook)))
-
-(use-package ibuffer
- ;; configuration for ibuffer
- :ensure t
- :defer t
- :bind ("C-x C-b" . ibuffer)
- :init
- (setq-default ibuffer-eliding-string "…")
- (setq ibuffer-show-empty-filter-groups nil
- ibuffer-formats '((mark modified read-only " "
- (name 30 30 :left :elide)
- " "
- (size 9 -1 :right)
- " "
- (mode 16 16 :left :elide)
- " " filename-and-process)
- (mark " "
- (name 16 -1)
- " " filename))
- ibuffer-saved-filter-groups
- (quote (("default"
- ("dired" (mode . dired-mode))
- ("elisp" (mode . emacs-lisp-mode))
- ("emacs" (or (name . "^\\*.*\\*$") (mode . fundamental-mode)))
- ("go" (mode . go-mode))
- ("java" (mode . java-mode))
- ("json" (mode . json-mode))
- ("lisp" (mode . lisp-mode))
- ("magit" (mode . magit-mode))
- ("puppet" (mode . puppet-mode))
- ("python" (mode . python-mode))
- ("repl" (name . "repl"))
- ("ruby" (mode . ruby-mode))
- ("sh" (mode . sh-mode))
- ("text" (mode . text-mode))))))
-
- (add-hook 'ibuffer-mode-hook ;; organise by filter-groups
- '(lambda ()
- (ibuffer-auto-mode 1)
- (setq mode-name "≣")
- (ibuffer-switch-to-saved-filter-groups "default"))))
-
-(use-package ivy
- ;; completion system
- :diminish (ivy-mode . "")
-
- :bind ("C-c m" . ivy-switch-project)
-
- :config
- (ivy-mode 1)
- (setq ivy-use-virtual-buffers t
- ivy-height 10
- ivy-count-format "(%d/%d) "
- ivy-initial-inputs-alist nil
- ivy-use-ignore-default 'always
- ivy-ignore-buffers '("company-statistics-cache.el" "company-statistics-autoload.el")
- ivy-re-builders-alist '((swiper . ivy--regex-ignore-order)
- (t . ivy--regex-fuzzy)
- (t . ivy--regex-ignore-order)))
-
- (defun ivy-switch-project ()
- (interactive)
- (ivy-read
- "Switch to project: "
- (if (projectile-project-p)
- (cons (abbreviate-file-name (projectile-project-root))
- (projectile-relevant-known-projects))
- projectile-known-projects)
- :action #'projectile-switch-project-by-name))
-
- (ivy-set-actions
- 'ivy-switch-project
- '(("d" dired "Open Dired in project's directory")
- ("v" counsel-projectile "Open project root in vc-dir or magit")
- ("c" projectile-compile-project "Compile project")
- ("r" projectile-remove-known-project "Remove project(s)"))))
-
-(use-package json-mode
- ;; mode to support json files
- :ensure t
-
- :mode "\\.json\\'"
-
- :config
- (setq json-reformat:indent-width 2))
-
-(use-package magit
- ;; interface to git
- :ensure t
-
- :mode (("differential-update-comments" . git-commit-mode)
- ("new-commit" . git-commit-mode))
-
- :bind (("C-x g s" . magit-status)
- ("C-x g b" . magit-checkout))
-
- :init
- (progn
- (setq magit-completing-read-function 'ivy-completing-read))
-
- :config
- (progn
- (global-git-commit-mode)
- (use-package git-commit :ensure t :defer t)
- (add-hook 'magit-mode-hook
- (lambda()
- (setq mode-name "⎇")))
- (add-hook 'magit-log-edit-mode-hook
- #'(lambda ()
- (set-fill-column 72)
- (flyspell-mode)))))
-
-(use-package make-mode
- ;; mode to support Makefile
- :config
- (add-hook 'makefile-mode-hook (lambda ()
- (setq-local tab-width 2))))
-
-(use-package markdown-mode
- ;; mode to support files in the Markdown format
- :ensure t
-
- :commands (markdown-mode gfm-mode)
-
- :mode (("\\.md\\'" . gfm-mode)
- ("\\.markdown\\'" . gfm-mode))
-
- :init (setq markdown-command "pandoc -f markdown_github -c https://goo.gl/OVmlwT --self-contained")
-
- :config
- (add-hook 'gfm-mode-hook 'visual-line-mode))
-
-(use-package midnight
- ;; clean old buffers at midnight
- :ensure t
- :config
- (midnight-mode t))
-
-(use-package org
- :defer t
- :init
- (progn
- (setq org-startup-indented t)
- (org-babel-do-load-languages 'org-babel-load-languages
- '(
- (sh . t))))
- :config
- (add-hook 'org-mode-hook #'(lambda ()
- (visual-line-mode)
- (org-indent-mode))))
-
-;; (use-package phabricator
-;; ;; interface to phabricator
-;; :load-path (lambda () (expand-file-name "~/src/phabricator.el/"))
-
-;; :config
-;; (setq diffusion-repo-prefix-list '(("source" "source"))))
-
-(use-package projectile
- ;; library to interact with projects
- :ensure t
-
- :diminish ""
-
- :bind-keymap ("C-c p" . projectile-command-map)
-
- :init
- (add-hook 'after-init-hook #'projectile-mode)
-
- :config
- (use-package counsel-projectile :ensure t)
- (setq projectile-switch-project-action 'projectile-dired
- projectile-enable-caching t
- projectile-completion-system 'ivy
- projectile-known-projects-file (expand-file-name "var/projectile-bookmarks.eld" user-emacs-directory)
- projectile-cache-file (expand-file-name "var/projectile.cache" user-emacs-directory))
- (add-to-list 'projectile-globally-ignored-files ".DS_Store"))
-
-(use-package python
- ;; configuration for Python
- :mode(("\\.aurora$" . python-mode)
- ("BUILD$" . python-mode)
- ("\\.py$" . python-mode))
-
- :interpreter ("python" . python-mode)
-
- :init
- (setq-default indent-tabs-mode nil)
-
- :config
- (setq python-indent-offset 2)
- (add-hook 'python-mode-hook 'eldoc-mode t))
-
-(use-package recentf
- ;; configuration for recentf, to interact with recent files
- :config
- (setq recentf-save-file (expand-file-name "var/recentf" user-emacs-directory)))
-
-(use-package sh-script
- ;; configuration to interact with shell scripts
- :mode ("bashrc" . sh-mode)
-
- :config
- (defun set-sh-mode-indent ()
- (setq sh-basic-offset 2
- sh-indentation 2))
- (add-hook 'sh-mode-hook 'set-sh-mode-indent)
- (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p))
-
-(use-package swiper
- ;; install swiper
- :ensure t)
-
-(use-package tramp
- ;; configuration for tramp
- :config
- (setq tramp-default-method "ssh"
- tramp-persistency-file-name (expand-file-name "var/tramp" user-emacs-directory)))
-
-(use-package wabi-sabi-theme
- ;; this is my own custom theme. No syntax highlighting
- :load-path (lambda () (expand-file-name "lib" user-emacs-directory))
- :config
- (load-theme 'wabi-sabi t))
-
-(use-package whitespace
- ;; highlight white spaces
- :config
- (setq whitespace-style '(face trailing tabs))
- (add-hook 'prog-mode-hook 'whitespace-mode))
-
-(use-package yaml-mode
- ;; mode to work wity YAML files
- :ensure t
-
- :init (add-hook 'yaml-mode-hook 'flycheck-mode)
-
- :mode ("\\.ya?ml\\'" . yaml-mode))
-
-(use-package twitter
- ;; finish by loading twitter's modules
- :load-path (lambda () (expand-file-name "lib" user-emacs-directory)))
+;; If this is not commented, Emacs will overwrite this configuration file
+;; on load time.
+;; (package-initialize)
+
+(defun emacs-lib (filename)
+ (expand-file-name (concat "lib" "/" filename) user-emacs-directory))
+
+(load (emacs-lib "settings.el"))
+(load (emacs-lib "funcs.el"))
+(load (emacs-lib "bindings.el"))
+(load (emacs-lib "packages.el"))
+(load (emacs-lib "twitter.el") 'missing-ok)
(add-hook 'emacs-startup-hook #'fc/load-time)