(require 'package) (setq package-user-dir "~/.emacs.d/var/elpa" 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)) (unless (package-installed-p 'use-package) (progn (package-refresh-contents) (package-install 'use-package))) (require 'use-package) (eval-and-compile (add-to-list 'load-path (expand-file-name "lib" user-emacs-directory))) (use-package my-settings) (use-package my-functions) (use-package server :config (unless (server-running-p) (server-start))) ;; other packages (use-package ag :ensure t :init (setq ag-reuse-buffers t ag-reuse-window t)) (use-package counsel :ensure t :config (setq counsel-find-file-at-point t)) (use-package diminish :ensure t) (use-package dired :bind ("C-x C-d" . dired) :config (let ((gls "/usr/local/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 lisp-mode :config (add-hook 'emacs-lisp-mode-hook (lambda() (setq mode-name "λ")))) ;; eshell configuration (use-package eshell :ensure t :bind ("C-x e" . eshell) :init (progn (add-hook 'eshell-mode-hook '(lambda ()(exec-path-from-shell-initialize))) (add-hook 'eshell-mode-hook (lambda () (setenv "PAGER" "less") (setenv "EDITOR" "emacsclient")))) :config (progn (setq eshell-aliases-file "~/.emacs.d/var/eshell/aliases") (use-package em-term :defer t :config (setq eshell-destroy-buffer-when-process-dies t eshell-visual-commands (append '("less" "tmux" "ssh" "htop" "top") eshell-visual-commands))))) ;; environment fixup for macOS. (use-package exec-path-from-shell :ensure t :commands (exec-path-from-shell-initialize exec-path-from-shell-copy-env) :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) (exec-path-from-shell-copy-envs '("PATH" "GOROOT" "GOPATH" "GEM_HOME" "GEM_PATH" "MY_RUBY_HOME")))) (use-package flycheck :ensure t :config (progn (use-package flycheck-pos-tip :ensure t :config (setq flycheck-display-errors-function #'flycheck-pos-tip-error-messages)) (defun check-source-predicate () (and (executable-find "check.pex") (buffer-file-name) (string-match "src/source/.*\.py$" (buffer-file-name)))) (add-hook 'prog-mode-hook 'flycheck-mode) (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) (setq flycheck-mode-line '(:eval (pcase flycheck-last-status-change (`not-checked nil) (`no-checker (propertize " -" 'face 'warning)) (`running "") (`errored (propertize " ✘" 'face 'error)) (`finished (if flycheck-current-errors (let* ((error-counts (flycheck-count-errors flycheck-current-errors)) (no-errors (cdr (assq 'error error-counts))) (no-warnings (cdr (assq 'warning error-counts))) (flycheck-face (cond (no-errors 'error) (no-warnings 'warning)))) (propertize (format " [✗:%s/%s]" (or no-errors 0) (or no-warnings 0)) 'face flycheck-face)) (propertize " [✓]" 'face 'success))) (`interrupted " -") (`suspicious '(propertize " ?" 'face 'warning))))) (flycheck-define-checker source-check "A syntax checker for python source code in Source, using `check.pex'" :command ("check.pex" source) ;;; errors are reported like this: ;;; E241:ERROR : :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end) (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end)) :predicate check-source-predicate :modes (python-mode)) (add-to-list 'flycheck-checkers 'source-check))) (use-package flyspell :ensure t :diminish flyspell-mode :init (setq ispell-program-name "aspell" ispell-list-command "--list")) (use-package geiser :ensure t :config (progn (setq geiser-default-implementation 'racket geiser-racket-binary "~/src/devbox/racket/racket-repl.sh"))) (use-package gist :ensure t :bind ("C-c G" . gist-region-or-buffer)) (use-package go-mode :ensure t :init (progn (use-package go-eldoc :ensure t) (use-package gotest :ensure t) (add-hook 'go-mode-hook (lambda () (setenv "GO15VENDOREXPERIMENT" "1") (go-eldoc-setup) (add-hook 'before-save-hook 'gofmt-before-save) (setq tab-width 4))))) (use-package helm :ensure t :bind (("C-c h l" . helm-resume)) :diminish " Ⓗ" :init (helm-mode 1) (with-eval-after-load 'helm-config (warn "`helm-config' loaded! Get rid of it ASAP!")) :config ;; Split inside selected window with Helm (setq helm-split-window-in-side-p t)) (use-package ibuffer :ensure t :defer t :bind ("C-x C-b" . ibuffer) :init (setq ibuffer-show-empty-filter-groups nil ibuffer-saved-filter-groups (quote (("default" ("repl" (name . "repl")) ("elisp" (mode . emacs-lisp-mode)) ("ruby" (name . "^\\.rb$")) ("json" (mode . json-mode)) ("sh" (mode . sh-mode)) ("lisp" (mode . lisp-mode)) ("magit" (mode . magit-mode)) ("python" (mode . python-mode)) ("java" (mode . java-mode)) ("go" (mode . go-mode)) ("text" (mode . text-mode)) ("dired" (mode . dired-mode)) ("emacs" (or (name . "^\\*.*\\*$") (mode . fundamental-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 :config (ivy-mode 1) (setq ivy-use-virtual-buffers t) (setq ivy-height 10) (setq ivy-count-format "(%d/%d) ") (setq ivy-initial-inputs-alist nil) ;; from https://github.com/company-mode/company-statistics ;; ignore buffers in the ignore buffer list. (setq ivy-use-ignore-default 'always) (setq ivy-ignore-buffers '("company-statistics-cache.el" "company-statistics-autoload.el")) ;; if ivy-flip is t, presents results on top of query. (setq ivy-flip nil) (setq 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)) (global-set-key (kbd "C-c m") 'ivy-switch-project) (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 :ensure t :mode "\\.json\\'" :config (setq json-reformat:indent-width 2)) (use-package magit :ensure t :bind ("C-x g" . magit-status) :config (add-hook 'magit-log-edit-mode-hook #'(lambda () (set-fill-column 72) (flyspell-mode)))) (use-package make-mode :config (add-hook 'makefile-mode-hook #'(lambda () (setq whitespace-style '(face trailing tabs)) (setq tab-width 2) (whitespace-mode)))) (use-package markdown-mode :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) (use-package pants :load-path (lambda () (expand-file-name "~/src/pants.el/")) :config (setq pants-source-tree-root "/Users/fcuny/src/source" pants-bury-compilation-buffer t pants-extra-args "-q") :bind (("C-c b" . pants-find-build-file) ("C-c r" . pants-run-binary) ("C-c t" . pants-run-test))) (use-package projectile :ensure t :diminish projectile-mode :bind-keymap ("C-c p" . projectile-command-map) :config (setq projectile-enable-caching t projectile-completion-system 'ivy projectile-known-projects-file "~/.emacs.d/var/projectile-bookmarks.eld" projectile-cache-file "~/.emacs.d/var/projectile.cache") (projectile-mode)) (use-package puppet-mode :ensure t :mode ("\\.pp\\'" . puppet-mode) :init (add-hook 'puppet-mode-hook 'flycheck-mode) :config (setq flycheck-puppet-lint-rc "/Users/fcuny/src/twitter-ops/utilities/puppet/.puppet-lint.rc")) (use-package 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 'color-identifiers-mode)) (use-package recentf :config (setq recentf-save-file "~/.emacs.d/var/recentf")) (use-package sh-script :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)) (use-package shell-pop :defer t :ensure t :bind ("C-:" . shell-pop) :init (progn (setq-default shell-pop-shell-type '("eshell" "*eshell-pop*" (lambda nil (eshell)))) (setq-default shell-pop-window-height 30) (setq-default shell-pop-full-span t) (setq-default shell-pop-window-position "bottom"))) (use-package swiper :ensure t :diminish ivy-mode :bind ("C-s" . swiper) :config (setq ivy-use-virtual-buffers t) (ivy-mode)) (use-package term :bind (("C-x t" . fc/open-term) ("C-x m" . fc/switch-to-term-buffer)) :config (progn (defun fc/make-term (new-buffer-name cmd &rest switches) (setq term-ansi-buffer-name (concat "<" new-buffer-name ">")) (setq term-ansi-buffer-name (generate-new-buffer-name term-ansi-buffer-name)) (setq term-ansi-buffer-name (apply 'make-term term-ansi-buffer-name cmd nil switches)) (set-buffer term-ansi-buffer-name) (term-mode) (term-char-mode) (term-set-escape-char ?\C-x) (switch-to-buffer term-ansi-buffer-name)) (defun fc/open-term (name) (interactive "sName: ") (fc/make-term name "bash")) (defun fc/list-term-buffers () "Returns a list of term buffers" (delq nil (mapcar (lambda(x) (set-buffer x) (when (string= major-mode "term-mode") (buffer-name))) (buffer-list)))) (defun fc/switch-to-term-buffer () "Switch to a term buffer." (interactive) (let ((collection (fc/list-term-buffers))) (ivy-read "term buffers:" collection :action (lambda (x) (switch-to-buffer x)) :caller 'fc/find-term-buffers))))) (use-package thrift :ensure t :mode ("\\.thrift\\'" . thrift-mode) :config (setq thrift-indent-level 2)) (use-package time :config (setq display-time-format "%I:%M" display-time-default-load-average nil display-time-24hr-format t) (display-time-mode +1)) (use-package tramp :config (setq tramp-default-method "ssh")) (use-package yaml-mode :ensure t :mode ("\\.ya?ml\\'" . yaml-mode)) ;; some bindings (global-set-key (kbd "M-j") 'join-line) (global-set-key (kbd "") 'toggle-frame-fullscreen) (define-key emacs-lisp-mode-map (kbd "C-c C-e") 'eval-buffer) (define-key emacs-lisp-mode-map (kbd "C-c C-r") 'eval-region) (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 (flycheck-pos-tip puppet-mode ag projectile magit multi-term shell-pop esh-opt em-term thrift json-mode helm gist flycheck exec-path-from-shell counsel use-package)))) (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. )