Created
June 9, 2016 13:39
-
-
Save davidelbe/fe1cfdd114407ea112000d99b5e9a387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; David's Emacs config - requires Emacs 24.4 or later | |
;; Hide menu | |
(menu-bar-mode -1) | |
;; Always prefer utf-8 | |
(prefer-coding-system 'utf-8) | |
(set-default-coding-systems 'utf-8) | |
(set-terminal-coding-system 'utf-8) | |
(set-keyboard-coding-system 'utf-8) | |
(set-language-environment 'utf-8) | |
;; Move between windows with ESC + arrow | |
(global-set-key (kbd "ESC <left>") 'windmove-left) | |
(global-set-key (kbd "ESC <right>") 'windmove-right) | |
(global-set-key (kbd "ESC <up>") 'windmove-up) | |
(global-set-key (kbd "ESC <down>") 'windmove-down) | |
;; Ctags and auto complete | |
;; apt-get install exuberant-ctags | |
(setq projectile-tags-command "ctags-exuberant -Re --exclude=db --exclude=test --exclude=.git --exclude=log --exclude=public -f \"%s\" %s") | |
;; (add-hook 'after-init-hook 'global-company-mode) | |
;; Display tooltips | |
(tooltip-mode -1) | |
;; (setq tooltip-use-echo-area t) | |
;; Stop prompting every time I open a gemspec | |
(setq safe-local-variable-values | |
(append '((encoding . utf-8)) safe-local-variable-values)) | |
;; Disable prompts | |
(fset 'yes-or-no-p 'y-or-n-p) | |
(setq confirm-nonexistent-file-or-buffer nil) | |
;; Moving to last line inserts newline | |
(setq next-line-add-newlines t) | |
(setq require-final-newline 't) | |
(setq mode-require-final-newline 't) | |
;; https://github.com/hbin/top-programming-fonts | |
(set-frame-font "Menlo:pixelsize=18") | |
;; Remove trailing space on save | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
;; Emacs is not a package manager, and here we load its package manager! | |
(require 'package) | |
(dolist (source '(("marmalade" . "http://marmalade-repo.org/packages/") | |
("elpa" . "http://tromey.com/elpa/") | |
("melpa" . "http://melpa.milkbox.net/packages/") | |
)) | |
(add-to-list 'package-archives source t)) | |
(package-initialize) | |
;; Required packages | |
;; everytime emacs starts, it will automatically check if those packages are | |
;; missing, it will install them automatically | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
(defvar tmtxt/packages | |
'(web-mode magit ruby-mode company multiple-cursors expand-region flycheck markdown-mode zenburn-theme yaml-mode helm helm-dash projectile helm-projectile editorconfig gist)) | |
(dolist (p tmtxt/packages) | |
(when (not (package-installed-p p)) | |
(package-install p))) | |
;; Editor config | |
(editorconfig-mode 1) | |
;; Helm | |
(require 'helm-config) | |
(helm-mode 1) | |
(helm-autoresize-mode 1) | |
(global-set-key (kbd "M-x") 'helm-M-x) | |
(setq helm-M-x-fuzzy-match t) ;; optional fuzzy matching for helm-M-x | |
;; Flycheck - syntax checking | |
;; (add-hook 'after-init-hook #'global-flycheck-mode) | |
(add-hook 'ruby-mode-hook 'flycheck-mode) | |
;; Projectile | |
(projectile-global-mode) | |
(setq projectile-completion-system 'helm) | |
(helm-projectile-on) | |
(global-set-key (kbd "C-x f") 'helm-projectile-find-file) | |
;; Selection | |
(require 'expand-region) | |
(global-set-key (kbd "C-x 9") 'er/expand-region) | |
;; Markdown | |
(autoload 'markdown-mode "markdown-mode" | |
"Major mode for editing Markdown files" t) | |
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode)) | |
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) | |
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) | |
;; Yaml | |
(require 'yaml-mode) | |
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) | |
;; Theme | |
(load-theme 'zenburn t) | |
;; Autosaving - I don't care about that | |
(setq auto-save-default nil) | |
;; Show line numbers when loading files | |
(global-linum-mode 1) | |
(add-hook 'eshell-mode-hook (lambda () (linum-mode -1))) | |
(setq linum-format " %5d ") | |
(set-face-attribute 'linum nil :background "#222") | |
(set-face-attribute 'linum nil :foreground "#666") | |
(setq-default left-fringe-width 10) | |
(setq-default right-fringe-width 0) | |
;; Multiple cursors | |
(global-set-key (kbd "C-c <") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-c >") 'mc/mark-all-like-this) | |
;; Ruby | |
(add-to-list 'auto-mode-alist | |
'("\\.\\(?:gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" . ruby-mode)) | |
(add-to-list 'auto-mode-alist | |
'("\\(Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" . ruby-mode)) | |
;; Ruby - dash | |
(add-hook 'ruby-mode-hook '(lambda () | |
(setq ruby-insert-encoding-magic-comment nil) | |
(company-mode) ;; use autocompletion | |
(setq-local helm-dash-docsets '("Ruby on Rails" "Ruby")) | |
(setq helm-current-buffer (current-buffer)))) | |
;; Tabs | |
;; Most of this should be taken care of by .editorconfig, but | |
;; I have added some defaults here | |
(setq-default indent-tabs-mode nil) | |
(setq tab-width 2) ; or any other preferred value | |
(defvaralias 'c-basic-offset 'tab-width) | |
(defvaralias 'cperl-indent-level 'tab-width) | |
;; Magit shortcut | |
(global-set-key (kbd "C-x g") 'magit-status) | |
(add-hook 'magit-status-mode-hook 'delete-other-windows) | |
;; PHP | |
(add-to-list 'auto-mode-alist '("\\.php$" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.scss\\'" . web-mode)) | |
(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. | |
'(safe-local-variable-values (quote ((encoding . utf-8))))) | |
(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. | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment