Move yasnippet and hippie-exp to auto-completion layer
This commit is contained in:
parent
d0b6a56b0a
commit
845126dac0
|
@ -25,6 +25,10 @@ The following completion engines are supported:
|
|||
- [company][]
|
||||
- [auto-complete][]
|
||||
|
||||
Snippets are supported via [yasnippet][].
|
||||
|
||||
This layer also configures `hippie-expand`.
|
||||
|
||||
## Install
|
||||
|
||||
To use this configuration layer add it to your `~/.spacemacs`
|
||||
|
@ -136,3 +140,4 @@ In `packages.el`:
|
|||
|
||||
[company]: http://company-mode.github.io/
|
||||
[auto-complete]: http://auto-complete.org/
|
||||
[yasnippet]: https://github.com/capitaomorte/yasnippet
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
|
||||
(setq auto-completion-packages
|
||||
'(
|
||||
company
|
||||
ac-ispell
|
||||
auto-complete
|
||||
ac-ispell
|
||||
company
|
||||
helm-c-yasnippet
|
||||
hippie-exp
|
||||
yasnippet
|
||||
))
|
||||
|
||||
;; company-quickhelp from MELPA is not compatible with 24.3 anymore
|
||||
|
@ -118,3 +121,85 @@
|
|||
(display-graphic-p))
|
||||
:defer t
|
||||
:init (add-hook 'company-mode-hook 'company-quickhelp-mode)))
|
||||
|
||||
(defun auto-completion/init-helm-c-yasnippet ()
|
||||
(use-package helm-c-yasnippet
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs/helm-yas ()
|
||||
"Properly lazy load helm-c-yasnipper."
|
||||
(interactive)
|
||||
(spacemacs/load-yasnippet)
|
||||
(require 'helm-c-yasnippet)
|
||||
(call-interactively 'helm-yas-complete))
|
||||
(evil-leader/set-key "is" 'spacemacs/helm-yas)
|
||||
(setq helm-c-yas-space-match-any-greedy t))))
|
||||
|
||||
(defun auto-completion/init-hippie-exp ()
|
||||
;; replace dabbrev-expand
|
||||
(global-set-key (kbd "M-/") 'hippie-expand)
|
||||
(setq hippie-expand-try-functions-list
|
||||
'(
|
||||
;; Try to expand word "dynamically", searching the current buffer.
|
||||
try-expand-dabbrev
|
||||
;; Try to expand word "dynamically", searching all other buffers.
|
||||
try-expand-dabbrev-all-buffers
|
||||
;; Try to expand word "dynamically", searching the kill ring.
|
||||
try-expand-dabbrev-from-kill
|
||||
;; Try to complete text as a file name, as many characters as unique.
|
||||
try-complete-file-name-partially
|
||||
;; Try to complete text as a file name.
|
||||
try-complete-file-name
|
||||
;; Try to expand word before point according to all abbrev tables.
|
||||
try-expand-all-abbrevs
|
||||
;; Try to complete the current line to an entire line in the buffer.
|
||||
try-expand-list
|
||||
;; Try to complete the current line to an entire line in the buffer.
|
||||
try-expand-line
|
||||
;; Try to complete as an Emacs Lisp symbol, as many characters as
|
||||
;; unique.
|
||||
try-complete-lisp-symbol-partially
|
||||
;; Try to complete word as an Emacs Lisp symbol.
|
||||
try-complete-lisp-symbol))
|
||||
(when (configuration-layer/package-usedp 'yasnippet)
|
||||
;; Try to expand yasnippet snippets based on prefix
|
||||
(push 'yas-hippie-try-expand hippie-expand-try-functions-list)))
|
||||
|
||||
(defun auto-completion/init-yasnippet ()
|
||||
(use-package yasnippet
|
||||
:commands yas-global-mode
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs/load-yasnippet ()
|
||||
(if (not (boundp 'yas-minor-mode))
|
||||
(progn
|
||||
(let* ((dir (configuration-layer/get-layer-property 'spacemacs :ext-dir))
|
||||
(private-yas-dir (concat configuration-layer-private-directory "snippets"))
|
||||
(yas-dir (concat dir "yasnippet-snippets")))
|
||||
(setq yas-snippet-dirs
|
||||
(append (when (boundp 'yas-snippet-dirs)
|
||||
yas-snippet-dirs)
|
||||
(list private-yas-dir yas-dir)))
|
||||
(setq yas-wrap-around-region t)
|
||||
(yas-global-mode 1)))))
|
||||
(add-to-hooks 'spacemacs/load-yasnippet '(prog-mode-hook
|
||||
markdown-mode-hook
|
||||
org-mode-hook))
|
||||
|
||||
(spacemacs|add-toggle yasnippet
|
||||
:status yas-minor-mode
|
||||
:on (yas-minor-mode)
|
||||
:off (yas-minor-mode -1)
|
||||
:documentation "Enable yasnippet."
|
||||
:evil-leader "ty")
|
||||
|
||||
(defun spacemacs/force-yasnippet-off ()
|
||||
(yas-minor-mode -1)
|
||||
(setq yas-dont-activate t))
|
||||
|
||||
(add-to-hooks 'spacemacs/force-yasnippet-off '(term-mode-hook
|
||||
shell-mode-hook)))
|
||||
:config
|
||||
(progn
|
||||
(spacemacs|diminish yas-minor-mode " ⓨ" " y"))))
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
guide-key-tip
|
||||
helm
|
||||
helm-ag
|
||||
helm-c-yasnippet
|
||||
helm-descbinds
|
||||
helm-flyspell
|
||||
helm-make
|
||||
|
@ -73,7 +72,6 @@
|
|||
highlight-indentation
|
||||
highlight-numbers
|
||||
highlight-parentheses
|
||||
hippie-exp
|
||||
hl-anything
|
||||
hungry-delete
|
||||
ido-vertical-mode
|
||||
|
@ -105,7 +103,6 @@
|
|||
whitespace
|
||||
window-numbering
|
||||
winner
|
||||
yasnippet
|
||||
zenburn-theme
|
||||
))
|
||||
|
||||
|
@ -1544,20 +1541,6 @@ ARG non nil means that the editing style is `vim'."
|
|||
:config
|
||||
(evil-define-key 'normal helm-ag-map "SPC" evil-leader--default-map)))
|
||||
|
||||
(defun spacemacs/init-helm-c-yasnippet ()
|
||||
(use-package helm-c-yasnippet
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs/helm-yas ()
|
||||
"Properly lazy load helm-c-yasnipper."
|
||||
(interactive)
|
||||
(spacemacs/load-yasnippet)
|
||||
(require 'helm-c-yasnippet)
|
||||
(call-interactively 'helm-yas-complete))
|
||||
(evil-leader/set-key "is" 'spacemacs/helm-yas)
|
||||
(setq helm-c-yas-space-match-any-greedy t))))
|
||||
|
||||
(defun spacemacs/init-helm-descbinds ()
|
||||
(use-package helm-descbinds
|
||||
:defer t
|
||||
|
@ -1722,34 +1705,6 @@ If ARG is non nil then `ag' and `pt' and ignored."
|
|||
:config
|
||||
(set-face-attribute 'hl-paren-face nil :weight 'ultra-bold)))
|
||||
|
||||
(defun spacemacs/init-hippie-exp ()
|
||||
(global-set-key (kbd "M-/") 'hippie-expand) ;; replace dabbrev-expand
|
||||
(setq hippie-expand-try-functions-list
|
||||
'(
|
||||
;; Try to expand yasnippet snippets based on prefix
|
||||
yas-hippie-try-expand
|
||||
;; Try to expand word "dynamically", searching the current buffer.
|
||||
try-expand-dabbrev
|
||||
;; Try to expand word "dynamically", searching all other buffers.
|
||||
try-expand-dabbrev-all-buffers
|
||||
;; Try to expand word "dynamically", searching the kill ring.
|
||||
try-expand-dabbrev-from-kill
|
||||
;; Try to complete text as a file name, as many characters as unique.
|
||||
try-complete-file-name-partially
|
||||
;; Try to complete text as a file name.
|
||||
try-complete-file-name
|
||||
;; Try to expand word before point according to all abbrev tables.
|
||||
try-expand-all-abbrevs
|
||||
;; Try to complete the current line to an entire line in the buffer.
|
||||
try-expand-list
|
||||
;; Try to complete the current line to an entire line in the buffer.
|
||||
try-expand-line
|
||||
;; Try to complete as an Emacs Lisp symbol, as many characters as
|
||||
;; unique.
|
||||
try-complete-lisp-symbol-partially
|
||||
;; Try to complete word as an Emacs Lisp symbol.
|
||||
try-complete-lisp-symbol)))
|
||||
|
||||
(defun spacemacs/init-hl-anything ()
|
||||
(use-package hl-anything
|
||||
:defer t
|
||||
|
@ -2806,44 +2761,6 @@ It is a string holding:
|
|||
(append winner-boring-buffers spacemacs/winner-boring-buffers))
|
||||
(winner-mode t))))
|
||||
|
||||
(defun spacemacs/init-yasnippet ()
|
||||
(use-package yasnippet
|
||||
:commands yas-global-mode
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs/load-yasnippet ()
|
||||
(if (not (boundp 'yas-minor-mode))
|
||||
(progn
|
||||
(let* ((dir (configuration-layer/get-layer-property 'spacemacs :ext-dir))
|
||||
(private-yas-dir (concat configuration-layer-private-directory "snippets"))
|
||||
(yas-dir (concat dir "yasnippet-snippets")))
|
||||
(setq yas-snippet-dirs
|
||||
(append (when (boundp 'yas-snippet-dirs)
|
||||
yas-snippet-dirs)
|
||||
(list private-yas-dir yas-dir)))
|
||||
(setq yas-wrap-around-region t)
|
||||
(yas-global-mode 1)))))
|
||||
(add-to-hooks 'spacemacs/load-yasnippet '(prog-mode-hook
|
||||
markdown-mode-hook
|
||||
org-mode-hook))
|
||||
|
||||
(spacemacs|add-toggle yasnippet
|
||||
:status yas-minor-mode
|
||||
:on (yas-minor-mode)
|
||||
:off (yas-minor-mode -1)
|
||||
:documentation "Enable yasnippet."
|
||||
:evil-leader "ty")
|
||||
|
||||
(defun spacemacs/force-yasnippet-off ()
|
||||
(yas-minor-mode -1)
|
||||
(setq yas-dont-activate t))
|
||||
|
||||
(add-to-hooks 'spacemacs/force-yasnippet-off '(term-mode-hook
|
||||
shell-mode-hook)))
|
||||
:config
|
||||
(progn
|
||||
(spacemacs|diminish yas-minor-mode " ⓨ" " y"))))
|
||||
|
||||
(defun spacemacs/init-zenburn-theme ()
|
||||
(use-package zenburn-theme
|
||||
:defer t))
|
||||
|
|
Loading…
Reference in New Issue