|
202 | 202 | (progn |
203 | 203 | ;; We don't want undefined variable errors |
204 | 204 | (defvar yas-global-mode nil) |
205 | | - |
| 205 | + (setq yas-triggers-in-field t |
| 206 | + yas-wrap-around-region t |
| 207 | + helm-yas-display-key-on-candidate t) |
| 208 | + ;; on multiple keys, fall back to completing read |
| 209 | + ;; typically this means helm |
| 210 | + (setq yas-prompt-functions '(yas-completing-prompt)) |
206 | 211 | ;; disable yas minor mode map |
207 | 212 | ;; use hippie-expand instead |
208 | 213 | (setq yas-minor-mode-map (make-sparse-keymap)) |
209 | | - |
210 | | - ;; allow nested expansions |
211 | | - (setq yas-triggers-in-field t) |
212 | | - |
213 | 214 | ;; this makes it easy to get out of a nested expansion |
214 | | - (define-key yas-minor-mode-map |
215 | | - (kbd "M-s-/") 'yas-next-field) |
216 | | - |
217 | | - ;; on multiple keys, fall back to completing read |
218 | | - ;; typically this means helm |
219 | | - (setq yas-prompt-functions '(yas-completing-prompt)) |
220 | | - |
221 | | - ;; add key into candidate list |
222 | | - (setq helm-yas-display-key-on-candidate t) |
223 | | - (setq spacemacs--auto-completion-dir |
224 | | - (configuration-layer/get-layer-property 'auto-completion :dir)) |
| 215 | + (define-key yas-minor-mode-map (kbd "M-s-/") 'yas-next-field) |
| 216 | + ;; configure snippet directories |
| 217 | + (let* ((spacemacs--auto-completion-dir |
| 218 | + (configuration-layer/get-layer-property 'auto-completion :dir)) |
| 219 | + (yasnippet--elpa-dir (spacemacs//get-package-directory 'yasnippet)) |
| 220 | + (private-yas-dir (if auto-completion-private-snippets-directory |
| 221 | + auto-completion-private-snippets-directory |
| 222 | + (concat |
| 223 | + configuration-layer-private-directory |
| 224 | + "snippets/"))) |
| 225 | + (spacemacs-snippets-dir (expand-file-name |
| 226 | + "snippets" |
| 227 | + spacemacs--auto-completion-dir)) |
| 228 | + (yasnippet-snippets-dir (expand-file-name |
| 229 | + "snippets" |
| 230 | + yasnippet--elpa-dir))) |
| 231 | + (setq yas-snippet-dirs |
| 232 | + (append (if (listp private-yas-dir) |
| 233 | + private-yas-dir |
| 234 | + (list private-yas-dir)) |
| 235 | + (list spacemacs-snippets-dir) |
| 236 | + (list yasnippet-snippets-dir)))) |
225 | 237 |
|
226 | 238 | (defun spacemacs/load-yasnippet () |
227 | | - (unless yas-global-mode |
228 | | - (progn |
229 | | - (require 'yasnippet) |
230 | | - (let ((private-yas-dir (if auto-completion-private-snippets-directory |
231 | | - auto-completion-private-snippets-directory |
232 | | - (concat |
233 | | - configuration-layer-private-directory |
234 | | - "snippets/"))) |
235 | | - (spacemacs-snippets-dir (expand-file-name |
236 | | - "snippets" |
237 | | - spacemacs--auto-completion-dir))) |
238 | | - (setq yas-snippet-dirs |
239 | | - (append (if (listp private-yas-dir) |
240 | | - private-yas-dir |
241 | | - (list private-yas-dir)) |
242 | | - (when (boundp 'yas-snippet-dirs) |
243 | | - (remove yas--default-user-snippets-dir yas-snippet-dirs)) |
244 | | - (list spacemacs-snippets-dir))) |
245 | | - (yas-global-mode 1) |
246 | | - (setq yas-wrap-around-region t)))) |
| 239 | + (unless yas-global-mode (yas-global-mode 1)) |
247 | 240 | (yas-minor-mode 1)) |
248 | | - |
249 | 241 | (spacemacs/add-to-hooks 'spacemacs/load-yasnippet '(prog-mode-hook |
250 | 242 | markdown-mode-hook |
251 | 243 | org-mode-hook)) |
|
259 | 251 | (defun spacemacs/force-yasnippet-off () |
260 | 252 | (yas-minor-mode -1) |
261 | 253 | (setq yas-dont-activate t)) |
262 | | - |
263 | | - (spacemacs/add-to-hooks 'spacemacs/force-yasnippet-off '(term-mode-hook |
264 | | - shell-mode-hook |
265 | | - eshell-mode-hook))) |
| 254 | + (spacemacs/add-to-hooks |
| 255 | + 'spacemacs/force-yasnippet-off '(term-mode-hook |
| 256 | + shell-mode-hook |
| 257 | + eshell-mode-hook))) |
266 | 258 | :config (spacemacs|diminish yas-minor-mode " ⓨ" " y"))) |
267 | 259 |
|
268 | 260 | (defun auto-completion/init-auto-yasnippet () |
|
0 commit comments