2014-12-05 17:28:03 -05:00
|
|
|
(use-package autoinsert
|
|
|
|
:init (auto-insert-mode 1)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; (setq auto-insert-directory "%/.emacs.d/templates/")
|
|
|
|
(setq auto-insert-query nil) ; Don't prompt before insertion
|
|
|
|
(setq auto-insert-alist '())))
|
2014-11-29 20:21:03 -05:00
|
|
|
|
2014-12-05 17:28:03 -05:00
|
|
|
(after "yasnippet"
|
2015-01-12 21:27:21 -05:00
|
|
|
(defmacro template (file-regexp uuid mode &optional project-only)
|
|
|
|
`(define-auto-insert ,file-regexp '(lambda () (my--template-insert ,uuid ,mode ,project-only))))
|
2014-12-05 17:28:03 -05:00
|
|
|
|
|
|
|
(defun my--template-insert (uuid mode &optional project-only)
|
2014-11-29 20:21:03 -05:00
|
|
|
"Expand snippet template in MODE by its UUID"
|
|
|
|
(unless (and project-only
|
|
|
|
(not (projectile-project-p)))
|
|
|
|
(yas-expand-snippet
|
|
|
|
(yas--template-content
|
|
|
|
(yas--get-template-by-uuid mode uuid)) (point-min) (point-max))
|
|
|
|
(evil-insert-state)))
|
|
|
|
|
2015-04-22 20:48:28 -04:00
|
|
|
(template "/\\.gitignore$" "%%" 'gitignore-mode)
|
2014-11-29 20:21:03 -05:00
|
|
|
|
|
|
|
;; C/C++
|
2015-04-22 20:48:28 -04:00
|
|
|
(template "/Makefile$" "%%" 'makefile-gmake-mode)
|
|
|
|
(template "/main\\.\\(cc\\|cpp\\)$" "%main.cpp%" 'c++-mode)
|
|
|
|
(template "/win32_\\.\\(cc\\|cpp\\)$" "%winmain.cpp%" 'c++-mode)
|
|
|
|
(template "\\.\\([Hh]\\|hpp\\)$" "%.h%" 'c++-mode)
|
|
|
|
(template "\\.\\([Cc]\\|cc\\|cpp\\)$" "%.cpp%" 'c++-mode)
|
2014-11-29 20:21:03 -05:00
|
|
|
|
|
|
|
;; Shell scripts
|
2015-04-22 20:48:28 -04:00
|
|
|
(template "\\.z?sh$" "%%" 'sh-mode)
|
|
|
|
|
|
|
|
;; Ruby
|
|
|
|
(template "/spec_helper\\.rb$" "%helper%" 'rspec-mode t)
|
|
|
|
(template "_spec\\.rb$" "%%" 'rspec-mode t)
|
|
|
|
(template "/\\.rspec$" "%.rspec%" 'rspec-mode)
|
|
|
|
(template "/Rakefile$" "%Rakefile%" 'ruby-mode t)
|
|
|
|
(template "/Gemfile$" "%Gemfile%" 'ruby-mode t)
|
|
|
|
;; (template "\\.gemspec$" "%.gemspec%" 'ruby-mode t)
|
|
|
|
(template "/lib/.+\\.rb$" "%module%" 'ruby-mode t)
|
|
|
|
(template "\\.rb$" "%%" 'ruby-mode)
|
|
|
|
|
|
|
|
;; ;; Python
|
|
|
|
;; (template "tests?/test_.+\\.py$" "%%" 'nose-mode)
|
|
|
|
;; (template "/setup\\.py$" "%setup%" 'python-mode)
|
2014-11-29 20:21:03 -05:00
|
|
|
(template "\\.py$" "%%" 'python-mode)
|
|
|
|
|
2015-04-22 20:48:28 -04:00
|
|
|
;; ;; PHP
|
|
|
|
;; (template "\\.class\\.php$" "%class%" 'php-mode)
|
|
|
|
;; (template "\\.php$" "%%" 'php-mode)
|
|
|
|
|
|
|
|
;; ;; Markdown
|
|
|
|
(template "/README\\.md$" "%README.md%" 'markdown-mode)
|
|
|
|
;; (template "/_posts/.+\\.md$" "%jekyll-post" 'markdown-mode)
|
|
|
|
;; (template "/_layouts/.+\\.html$" "%jekyll-layout%" 'web-mode)
|
|
|
|
|
|
|
|
;; ;; Javascript
|
|
|
|
;; (template "\\.lbaction/Contents/Info.plist$" "%lb6%" 'nxml-mode)
|
|
|
|
;; (template "\\.lbaction/.+/\\(default\\|suggestions\\)\\.js$" "%lb6%" 'js-mode)
|
|
|
|
;; (template "/package\\.json$" "%package.json%" 'json-mode)
|
|
|
|
;; (template "\\.\\(json\\|jshintrc\\)$" "%%" 'json-mode)
|
|
|
|
|
|
|
|
;; ;; SCSS
|
|
|
|
;; (template "/master\\.scss$" "%master%" 'scss-mode)
|
|
|
|
;; (template "/normalize\\.scss$" "%normalize%" 'scss-mode)
|
|
|
|
;; (template "\\.scss$" "%%" 'scss-mode)
|
|
|
|
|
|
|
|
;; ;; HTML
|
|
|
|
;; (template "\\.html$" "%%" 'web-mode)
|
|
|
|
|
|
|
|
;; Lua
|
|
|
|
;; (template "\\.love/main\\.lua$" "%love.main%" 'lua-mode)
|
|
|
|
;; (template "\\.love/conf\\.lua$" "%love.conf%" 'lua-mode)
|
|
|
|
;; (template "\\.lua$" "%%" 'lua-mode)
|
|
|
|
|
|
|
|
;; ;; Java
|
2015-05-07 03:19:24 -04:00
|
|
|
(template "/src/.+/.+\\.java$" "%%" 'java-mode)
|
2015-04-22 20:48:28 -04:00
|
|
|
;; (template "\\.gradle$" "%%" 'groovy-mode)
|
|
|
|
|
|
|
|
;; ;; Elisp
|
|
|
|
(template "\\.emacs\\.d/.+\\.el$" "%initfile%" 'emacs-lisp-mode)
|
|
|
|
(template "\\.emacs\\.d/snippets/.+$" "%%" 'snippet-mode))
|
2014-12-10 15:54:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
(provide 'init-auto-insert)
|
|
|
|
;;; init-auto-insert.el ends here
|