From 6792e9fe6eeb7d3df12d4d54e96ca881e34b4c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Alvari=C3=B1o?= Date: Fri, 18 Mar 2022 19:58:51 +0100 Subject: [PATCH] Add Projectile, Magit and Yasnippets --- myconfig.org | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 2 deletions(-) diff --git a/myconfig.org b/myconfig.org index 3b875c9..1718b25 100644 --- a/myconfig.org +++ b/myconfig.org @@ -134,7 +134,8 @@ This file: (global-set-key [C-tab] 'hippie-expand) ; expand (global-set-key [C-kp-subtract] 'undo) ; [Undo] - (global-set-key [C-kp-multiply] 'goto-line) ; goto line + ;; (global-set-key [C-kp-multiply] 'goto-line) ; old goto line + (global-set-key [C-kp-multiply] 'consult-goto-line) ; goto line (global-set-key [C-kp-add] 'toggle-truncate-lines) ; truncate lines (global-set-key [C-kp-divide] 'delete-trailing-whitespace) ; delete trailing whitespace (global-set-key [C-kp-decimal] 'completion-at-point) ; complete at point @@ -371,6 +372,19 @@ This file: #+end_src * Editor Enhancements +** ace-windows + To jump to different windows easily + #+begin_src emacs-lisp + (use-package ace-window + :ensure t + :init + (global-set-key [remap other-window] 'ace-window) + (custom-set-faces + '(aw-leading-char-face + ((t (:inherit ace-jump-face-foreground :height 3.0))))) + ) + #+end_src + ** ripgrep [[https://github.com/dajva/rg.el][rg repo]] #+begin_src emacs-lisp @@ -395,6 +409,7 @@ This file: ** Hydra [[https://github.com/abo-abo/hydra][Hydra repo]] + See [[https://readingworldmagazine.com/emacs/2020-02-27-emacs-hydra-set-up-code/][this]] someday #+begin_src emacs-lisp (use-package hydra) #+end_src @@ -442,13 +457,14 @@ This file: ("p" (lambda () (interactive) (forward-line -1)) "up") ("g" goto-line "consult-goto-line") ("i" consult-imenu "cons-imenu" :column "Header") + ("o" consult-org-heading "cons-org-head") ("q" nil "quit") ) ) #+end_src ** avy - Quick navigation to words +Quick navigation to words #+begin_src emacs-lisp ;;(use-package avy ;; :config @@ -467,6 +483,88 @@ This file: ("C-รง" . iedit-mode)) #+end_src +* Project management with projectile + #+begin_src emacs-lisp + (use-package projectile + :config + (projectile-global-mode) + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + ) + #+end_src + +* Git management + All you need for git + - [[https://github.com/magit/magit][magit]] interface to git from emacs (there are a lot of tutos) + - [[https://github.com/emacsorphanage/git-gutter][git-gutter]] See lines changed in buffer edited + - [[https://github.com/emacsmirror/git-timemachine][git-time-machine]] Visit previous git versions of edited buffer + #+begin_src emacs-lisp + ;; dirty hack to avoid problem when pushing + (setenv "SSH_AUTH_SOCK" "/run/user/1000/keyring/ssh") + + (use-package magit + :init + (progn + (bind-key "C-x g" 'magit-status) + ) + ) + + (setq magit-status-margin + '(t "%Y-%m-%d %H:%M " magit-log-margin-width t 18)) + + (use-package git-gutter + :init + (global-git-gutter-mode +1) + ) + (defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1) + :hint nil) + " + Git gutter: + _j_: next hunk _s_tage hunk _q_uit + _k_: previous hunk _r_evert hunk _Q_uit and deactivate git-gutter + ^ ^ _p_opup hunk + _h_: first hunk + _l_: last hunk set start _R_evision + " + ("j" git-gutter:next-hunk) + ("k" git-gutter:previous-hunk) + ("h" (progn (goto-char (point-min)) + (git-gutter:next-hunk 1))) + ("l" (progn (goto-char (point-min)) + (git-gutter:previous-hunk 1))) + ("s" git-gutter:stage-hunk) + ("r" git-gutter:revert-hunk) + ("p" git-gutter:popup-hunk) + ("R" git-gutter:set-start-revision) + ("q" nil :color blue) + ("Q" (progn (git-gutter-mode -1) + ;; git-gutter-fringe doesn't seem to + ;; clear the markup right away + (sit-for 0.1) + (git-gutter:clear)) + :color blue)) + (global-set-key (kbd "M-g M-g") 'hydra-git-gutter/body) + + (use-package git-timemachine + ) + #+end_src + +* yasnippet + - [[https://github.com/joaotavora/yasnippet][yasnippet]] (there are many tutorials) + - [[https://github.com/abo-abo/auto-yasnippet][auto-yasnippet]] (disposable snippets) + - [[https://github.com/AndreaCrotti/yasnippet-snippets][yasnippets-snippets]] + Place your own snippets on =~/.cache/emacs/etc/yasnippet/snippets= + #+begin_src emacs-lisp + (use-package yasnippet + :config + :init + (yas-global-mode 1) + ) + (use-package auto-yasnippet + ) + (use-package yasnippet-snippets + ) + #+end_src + * next #+begin_src emacs-lisp #+end_src