Initial commit
dotbot, X, emacs, zsh, i3
This commit is contained in:
commit
c154ac3f7c
17 changed files with 2241 additions and 0 deletions
272
emacs/init.el
Normal file
272
emacs/init.el
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
(require 'package)
|
||||
(push '("melpa" . "http://melpa.milkbox.net/packages/")
|
||||
package-archives)
|
||||
(package-initialize)
|
||||
|
||||
(require 'cl)
|
||||
|
||||
(defvar my-packages
|
||||
'(
|
||||
autopair
|
||||
evil
|
||||
evil-surround
|
||||
go-mode
|
||||
goto-chg
|
||||
haskell-mode
|
||||
jinja2-mode
|
||||
markdown-mode
|
||||
php-mode
|
||||
scala-mode
|
||||
undo-tree
|
||||
web-mode
|
||||
)
|
||||
"A list of packages to ensure are installed at launch.")
|
||||
|
||||
(defun my-packages-installed-p ()
|
||||
(loop for p in my-packages
|
||||
when (not (package-installed-p p)) do (return nil)
|
||||
finally (return t)))
|
||||
|
||||
(unless (my-packages-installed-p)
|
||||
;; check for new packages (package versions)
|
||||
(package-refresh-contents)
|
||||
;; install the missing packages
|
||||
(dolist (p my-packages)
|
||||
(when (not (package-installed-p p))
|
||||
(package-install p))))
|
||||
|
||||
(require 'evil)
|
||||
(evil-mode 1)
|
||||
|
||||
(require 'evil-surround)
|
||||
(global-evil-surround-mode 1)
|
||||
|
||||
(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.
|
||||
'(global-subword-mode t)
|
||||
'(indent-tabs-mode nil)
|
||||
'(inhibit-startup-buffer-menu t)
|
||||
'(inhibit-startup-screen t)
|
||||
'(initial-scratch-message "")
|
||||
'(menu-bar-mode nil)
|
||||
'(mouse-wheel-mode nil)
|
||||
'(require-final-newline t)
|
||||
'(scheme-program-name "mit-scheme")
|
||||
'(split-height-threshold 0)
|
||||
'(split-width-threshold 0)
|
||||
'(tab-width 4)
|
||||
'(tool-bar-mode t)
|
||||
'(visible-cursor nil))
|
||||
|
||||
(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.
|
||||
'(hl-line ((t (:background "black")))))
|
||||
|
||||
(require 'autopair)
|
||||
(autopair-global-mode)
|
||||
|
||||
(require 'ido)
|
||||
(ido-mode t)
|
||||
|
||||
;; remove line wrap character
|
||||
(set-display-table-slot standard-display-table 'wrap ?\ )
|
||||
|
||||
;; longlines mode everywhere
|
||||
(global-visual-line-mode t)
|
||||
|
||||
;; show line/column numbers
|
||||
(setq line-number-mode t)
|
||||
(setq column-number-mode t)
|
||||
|
||||
;; pretty-greek
|
||||
(defun pretty-greek ()
|
||||
(let ((greek '("alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta" "theta" "iota" "kappa" "lambda" "mu" "nu" "xi" "omicron" "pi" "rho" "sigma_final" "sigma" "tau" "upsilon" "phi" "chi" "psi" "omega")))
|
||||
(loop for word in greek
|
||||
for code = 97 then (+ 1 code)
|
||||
do (let ((greek-char (make-char 'greek-iso8859-7 code)))
|
||||
(font-lock-add-keywords nil
|
||||
`((,(concatenate 'string "\\(^\\|[^a-zA-Z0-9]\\)\\(" word "\\)[a-zA-Z]")
|
||||
(0 (progn (decompose-region (match-beginning 2) (match-end 2))
|
||||
nil)))))
|
||||
(font-lock-add-keywords nil
|
||||
`((,(concatenate 'string "\\(^\\|[^a-zA-Z0-9]\\)\\(" word "\\)[^a-zA-Z]")
|
||||
(0 (progn (compose-region (match-beginning 2) (match-end 2)
|
||||
,greek-char)
|
||||
nil)))))))))
|
||||
|
||||
(add-hook 'tex-mode-hook 'pretty-greek)
|
||||
(add-hook 'prog-mode-hook 'pretty-greek)
|
||||
|
||||
(put 'narrow-to-region 'disabled nil)
|
||||
(global-hl-line-mode 1)
|
||||
|
||||
;; comment current line
|
||||
;; Original idea from
|
||||
;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html
|
||||
(defun comment-dwim-line (&optional arg)
|
||||
"Replacement for the comment-dwim command.
|
||||
If no region is selected and current line is not blank and we are not at the end of the line,
|
||||
then comment current line.
|
||||
Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line."
|
||||
(interactive "*P")
|
||||
(comment-normalize-vars)
|
||||
(if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
|
||||
(comment-or-uncomment-region (line-beginning-position) (line-end-position))
|
||||
(comment-dwim arg)))
|
||||
(global-set-key "\M-;" 'comment-dwim-line)
|
||||
|
||||
;; python3
|
||||
(add-to-list 'auto-mode-alist '("\\.py3\\'" . python-mode))
|
||||
|
||||
;; highlight matching parens
|
||||
(require 'paren)
|
||||
(defun lispy-parens ()
|
||||
"Setup parens display for lisp modes"
|
||||
(setq show-paren-delay 0)
|
||||
(setq show-paren-style 'parenthesis)
|
||||
(make-variable-buffer-local 'show-paren-mode)
|
||||
(show-paren-mode 1)
|
||||
(set-face-attribute 'show-paren-match-face nil :foreground "orange")
|
||||
(set-face-attribute 'show-paren-match-face nil :background "black")
|
||||
(set-face-attribute 'show-paren-match-face nil :weight 'extra-bold))
|
||||
|
||||
(add-hook 'emacs-lisp-mode-hook 'lispy-parens)
|
||||
(add-hook 'scheme-mode-hook 'lispy-parens)
|
||||
|
||||
;; Missing things from scheme IDE
|
||||
(defun scheme-send-buffer ()
|
||||
(interactive)
|
||||
(let ((oldbuf (current-buffer)))
|
||||
(run-scheme scheme-program-name)
|
||||
(switch-to-buffer oldbuf)
|
||||
(scheme-send-region (point-min) (point-max))))
|
||||
|
||||
(defun scheme-send-buffer-and-go ()
|
||||
(interactive)
|
||||
(let ((oldbuf (current-buffer)))
|
||||
(if (= (length (window-list)) 1)
|
||||
(split-window-right))
|
||||
(other-window 1)
|
||||
(run-scheme scheme-program-name)
|
||||
(other-window -1))
|
||||
(scheme-send-region (point-min) (point-max)))
|
||||
|
||||
(eval-after-load 'scheme
|
||||
'(define-key scheme-mode-map (kbd "C-c C-s") 'scheme-send-buffer))
|
||||
|
||||
(require 'php-mode)
|
||||
|
||||
|
||||
(require 'markdown-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
|
||||
|
||||
;; linum-mode
|
||||
(add-hook 'prog-mode-hook (lambda () (linum-mode 1)))
|
||||
(unless window-system
|
||||
(add-hook 'linum-before-numbering-hook
|
||||
(lambda ()
|
||||
(setq-local linum-format-fmt
|
||||
(let ((w (length (number-to-string
|
||||
(count-lines (point-min) (point-max))))))
|
||||
(concat "%" (number-to-string w) "d"))))))
|
||||
|
||||
(defun linum-format-func (line)
|
||||
(concat
|
||||
(propertize (format linum-format-fmt line) 'face 'linum)
|
||||
(propertize " " 'face 'linum)))
|
||||
|
||||
(unless window-system
|
||||
(setq linum-format 'linum-format-func))
|
||||
|
||||
;; delete trailing whitespace on save
|
||||
(add-hook 'prog-mode-hook (lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
|
||||
|
||||
(require 'jinja2-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.jinja2\\'" . jinja2-mode))
|
||||
|
||||
;; found at https://gist.github.com/NFicano/1356280
|
||||
;; modified for 24.3
|
||||
|
||||
(defadvice python-indent-calculate-indentation (around fix-list-indentation)
|
||||
"Fix indentation in continuation lines within lists"
|
||||
(unless (save-excursion
|
||||
(beginning-of-line)
|
||||
(when (python-info-continuation-line-p)
|
||||
(let* ((syntax (syntax-ppss))
|
||||
(open-start (cadr syntax))
|
||||
(point (point)))
|
||||
(when open-start
|
||||
;; Inside bracketed expression.
|
||||
(goto-char (1+ open-start))
|
||||
;; Indent relative to statement start, one
|
||||
;; level per bracketing level.
|
||||
(goto-char (1+ open-start))
|
||||
(python-nav-beginning-of-statement)
|
||||
(setq ad-return-value (+ (current-indentation) (* (car syntax) python-indent)))))))
|
||||
ad-do-it))
|
||||
|
||||
(defadvice python-indent-calculate-indentation (around outdent-closing-brackets)
|
||||
"Handle lines beginning with a closing bracket and indent them so that
|
||||
they line up with the line containing the corresponding opening bracket."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(let ((syntax (syntax-ppss)))
|
||||
(if (and (not (eq 'string (syntax-ppss-context syntax)))
|
||||
(python-info-continuation-line-p)
|
||||
(cadr syntax)
|
||||
(skip-syntax-forward "-")
|
||||
(looking-at "\\s)"))
|
||||
(progn
|
||||
(forward-char 1)
|
||||
(ignore-errors (backward-sexp))
|
||||
(setq ad-return-value (current-indentation)))
|
||||
ad-do-it))))
|
||||
|
||||
|
||||
;; Activate Python ident advice
|
||||
(ad-activate 'python-indent-calculate-indentation)
|
||||
|
||||
(require 'scala-mode)
|
||||
|
||||
(require 'haskell-mode)
|
||||
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
|
||||
|
||||
(require 'web-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
|
||||
|
||||
(add-hook 'web-mode-hook
|
||||
(lambda ()
|
||||
(setq web-mode-markup-indent-offset 2)
|
||||
(setq web-mode-css-indent-offset 2)
|
||||
(setq web-mode-code-indent-offset 2)
|
||||
(setq web-mode-enable-auto-pairing t)
|
||||
(setq web-mode-enable-auto-expanding t)
|
||||
|
||||
(setq web-mode-enable-html-colorization t)
|
||||
(setq web-mode-enable-css-colorization t)
|
||||
|
||||
(set-face-attribute 'web-mode-html-attr-name-face nil :foreground "#3387cc")
|
||||
(set-face-attribute 'web-mode-html-attr-equal-face nil :foreground "gray60")
|
||||
(set-face-attribute 'web-mode-html-tag-bracket-face nil :foreground "gray60")
|
||||
(set-face-attribute 'web-mode-html-tag-face nil :foreground "#e9c062")
|
||||
|
||||
(define-key web-mode-map (kbd "C-c /") 'web-mode-element-close)))
|
||||
|
||||
(require 'go-mode-autoloads)
|
||||
|
||||
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
|
||||
(load-theme 'jdkaplan t)
|
||||
|
||||
(add-to-list 'auto-mode-alist '(("/tmp/mutt.*" . mail-mode)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue