Added yasnippets.

This commit is contained in:
tastytea 2019-08-07 11:35:38 +02:00
parent cf08df6ca3
commit 1a09bcf255
3 changed files with 37 additions and 4 deletions

15
init.el
View File

@ -1,5 +1,5 @@
;;; init.el --- tastytea's Emacs init file.
;; Time-stamp: <2019-08-06T22:03:53+00:00>
;; Time-stamp: <2019-08-07T09:37:23+00:00>
;;; Commentary:
;; I am using this file with Emacs 26, but most of it will probably work with
@ -366,6 +366,16 @@ With argument, do this that many times."
:config
(editorconfig-mode 1))
;; A template system.
(use-package yasnippet
:hook
(prog-mode . yas-minor-mode)
)
;; Install snippet-collection.
(use-package yasnippet-snippets
:after yasnippet)
;;;;;;;;;;;;;;;;;;;; Programming / C++ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Set coding style.
(use-package cc-mode
@ -817,9 +827,6 @@ With argument, do this that many times."
("C-x M-h" . easy-hugo)
)
;; A template system.
(use-package yasnippet)
;; Automatically insert text in new files.
(use-package autoinsert
:after yasnippet

10
snippets/cc-mode/case Normal file
View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: case : {...}
# key: case
# expand-env: ((yas-also-auto-indent-first-line t))
# --
case ${2:constexpr}:
{
$0
break;
}

16
snippets/cc-mode/switch Normal file
View File

@ -0,0 +1,16 @@
# -*- mode: snippet -*-
# name: switch (...) { case : ... default: ...}
# key: switch
# --
switch (${1:expr})
{
case ${2:constexpr}:
{
$0
break;
}
default:
{
break;
}
}