Skip to content

Instantly share code, notes, and snippets.

@seandewar
Last active May 7, 2019 19:48
Show Gist options
  • Save seandewar/cd481952c24fe779f0c1ed3c5cbb0c28 to your computer and use it in GitHub Desktop.
Save seandewar/cd481952c24fe779f0c1ed3c5cbb0c28 to your computer and use it in GitHub Desktop.
;;; init.el --- Sean Dewar's GNU Emacs 24.3+ configuration
;;; Commentary:
;; Sean Dewar's (seandewar @ github) init.el configuration.
;;
;; Feel free to use whatever you want from this configuration file.
;; Always a work in progress!
;;; Code:
;;; setup package manager
(require 'package)
(setq package-enable-at-startup nil)
;; add melpa package archive
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
;;; setup use-package
;; make sure use-package is installed
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;;; setup cygwin support for windows
(if (eq system-type 'windows-nt)
(progn
;; setup PATH and emacs exec path to include cygwin bin dir
(setenv "PATH" (concat "C:\\cygwin\\bin;" (getenv "PATH")))
(setq exec-path (add-to-list 'exec-path "C:/cygwin/bin"))
;; use cygwin-mount
(use-package cygwin-mount
:ensure t
:config
(cygwin-mount-activate))
;; stop ^M from being shown all over the terminal in some situations
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))
;;; configure shell to use bash
(setq shell-file-name "bash")
(setq explicit-shell-file-name shell-file-name)
(setenv "SHELL" shell-file-name)
(setq explicit-bash-args '("--noediting" "--login" "-i"))
;;; ui
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode 0)
(line-number-mode)
(column-number-mode)
(size-indication-mode)
(global-linum-mode)
;;; themes
(use-package monokai-theme
:ensure t
:init
(load-theme 'monokai t))
(use-package darkokai-theme
:disabled t)
(use-package zenburn-theme
:disabled t)
;;; enhancements
(use-package helm
:ensure t
:config
(progn
;; sometimes helm-mode takes ages to start if we don't configure
;; tramp like this...
(setq tramp-ssh-controlmaster-options
"-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no")
(require 'tramp)
(bind-key "C-c M-x" 'helm-M-x)
(helm-mode)))
(use-package smex
:ensure t
:config
(bind-key "M-x" 'smex)
(bind-key "M-X" 'smex-major-mode-commands)
(bind-key "C-c C-c M-x" 'execute-extended-command)
(smex-initialize))
(use-package linum-relative
:ensure t
:config
;; show real line number at current line
(setq linum-relative-current-symbol ""))
;;; project management
(use-package projectile
:ensure t
:config
(projectile-mode))
(use-package helm-projectile
:ensure t
:config
(helm-projectile-on))
;;; completion
(use-package company
:ensure t
:config
(progn
(global-company-mode)
(setq company-tooltip-align-annotations t
company-show-numbers t
company-idle-delay 0.25)
(bind-key "<C-tab>" 'company-complete)))
;;; editing
(auto-compression-mode)
;; spaces instead of tabs
(setq-default tab-stop-list (number-sequence 4 200 4)
indent-tabs-mode nil
tab-width 4
c-basic-offset 4)
(use-package evil-leader
:ensure t
:config
(progn
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key
;; window management
"wf" 'fit-window-to-buffer
;; linum-relative toggle
"l" 'linum-relative-toggle
;; flycheck error management
"el" 'flycheck-list-errors
"en" 'flycheck-next-error
"eN" 'flycheck-previous-error)
(global-evil-leader-mode)))
(use-package evil
:ensure t
:init
(setq evil-want-C-u-scroll t
evil-want-C-w-in-emacs-state t
evil-want-C-w-delete t)
:config
(evil-mode))
(use-package flycheck
:ensure t
:config
(global-flycheck-mode))
;;; git
(use-package magit
:config
(progn
(bind-key "C-x g" 'magit-status)
(bind-key "C-x M-g" 'magit-dispatch-popup)
(global-magit-file-mode)))
(use-package git-gutter-fringe)
;;; rust
(use-package rust-mode
:ensure t
:defer t)
(use-package racer
:ensure t
:defer t
:init
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode))
(use-package flycheck-rust
:ensure t
:defer t
:init
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
;;; auto-generated config
(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.
'(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 112 :width normal)))))
;;; init.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment