Updating emacs.d files

This commit is contained in:
Henrik Lissner 2015-04-22 20:48:28 -04:00
parent ec6d152756
commit cb99d818fb
14 changed files with 242 additions and 219 deletions

View file

@ -29,7 +29,7 @@
(auto-compression-mode t) ; Transparently open compressed files (auto-compression-mode t) ; Transparently open compressed files
(global-font-lock-mode t) ; Enable syntax highlighting for older emacs (global-font-lock-mode t) ; Enable syntax highlighting for older emacs
(global-auto-revert-mode 1) ; revert buffers for changed files (global-auto-revert-mode 1) ; revert buffers for changed files
(electric-indent-mode -1) ; In case of emacs 24.4 (electric-indent-mode -1) ; In case of emacs >24.4
;;; window layout undo/redo ;;; window layout undo/redo
(winner-mode 1) (winner-mode 1)
@ -145,7 +145,7 @@
;;;; Editor behavior ;;;;;;;;;;;;;;;; ;;;; Editor behavior ;;;;;;;;;;;;;;;;
;; spaces instead of tabs ;; spaces instead of tabs
(setq-default indent-tabs-mode nil) ; spaces instead of tabs (setq-default indent-tabs-mode nil) ; spaces instead of tabs
(setq-default tab-always-indent nil) (setq-default tab-always-indent t)
(setq-default tab-width 4) (setq-default tab-width 4)
(setq require-final-newline t) (setq require-final-newline t)

View file

@ -6,24 +6,13 @@
;;;###autoload ;;;###autoload
(defun load-dark-theme() (defun load-dark-theme()
(interactive) (interactive)
;; (sml/apply-theme 'respectful)
(load-theme *dark-theme t)) (load-theme *dark-theme t))
;;;###autoload ;;;###autoload
(defun load-light-theme() (defun load-light-theme()
(interactive) (interactive)
;; (sml/apply-theme 'light)
(load-theme *light-theme t)) (load-theme *light-theme t))
;;;###autoload
(defun load-font (font size)
(interactive)
(when window-system
(let ((font-str (concat font "-" (number-to-string size))))
(if (member font (font-family-list))
(set-frame-font font-str t t)
(error "Font %s not installed" font)))))
;;;###autoload ;;;###autoload
(defun toggle-transparency () (defun toggle-transparency ()
(interactive) (interactive)
@ -49,16 +38,4 @@
(if (>= my/cycle-font-i (1- (length *fonts))) (if (>= my/cycle-font-i (1- (length *fonts)))
(setq my/cycle-font-i 0) (setq my/cycle-font-i 0)
(cl-incf my/cycle-font-i))) (cl-incf my/cycle-font-i)))
(let* ((font (nth my/cycle-font-i *fonts)) (set-frame-font (nth my/cycle-font-i *fonts)))
(font-name (nth 0 font))
(font-size (nth 1 font))
(font-aa (nth 2 font))
(font-line (nth 3 font)))
(unless (member font-name (font-family-list))
(error "Font %s isn't installed" font-name))
(let ((font-str (concat font-name "-" (number-to-string font-size))))
(add-to-list 'default-frame-alist `(font . ,font-str))
(add-to-list 'initial-frame-alist `(font . ,font-str)))
(load-font font-name font-size)
(setq ns-antialias-text font-aa)
(setq-default line-spacing font-line)))

35
init.el
View file

@ -18,11 +18,6 @@
;;; Code: ;;; Code:
(defconst DEBUG-MODE nil) (defconst DEBUG-MODE nil)
(require 'cask)
(cask-initialize)
(eval-when-compile (require 'use-package))
(defconst my-dir user-emacs-directory) (defconst my-dir user-emacs-directory)
(defconst my-core-dir (concat my-dir "core/")) (defconst my-core-dir (concat my-dir "core/"))
(defconst my-modules-dir (concat my-dir "init/")) (defconst my-modules-dir (concat my-dir "init/"))
@ -34,9 +29,9 @@
(defconst *dark-theme 'v0) (defconst *dark-theme 'v0)
(defconst *light-theme 'github) ; wtb better light theme... (defconst *light-theme 'github) ; wtb better light theme...
(defconst *fonts `(("Terminus (TTF)" 12 nil 0.1) (defconst *fonts `(,(font-spec :family "Terminus (TTF)" :size 12 :antialias nil)
("Ubuntu Mono" 16 t 0) ,(font-spec :family "Ubuntu Mono" :size 16 :antialias t)
("Inconsolata" 22 t 0))) ,(font-spec :family "Inconsolata" :size 22 :antialias t)))
(add-to-list 'load-path my-core-dir) (add-to-list 'load-path my-core-dir)
(add-to-list 'load-path my-modules-dir) (add-to-list 'load-path my-modules-dir)
@ -47,7 +42,11 @@
(normal-top-level-add-subdirs-to-load-path)) (normal-top-level-add-subdirs-to-load-path))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Just the... bear necessities...
(require 'cask)
(cask-initialize)
(eval-when-compile (require 'use-package))
(mapc 'require (mapc 'require
;; ls init/{init,my}* | xargs basename | sed -e 's/\..*$//' ;; ls init/{init,my}* | xargs basename | sed -e 's/\..*$//'
'(core '(core
@ -55,27 +54,28 @@
;; init-auto-complete ;; init-auto-complete
init-auto-insert ; for the lazy typis init-auto-insert ; for the lazy typis
init-company ; see above init-company ; see above
init-dev ; general dev tools/settings
;; init-floobits ; when I'm feeling lonely
init-fly ; fly(check|spell)
init-git ; git-gutter + modes
init-helm ; a search engine for your life
init-ido ; a search engine for your car keys
init-project ; project tools - dired, perspective, neotree
init-projectile ; when you forget where you put your house
init-cc ; C/C++/Obj-C madness init-cc ; C/C++/Obj-C madness
;; init-d ; D - It's C, but better! ;; init-d ; D - It's C, but better!
;; init-cscope ;; init-cscope
init-csharp init-csharp
init-dev ; general dev tools/settings
init-lisp ; all things lisp; elisp, clojure init-lisp ; all things lisp; elisp, clojure
;; init-erlang ;; init-erlang
;; init-eshell ;; init-eshell
;; init-floobits ; when I'm feeling lonely
init-fly ; fly(check|spell)
init-git ; git-gutter + modes
;; init-go ;; init-go
init-helm ; a search engine for your life
init-ido ; a search engine for your car keys
init-java ; the poster child for carpal tunnel syndome init-java ; the poster child for carpal tunnel syndome
init-js ; alert("not java, javascript!") init-js ; alert("not java, javascript!")
init-lua ; zero-based indices? Zero-based indices. init-lua ; zero-based indices? Zero-based indices.
init-org ; for fearless leader (who is organized) init-org ; for fearless leader (who is organized)
init-php ; making php less painful to work with init-php ; making php less painful to work with
init-project ; project tools - dired, perspective, neotree
init-projectile ; when you forget where you put your house
init-python ; beautiful is better than ugly init-python ; beautiful is better than ugly
init-regex ; /^[^\s](meaning)[^\n]*/ init-regex ; /^[^\s](meaning)[^\n]*/
init-ruby ; <3 init-ruby ; <3
@ -93,6 +93,7 @@
my-bindings my-bindings
my-settings my-settings
my-defuns
)) ))
;; I've created a monster! ;; I've created a monster!

View file

@ -19,68 +19,68 @@
(yas--get-template-by-uuid mode uuid)) (point-min) (point-max)) (yas--get-template-by-uuid mode uuid)) (point-min) (point-max))
(evil-insert-state))) (evil-insert-state)))
(template "/\\.gitignore$" "%%" 'gitignore-mode) (template "/\\.gitignore$" "%%" 'gitignore-mode)
;; C/C++ ;; C/C++
(template "/Makefile$" "%%" 'makefile-gmake-mode) (template "/Makefile$" "%%" 'makefile-gmake-mode)
(template "/main\\.\\(cc\\|cpp\\)$" "%main.cpp%" 'c++-mode) (template "/main\\.\\(cc\\|cpp\\)$" "%main.cpp%" 'c++-mode)
(template "/win32_\\.\\(cc\\|cpp\\)$" "%winmain.cpp%" 'c++-mode) (template "/win32_\\.\\(cc\\|cpp\\)$" "%winmain.cpp%" 'c++-mode)
(template "\\.\\([Hh]\\|hpp\\)$" "%.h%" 'c++-mode) (template "\\.\\([Hh]\\|hpp\\)$" "%.h%" 'c++-mode)
(template "\\.\\([Cc]\\|cc\\|cpp\\)$" "%.cpp%" 'c++-mode) (template "\\.\\([Cc]\\|cc\\|cpp\\)$" "%.cpp%" 'c++-mode)
;; Shell scripts ;; Shell scripts
(template "\\.z?sh$" "%%" 'sh-mode) (template "\\.z?sh$" "%%" 'sh-mode)
;; ;; ;; Ruby ;; Ruby
(template "/spec_helper\\.rb$" "%helper%" 'rspec-mode t) (template "/spec_helper\\.rb$" "%helper%" 'rspec-mode t)
(template "_spec\\.rb$" "%%" 'rspec-mode t) (template "_spec\\.rb$" "%%" 'rspec-mode t)
(template "/\\.rspec$" "%.rspec%" 'rspec-mode) (template "/\\.rspec$" "%.rspec%" 'rspec-mode)
(template "/Rakefile$" "%Rakefile%" 'ruby-mode t) (template "/Rakefile$" "%Rakefile%" 'ruby-mode t)
(template "/Gemfile$" "%Gemfile%" 'ruby-mode t) (template "/Gemfile$" "%Gemfile%" 'ruby-mode t)
;; (template "\\.gemspec$" "%.gemspec%" 'ruby-mode t) ;; (template "\\.gemspec$" "%.gemspec%" 'ruby-mode t)
(template "/lib/.+\\.rb$" "%module%" 'ruby-mode t) (template "/lib/.+\\.rb$" "%module%" 'ruby-mode t)
(template "\\.rb$" "%%" 'ruby-mode) (template "\\.rb$" "%%" 'ruby-mode)
;; ;; ;; Python ;; ;; Python
;; ;; (template "tests?/test_.+\\.py$" "%%" 'nose-mode) ;; (template "tests?/test_.+\\.py$" "%%" 'nose-mode)
;; ;; (template "/setup\\.py$" "%setup%" 'python-mode) ;; (template "/setup\\.py$" "%setup%" 'python-mode)
(template "\\.py$" "%%" 'python-mode) (template "\\.py$" "%%" 'python-mode)
;; ;; ;; PHP ;; ;; PHP
;; ;; (template "\\.class\\.php$" "%class%" 'php-mode) ;; (template "\\.class\\.php$" "%class%" 'php-mode)
;; ;; (template "\\.php$" "%%" 'php-mode) ;; (template "\\.php$" "%%" 'php-mode)
;; ;; ;; Markdown ;; ;; Markdown
(template "/README\\.md$" "%README.md%" 'markdown-mode) (template "/README\\.md$" "%README.md%" 'markdown-mode)
;; ;; (template "/_posts/.+\\.md$" "%jekyll-post" 'markdown-mode) ;; (template "/_posts/.+\\.md$" "%jekyll-post" 'markdown-mode)
;; ;; (template "/_layouts/.+\\.html$" "%jekyll-layout%" 'web-mode) ;; (template "/_layouts/.+\\.html$" "%jekyll-layout%" 'web-mode)
;; ;; ;; Javascript ;; ;; Javascript
;; ;; (template "\\.lbaction/Contents/Info.plist$" "%lb6%" 'nxml-mode) ;; (template "\\.lbaction/Contents/Info.plist$" "%lb6%" 'nxml-mode)
;; ;; (template "\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "%lb6%" 'js-mode) ;; (template "\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "%lb6%" 'js-mode)
;; ;; (template "/package\\.json$" "%package.json%" 'json-mode) ;; (template "/package\\.json$" "%package.json%" 'json-mode)
;; ;; (template "\\.\\(json\\|jshintrc\\)$" "%%" 'json-mode) ;; (template "\\.\\(json\\|jshintrc\\)$" "%%" 'json-mode)
;; ;; ;; SCSS ;; ;; SCSS
;; ;; (template "/master\\.scss$" "%master%" 'scss-mode) ;; (template "/master\\.scss$" "%master%" 'scss-mode)
;; ;; (template "/normalize\\.scss$" "%normalize%" 'scss-mode) ;; (template "/normalize\\.scss$" "%normalize%" 'scss-mode)
;; ;; (template "\\.scss$" "%%" 'scss-mode) ;; (template "\\.scss$" "%%" 'scss-mode)
;; ;; ;; HTML ;; ;; HTML
;; ;; (template "\\.html$" "%%" 'web-mode) ;; (template "\\.html$" "%%" 'web-mode)
;; ;; ;; Lua ;; Lua
;; ;; (template "\\.love/main\\.lua$" "%love.main%" 'lua-mode) ;; (template "\\.love/main\\.lua$" "%love.main%" 'lua-mode)
;; ;; (template "\\.love/conf\\.lua$" "%love.conf%" 'lua-mode) ;; (template "\\.love/conf\\.lua$" "%love.conf%" 'lua-mode)
;; ;; (template "\\.lua$" "%%" 'lua-mode) ;; (template "\\.lua$" "%%" 'lua-mode)
;; ;; ;; Java ;; ;; Java
;; ;; (template "/src/.+/.+\\.java$ "%%" 'java-mode) ;; (template "/src/.+/.+\\.java$ "%%" 'java-mode)
;; ;; (template "\\.gradle$" "%%" 'groovy-mode) ;; (template "\\.gradle$" "%%" 'groovy-mode)
;; ;; ;; Elisp ;; ;; Elisp
(template "\\.emacs\\.d/.+\\.el$" "%initfile%" 'emacs-lisp-mode) (template "\\.emacs\\.d/.+\\.el$" "%initfile%" 'emacs-lisp-mode)
(template "\\.emacs\\.d/snippets/.+$" "%%" 'snippet-mode)) (template "\\.emacs\\.d/snippets/.+$" "%%" 'snippet-mode))
(provide 'init-auto-insert) (provide 'init-auto-insert)

View file

@ -1,5 +1,4 @@
(use-package cmake-mode (use-package cmake-mode
:disabled t
:mode "CMakeLists\\.txt$" :mode "CMakeLists\\.txt$"
:config :config
(progn (progn
@ -59,26 +58,6 @@
. objc-mode)) . objc-mode))
(after "flycheck" (add-hook! 'objc-mode-hook (use-package flycheck-objc)))) (after "flycheck" (add-hook! 'objc-mode-hook (use-package flycheck-objc))))
;; (use-package ycmd
;; :init (add-hook 'c++-mode-hook 'ycmd-mode)
;; :config
;; (progn
;; (setq ycmd-global-config (f-full "~/.ycm_extra_conf.py"))
;; (setq ycmd-server-command `("/usr/local/bin/python" ,(f-full "~/.emacs.d/ext/YouCompleteMe/third_party/ycmd/ycmd/")))
;; (use-package company-ycmd
;; :init (company--backend-on 'c++-mode-hook 'company-ycmd))))
;; (after "auto-complete"
;; (when is-mac (setq ac-clang-flags (my--clang-includes-flags)))
;; (add-hook! 'c-mode-common-hook
;; (use-package auto-complete-clang)
;; (use-package auto-complete-c-headers)
;; (setq ac-sources
;; '(ac-source-clang
;; ac-source-c-headers
;; ac-source-yasnippet
;; ac-source-words-in-same-mode-buffers))))
(after "company" (after "company"
;; TODO Clang is *really* slow in larger projects, maybe replace it with irony-mode or ycmd? ;; TODO Clang is *really* slow in larger projects, maybe replace it with irony-mode or ycmd?
(company--backend-on 'c-mode-hook 'company-c-headers 'company-clang) (company--backend-on 'c-mode-hook 'company-c-headers 'company-clang)
@ -93,6 +72,8 @@
(c-set-offset 'block-open '+) (c-set-offset 'block-open '+)
(c-set-offset 'brace-list-open '+) ; all "opens" should be indented by the c-indent-level (c-set-offset 'brace-list-open '+) ; all "opens" should be indented by the c-indent-level
(c-set-offset 'case-label '+) ; indent case labels by c-indent-level, too (c-set-offset 'case-label '+) ; indent case labels by c-indent-level, too
(c-set-offset 'access-label '-)
(c-set-offset 'inclass '++)
;; DEL mapping interferes with smartparens and my.deflate-maybe ;; DEL mapping interferes with smartparens and my.deflate-maybe
(bind c-mode-map (kbd "DEL") nil)) (bind c-mode-map (kbd "DEL") nil))
@ -148,8 +129,7 @@
;; user-defined types (rather project-specific) ;; user-defined types (rather project-specific)
("\\<[A-Za-z_]+[A-Za-z_0-9]*_\\(type\\|ptr\\)\\>" . font-lock-type-face) ("\\<[A-Za-z_]+[A-Za-z_0-9]*_\\(type\\|ptr\\)\\>" . font-lock-type-face)
("\\<\\(xstring\\|xchar\\)\\>" . font-lock-type-face) ("\\<\\(xstring\\|xchar\\)\\>" . font-lock-type-face)
)) )) t)
t)
;; Fix enum and C++11 lambda indentation ;; Fix enum and C++11 lambda indentation
(defadvice c-lineup-arglist (around c-lineup-arglist-indent-fix activate) (defadvice c-lineup-arglist (around c-lineup-arglist-indent-fix activate)

View file

@ -2,7 +2,8 @@
:defer t :defer t
:config :config
(progn (progn
(setq omnisharp-server-executable-path "~/Dropbox/projects/lib/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe") (setq omnisharp-server-executable-path
"~/Dropbox/projects/lib/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe")
(bind 'normal omnisharp-mode-map (bind 'normal omnisharp-mode-map
"gd" 'omnisharp-go-to-definition) "gd" 'omnisharp-go-to-definition)
@ -11,19 +12,12 @@
(company--backend-on 'csharp-mode-hook 'company-omnisharp) (company--backend-on 'csharp-mode-hook 'company-omnisharp)
(add-hook 'csharp-mode-hook 'turn-on-eldoc-mode)))) (add-hook 'csharp-mode-hook 'turn-on-eldoc-mode))))
(use-package csharp-mode :mode "\\.cs$") (use-package csharp-mode :mode "\\.cs$"
;; (use-package csharp-mode :config
;; :mode "\\.cs$" (after "flycheck" (add-hook 'csharp-mode-hook 'flycheck-mode)))
;; :config
;; (bind 'insert csharp-mode-map (kbd "C-SPC") 'omnisharp-auto-complete))
;; :init
;; (add-hook! 'csharp-mode-hook (omnisharp-mode t) (flycheck-mode t)))
;; unity shaders ;; unity shaders
(use-package shaderlab-mode :mode "\\.shader$") (use-package shaderlab-mode :mode "\\.shader$")
;; TODO Make more Unity-friendly
(provide 'init-csharp) (provide 'init-csharp)
;;; init-csharp.el ends here ;;; init-csharp.el ends here

View file

@ -5,10 +5,15 @@
(setq-default flycheck-indication-mode 'right-fringe (setq-default flycheck-indication-mode 'right-fringe
;; Removed checks on idle/change for snappiness ;; Removed checks on idle/change for snappiness
flycheck-check-syntax-automatically '(save mode-enabled) flycheck-check-syntax-automatically '(save mode-enabled)
flycheck-disabled-checkers '(emacs-lisp-checkdoc emacs-lisp make)) flycheck-disabled-checkers '(emacs-lisp-checkdoc make))
(dolist (hook '(ruby-mode-hook (dolist (hook '(ruby-mode-hook
python-mode-hook python-mode-hook
php-mode-hook
lua-mode-hook
shell-mode-hook shell-mode-hook
scss-mode-hook
c++-mode-hook
c-mode-hook
)) ))
(add-hook hook 'flycheck-mode))) (add-hook hook 'flycheck-mode)))
:config :config

View file

@ -51,9 +51,11 @@
(use-package unityjs-mode (use-package unityjs-mode
:mode "/Assets/*.js$" :mode "/Assets/*.js$"
:config :config
(add-hook! 'unityjs-mode-hook (progn
(enable-tab-width-2) (add-hook 'unityjs-mode-hook 'flycheck-mode)
(setq js-indent-level 2))) (add-hook! 'unityjs-mode-hook
(enable-tab-width-2)
(setq js-indent-level 2))))
(provide 'init-js) (provide 'init-js)

View file

@ -193,23 +193,23 @@
"C-k" nil) "C-k" nil)
(bind '(normal insert) evil-org-mode-map (bind '(normal insert) evil-org-mode-map
"M-l" 'org-metaright "¬" 'org-metaright ; M-j
"M-h" 'org-metaleft "˙" 'org-metaleft ; M-h
"M-k" 'org-metaup "˚" 'org-metaup ; M-k
"M-j" 'org-metadown "Δ" 'org-metadown ; M-j
"M-L" 'org-shiftmetaright "Ò" 'org-shiftmetaright ; M-L
"M-H" 'org-shiftmetaleft "Ó" 'org-shiftmetaleft ; M-H
"M-K" 'org-shiftmetaup "" 'org-shiftmetaup ; M-K
"M-J" 'org-shiftmetadown) "Ô" 'org-shiftmetadown) ; M-J
(bind 'insert evil-org-mode-map (bind 'insert evil-org-mode-map
"C-e" 'org-end-of-line "C-e" 'org-end-of-line
"C-a" 'org-beginning-of-line) "C-a" 'org-beginning-of-line)
(bind '(insert normal) evil-org-mode-map (bind '(insert normal) evil-org-mode-map
"<s-left>" 'org-beginning-of-line "<M-left>" 'org-beginning-of-line
"<s-right>" 'org-end-of-line "<M-right>" 'org-end-of-line
"<s-up>" 'org-up-element "<M-up>" 'org-up-element
"<s-down>" 'org-down-element) "<M-down>" 'org-down-element)
;; Formatting shortcuts ;; Formatting shortcuts
(defun my/org-surround (delim) (defun my/org-surround (delim)
@ -217,19 +217,19 @@
(bind 'insert evil-org-mode-map (bind 'insert evil-org-mode-map
;; Add new header line before this line ;; Add new header line before this line
(kbd "<S-s-return>") 'my--org-insert-item-before (kbd "<S-M-return>") 'my--org-insert-item-before
;; Add new header line after this line ;; Add new header line after this line
(kbd "<s-return>") 'my--org-insert-item-after (kbd "<M-return>") 'my--org-insert-item-after
(kbd "s-b") (λ (my/org-surround "*")) ; bold (kbd "M-b") (λ (my/org-surround "*")) ; bold
(kbd "s-u") (λ (my/org-surround "_")) ; underline (kbd "M-u") (λ (my/org-surround "_")) ; underline
(kbd "s-i") (λ (my/org-surround "/")) ; italics (kbd "M-i") (λ (my/org-surround "/")) ; italics
(kbd "s-`") (λ (my/org-surround "+"))) ; strikethrough (kbd "M-`") (λ (my/org-surround "+"))) ; strikethrough
(bind 'visual evil-org-mode-map (bind 'visual evil-org-mode-map
(kbd "s-b") "S*" (kbd "M-b") "S*"
(kbd "s-u") "S_" (kbd "M-u") "S_"
(kbd "s-i") "S/" (kbd "M-i") "S/"
(kbd "s-`") "S+") (kbd "M-`") "S+")
(bind '(normal visual) evil-org-mode-map (bind '(normal visual) evil-org-mode-map
", l" 'org-insert-link) ", l" 'org-insert-link)
@ -267,8 +267,8 @@
"-" 'org-cycle-list-bullet "-" 'org-cycle-list-bullet
", SPC" 'my--toggle-checkbox ", SPC" 'my--toggle-checkbox
", <return>" 'org-archive-subtree ", <return>" 'org-archive-subtree
"<S-s-return>" 'my--org-insert-item-before "<S-M-return>" 'my--org-insert-item-before
"<s-return>" 'my--org-insert-item-after "<M-return>" 'my--org-insert-item-after
"RET" (λ (cond ((org-at-item-checkbox-p) "RET" (λ (cond ((org-at-item-checkbox-p)
(org-toggle-checkbox)) (org-toggle-checkbox))
((org-entry-is-todo-p) ((org-entry-is-todo-p)

View file

@ -52,6 +52,7 @@
:defer t :defer t
:init :init
(progn (progn
(add-hook 'css-mode-hook 'emmet-mode)
(add-hook 'scss-mode-hook 'emmet-mode) (add-hook 'scss-mode-hook 'emmet-mode)
(add-hook 'web-mode-hook 'emmet-mode) (add-hook 'web-mode-hook 'emmet-mode)
(add-hook 'html-mode-hook 'emmet-mode) (add-hook 'html-mode-hook 'emmet-mode)

View file

@ -115,7 +115,15 @@
(goto-char position)))) (goto-char position))))
;; Prevents Yas from stepping on my toes when I use backspace ;; Prevents Yas from stepping on my toes when I use backspace
(defun my/yas-clear-field (&optional field) (defun my/yas-backspace (&optional field)
(interactive)
(let ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field)))))
(cond ((eq (point) (marker-position (yas--field-start field))) nil)
(t (delete-char -1)))))
(defun my/yas-delete (&optional field)
(interactive) (interactive)
(let ((field (or field (and yas--active-field-overlay (let ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay) (overlay-buffer yas--active-field-overlay)
@ -125,15 +133,28 @@
(eq (point) (marker-position (yas--field-start field)))) (eq (point) (marker-position (yas--field-start field))))
(yas--skip-and-clear field) (yas--skip-and-clear field)
(yas-next-field 1)) (yas-next-field 1))
(t (delete-char -1))))) ((eq (point) (marker-position (yas--field-end field))) nil)
(t (delete-char 1)))))
(defun my/yas-clear-to-sof (&optional field)
(interactive)
(let* ((field (or field (and yas--active-field-overlay
(overlay-buffer yas--active-field-overlay)
(overlay-get yas--active-field-overlay 'yas--field))))
(sof (marker-position (yas--field-start field))))
(when (and field (> (point) sof))
(delete-region sof (point)))))
;; keybinds ;; keybinds
(bind yas-keymap (bind yas-keymap
"C-e" 'my/yas-goto-end-of-field "C-e" 'my/yas-goto-end-of-field
"C-a" 'my/yas-goto-start-of-field "C-a" 'my/yas-goto-start-of-field
"<s-right>" 'my/yas-goto-end-of-field "<M-right>" 'my/yas-goto-end-of-field
"<s-left>" 'my/yas-goto-start-of-field "<M-left>" 'my/yas-goto-start-of-field
[backspace] 'my/yas-clear-field))) "<M-backspace>" 'my/yas-clear-to-sof
[backspace] 'my/yas-backspace
"<delete>" 'my/yas-delete)))
(provide 'init-yasnippet) (provide 'init-yasnippet)

View file

@ -2,28 +2,25 @@
;; Global keymaps ;; ;; Global keymaps ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(bind (kbd "M-x") 'smex (bind (kbd "") 'smex
(kbd "M-X") 'smex-major-mode-commands (kbd "˛") 'smex-major-mode-commands
(kbd "C-;") 'eval-expression (kbd "C-;") 'eval-expression
(kbd "C-`") 'popwin:toggle-popup-window (kbd "C-`") 'popwin:toggle-popup-window
(kbd "s-=") 'text-scale-increase (kbd "M-=") 'text-scale-increase
(kbd "s--") 'text-scale-decrease (kbd "M--") 'text-scale-decrease
(kbd "s-w") 'evil-window-delete (kbd "M-w") 'evil-window-delete
(kbd "s-/") 'evilnc-comment-or-uncomment-lines) (kbd "M-/") 'evilnc-comment-or-uncomment-lines
(kbd "M-s") 'save-buffer)
;; Faster scrolling ;; Faster scrolling
(bind 'motion my-mode-map (bind 'motion my-mode-map
(kbd "s-j") "6j" (kbd "M-j") "6j"
(kbd "s-k") "6k") (kbd "M-k") "6k")
(bind 'normal my-mode-map (bind 'normal my-mode-map
(kbd "s-o") 'ido-find-file (kbd "M-o") 'ido-find-file
(kbd "s-d") 'dash-at-point) (kbd "M-d") 'dash-at-point)
(bind 'visual my-mode-map
(kbd "s-r") 'my-run-code-region
(kbd "s-R") 'my-send-region-to-repl)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -119,17 +116,17 @@
(bind 'emacs [escape] 'evil-normal-state) (bind 'emacs [escape] 'evil-normal-state)
(bind 'insert my-mode-map (bind 'insert my-mode-map
"<M-kp-delete>" (λ (evil-forward-word) (evil-delete-backward-word)) "<A-backspace>" 'evil-delete-backward-word
"<A-delete>" (λ (evil-forward-word) (evil-delete-backward-word))
;; Newline magic ;; Newline magic
"<backspace>" 'backward-delete-char-untabify "<backspace>" 'backward-delete-char-untabify
"<S-backspace>" 'backward-delete-char "<M-backspace>" 'my.backward-kill-to-bol-and-indent
"<C-return>" 'evil-ret-and-indent "<C-return>" 'evil-ret-and-indent
"<M-return>" (kbd "<return> DEL") ; newline and dedent
;; Textmate-esque indent shift left/right ;; Textmate-esque indent shift left/right
"s-[" (kbd "C-o m l C-o I DEL C-o ` l") "M-[" (kbd "C-o m l C-o I DEL C-o ` l")
"s-]" (λ (evil-shift-right (point-at-bol) (point-at-eol))) "M-]" (λ (evil-shift-right (point-at-bol) (point-at-eol)))
"<backtab>" (kbd "s-[")) "<backtab>" (kbd "s-["))
;; Enable TAB to do matchit ;; Enable TAB to do matchit
@ -165,5 +162,58 @@
(evil-make-overriding-map my-mode-map nil) (evil-make-overriding-map my-mode-map nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keymap fixes ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This section is dedicated to keymaps that "fix" certain keys so
;; that they behave more like vim (or how I like it).
;; Restores "dumb" indentation to the tab key. This rustles a lot of
;; peoples' jimmies, apparently, but it's how I like it.
(bind 'insert "<tab>" 'my.dumb-indent)
(bind 'insert "<A-tab>" 'indent-for-tab-command)
;; Except for lisp
(bind 'insert lisp-mode-map [remap my.dumb-indent] 'indent-for-tab-command)
(bind 'insert emacs-lisp-mode-map [remap my.dumb-indent] 'indent-for-tab-command)
;; Highjacks space/backspace to:
;; a) delete spaces on either side of the cursor, if present ( | ) -> (|)
;; b) allow backspace to delete space-indented blocks intelligently
;; c) and not do any of this magic when inside a string
(bind 'insert
"SPC" 'my.inflate-space-maybe
[remap backward-delete-char-untabify] 'my.deflate-space-maybe
[remap newline] 'my.newline-and-indent
;; Smarter move-to-beginning-of-line
[remap move-beginning-of-line] 'my.move-to-bol
;; Restore bash-esque keymaps in insert mode; C-w and C-a already exist
"\C-e" 'my.move-to-eol
"\C-u" 'my.backward-kill-to-bol-and-indent
;; Fixes delete
(kbd "<kp-delete>") 'delete-char)
(bind '(insert normal)
;; Textmate-esque insert-line before/after
(kbd "<M-return>") 'evil-open-below
(kbd "<S-M-return>") 'evil-open-above)
;; Fix osx keymappings and then some
(use-package smart-forward
:config
(bind 'insert
(kbd "<M-left>") 'smart-backward
(kbd "<M-right>") 'smart-forward
;; (kbd "<M-up>") 'beginning-of-buffer
(kbd "<M-up>") 'smart-up
(kbd "<M-down>") 'smart-down
(kbd "<M-backspace>") 'my.backward-kill-to-bol-and-indent))
(provide 'my-bindings) (provide 'my-bindings)
;;; my-bindings.el ends here ;;; my-bindings.el ends here

33
init/my-defuns.el Normal file
View file

@ -0,0 +1,33 @@
(defmacro -defreplace (name search replace)
`(evil-define-operator ,(make-symbol (concat "replace:" (symbol-name name))) (beg end)
:type inclusive
:repeat nil
(interactive "<r>")
(replace-regexp ,search ,replace t beg end)))
;;;; HTML ;;;;
;; Replace smart quotes and other MS Word verbiage into plain text
(defun replace:plain-textify (beg end)
(interactive "r")
(replace-regexp "" "..." nil beg end)
(replace-regexp "[]" "'" nil beg end)
(replace-regexp "[“”]" "\"" nil beg end))
;; Email address with mailto link
(defun replace:email2mailto (beg end)
(interactive "r")
(replace-regexp "\\b\\([a-zA-Z0-9._+-%]+@[a-zA-Z0-9-.]+\\.[a-zA-Z]+\\)\\b"
"<a href=\"mailto:\\1\">\\1</a>"
nil beg end))
;; Link with anchor
(defun replace:url2anchor (beg end)
(interactive "r")
(replace-regexp "\\bhttps?://.+?\\b"
"<a href=\"\\1\">\\1</a>"
nil beg end))
(provide 'my-defuns)
;;; my-defuns.el ends here

View file

@ -36,47 +36,7 @@
;;;; Keymap Fixes ;;;;;;;;;;;;;;;;;;;;;; ;;;; Keymap Fixes ;;;;;;;;;;;;;;;;;;;;;;
;; This section is dedicated to keymaps that "fix" certain keys so ;; Implements some helpful keymappings for emacs sub-modes
;; that they behave more like vim (or how I like it).
;; Restores "dumb" indentation to the tab key. This rustles a lot of
;; peoples' jimmies, apparently, but it's how I like it.
(bind 'insert (kbd "TAB") 'my.dumb-indent)
;; Except for lisp
(bind 'insert lisp-mode-map [remap my.dumb-indent] 'indent-for-tab-command)
(bind 'insert emacs-lisp-mode-map [remap my.dumb-indent] 'indent-for-tab-command)
;; Highjacks backspace to:
;; a) deletes spaces on either side of the cursor, if present ( | ) -> (|)
;; b) allow backspace to delete space-indented blocks intelligently
;; c) and not do any of this magic when inside a string
(bind 'insert
[remap backward-delete-char-untabify] 'my.deflate-space-maybe
[remap newline] 'my.newline-and-indent
;; Smarter move-to-beginning-of-line
[remap move-beginning-of-line] 'my.move-to-bol
;; Restore bash-esque keymaps in insert mode; C-w and C-a already exist
"\C-e" 'my.move-to-eol
"\C-u" 'my.backward-kill-to-bol-and-indent
;; Fixes delete
(kbd "<kp-delete>") 'delete-char)
(bind '(insert normal)
;; Textmate-esque insert-line before/after
(kbd "<s-return>") 'evil-open-below
(kbd "<S-s-return>") 'evil-open-above)
;; Fix osx keymappings and then some
(bind 'insert
(kbd "<s-left>") 'my.move-to-bol
(kbd "<s-right>") 'my.move-to-eol
(kbd "<s-up>") 'beginning-of-buffer
(kbd "<s-down>") 'end-of-buffer
(kbd "<s-backspace>") 'my.backward-kill-to-bol-and-indent)
(add-hook! 'ido-setup-hook (add-hook! 'ido-setup-hook
(bind ido-completion-map (bind ido-completion-map
(kbd "<backspace>") 'ido-delete-backward-updir (kbd "<backspace>") 'ido-delete-backward-updir
@ -91,7 +51,6 @@
minibuffer-local-isearch-map) minibuffer-local-isearch-map)
[escape] 'my--minibuffer-quit) [escape] 'my--minibuffer-quit)
(bind 'emacs [escape] 'my--minibuffer-quit) (bind 'emacs [escape] 'my--minibuffer-quit)
(bind 'god [escape] 'evil-god-state-bail)
(bind 'normal evil-command-window-mode-map [escape] 'kill-buffer-and-window) (bind 'normal evil-command-window-mode-map [escape] 'kill-buffer-and-window)
;; (bind evil-ex-map [escape] 'my--minibuffer-quit) ;; (bind evil-ex-map [escape] 'my--minibuffer-quit)
@ -121,7 +80,7 @@
(interactive) (interactive)
(message "Gee, I dunno Brain...")) (message "Gee, I dunno Brain..."))
(if is-mac (global-set-key (kbd "s-q") 'my-emacs-is-not-kill)) (if is-mac (global-set-key (kbd "M-q") 'my-emacs-is-not-kill))
(provide 'my-settings) (provide 'my-settings)