;; 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 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 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 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 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))