Last active
May 2, 2017 01:00
-
-
Save claudiosikeda/256811b620904be578d29bb78b4d0d5a to your computer and use it in GitHub Desktop.
Emacs configuration
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
From github: | |
autopair; | |
emacs-async; | |
emacs-neotree; | |
Fill-Column-Indicator; | |
helm; | |
helm-projectile; | |
highlight-indent-guides; | |
From Melpa: | |
async; | |
evil; | |
flycheck; | |
helm-ag; | |
js2-mode; | |
projectile; | |
sublime-themes; | |
web-mode; |
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
(when (>= emacs-major-version 24) | |
(require 'package) | |
(add-to-list | |
'package-archives | |
'("melpa" . "http://melpa.org/packages/") | |
t) | |
(package-initialize)) | |
;; If async is installed | |
(add-to-list 'load-path "~/.emacs.d/plugins/emacs-async") | |
(add-to-list 'load-path "~/.emacs.d/plugins/helm") | |
(require 'helm-config) | |
(add-hook 'prog-mode-hook 'projectile-mode) | |
;; Enable mouse support | |
(unless window-system | |
(require 'mouse) | |
(xterm-mouse-mode t) | |
(global-set-key [mouse-4] (lambda () | |
(interactive) | |
(scroll-down 1))) | |
(global-set-key [mouse-5] (lambda () | |
(interactive) | |
(scroll-up 1))) | |
(defun track-mouse (e)) | |
(setq mouse-sel-mode t) | |
) | |
;; Vim mode | |
(require 'evil) | |
(evil-mode 1) | |
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter) | |
(evil-define-key 'normal neotree-mode-map (kbd "SPC") 'neotree-enter) | |
(evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide) | |
(evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter) | |
;; Hide Toolbar and Menubar | |
(tool-bar-mode -1) | |
(menu-bar-mode -1) | |
;; Line numbers | |
(add-hook 'prog-mode-hook 'linum-mode) | |
(setq linum-format "%d ") | |
;; indentation guides | |
(add-to-list 'load-path "~/.emacs.d/plugins/highlight-indent-guides") | |
(require 'highlight-indent-guides) | |
(setq highlight-indent-guides-method 'character) | |
;; (setq highlight-indent-guides-character ?\┆) | |
(setq highlight-indent-guides-auto-enabled nil) | |
(set-face-background 'highlight-indent-guides-odd-face "gray20") | |
(set-face-background 'highlight-indent-guides-even-face "gray20") | |
(set-face-foreground 'highlight-indent-guides-character-face "gray20") | |
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode) | |
;; Neotree | |
(add-to-list 'load-path "~/.emacs.d/plugins/emacs-neotree") | |
(require 'neotree) | |
(global-set-key [f8] 'neotree-toggle) | |
(put 'dired-find-alternate-file 'disabled nil) | |
;; Automagically pair braces and quotes in emacs like TextMate | |
(add-to-list 'load-path "~/.emacs.d/plugins/autopair") | |
(require 'autopair) | |
(autopair-global-mode) | |
;; Theme | |
(load-theme 'spolsky t nil) | |
;; 80 column indicator | |
(add-to-list 'load-path "~/.emacs.d/plugins/Fill-Column-Indicator") | |
(require 'fill-column-indicator) | |
(define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1))) | |
(global-fci-mode 1) | |
(setq fci-rule-width 1) | |
(setq fci-rule-color "gray20") | |
(setq fci-rule-column 80) | |
;; Font size | |
(set-face-attribute 'default nil :height 150) | |
;; Rails | |
(setq ruby-insert-encoding-magic-comment nil) | |
;; Javascript http://codewinds.com/blog/2015-04-02-emacs-flycheck-eslint-jsx.html | |
(setq js2-highlight-level 3) | |
;; use web-mode for .jsx files | |
(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode)) | |
;; http://www.flycheck.org/manual/latest/index.html | |
(require 'flycheck) | |
;; turn on flychecking globally | |
(add-hook 'after-init-hook #'global-flycheck-mode) | |
;; disable jshint since we prefer eslint checking | |
(setq-default flycheck-disabled-checkers | |
(append flycheck-disabled-checkers | |
'(javascript-jshint))) | |
;; use eslint with web-mode for jsx files | |
(flycheck-add-mode 'javascript-eslint 'web-mode) | |
;; customize flycheck temp file prefix | |
(setq-default flycheck-temp-prefix ".flycheck") | |
;; disable json-jsonlist checking for json files | |
(setq-default flycheck-disabled-checkers | |
(append flycheck-disabled-checkers | |
'(json-jsonlist))) | |
;; https://github.com/purcell/exec-path-from-shell | |
;; only need exec-path-from-shell on OSX | |
;; this hopefully sets up path and other vars better | |
(when (memq window-system '(mac ns)) | |
(exec-path-from-shell-initialize)) | |
;; use local eslint from node_modules before global | |
;; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable | |
(defun my/use-eslint-from-node-modules () | |
(let* ((root (locate-dominating-file | |
(or (buffer-file-name) default-directory) | |
"node_modules")) | |
(eslint (and root | |
(expand-file-name "node_modules/eslint/bin/eslint.js" | |
root)))) | |
(when (and eslint (file-executable-p eslint)) | |
(setq-local flycheck-javascript-eslint-executable eslint)))) | |
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules) | |
;; adjust indents for web-mode to 2 spaces | |
(defun my-web-mode-hook () | |
"Hooks for Web mode. Adjust indents" | |
;;; http://web-mode.org/ | |
(setq web-mode-markup-indent-offset 2) | |
(setq web-mode-css-indent-offset 2) | |
(setq web-mode-code-indent-offset 2)) | |
(add-hook 'web-mode-hook 'my-web-mode-hook) | |
;; identation config | |
(setq-default indent-tabs-mode nil) | |
(setq js-indent-level 2) | |
;; for better jsx syntax-highlighting in web-mode | |
;; - courtesy of Patrick @halbtuerke | |
(defadvice web-mode-highlight-part (around tweak-jsx activate) | |
(if (equal web-mode-content-type "jsx") | |
(let ((web-mode-enable-part-face nil)) | |
ad-do-it) | |
ad-do-it)) | |
;; BACKUP AND AUTO SAVE FILES | |
(setq backup-directory-alist | |
`((".*" . ,"~/tmp/emacs-files"))) | |
(setq auto-save-file-name-transforms | |
`((".*" ,"~/tmp/emacs-files" t))) | |
(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. | |
) | |
(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 (:background nil)))) | |
'(scroll-bar ((t (:background "gray0"))))) | |
(setq debug-on-error t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment