Emacs configuration for Clojure on MacOS
This commit is contained in:
69
.emacs.d.clojure/customizations/editing.el
Normal file
69
.emacs.d.clojure/customizations/editing.el
Normal file
@@ -0,0 +1,69 @@
|
||||
;; Customizations relating to editing a buffer.
|
||||
|
||||
;; Key binding to use "hippie expand" for text autocompletion
|
||||
;; http://www.emacswiki.org/emacs/HippieExpand
|
||||
(global-set-key (kbd "M-/") 'hippie-expand)
|
||||
|
||||
;; Lisp-friendly hippie expand
|
||||
(setq hippie-expand-try-functions-list
|
||||
'(try-expand-dabbrev
|
||||
try-expand-dabbrev-all-buffers
|
||||
try-expand-dabbrev-from-kill
|
||||
try-complete-lisp-symbol-partially
|
||||
try-complete-lisp-symbol))
|
||||
|
||||
;; Highlights matching parenthesis
|
||||
(show-paren-mode 1)
|
||||
|
||||
;; Highlight current line
|
||||
(global-hl-line-mode 1)
|
||||
|
||||
;; Interactive search key bindings. By default, C-s runs
|
||||
;; isearch-forward, so this swaps the bindings.
|
||||
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
|
||||
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
|
||||
(global-set-key (kbd "C-M-s") 'isearch-forward)
|
||||
(global-set-key (kbd "C-M-r") 'isearch-backward)
|
||||
|
||||
;; Don't use hard tabs
|
||||
(setq-default indent-tabs-mode nil)
|
||||
|
||||
;; When you visit a file, point goes to the last place where it
|
||||
;; was when you previously visited the same file.
|
||||
;; http://www.emacswiki.org/emacs/SavePlace
|
||||
(require 'saveplace)
|
||||
(setq-default save-place t)
|
||||
;; keep track of saved places in ~/.emacs.d/places
|
||||
(setq save-place-file (concat user-emacs-directory "places"))
|
||||
|
||||
;; Emacs can automatically create backup files. This tells Emacs to
|
||||
;; put all backups in ~/.emacs.d/backups. More info:
|
||||
;; http://www.gnu.org/software/emacs/manual/html_node/elisp/Backup-Files.html
|
||||
(setq backup-directory-alist `(("." . ,(concat user-emacs-directory
|
||||
"backups"))))
|
||||
(setq auto-save-default nil)
|
||||
|
||||
|
||||
;; comments
|
||||
(defun toggle-comment-on-line ()
|
||||
"comment or uncomment current line"
|
||||
(interactive)
|
||||
(comment-or-uncomment-region (line-beginning-position) (line-end-position)))
|
||||
(global-set-key (kbd "C-;") 'toggle-comment-on-line)
|
||||
|
||||
;; use 2 spaces for tabs
|
||||
(defun die-tabs ()
|
||||
(interactive)
|
||||
(set-variable 'tab-width 2)
|
||||
(mark-whole-buffer)
|
||||
(untabify (region-beginning) (region-end))
|
||||
(keyboard-quit))
|
||||
|
||||
;; fix weird os x kill error
|
||||
(defun ns-get-pasteboard ()
|
||||
"Returns the value of the pasteboard, or nil for unsupported formats."
|
||||
(condition-case nil
|
||||
(ns-get-selection-internal 'CLIPBOARD)
|
||||
(quit nil)))
|
||||
|
||||
(setq electric-indent-mode nil)
|
||||
15
.emacs.d.clojure/customizations/elisp-editing.el
Normal file
15
.emacs.d.clojure/customizations/elisp-editing.el
Normal file
@@ -0,0 +1,15 @@
|
||||
;; Automatically load paredit when editing a lisp file
|
||||
;; More at http://www.emacswiki.org/emacs/ParEdit
|
||||
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
|
||||
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
|
||||
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
|
||||
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
|
||||
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
|
||||
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
|
||||
(add-hook 'scheme-mode-hook #'enable-paredit-mode)
|
||||
|
||||
;; eldoc-mode shows documentation in the minibuffer when writing code
|
||||
;; http://www.emacswiki.org/emacs/ElDoc
|
||||
(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
|
||||
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
|
||||
(add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
|
||||
12
.emacs.d.clojure/customizations/misc.el
Normal file
12
.emacs.d.clojure/customizations/misc.el
Normal file
@@ -0,0 +1,12 @@
|
||||
;; Changes all yes/no questions to y/n type
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;; shell scripts
|
||||
(setq-default sh-basic-offset 2)
|
||||
(setq-default sh-indentation 2)
|
||||
|
||||
;; No need for ~ files when editing
|
||||
(setq create-lockfiles nil)
|
||||
|
||||
;; Go straight to scratch buffer on startup
|
||||
(setq inhibit-startup-message t)
|
||||
62
.emacs.d.clojure/customizations/navigation.el
Normal file
62
.emacs.d.clojure/customizations/navigation.el
Normal file
@@ -0,0 +1,62 @@
|
||||
;; These customizations make it easier for you to navigate files,
|
||||
;; switch buffers, and choose options from the minibuffer.
|
||||
|
||||
|
||||
;; "When several buffers visit identically-named files,
|
||||
;; Emacs must give the buffers distinct names. The usual method
|
||||
;; for making buffer names unique adds ‘<2>’, ‘<3>’, etc. to the end
|
||||
;; of the buffer names (all but one of them).
|
||||
;; The forward naming method includes part of the file's directory
|
||||
;; name at the beginning of the buffer name
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html
|
||||
(require 'uniquify)
|
||||
(setq uniquify-buffer-name-style 'forward)
|
||||
|
||||
;; Turn on recent file mode so that you can more easily switch to
|
||||
;; recently edited files when you first start emacs
|
||||
(setq recentf-save-file (concat user-emacs-directory ".recentf"))
|
||||
(require 'recentf)
|
||||
(recentf-mode 1)
|
||||
(setq recentf-max-menu-items 40)
|
||||
|
||||
|
||||
;; ido-mode allows you to more easily navigate choices. For example,
|
||||
;; when you want to switch buffers, ido presents you with a list
|
||||
;; of buffers in the the mini-buffer. As you start to type a buffer's
|
||||
;; name, ido will narrow down the list of buffers to match the text
|
||||
;; you've typed in
|
||||
;; http://www.emacswiki.org/emacs/InteractivelyDoThings
|
||||
(ido-mode t)
|
||||
|
||||
;; This allows partial matches, e.g. "tl" will match "Tyrion Lannister"
|
||||
(setq ido-enable-flex-matching t)
|
||||
|
||||
;; Turn this behavior off because it's annoying
|
||||
(setq ido-use-filename-at-point nil)
|
||||
|
||||
;; Don't try to match file across all "work" directories; only match files
|
||||
;; in the current directory displayed in the minibuffer
|
||||
(setq ido-auto-merge-work-directories-length -1)
|
||||
|
||||
;; Includes buffer names of recently open files, even if they're not
|
||||
;; open now
|
||||
(setq ido-use-virtual-buffers t)
|
||||
|
||||
;; This enables ido in all contexts where it could be useful, not just
|
||||
;; for selecting buffer and file names
|
||||
(ido-ubiquitous-mode t)
|
||||
(ido-everywhere t)
|
||||
|
||||
;; Shows a list of buffers
|
||||
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
||||
|
||||
|
||||
;; Enhances M-x to allow easier execution of commands. Provides
|
||||
;; a filterable list of possible commands in the minibuffer
|
||||
;; http://www.emacswiki.org/emacs/Smex
|
||||
(setq smex-save-file (concat user-emacs-directory ".smex-items"))
|
||||
(smex-initialize)
|
||||
(global-set-key (kbd "M-x") 'smex)
|
||||
|
||||
;; projectile everywhere!
|
||||
(projectile-global-mode)
|
||||
83
.emacs.d.clojure/customizations/setup-clojure.el
Normal file
83
.emacs.d.clojure/customizations/setup-clojure.el
Normal file
@@ -0,0 +1,83 @@
|
||||
;;;;
|
||||
;; Clojure
|
||||
;;;;
|
||||
|
||||
;; Enable paredit for Clojure
|
||||
(add-hook 'clojure-mode-hook 'enable-paredit-mode)
|
||||
|
||||
;; This is useful for working with camel-case tokens, like names of
|
||||
;; Java classes (e.g. JavaClassName)
|
||||
(add-hook 'clojure-mode-hook 'subword-mode)
|
||||
|
||||
;; A little more syntax highlighting
|
||||
(require 'clojure-mode-extra-font-locking)
|
||||
|
||||
;; syntax hilighting for midje
|
||||
(add-hook 'clojure-mode-hook
|
||||
(lambda ()
|
||||
(setq inferior-lisp-program "lein repl")
|
||||
(font-lock-add-keywords
|
||||
nil
|
||||
'(("(\\(facts?\\)"
|
||||
(1 font-lock-keyword-face))
|
||||
("(\\(background?\\)"
|
||||
(1 font-lock-keyword-face))))
|
||||
(define-clojure-indent (fact 1))
|
||||
(define-clojure-indent (facts 1))
|
||||
(rainbow-delimiters-mode)))
|
||||
|
||||
;;;;
|
||||
;; Cider
|
||||
;;;;
|
||||
|
||||
;; provides minibuffer documentation for the code you're typing into the repl
|
||||
(add-hook 'cider-mode-hook 'eldoc-mode)
|
||||
|
||||
;; go right to the REPL buffer when it's finished connecting
|
||||
(setq cider-repl-pop-to-buffer-on-connect t)
|
||||
|
||||
;; When there's a cider error, show its buffer and switch to it
|
||||
(setq cider-show-error-buffer t)
|
||||
(setq cider-auto-select-error-buffer t)
|
||||
|
||||
;; Where to store the cider history.
|
||||
(setq cider-repl-history-file "~/.emacs.d/cider-history")
|
||||
|
||||
;; Wrap when navigating history.
|
||||
(setq cider-repl-wrap-history t)
|
||||
|
||||
;; enable paredit in your REPL
|
||||
(add-hook 'cider-repl-mode-hook 'paredit-mode)
|
||||
|
||||
;; Use clojure mode for other extensions
|
||||
(add-to-list 'auto-mode-alist '("\\.edn$" . clojure-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.boot$" . clojure-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.cljs.*$" . clojure-mode))
|
||||
(add-to-list 'auto-mode-alist '("lein-env" . enh-ruby-mode))
|
||||
|
||||
|
||||
;; key bindings
|
||||
;; these help me out with the way I usually develop web apps
|
||||
(defun cider-start-http-server ()
|
||||
(interactive)
|
||||
(cider-load-current-buffer)
|
||||
(let ((ns (cider-current-ns)))
|
||||
(cider-repl-set-ns ns)
|
||||
(cider-interactive-eval (format "(println '(def server (%s/start))) (println 'server)" ns))
|
||||
(cider-interactive-eval (format "(def server (%s/start)) (println server)" ns))))
|
||||
|
||||
|
||||
(defun cider-refresh ()
|
||||
(interactive)
|
||||
(cider-interactive-eval (format "(user/reset)")))
|
||||
|
||||
(defun cider-user-ns ()
|
||||
(interactive)
|
||||
(cider-repl-set-ns "user"))
|
||||
|
||||
(eval-after-load 'cider
|
||||
'(progn
|
||||
(define-key clojure-mode-map (kbd "C-c C-v") 'cider-start-http-server)
|
||||
(define-key clojure-mode-map (kbd "C-M-r") 'cider-refresh)
|
||||
(define-key clojure-mode-map (kbd "C-c u") 'cider-user-ns)
|
||||
(define-key cider-mode-map (kbd "C-c u") 'cider-user-ns)))
|
||||
22
.emacs.d.clojure/customizations/setup-js.el
Normal file
22
.emacs.d.clojure/customizations/setup-js.el
Normal file
@@ -0,0 +1,22 @@
|
||||
;; javascript / html
|
||||
(add-to-list 'auto-mode-alist '("\\.js$" . js-mode))
|
||||
(add-hook 'js-mode-hook 'subword-mode)
|
||||
(add-hook 'html-mode-hook 'subword-mode)
|
||||
(setq js-indent-level 2)
|
||||
(eval-after-load "sgml-mode"
|
||||
'(progn
|
||||
(require 'tagedit)
|
||||
(tagedit-add-paredit-like-keybindings)
|
||||
(add-hook 'html-mode-hook (lambda () (tagedit-mode 1)))))
|
||||
|
||||
|
||||
;; coffeescript
|
||||
(add-to-list 'auto-mode-alist '("\\.coffee.erb$" . coffee-mode))
|
||||
(add-hook 'coffee-mode-hook 'subword-mode)
|
||||
(add-hook 'coffee-mode-hook 'highlight-indentation-current-column-mode)
|
||||
(add-hook 'coffee-mode-hook
|
||||
(defun coffee-mode-newline-and-indent ()
|
||||
(define-key coffee-mode-map "\C-j" 'coffee-newline-and-indent)
|
||||
(setq coffee-cleanup-whitespace nil)))
|
||||
(custom-set-variables
|
||||
'(coffee-tab-width 2))
|
||||
10
.emacs.d.clojure/customizations/shell-integration.el
Normal file
10
.emacs.d.clojure/customizations/shell-integration.el
Normal file
@@ -0,0 +1,10 @@
|
||||
;; Sets up exec-path-from shell
|
||||
;; https://github.com/purcell/exec-path-from-shell
|
||||
(add-to-list 'my-packages 'exec-path-from-shell)
|
||||
(when (memq window-system '(mac ns))
|
||||
;; Active debug mode
|
||||
;;(setq exec-path-from-shell-debug t)
|
||||
(exec-path-from-shell-initialize)
|
||||
(exec-path-from-shell-copy-envs
|
||||
'("PATH")))
|
||||
|
||||
104
.emacs.d.clojure/customizations/ui.el
Normal file
104
.emacs.d.clojure/customizations/ui.el
Normal file
@@ -0,0 +1,104 @@
|
||||
;; These customizations change the way emacs looks and disable/enable
|
||||
;; some user interface elements. Some useful customizations are
|
||||
;; commented out, and begin with the line "CUSTOMIZE". These are more
|
||||
;; a matter of preference and may require some fiddling to match your
|
||||
;; preferences
|
||||
|
||||
;; Turn off the menu bar at the top of each frame because it's distracting
|
||||
(menu-bar-mode -1)
|
||||
|
||||
;; Show line numbers
|
||||
(global-linum-mode)
|
||||
|
||||
;; Change cursor type to underline
|
||||
(set-default 'cursor-type 'hbar)
|
||||
|
||||
;; You can uncomment this to remove the graphical toolbar at the top. After
|
||||
;; awhile, you won't need the toolbar.
|
||||
(when (fboundp 'tool-bar-mode)
|
||||
(tool-bar-mode -1))
|
||||
|
||||
;; Don't show native OS scroll bars for buffers because they're redundant
|
||||
(when (fboundp 'scroll-bar-mode)
|
||||
(scroll-bar-mode -1))
|
||||
|
||||
;; Color Themes
|
||||
;; Read http://batsov.com/articles/2012/02/19/color-theming-in-emacs-reloaded/
|
||||
;; for a great explanation of emacs color themes.
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Custom-Themes.html
|
||||
;; for a more technical explanation.
|
||||
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
|
||||
(add-to-list 'load-path "~/.emacs.d/themes")
|
||||
|
||||
;; set theme
|
||||
(load-theme 'darcula t)
|
||||
|
||||
;; increase font size for better readability
|
||||
;;(set-face-attribute 'default nil :height 140)
|
||||
|
||||
;; Set font family and size
|
||||
(set-frame-font "Monaco 16" nil t)
|
||||
|
||||
;; Maximize Emacs window on startup
|
||||
(add-to-list 'default-frame-alist '(fullscreen . maximized))
|
||||
|
||||
;;(windmove-default-keybindings)
|
||||
|
||||
;; Change META button for MacOS from Option to Cmd
|
||||
(setq mac-option-modifier nil
|
||||
mac-command-modifier 'meta
|
||||
x-select-enable-clipboart t)
|
||||
|
||||
|
||||
|
||||
;; Uncomment the lines below by removing semicolons and play with the
|
||||
;; values in order to set the width (in characters wide) and height
|
||||
;; (in lines high) Emacs will have whenever you start it
|
||||
;; (setq initial-frame-alist '((top . 0) (left . 0) (width . 177) (height . 53)))
|
||||
|
||||
;; These settings relate to how emacs interacts with your operating system
|
||||
(setq ;; makes killing/yanking interact with the clipboard
|
||||
x-select-enable-clipboard t
|
||||
|
||||
;; I'm actually not sure what this does but it's recommended?
|
||||
x-select-enable-primary t
|
||||
|
||||
;; Save clipboard strings into kill ring before replacing them.
|
||||
;; When one selects something in another program to paste it into Emacs,
|
||||
;; but kills something in Emacs before actually pasting it,
|
||||
;; this selection is gone unless this variable is non-nil
|
||||
save-interprogram-paste-before-kill t
|
||||
|
||||
;; Shows all options when running apropos. For more info,
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Apropos.html
|
||||
apropos-do-all t
|
||||
|
||||
;; Mouse yank commands yank at point instead of at click.
|
||||
mouse-yank-at-point t)
|
||||
|
||||
;; No cursor blinking, it's distracting
|
||||
(blink-cursor-mode 1)
|
||||
|
||||
;; full path in title bar
|
||||
(setq-default frame-title-format "%b (%f)")
|
||||
|
||||
;; don't pop up font menu
|
||||
(global-set-key (kbd "s-t") '(lambda () (interactive)))
|
||||
|
||||
;; no bell
|
||||
(setq ring-bell-function 'ignore)
|
||||
|
||||
|
||||
(global-hl-line-mode)
|
||||
|
||||
(setq confirm-kill-emacs 'y-or-n-p)
|
||||
|
||||
;; Changes all yes/no questions to y/n type
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(message "Emacs ready in %s with %d garbage collections."
|
||||
(format "%.2f seconds"
|
||||
(float-time (time-subtract after-init-time before-init-time)))
|
||||
gcs-done)))
|
||||
Reference in New Issue
Block a user