.emacs.d

My Emacs configuration files.
Log | Files | Refs | README

commit 48e8417e4825658669c9dec34f86eba3ce35ec74
parent 3ebbc243c48254c395b4532693aef78fdd650948
Author: Hugo Soucy <hugo.soucy@toumoro.com>
Date:   Fri, 20 Mar 2020 13:56:00 -0400

Add new snippets

Diffstat:
Adefuns/select-html-value.el | 8++++++++
Mpartials/autocompletion.el | 2+-
Mpartials/email.el | 5++++-
Mpartials/webdev.el | 39+++++++++++++++++++++++++++++++++++++--
Asnippets/css-mode/remcalc | 6++++++
Asnippets/css-mode/sasschild | 8++++++++
Asnippets/css-mode/vardec | 6++++++
Asnippets/css-mode/varfunc | 6++++++
Asnippets/js2-mode/consolelog | 6++++++
Msnippets/web-mode/svg-use | 4++--
10 files changed, 84 insertions(+), 6 deletions(-)

diff --git a/defuns/select-html-value.el b/defuns/select-html-value.el @@ -0,0 +1,8 @@ +(defun ejemba/select-html-value () + ;;; Select the next value in html/xml. + (interactive) + (search-forward "\"") + (set-mark-command nil) + (search-forward "\"") + (backward-char 1) + ) diff --git a/partials/autocompletion.el b/partials/autocompletion.el @@ -44,7 +44,7 @@ :pin melpa) (use-package company-web - ;; Company version of ac-html, complete for web,html,emmet,jade,slim modes + ;; Company version of ac-html, complete for web, html, emmet, jade, slim modes :after company :ensure t :pin melpa) diff --git a/partials/email.el b/partials/email.el @@ -1,6 +1,9 @@ ;; EMAIL SETUP FILE (setq user-full-name "Hugo Soucy") -(setq user-mail-address "hugo@soucy.cc") +(if (eq (system-name) 'hs0ucy-t590) + (setq user-mail-address "hugo.soucy@toumoro.com") + (setq user-mail-address "hugo@soucy.cc") + ) ;; (use-package mu4e ;; ;; Mail client for Emacs. diff --git a/partials/webdev.el b/partials/webdev.el @@ -1,5 +1,19 @@ ;; WEBDEV ;; +;;; Code + +(use-package js2-refactor + ;; A JavaScript refactoring library for emacs. + :after js2-mode + :ensure t + :pin melpa) + +(use-package xref-js2 + ;; Jump to references/definitions using ag & js2-mode's AST + :after js2-mode + :ensure t + :pin melpa) + (use-package js2-mode ;;; Improved JavaScript editing mode. :ensure t @@ -7,7 +21,23 @@ :config (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) (add-hook 'js2-mode-hook #'js2-imenu-extras-mode) - (add-hook 'js2-mode-hook #'js2-refactor-mode)) + (add-hook 'js2-mode-hook #'js2-refactor-mode) + (add-hook 'js2-mode-hook (lambda () + (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t))) + (js2r-add-keybindings-with-prefix "C-c C-r") + (add-hook 'js2-mode-hook (lambda () + (tern-mode) + (company-mode)))) + +(use-package js2-highlight-vars + ;; highlight occurrences of the variable under cursor + :after js2-mode + :ensure t + :pin melpa + :config + (eval-after-load "js2-highlight-vars-autoloads" + '(add-hook 'js2-mode-hook (lambda () (js2-highlight-vars-mode)))) + ) (use-package web-mode ;; major mode for editing web templates. @@ -29,16 +59,21 @@ (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) - (add-to-list 'auto-mode-alist '("\\.etlua\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.twig\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode)) + (defadvice web-mode-highlight-part (around tweak-jsx activate) (if (equal web-mode-content-type "jsx") (let ((web-mode-enable-part-face nil)) ad-do-it) ad-do-it))) +(use-package web-mode-edit-element + ;; Helper-functions for attribute- and element-handling + :ensure t + :pin melpa) + (use-package markdown-mode ;; Major mode for Markdown-formatted text. :ensure t diff --git a/snippets/css-mode/remcalc b/snippets/css-mode/remcalc @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: SCSS rem-calc() function +# key: remcalc +# -- + +rem-calc(${1:}px) diff --git a/snippets/css-mode/sasschild b/snippets/css-mode/sasschild @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: SCSS child declaration +# key: sasschild +# -- + +&__${1:} { + ${2:} +} diff --git a/snippets/css-mode/vardec b/snippets/css-mode/vardec @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: CSS var declaration +# key: vardec +# -- + +--${1:}: ${2:}; diff --git a/snippets/css-mode/varfunc b/snippets/css-mode/varfunc @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: CSS var() function +# key: varfunc +# -- + +var(--${1:}) diff --git a/snippets/js2-mode/consolelog b/snippets/js2-mode/consolelog @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: console log +# key: clog +# -- +console.log(${1:});+ \ No newline at end of file diff --git a/snippets/web-mode/svg-use b/snippets/web-mode/svg-use @@ -3,6 +3,6 @@ # key: svguse # -- -<svg class="x__ico"> - <use xlink:href="#ico-"></use> +<svg aria-hidden="true" class="ico-${1:ico}"> + <use xlink:href="#ico-${2:}"></use> </svg>