From 96f8d20c9df3bf7695d7d90c66d955776454bb8c Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 11 Apr 2017 09:11:35 +0200 Subject: emacs: added rust-mode and a binding for a magit-log command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- emacs/custom.el | 2 +- emacs/init.html | 223 ++++++++++++++++++++++++++++++++++---------------------- emacs/init.org | 93 +++++++++++++++-------- 3 files changed, 197 insertions(+), 121 deletions(-) (limited to 'emacs') diff --git a/emacs/custom.el b/emacs/custom.el index 87fb543..32d4b7e 100644 --- a/emacs/custom.el +++ b/emacs/custom.el @@ -15,7 +15,7 @@ '(markdown-command "/usr/bin/markdown-calibre") '(package-selected-packages (quote - (rust-mode vue-mode coffee-mode json-reformat erc-hl-nicks emoji-cheat-sheet-plus helm-circe htmlize cmake-mode websocket markdown-mode go-mode magit evil-leader evil helm projectile writeroom-mode org-eldoc evil-commentary yasnippet yaml-mode which-key web-mode wc-mode use-package terraform-mode smart-tabs-mode slim-mode scss-mode rainbow-delimiters php-mode org-evil olivetti mu4e-alert mmm-jinja2 markdown-preview-mode helm-projectile helm-ag go-eldoc go-add-tags flycheck expand-region evil-surround evil-org evil-numbers evil-mu4e evil-magit evil-args dockerfile-mode disable-mouse default-text-scale crux cmake-font-lock ag)))) + (salt-mode emms flycheck-rust rust-playground rust-mode vue-mode coffee-mode json-reformat erc-hl-nicks emoji-cheat-sheet-plus helm-circe htmlize cmake-mode websocket markdown-mode go-mode magit evil-leader evil helm projectile writeroom-mode org-eldoc evil-commentary yasnippet yaml-mode which-key web-mode wc-mode use-package terraform-mode smart-tabs-mode slim-mode scss-mode rainbow-delimiters php-mode org-evil olivetti mu4e-alert mmm-jinja2 markdown-preview-mode helm-projectile helm-ag go-eldoc go-add-tags flycheck expand-region evil-surround evil-org evil-numbers evil-mu4e evil-magit evil-args dockerfile-mode disable-mouse default-text-scale crux cmake-font-lock ag)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/emacs/init.html b/emacs/init.html index f64093b..5f6fb91 100644 --- a/emacs/init.html +++ b/emacs/init.html @@ -4,7 +4,7 @@ mssola's GNU Emacs configuration - + @@ -190,10 +190,12 @@ for the JavaScript code in this tag.
  • C and C++
  • Ruby
  • Go
  • -
  • Tabs vs spaces
  • -
  • Inferior markup languages.
  • -
  • Web-related stuff.
  • -
  • Others
  • +
  • Rust
  • +
  • Tabs vs spaces
  • +
  • Inferior markup languages.
  • +
  • Web-related stuff.
  • +
  • Devops
  • +
  • Others
  • WoMan
  • @@ -776,7 +778,7 @@ require it here on the very top.
    -
    (use-package diminish
    +
    (use-package diminish
       :ensure t)
     
    @@ -794,7 +796,7 @@ Ayo silver!
    -
    (use-package ag
    +
    (use-package ag
       :ensure t
       :config
     
    @@ -816,12 +818,12 @@ Then, for keeping up with my projects I use the Projectile + Helm combination.
     
     
    -
    (use-package projectile
    +
    (use-package projectile
       :ensure t
       :config
       (projectile-mode 1))
     
    -(use-package helm
    +(use-package helm
       :ensure t
       :config
       (setq projectile-completion-system 'helm)
    @@ -853,10 +855,10 @@ Then, for keeping up with my projects I use the Projectile + Helm combination.
       (define-key helm-map (kbd "C-j") 'helm-next-line)
       (define-key helm-map (kbd "C-k") 'helm-previous-line)
     
    -  (use-package helm-ag
    +  (use-package helm-ag
         :ensure t))
     
    -(use-package helm-projectile
    +(use-package helm-projectile
       :ensure t
       :config
       (helm-projectile-on)
    @@ -969,10 +971,10 @@ extension. This works with lots of languages with proper glue code.
     
     
    -
    (use-package let-alist
    +
    (use-package let-alist
       :ensure t)
     
    -(use-package flycheck
    +(use-package flycheck
       :ensure t
       :diminish
       :config
    @@ -995,7 +997,7 @@ with your editor, you have to increase/decrease the fonts. I use the
     
     
    -
    (use-package default-text-scale
    +
    (use-package default-text-scale
       :ensure t
       :config
       (global-set-key (kbd "C-+") 'default-text-scale-increase)
    @@ -1012,7 +1014,7 @@ supports it).
     
     
    -
    (use-package rainbow-delimiters
    +
    (use-package rainbow-delimiters
       :ensure t)
     
    @@ -1023,7 +1025,7 @@ I never use the mouse.
    -
    (use-package disable-mouse
    +
    (use-package disable-mouse
       :ensure t
       :config
       (global-disable-mouse-mode)
    @@ -1039,7 +1041,7 @@ commands for the current chord as a list.
     
     
    -
    (use-package which-key
    +
    (use-package which-key
       :ensure t
       :diminish which-key-mode
       :config
    @@ -1054,7 +1056,7 @@ this, we have wc-mode.
     
     
    -
    (use-package wc-mode
    +
    (use-package wc-mode
       :ensure t)
     
    @@ -1066,7 +1068,7 @@ that often, but it's cool to have a distraction-free screen from time to time.
    -
    (use-package writeroom-mode
    +
    (use-package writeroom-mode
       :ensure t)
     
    @@ -1079,7 +1081,7 @@ most of my uses, it's convenient to have this tool anyways.
    -
    (use-package expand-region
    +
    (use-package expand-region
       :ensure t
       :config
     
    @@ -1131,7 +1133,7 @@ remember some of these snippets, I've mapped , h to
     
     
    -
    (use-package yasnippet
    +
    (use-package yasnippet
       :ensure t
       :diminish yas-minor-mode
       :init (yas-global-mode)
    @@ -1291,7 +1293,7 @@ Now make sure that Evil is installed, and call the relevant configuration functi
     
     
    -
    (use-package evil
    +
    (use-package evil
       :ensure t
       :config
     
    @@ -1321,7 +1323,7 @@ Vim into Evil.
     
     
    -
    (use-package evil-leader
    +
    (use-package evil-leader
       :ensure t
       :config
       (global-evil-leader-mode)
    @@ -1348,7 +1350,7 @@ having double quotes with single quotes in a single command).
     
     
    -
    (use-package evil-surround
    +
    (use-package evil-surround
       :ensure t
       :config
       (global-evil-surround-mode 1))
    @@ -1364,7 +1366,7 @@ the current line, regardless of the programming language.
     
     
    -
    (use-package evil-commentary
    +
    (use-package evil-commentary
       :ensure t
       :config
       (evil-commentary-mode t))
    @@ -1380,7 +1382,7 @@ respectively.
     
     
    -
    (use-package evil-args
    +
    (use-package evil-args
       :ensure t
       :config
       ; Configuration taken from the documentation of evil-args.
    @@ -1406,7 +1408,7 @@ into Evil: C-a for increasing a number, and
     
     
    -
    (use-package evil-numbers
    +
    (use-package evil-numbers
       :ensure t
       :config
       (define-key evil-normal-state-map (kbd "C-a") 'evil-numbers/inc-at-pt)
    @@ -1426,7 +1428,7 @@ certainly useful for some common tasks (I guess that I still need some learning)
     
     
    -
    (use-package magit
    +
    (use-package magit
       :ensure t
       :config
     
    @@ -1461,12 +1463,13 @@ the rest.

    -Set a key binding for magit-blame. +Set a key binding for magit-blame and magit-log-buffer-file.

    (global-set-key (kbd "C-c b") 'magit-blame)
    +(global-set-key (kbd "C-c l") 'magit-log-buffer-file)
     
    @@ -1479,7 +1482,7 @@ And repair some key bindings from Evil mode.
    (with-eval-after-load 'evil-leader
       (evil-leader/set-key "s" 'magit-status)
     
    -  (use-package evil-magit
    +  (use-package evil-magit
         :ensure t
         :config
     
    @@ -1827,7 +1830,7 @@ I want desktop notifications when receiving email.
     
     
    -
    (use-package mu4e-alert
    +
    (use-package mu4e-alert
       :ensure t
       :config
     
    @@ -1843,7 +1846,7 @@ I want desktop notifications when receiving email.
     
     ; Evil mode in mu4e
     (with-eval-after-load 'evil
    -  (use-package evil-mu4e
    +  (use-package evil-mu4e
         :ensure t
         :config
     
    @@ -1987,7 +1990,7 @@ blocks to be converted into HTML as well, so we can properly colorize it).
     
     
    -
    (use-package htmlize
    +
    (use-package htmlize
       :ensure t)
     
    @@ -2194,7 +2197,7 @@ I'm giving ERC a chance. First of all, I'm setting up basic stuff.
    -
    (use-package erc
    +
    (use-package erc
       :config
     
       (erc-track-mode t)
    @@ -2237,7 +2240,7 @@ Use the erc-hl-nicks package, so highlight support for nicknames is
     
     
    -
    (use-package erc-hl-nicks
    +
    (use-package erc-hl-nicks
       :ensure t
       :init
       (with-eval-after-load 'erc
    @@ -2390,6 +2393,31 @@ comments and the usage of tabs instead of spaces.
       (lambda () (setq indent-tabs-mode t)))
     
    + +

    +CMake for y'all. +

    + +
    + +
    (use-package cmake-mode
    +  :ensure t
    +  :config
    +
    +  (setq auto-mode-alist
    +        (append
    +         '(("CMakeLists\\.txt\\'" . cmake-mode))
    +         '(("\\.cmake\\'" . cmake-mode))
    +         auto-mode-alist))
    +
    +  (use-package cmake-font-lock
    +    :ensure t
    +    :config
    +
    +    (add-hook 'cmake-mode-hook 'cmake-font-lock-activate)
    +    (add-hook 'yaml-mode-hook 'warnings-mode-hook)))
    +
    +
    @@ -2439,18 +2467,18 @@ And now my Go configuration. This includes stuff like the usage of goimpor (flyspell-prog-mode) ; eldoc support - (use-package go-eldoc + (use-package go-eldoc :ensure t :config (require 'go-eldoc)) - (use-package go-add-tags + (use-package go-add-tags :ensure t :config (evil-leader/set-key "t" 'go-add-tags))) ;; Go -(use-package go-mode +(use-package go-mode :ensure t :pin melpa-stable :config @@ -2464,9 +2492,37 @@ And now my Go configuration. This includes stuff like the usage of goimpor
    -

    Tabs vs spaces

    +

    Rust

    +Install rust-mode and add some hooks to make it friendlier. +

    + +
    + +
    (use-package rust-mode
    +  :ensure t
    +  :config
    +
    +  (add-hook 'before-save-hook
    +            #'(lambda ()
    +                (when (eq major-mode 'rust-mode)
    +                  (rust-format-buffer))))
    +
    +  (use-package flycheck-rust
    +    :ensure t
    +    :config
    +
    +    (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))
    +
    +
    +
    +
    + +
    +

    Tabs vs spaces

    +
    +

    Tabs or spaces? Both. The smart-tabs-mode has the philosophy of: tabs for indentation, spaces for alignment. This is only applied in languages where I'm usings tabs for indentation (C, C++ and Go). @@ -2474,7 +2530,7 @@ usings tabs for indentation (C, C++ and Go).

    -
    (use-package smart-tabs-mode
    +
    (use-package smart-tabs-mode
       :ensure t
       :config
       (smart-tabs-add-language-support golang go-mode-hook
    @@ -2486,13 +2542,13 @@ usings tabs for indentation (C, C++ and Go).
     
    -
    -

    Inferior markup languages.

    -
    +
    +

    Inferior markup languages.

    +
    ;; Markdown mode with preview mode in the browser.
    -(use-package markdown-mode
    +(use-package markdown-mode
       :ensure t
       :config
     
    @@ -2502,14 +2558,14 @@ usings tabs for indentation (C, C++ and Go).
     
       ; Preview mode does its things through websockets, so it's a requirement.
       ; After that, we can safely require it.
    -  (use-package websocket
    +  (use-package websocket
         :ensure t
         :config
    -    (use-package markdown-preview-mode
    +    (use-package markdown-preview-mode
           :ensure t)))
     
     ; YAML
    -(use-package yaml-mode
    +(use-package yaml-mode
       :ensure t
       :config
     
    @@ -2519,26 +2575,26 @@ usings tabs for indentation (C, C++ and Go).
     
    -
    -

    Web-related stuff.

    -
    +
    +

    Web-related stuff.

    +

    Slim and SCSS.

    -
    (use-package slim-mode
    +
    (use-package slim-mode
       :ensure t)
     
    -(use-package scss-mode
    +(use-package scss-mode
       :ensure t
       :config
     
       (setq scss-compile-at-save nil)
       (add-hook 'yaml-mode-hook 'warnings-mode-hook))
     
    -(use-package coffee-mode
    +(use-package coffee-mode
       :ensure t)
     
    @@ -2550,10 +2606,10 @@ bundle of features which are interesting for web-related stuff.
    -
    (use-package php-mode
    +
    (use-package php-mode
       :ensure t)
     
    -(use-package web-mode
    +(use-package web-mode
       :ensure t
       :config
     
    @@ -2572,7 +2628,7 @@ bundle of features which are interesting for web-related stuff.
                   (setq js-indent-level 2)
                   (rainbow-delimiters-mode 1)))
     
    -  (use-package vue-mode
    +  (use-package vue-mode
         :ensure t
         :config
         (setq mmm-submode-decoration-level 0))
    @@ -2599,68 +2655,59 @@ can be frustrating without proper formatting.
     
     
    -
    (use-package json-reformat
    +
    (use-package json-reformat
       :ensure t)
     
    -
    -

    Others

    -
    +
    +

    Devops

    +

    -CMake for y'all. +Highlighting for Dockerfiles.

    -
    (use-package cmake-mode
    +
    (use-package dockerfile-mode
       :ensure t
       :config
     
    -  (setq auto-mode-alist
    -        (append
    -         '(("CMakeLists\\.txt\\'" . cmake-mode))
    -         '(("\\.cmake\\'" . cmake-mode))
    -         auto-mode-alist))
    -
    -  (use-package cmake-font-lock
    -    :ensure t
    -    :config
    -
    -    (add-hook 'cmake-mode-hook 'cmake-font-lock-activate)
    -    (add-hook 'yaml-mode-hook 'warnings-mode-hook)))
    +  (add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)))
     

    -Some devops stuff, like Docker, terraform, etc. I have salt-mode disabled for -now because it's buggy, but I still have hope. +Stuff from Hashicorp like terraform and HCL.

    -
    (use-package dockerfile-mode
    -  :ensure t
    -  :config
    -
    -  (add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)))
    -
    -(use-package terraform-mode
    +
    (use-package terraform-mode
       :ensure t
       :config
     
       (terraform-format-on-save-mode))
     
    -(use-package hcl-mode
    +(use-package hcl-mode
       :ensure t)
    +
    +
    -;(use-package salt-mode - ;:ensure t) +
    + +
    (use-package salt-mode
    +  :ensure t)
     
    +
    +
    +
    +

    Others

    +

    The soria theme has the soria-purple-identifiers hook. This hook instructs the theme to use purple for identifiers instead of the default color. This is a @@ -2727,7 +2774,7 @@ too many things into my leader and these shortcuts look sensible to me).

    -
    (use-package crux
    +
    (use-package crux
       :ensure t
       :config
     
    @@ -2792,7 +2839,7 @@ along with this program.  If not, see <
     
    diff --git a/emacs/init.org b/emacs/init.org index 07d1efe..c4d16da 100644 --- a/emacs/init.org +++ b/emacs/init.org @@ -986,10 +986,11 @@ the rest. 'show))) #+END_SRC -Set a key binding for =magit-blame=. +Set a key binding for =magit-blame= and =magit-log-buffer-file=. #+BEGIN_SRC elisp (global-set-key (kbd "C-c b") 'magit-blame) + (global-set-key (kbd "C-c l") 'magit-log-buffer-file) #+END_SRC And repair some key bindings from Evil mode. @@ -1701,6 +1702,27 @@ comments and the usage of tabs instead of spaces. (lambda () (setq indent-tabs-mode t))) #+END_SRC +CMake for y'all. + +#+BEGIN_SRC elisp + (use-package cmake-mode + :ensure t + :config + + (setq auto-mode-alist + (append + '(("CMakeLists\\.txt\\'" . cmake-mode)) + '(("\\.cmake\\'" . cmake-mode)) + auto-mode-alist)) + + (use-package cmake-font-lock + :ensure t + :config + + (add-hook 'cmake-mode-hook 'cmake-font-lock-activate) + (add-hook 'yaml-mode-hook 'warnings-mode-hook))) +#+END_SRC + ** Ruby Include warning keywords in Ruby. @@ -1757,6 +1779,27 @@ And now my Go configuration. This includes stuff like the usage of =goimports=, (add-hook 'go-mode-hook 'mssola-go-mode)) #+END_SRC +** Rust + +Install =rust-mode= and add some hooks to make it friendlier. + +#+BEGIN_SRC elisp +(use-package rust-mode + :ensure t + :config + + (add-hook 'before-save-hook + #'(lambda () + (when (eq major-mode 'rust-mode) + (rust-format-buffer)))) + + (use-package flycheck-rust + :ensure t + :config + + (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))) +#+END_SRC + ** Tabs vs spaces Tabs or spaces? [[https://www.emacswiki.org/emacs/TabsSpacesBoth][Both]]. The =smart-tabs-mode= has the philosophy of: tabs for @@ -1873,52 +1916,38 @@ can be frustrating without proper formatting. :ensure t) #+END_SRC -** Others +** Devops -CMake for y'all. +Highlighting for Dockerfiles. #+BEGIN_SRC elisp - (use-package cmake-mode + (use-package dockerfile-mode :ensure t :config - (setq auto-mode-alist - (append - '(("CMakeLists\\.txt\\'" . cmake-mode)) - '(("\\.cmake\\'" . cmake-mode)) - auto-mode-alist)) - - (use-package cmake-font-lock - :ensure t - :config - - (add-hook 'cmake-mode-hook 'cmake-font-lock-activate) - (add-hook 'yaml-mode-hook 'warnings-mode-hook))) + (add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))) #+END_SRC -Some devops stuff, like Docker, terraform, etc. I have salt-mode disabled for -now because it's buggy, but I still have hope. +Stuff from Hashicorp like terraform and HCL. #+BEGIN_SRC elisp - (use-package dockerfile-mode - :ensure t - :config - - (add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))) - - (use-package terraform-mode - :ensure t - :config +(use-package terraform-mode + :ensure t + :config - (terraform-format-on-save-mode)) + (terraform-format-on-save-mode)) - (use-package hcl-mode - :ensure t) +(use-package hcl-mode + :ensure t) +#+END_SRC - ;(use-package salt-mode - ;:ensure t) +#+BEGIN_SRC elisp +(use-package salt-mode + :ensure t) #+END_SRC +** Others + The [[https;//github.com/mssola/soria][soria]] theme has the =soria-purple-identifiers= hook. This hook instructs the theme to use purple for identifiers instead of the default color. This is a remnant from my Vim times, and I only apply it to some languages (random -- cgit v1.2.3