Skip to content

johnmegahan/emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs Configuration (JCM)

This is my Emacs configuration, which is certainly in it’s early days. The init.el file tangles this file using org and loads it as configuration. I use this repository by cloning it to my home folder. Generally, I’ll have already installed nvm. Until I can figure out a better way, after cloning this, you should go into the /tern folder and run npm install to install tern’s dependencies.

Bootstrap

Settings

(setq
 auto-window-vscroll t                           ; Normalize vertical scroll offset
 confirm-kill-emacs 'yes-or-no-p                 ; Confirm before exiting Emacs
 cursor-in-non-selected-windows t                ; Hide the cursor in inactive windows
 delete-by-moving-to-trash t                     ; Delete files to trash
 display-time-default-load-average nil           ; Don't display load average
 display-time-format "%H:%M"                     ; Format the time string
 fill-column 80                                  ; Set width for automatic line breaking
 gc-cons-threshold most-positive-fixnum          ; Increase garbage collector treshold
 help-window-select t                            ; Focus new help windows when opened
 indent-tabs-mode nil                            ; Stop using tabs to indent
 initial-major-mode 'org-mode                    ; Start in Org mode for quick notes
 initial-scratch-message ""                      ; Empty the initial *scratch* buffer
 inhibit-startup-screen t                        ; Disable start-up screen
 make-backup-files nil                           ; Backups annoy me and I use git
 auto-save-default nil                           ; No temp files either
 mouse-yank-at-point t                           ; Yank at point rather than cursor
 require-final-newline 'visit                    ; Add a newline at EOF on visit
 scroll-step 1                                   ; Fix the scroll line step
 show-trailing-whitespace nil                    ; Display trailing whitespaces
 split-height-threshold nil                      ; Disable vertical window splitting
 split-width-threshold nil                       ; Disable horizontal window splitting
 tab-width 4                                     ; Set width for tabs
 uniquify-buffer-name-style 'forward             ; Uniquify buffer names
 window-combination-resize t                     ; Resize windows proportionally
 x-select-enable-clipboard t)                    ; Merge system's and Emacs' clipboard

UI

  (when window-system
    (scroll-bar-mode 0)                            ; Disable the scroll bar
    (tool-bar-mode 0)                              ; Disable the tool bar
    (tooltip-mode 0))                              ; Disable the tooltips
  (column-number-mode 1)                           ; Show the column number
  (display-battery-mode 0)                         ; Hide the battery level
  (display-time-mode 1)                            ; Hide the time representation
  (fringe-mode '(10 . 10))                         ; Show vertical fringes
  (global-hl-line-mode 1)                          ; Hightlight current line
  (global-subword-mode 1)                          ; Iterate through CamelCase words
  (line-number-mode 1)                             ; Show the line number
  (menu-bar-mode 0)                                ; Disable the menu bar
  (mouse-avoidance-mode 'animate)                  ; Avoid pointer/point collision
;  (set-frame-parameter nil 'fullscreen 'fullboth)  ; Enable fullscreen mode
  (show-paren-mode 1)                              ; Show matching parens pairs

Other

(fset 'yes-or-no-p 'y-or-n-p)                    ; Replace yes/no prompts with y/n

Reset garbage collector treshold after initialization is finished and garbage-collect on focus-out. Emacs should feel snappier, I do however experience long garbage collects when returning to the Emacs frame.

(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold 800000)))
(add-hook 'focus-out-hook 'garbage-collect)

Font

(defvar jcm/font-family            "Hasklig" "The font to use.")
(defvar jcm/font-size-default      240       "The font size to use for default text.")
(defvar jcm/font-size-header       280       "The font size to use for headers.")
(defvar jcm/font-size-mode-line    240       "The font size to use for the mode line.")
(setq org-src-fontify-natively t)
(add-to-list 'default-frame-alist '(font . "Hasklig-24"))
(set-face-attribute 'default t :font "Hasklig-24")

Load .custom.el

When you modify emacs through the UI, it wants to save those modifications somewhere. To keep this file clean, I move those to a different file.

(setq-default custom-file (expand-file-name ".custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file))

Load .secret.el

I load ~/.emacs.d/.secret.el to keep sensible things out of version control. For instance, you could set your identity by customizing both user-full-name and user-mail-address in this file.

(let ((secret.el (expand-file-name ".secret.el" user-emacs-directory)))
  (when (file-exists-p secret.el)
    (load secret.el)))

Package Manager

Since I pull in my theme from the package manager, I have to get that set up first

 (require 'package)
 (setq package-enable-at-startup nil)
 (setq package-archives
    '( ("melpa-stable" . "http://stable.melpa.org/packages/")
	("melpa"     . "http://melpa.milkbox.net/packages/")
	("marmalade" . "http://marmalade-repo.org/packages/")
       ("gnu"       . "http://elpa.gnu.org/packages/")))
 (package-initialize)

 (unless (package-installed-p 'use-package)
   (package-refresh-contents)
   (package-install 'use-package))

You can run into all kinds of problems on OSX where the path is wronge.

(use-package exec-path-from-shell
  :ensure t
  :config
  (when (memq window-system '(mac ns))
    (exec-path-from-shell-initialize)))

Theme

Right now I like to use greduan’s port of the Gruvbox theme. Unfortunately there’s no light mode right now but i’m hoping to add it at some point.

(use-package gruvbox-theme
  :ensure t
  :config (load-theme 'gruvbox t))

Navigation

Completion

I use Ivy as my completion frontend

(use-package ivy
  :ensure t
  :diminish (ivy-mode)
  :bind ("C-x b" . ivy-switch-buffer)
  :config
  (ivy-mode 1)
  (setq ivy-use-virtual-buffers t)
  (setq ivy-display-style 'fancy)
  (setq ivy-extra-directories nil)
  (setq ivy-height 10)
  (setq ivy-count-format "(%d/%d) "))

Counsel provides ivy-based versions of emacs commands

(use-package counsel
  :ensure t
  :bind (("M-x" . counsel-M-x)
	 ("C-x C-f" . counsel-find-file)
	 ("C-c g" . counsel-git)
	 ("C-c j" . counsel-git-grep)
	 ("C-c k" . counsel-ag)
	 ("C-x l" . counsel-locate)
	 ("C-S-o" . counsel-rhythmbox)))
(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)

Search

Swiper is an i-search replacement that uses ivy

(use-package swiper
  :ensure t
  :bind ("C-s" . swiper))

On-screen

On-screen navigation is a little different. I use Avy for that.

(use-package avy
  :ensure t
  :bind ("M-s" . avy-goto-char-timer))

Languages

General

A lot of teams I’m on use EditorConfig to keep project-based configs

(use-package editorconfig
  :ensure t
  :config
  (add-hook 'prog-mode-hook (editorconfig-mode 1))
  (add-hook 'text-mode-hook (editorconfig-mode 1)))

I use flycheck for syntax checking

(use-package flycheck
  :ensure t
  :config
  (global-flycheck-mode))

I use company for code completion

(use-package company
  :ensure t
  :config
  (add-hook 'after-init-hook 'global-company-mode))

Prettify

 (setq prettify-symbols-alist
	'(("===" . (decode-char 'ucs #XE108))
         ("lambda" . 955) ; λ
         ("->" . 8594)    ;
         ("=>" . 8658)    ;
         ))

EcmaScript

I spend my time day-to-day in JavaScript/EcmaScript and so right now that is where the majority of my packages go.

js2-mode is best at node stuff right now

(use-package js2-mode
  :ensure t
  :mode "\\.js\\'"
  :interpreter "node"
  :config
  (setq-default
    js2-include-node-externs t
    js2-mode-show-parse-errors nil
    js2-highlight-level 3)
  (js2-mode-hide-warnings-and-errors))

I use tern for my js code completion backend.

(use-package tern
  :config (add-hook 'js2-mode-hook 'tern-mode))

(use-package company-tern
  :ensure t
  :config
  (add-to-list 'company-backends 'company-tern))

PureScript

(add-hook 'purescript-mode-hook
	    (lambda ()
	      (setq prettify-symbols-alist
		    '(
		      ("&&"   . #XE100)
		      ("***"  . #XE101)
		      ("*>"   . #XE102)
		      ("\\\\" . #XE103)
		      ("||"   . #XE104)
		      ("|>"   . #XE105)
		      ("::"   . #XE106)
		      ("=="   . #XE107)
		      ("==="  . #XE108)
		      ("==>"  . #XE109)
		      ("=>"   . #XE10A)
		      ("=<<"  . #XE10B)
		      ("!!"   . #XE10C)
		      (">>"   . #XE10D)
		      (">>="  . #XE10E)
		      (">>>"  . #XE10F)
		      (">>-"  . #XE110)
		      (">-"   . #XE111)
		      ("->"   . #XE112)
		      ("-<"   . #XE113)
		      ("-<<"  . #XE114)
		      ("<*"   . #XE115)
		      ("<*>"  . #XE116)
		      ("<|"   . #XE117)
		      ("<|>"  . #XE118)
		      ("<$>"  . #XE119)
		      ("<>"   . #XE11A)
		      ("<-"   . #XE11B)
		      ("<<"   . #XE11C)
		      ("<<<"  . #XE11D)
		      ("<+>"  . #XE11E)
		      (".."   . #XE11F)
		      ("..."  . #XE120)
		      ("++"   . #XE121)
		      ("+++"  . #XE122)
		      ("/="   . #XE123)
		      ))))
(add-hook 'purescript-mode-hook 'prettify-symbols-mode)
(add-hook 'purescript-mode-hook 'purescript-indentation-mode)

Mustache Templates

(use-package mustache-mode
  :ensure t)

Source Control

Magit

(use-package magit
  :ensure t
  :bind ("C-x g" . magit-status))

Project Management

Projectile

(use-package projectile
  :ensure t
  :config
  (projectile-global-mode))

(use-package counsel-projectile
  :ensure t)

Snippets

yasnippets are in the snippets folder by default

(use-package yasnippet
  :ensure t
  :config
  (yas-global-mode 1))

RSS

(use-package elfeed
  :ensure t)

(use-package elfeed-org
  :ensure t
  :config
  (elfeed-org)
  (setq rmh-elfeed-org-files (list "~/org/rss-feeds.org")))

About

Johnny's Emacs Configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published