Created
April 20, 2022 14:33
-
-
Save adrien-barret/a70984868818a8ba88ec5a36fdf44afe to your computer and use it in GitHub Desktop.
emacs_settings.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* company-box Package managemnt | |
** Add Melpa | |
#+begin_src emacs-lisp | |
(eval-and-compile | |
(customize-set-variable | |
'package-archives '(("org" . "https://orgmode.org/elpa/") | |
("gnu" . "https://elpa.gnu.org/packages/") | |
("melpa" . "https://melpa.org/packages/"))) | |
(package-initialize) | |
(unless (package-installed-p 'use-package) | |
(package-refresh-contents) | |
(package-install 'use-package))) | |
#+end_src | |
** Ensure always install pkg if not there | |
#+begin_src emacs-lisp | |
(setq use-package-always-ensure t) | |
#+end_src | |
** load bunch of usefull pkg | |
#+begin_src emacs-lisp | |
(use-package lorem-ipsum) | |
(use-package pdf-tools | |
:defer t) | |
(use-package refine) | |
(use-package request) | |
(use-package csv) | |
(use-package multiple-cursors) | |
;; (use-package csharp-mode) | |
(use-package keychain-environment) | |
(use-package prodigy) | |
(use-package vlf) | |
(use-package cheat-sh) | |
(use-package transpose-frame) | |
(use-package x509-mode) ;; cert viewer and generator | |
#+end_src | |
* custom usages | |
** Disable useless stuff | |
#+begin_src emacs-lisp | |
;; Remove initial buffer, set index file | |
;;(setq initial-buffer-choice "index.org") | |
;; Hide Scroll bar,menu bar, tool bar | |
(scroll-bar-mode -1) | |
(tool-bar-mode -1) | |
(menu-bar-mode -1) | |
;; Line numbering | |
(global-display-line-numbers-mode) | |
(setq display-line-numbers-type 'relative) | |
;; Display battery for when in full screen mode | |
(display-battery-mode t) | |
;; Misc stuff | |
(setenv "HOME" "/home/adrien") | |
(server-start) | |
(setq | |
make-backup-files nil | |
;; auto-save-default nil | |
inhibit-startup-message t | |
ring-bell-function 'ignore) | |
#+end_src | |
** Setup UTF-8 full compability | |
#+begin_src emacs-lisp | |
(set-charset-priority 'unicode) | |
(setq locale-coding-system 'utf-8) | |
(set-terminal-coding-system 'utf-8) | |
(set-keyboard-coding-system 'utf-8) | |
(set-selection-coding-system 'utf-8) | |
(prefer-coding-system 'utf-8) | |
(setq default-process-coding-system '(utf-8-unix . utf-8-unix)) | |
#+end_src | |
** Replace yes/no by y/n | |
#+begin_src emacs-lisp | |
(fset 'yes-or-no-p 'y-or-n-p) | |
#+end_src | |
** Confirm exit emacs | |
#+begin_src emacs-lisp | |
(setq confirm-kill-emacs 'yes-or-no-p) | |
#+end_src | |
** use zsh in shell | |
#+begin_src emacs-lisp | |
(setq explicit-shell-file-name "/bin/zsh") | |
#+end_src | |
** Common | |
#+begin_src emacs-lisp | |
(setq frame-title-format nil) | |
(setq ring-bell-function 'ignore) | |
(setq uniquify-buffer-name-style 'post-forward-angle-brackets) ; Show path if names are same | |
(setq adaptive-fill-regexp "[ t]+|[ t]*([0-9]+.|*+)[ t]*") | |
(setq adaptive-fill-first-line-regexp "^* *$") | |
(setq sentence-end "\\([。、!?]\\|……\\|[,.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*") | |
(setq sentence-end-double-space nil) | |
(setq delete-by-moving-to-trash t) ; Deleting files go to OS's trash folder | |
;; (setq make-backup-files nil) ; Forbide to make backup files | |
;; (setq auto-save-default nil) ; Disable auto save | |
(setq set-mark-command-repeat-pop t) ; Repeating C-SPC after popping mark pops it again | |
(setq track-eol t) ; Keep cursor at end of lines. | |
(setq line-move-visual nil) ; To be required by track-eol | |
;; Delete selection if insert someting | |
(use-package delsel | |
:ensure nil | |
:hook (after-init . delete-selection-mode)) | |
;; Automatically reload files was modified by external program | |
(use-package autorevert | |
:ensure nil | |
:diminish | |
:hook (after-init . global-auto-revert-mode)) | |
#+end_src | |
** Scratch Buffer | |
#+BEGIN_SRC emacs-lisp | |
(defun generate-scratch-buffer () | |
"Create and switch to a temporary scratch buffer with a random | |
name." | |
(interactive) | |
(switch-to-buffer (make-temp-name "scratch-"))) | |
#+END_SRC | |
** New lines | |
#+BEGIN_SRC emacs-lisp | |
;; Add new line to end of text | |
(setq require-final-newline t) | |
;; Delete white space on end of line when saving | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
#+END_SRC | |
** insert a file name | |
#+BEGIN_SRC emacs-lisp | |
(defun my-insert-file-name (filename &optional args) | |
"Insert name of file FILENAME into buffer after point. | |
Prefixed with \\[universal-argument], expand the file name to | |
its fully canocalized path. See `expand-file-name'. | |
Prefixed with \\[negative-argument], use relative path to file | |
name from current directory, `default-directory'. See | |
`file-relative-name'. | |
The default with no prefix is to insert the file name exactly as | |
it appears in the minibuffer prompt." | |
;; Based on insert-file in Emacs -- ashawley 20080926 | |
(interactive "*fInsert file name: \nP") | |
(cond ((eq '- args) | |
(insert (file-relative-name filename))) | |
((not (null args)) | |
(insert (expand-file-name filename))) | |
(t | |
(insert filename)))) | |
#+END_SRC | |
* UX/UI | |
** Helm (Like Yvi) | |
#+begin_src emacs-lisp | |
(use-package helm | |
:init | |
(require 'helm-config) | |
(setq helm-split-window-in-side-p t | |
helm-move-to-line-cycle-in-source t) | |
:config | |
(helm-mode 1) ;; Most of Emacs prompts become helm-enabled | |
(helm-autoresize-mode 1) ;; Helm resizes according to the number of candidates | |
(global-set-key (kbd "C-x b") 'helm-buffers-list) ;; List buffers ( Emacs way ) | |
(global-set-key (kbd "C-x r b") 'helm-bookmarks) ;; Bookmarks menu | |
(global-set-key (kbd "C-x C-f") 'helm-find-files) ;; Finding files with Helm | |
; (global-set-key (kbd "M-c") 'helm-calcul-expression) ;; Use Helm for calculations | |
(global-set-key (kbd "C-s") 'helm-occur) ;; Replaces the default isearch keybinding | |
; (global-set-key (kbd "C-h a") 'helm-apropos) ;; Helmized apropos interface | |
(global-set-key (kbd "M-x") 'helm-M-x) ;; Improved M-x menu | |
; (global-set-key (kbd "M-y") 'helm-show-kill-ring) ;; Show kill ring, pick something to paste | |
:ensure t) | |
#+end_src | |
** Dired as File management | |
#+begin_src emacs-lisp | |
;(use-package dired | |
;:ensure t | |
;:config (require 'dired)) | |
;;(add-hook 'dired-load-hook | |
;;(function (lambda () (load "dired-x")))) | |
#+end_src | |
** Treemacs | |
#+begin_src emacs-lisp | |
(use-package treemacs | |
:ensure t | |
:defer t | |
:init | |
(with-eval-after-load 'winum | |
(define-key winum-keymap (kbd "M-0") 'treemacs-select-window)) | |
:config | |
(progn | |
(setq treemacs-collapse-dirs (if (executable-find "python") 3 0) | |
treemacs-deferred-git-apply-delay 0.5 | |
treemacs-display-in-side-window t | |
treemacs-file-event-delay 5000 | |
treemacs-file-follow-delay 0.2 | |
treemacs-follow-after-init t | |
treemacs-follow-recenter-distance 0.1 | |
treemacs-git-command-pipe "" | |
treemacs-goto-tag-strategy 'refetch-index | |
treemacs-indentation 2 | |
treemacs-indentation-string " " | |
treemacs-is-never-other-window nil | |
treemacs-max-git-entries 5000 | |
treemacs-no-png-images nil | |
treemacs-no-delete-other-windows t | |
treemacs-project-follow-cleanup nil | |
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) | |
treemacs-recenter-after-file-follow nil | |
treemacs-recenter-after-tag-follow nil | |
treemacs-show-cursor nil | |
treemacs-show-hidden-files nil | |
treemacs-silent-filewatch nil | |
treemacs-silent-refresh nil | |
treemacs-sorting 'alphabetic-desc | |
treemacs-space-between-root-nodes t | |
treemacs-tag-follow-cleanup t | |
treemacs-tag-follow-delay 1.5 | |
treemacs-width 35) | |
;; The default width and height of the icons is 22 pixels. If you are | |
;; using a Hi-DPI display, uncomment this to double the icon size. | |
;;(treemacs-resize-icons 44) | |
(treemacs-follow-mode t) | |
(treemacs-filewatch-mode t) | |
(treemacs-fringe-indicator-mode t) | |
(pcase (cons (not (null (executable-find "git"))) | |
(not (null (executable-find "python3")))) | |
(`(t . t) | |
(treemacs-git-mode 'deferred)) | |
(`(t . _) | |
(treemacs-git-mode 'simple)))) | |
:bind | |
(:map global-map | |
("M-0" . treemacs-select-window) | |
("C-x t 1" . treemacs-delete-other-windows) | |
("C-x t t" . treemacs) | |
("C-x t B" . treemacs-bookmark) | |
("C-x t C-t" . treemacs-find-file) | |
("C-x t M-t" . treemacs-find-tag))) | |
(use-package treemacs-projectile | |
:after treemacs projectile | |
:ensure t) | |
#+end_src | |
** Neotree | |
#+begin_src emacs-lisp | |
(use-package neotree | |
:after | |
projectile | |
:commands | |
(neotree-show neotree-hide neotree-dir neotree-find) | |
:custom | |
(neo-theme 'nerd2) | |
:bind | |
("<f8>" . neotree-current-dir-toggle) | |
("<f9>" . neotree-projectile-toggle) | |
:preface | |
(defun neotree-projectile-toggle () | |
(interactive) | |
(let ((project-dir | |
(ignore-errors | |
;;; Pick one: projectile or find-file-in-project | |
(projectile-project-root) | |
)) | |
(file-name (buffer-file-name)) | |
(neo-smart-open t)) | |
(if (and (fboundp 'neo-global--window-exists-p) | |
(neo-global--window-exists-p)) | |
(neotree-hide) | |
(progn | |
(neotree-show) | |
(if project-dir | |
(neotree-dir project-dir)) | |
(if file-name | |
(neotree-find file-name)))))) | |
(defun neotree-current-dir-toggle () | |
(interactive) | |
(let ((project-dir | |
(ignore-errors | |
(ffip-project-root) | |
)) | |
(file-name (buffer-file-name)) | |
(neo-smart-open t)) | |
(if (and (fboundp 'neo-global--window-exists-p) | |
(neo-global--window-exists-p)) | |
(neotree-hide) | |
(progn | |
(neotree-show) | |
(if project-dir | |
(neotree-dir project-dir)) | |
(if file-name | |
(neotree-find file-name))))))) | |
(setq neo-window-fixed-size nil) | |
#+end_src | |
** persp | |
#+begin_src emacs-lisp | |
(use-package persp-mode | |
:disabled | |
:diminish | |
:commands (get-current-persp persp-contain-buffer-p) | |
:hook (after-init . persp-mode)) | |
#+end_src | |
** Imenu list | |
#+begin_src emacs-lisp | |
(use-package imenu-list | |
:load-path "/home/adrien/.emacs.d/imenu-list" | |
:bind | |
("<f10>" . imenu-list-smart-toggle) | |
:custom-face | |
(imenu-list-entry-face-1 ((t (:foreground "#ff017d")))) | |
:custom | |
(imenu-list-focus-after-activation t) | |
(imenu-list-auto-resize t)) | |
#+end_src | |
** Smart Parent | |
#+begin_src emacs-lisp | |
(use-package smartparens | |
:hook | |
(after-init . smartparens-global-mode) | |
:config | |
(require 'smartparens-config) | |
(sp-pair "=" "=" :actions '(wrap)) | |
(sp-pair "+" "+" :actions '(wrap)) | |
(sp-pair "<" ">" :actions '(wrap)) | |
(sp-pair "{" "}" :actions '(wrap)) | |
(sp-pair "$" "$" :actions '(wrap))) | |
#+end_src | |
** Paren | |
#+begin_src emacs-lisp | |
(use-package paren | |
:ensure nil | |
:hook | |
(after-init . show-paren-mode) | |
:custom-face | |
(show-paren-match ((nil (:background "#44475a" :foreground "#f1fa8c")))) ;; :box t | |
:custom | |
(show-paren-style 'mixed) | |
(show-paren-when-point-inside-paren t) | |
(show-paren-when-point-in-periphery t)) | |
#+end_src | |
** Highline line | |
#+begin_src emacs-lisp | |
(use-package hl-line | |
:ensure nil | |
:hook | |
(after-init . global-hl-line-mode)) | |
#+end_src | |
** Collumn indicator | |
#+begin_src emacs-lisp | |
(use-package fill-column-indicator | |
:hook | |
((markdown-mode | |
git-commit-mode) . fci-mode)) | |
#+end_src | |
** Dimmer | |
#+begin_src emacs-lisp | |
(use-package dimmer | |
:disabled | |
:custom | |
(dimmer-fraction 0.5) | |
(dimmer-exclusion-regexp-list | |
'(".*Minibuf.*" | |
".*which-key.*" | |
".*NeoTree.*" | |
".*Messages.*" | |
".*Async.*" | |
".*Warnings.*" | |
".*LV.*" | |
".*Ilist.*")) | |
:config | |
(dimmer-mode t)) | |
#+end_src | |
** Add modline | |
#+begin_src emacs-lisp | |
(use-package hide-mode-line | |
:hook | |
((neotree-mode imenu-list-minor-mode minimap-mode) . hide-mode-line-mode)) | |
#+end_src | |
** Line Number | |
#+begin_src emacs-lisp | |
(use-package display-line-numbers | |
:ensure nil | |
:hook | |
((prog-mode yaml-mode systemd-mode) . display-line-numbers-mode)) | |
#+end_src | |
** Nyan | |
#+begin_src emacs-lisp | |
(use-package nyan-mode | |
:custom | |
(nyan-cat-face-number 4) | |
(nyan-animate-nyancat t) | |
:hook | |
(doom-modeline-mode . nyan-mode)) | |
#+end_src | |
** MiniMap | |
#+begin_src emacs-lisp | |
(use-package minimap | |
:commands | |
(minimap-bufname minimap-create minimap-kill) | |
:custom | |
(minimap-major-modes '(prog-mode)) | |
(minimap-window-location 'right) | |
(minimap-update-delay 0.2) | |
(minimap-minimum-width 20) | |
:bind | |
;;("C-t p" . hk/toggle-minimap) | |
:preface | |
(defun hk/toggle-minimap () | |
"Toggle minimap for current buffer." | |
(interactive) | |
(if (null minimap-bufname) | |
(minimap-create) | |
(minimap-kill))) | |
:config | |
(custom-set-faces | |
'(minimap-active-region-background | |
((((background dark)) (:background "#555555555555")) | |
(t (:background "#C847D8FEFFFF"))) :group 'minimap))) | |
#+end_src | |
** History | |
#+begin_src emacs-lisp | |
;; History | |
(use-package saveplace | |
:ensure nil | |
:hook (after-init . save-place-mode)) | |
;; Recent files | |
(use-package recentf | |
:ensure nil | |
:hook (after-init . recentf-mode) | |
:custom | |
(recentf-max-saved-items 20000000) | |
(recentf-auto-cleanup 'never) | |
(recentf-exclude '((expand-file-name package-user-dir) | |
".cache" | |
"cache" | |
"recentf" | |
"COMMIT_EDITMSG\\'")) | |
:preface | |
(defun ladicle/recentf-save-list-silence () | |
(interactive) | |
(let ((message-log-max nil)) | |
(if (fboundp 'shut-up) | |
(shut-up (recentf-save-list)) | |
(recentf-save-list))) | |
(message "")) | |
(defun ladicle/recentf-cleanup-silence () | |
(interactive) | |
(let ((message-log-max nil)) | |
(if shutup-p | |
(shut-up (recentf-cleanup)) | |
(recentf-cleanup))) | |
(message ""))) | |
#+end_src | |
** Undo/Redo | |
#+begin_src emacs-lisp | |
(use-package undo-tree | |
:bind | |
("M-/" . undo-tree-redo) | |
:config | |
(global-undo-tree-mode)) | |
#+end_src | |
** Auto Complete | |
#+begin_src emacs-lisp | |
(use-package auto-complete | |
:ensure t | |
:config | |
(ac-config-default) | |
) | |
#+end_src | |
** CaseLetter | |
#+begin_src emacs-lisp | |
(defun upcase-backward-word (arg) | |
(interactive "p") | |
(upcase-word (- arg))) | |
(defun downcase-backward-word (arg) | |
(interactive "p") | |
(downcase-word (- arg))) | |
(defun capitalize-backward-word (arg) | |
(interactive "p") | |
(capitalize-word (- arg))) | |
(global-set-key (kbd "C-M-u") 'upcase-backward-word) | |
(global-set-key (kbd "C-M-l") 'downcase-backward-word) | |
(global-set-key (kbd "M-c") 'capitalize-backward-word) | |
#+end_src | |
** Google Translate | |
#+begin_src emacs-lisp | |
(use-package google-translate | |
:bind | |
("M-o t" . google-translate-at-point) | |
("M-o T" . google-translate-at-point-reverse) | |
:custom | |
(google-translate-default-source-language "en") | |
(google-translate-default-target-language "fr")) | |
#+end_src | |
** Google Search | |
#+begin_src emacs-lisp | |
(use-package google-this) | |
#+end_src | |
** Copy FilePath | |
#+begin_src emacs-lisp | |
(defun put-current-path-to-clipboard () | |
(interactive) | |
(let ((file-path buffer-file-name) | |
(dir-path default-directory)) | |
(cond (file-path | |
(kill-new (expand-file-name file-path)) | |
(message "This file path is on the clipboard!")) | |
(dir-path | |
(kill-new (expand-file-name dir-path)) | |
(message "This directory path is on the clipboard!")) | |
(t | |
(error-message-string "Fail to get path name."))))) | |
(defun put-current-filename-to-clipboard () | |
(interactive) | |
(let ((file-path buffer-file-name) | |
(dir-path default-directory)) | |
(cond (file-path | |
(kill-new (file-name-nondirectory file-path)) | |
(message "This file path is on the clipboard!")) | |
(dir-path | |
(kill-new (file-name-nondirectory dir-path)) | |
(message "This directory path is on the clipboard!")) | |
(t | |
(error-message-string "Fail to get path name."))))) | |
(defun put-current-filename-with-line-to-clipboard () | |
(interactive) | |
(let ((file-path buffer-file-name) | |
(dir-path default-directory)) | |
(cond (file-path | |
(kill-new (format "%s:%s" | |
(file-name-nondirectory file-path) | |
(count-lines (point-min) (point)))) | |
(message "This file path is on the clipboard!")) | |
(dir-path | |
(kill-new (file-name-nondirectory dir-path)) | |
(message "This directory path is on the clipboard!")) | |
(t | |
(error-message-string "Fail to get path name."))))) | |
#+end_src | |
** Volatile | |
#+begin_src emacs-lisp | |
(use-package volatile-highlights | |
:diminish | |
:hook | |
(after-init . volatile-highlights-mode) | |
:custom-face | |
(vhl/default-face ((nil (:foreground "#FF3333" :background "#FFCDCD"))))) | |
#+end_src | |
** indent | |
#+begin_src emacs-lisp | |
(use-package highlight-indent-guides | |
:diminish | |
:hook | |
((prog-mode yaml-mode) . highlight-indent-guides-mode) | |
:custom | |
(highlight-indent-guides-auto-enabled t) | |
(highlight-indent-guides-responsive t) | |
(highlight-indent-guides-method 'character)) ; column | |
#+end_src | |
** Dashboard | |
#+begin_src emacs-lisp | |
(use-package dashboard | |
:hook | |
(after-init . dashboard-setup-startup-hook)) | |
#+end_src | |
** Custom functions | |
*** move cursor 10 lines up/down | |
#+begin_src emacs-lisp | |
(defun move-text-internal (arg) | |
(cond | |
((and mark-active transient-mark-mode) | |
(if (> (point) (mark)) | |
(exchange-point-and-mark)) | |
(let ((column (current-column)) | |
(text (delete-and-extract-region (point) (mark)))) | |
(forward-line arg) | |
(move-to-column column t) | |
(set-mark (point)) | |
(insert text) | |
(exchange-point-and-mark) | |
(setq deactivate-mark nil))) | |
(t | |
(let ((column (current-column))) | |
(beginning-of-line) | |
(when (or (> arg 0) (not (bobp))) | |
(forward-line) | |
(when (or (< arg 0) (not (eobp))) | |
(transpose-lines arg) | |
(when (and (eval-when-compile | |
'(and (>= emacs-major-version 24) | |
(>= emacs-minor-version 3))) | |
(< arg 0)) | |
(forward-line -1))) | |
(forward-line -1)) | |
(move-to-column column t))))) | |
(defun move-text-down (arg) | |
"Move region (transient-mark-mode active) or current line | |
arg lines down." | |
(interactive "*p") | |
(move-text-internal arg)) | |
(defun move-text-up (arg) | |
"Move region (transient-mark-mode active) or current line | |
arg lines up." | |
(interactive "*p") | |
(move-text-internal (- arg))) | |
#+end_src | |
*** Move a line Up/Down | |
#+begin_src emacs-lisp | |
(defun move-line-up () | |
"Move up the current line." | |
(interactive) | |
(transpose-lines 1) | |
(forward-line -2) | |
(indent-according-to-mode)) | |
(defun move-line-down () | |
"Move down the current line." | |
(interactive) | |
(forward-line 1) | |
(transpose-lines 1) | |
(forward-line -1) | |
(indent-according-to-mode)) | |
#+end_src | |
*** Duplicate line | |
#+begin_src emacs-lisp | |
(defun duplicate-line (arg) | |
"Duplicate current line, leaving point in lower line." | |
(interactive "*p") | |
;; save the point for undo | |
(setq buffer-undo-list (cons (point) buffer-undo-list)) | |
;; local variables for start and end of line | |
(let ((bol (save-excursion (beginning-of-line) (point))) | |
eol) | |
(save-excursion | |
;; don't use forward-line for this, because you would have | |
;; to check whether you are at the end of the buffer | |
(end-of-line) | |
(setq eol (point)) | |
;; store the line and disable the recording of undo information | |
(let ((line (buffer-substring bol eol)) | |
(buffer-undo-list t) | |
(count arg)) | |
;; insert the line arg times | |
(while (> count 0) | |
(newline) ;; because there is no newline in 'line' | |
(insert line) | |
(setq count (1- count))) | |
) | |
;; create the undo information | |
(setq buffer-undo-list (cons (cons eol (point)) buffer-undo-list))) | |
) ; end-of-let | |
;; put the point in the lowest line and return | |
(next-line arg)) | |
#+end_src | |
* Git | |
** Magit | |
#+begin_src emacs-lisp | |
(use-package magit | |
:ensure t) | |
#+end_src | |
** TimeMachine | |
#+begin_src emacs-lisp | |
(use-package git-timemachine | |
:bind ("M-g t" . git-timemachine-toggle)) | |
#+end_src | |
** Diffview | |
#+begin_src emacs-lisp | |
(use-package diffview | |
:commands (diffview-region diffview-current) | |
:preface | |
(defun ladicle/diffview-dwim () | |
(interactive) | |
(if (region-active-p) | |
(diffview-region) | |
(diffview-current))) | |
:bind ("M-g v" . hk/diffview-dwim)) | |
#+end_src | |
** Git Mode | |
#+begin_src emacs-lisp | |
(use-package gitattributes-mode :defer t) | |
(use-package gitconfig-mode :defer t) | |
(use-package gitignore-mode :defer t) | |
#+end_src | |
** Git Gutter | |
#+begin_src emacs-lisp | |
(use-package git-gutter | |
:custom | |
(git-gutter:modified-sign "~") ; | |
(git-gutter:added-sign "+") ; | |
(git-gutter:deleted-sign "-") ; | |
:custom-face | |
(git-gutter:modified ((t (:foreground "#f1fa8c" :background "#f1fa8c")))) | |
(git-gutter:added ((t (:foreground "#50fa7b" :background "#50fa7b")))) | |
(git-gutter:deleted ((t (:foreground "#ff79c6" :background "#ff79c6")))) | |
:config | |
(global-git-gutter-mode +1)) | |
#+end_src | |
* Theming stuff | |
** Padding | |
#+begin_src emacs-lisp | |
(set-window-margins nil 3) | |
#+end_src | |
** Turn off menu bar | |
#+BEGIN_SRC emacs-lisp | |
(menu-bar-mode -1) | |
#+END_SRC | |
** Theme selection | |
#+begin_src emacs-lisp | |
(use-package doom-themes | |
:custom | |
(doom-themes-enable-italic t) | |
(doom-themes-enable-bold t) | |
:custom-face | |
;; (vertical-bar (doom-darken base5 0.4)) | |
;; (doom-darken bg 0.4) | |
:config | |
;; (load-theme 'doom-horizon t) | |
;; (load-theme 'doom-Iosvkem t) | |
;; (load-theme 'doom-molokai t) | |
(load-theme 'doom-nova t) | |
;; (load-theme 'doom-opera t) | |
;; (load-theme 'doom-spacegrey t) | |
;; (load-theme 'doom-peacock t) | |
;; (load-theme 'doom-nord t) | |
;; (load-theme 'doom-nord-light t) | |
;; (load-theme 'doom-material t) | |
;; (load-theme 'doom-dark+ t) | |
;; (load-theme 'doom-dracula t) | |
(doom-themes-neotree-config) | |
(doom-themes-org-config) | |
;; Modeline | |
(use-package doom-modeline | |
:custom | |
(doom-modeline-buffer-file-name-style 'truncate-with-project) | |
(doom-modeline-icon t) | |
(doom-modeline-major-mode-icon nil) | |
(doom-modeline-minor-modes nil) | |
:hook | |
(after-init . doom-modeline-mode) | |
:config | |
(set-cursor-color "cyan") | |
(line-number-mode 0) | |
(column-number-mode 0) | |
(doom-modeline-def-modeline 'main | |
'(bar window-number matches buffer-info remote-host buffer-position parrot selection-info) | |
'(misc-info persp-name lsp github debug minor-modes input-method major-mode process vcs checker)))) | |
#+end_src | |
** Rainbow delimiter & Mode | |
#+begin_src emacs-lisp | |
(use-package rainbow-delimiters | |
:hook | |
(prog-mode . rainbow-delimiters-mode)) | |
(use-package rainbow-mode | |
:diminish | |
:hook (emacs-lisp-mode . rainbow-mode)) | |
#+end_src | |
** beacon | |
#+begin_src emacs-lisp | |
(use-package beacon | |
:custom | |
(beacon-color "#f1fa8c") | |
:hook (after-init . beacon-mode)) | |
#+end_src | |
** Cursor Style && Vertical border | |
#+begin_src emacs-lisp | |
;; Change cursor style | |
(add-to-list 'default-frame-alist '(cursor-type . bar)) | |
;; vertical border | |
(let ((display-table (or standard-display-table (make-display-table)))) | |
(set-display-table-slot display-table 'vertical-border (make-glyph-code ?│)) ; or ┃ │ | |
(setq standard-display-table display-table)) | |
(set-face-background 'vertical-border "#0e0f1b") | |
(set-face-foreground 'vertical-border (face-background 'vertical-border)) | |
#+end_src | |
** All the Icons | |
#+begin_src emacs-lisp | |
(use-package all-the-icons :defer t) | |
#+end_src | |
** Postframe | |
#+begin_src emacs-lisp | |
(use-package posframe) | |
#+end_src | |
* Org-Mode | |
** Customization | |
#+begin_src emacs-lisp | |
(use-package org-superstar ;; Improved version of org-bullets | |
:ensure t | |
:config | |
(add-hook 'org-mode-hook (lambda () (org-superstar-mode 1)))) | |
(setq org-startup-indented t) ;; Indent according to section | |
(setq org-startup-with-inline-images t) ;; Display images in-buffer by default | |
#+end_src | |
** Agenda | |
#+begin_src emacs-lisp | |
(setq org-agenda-custom-commands | |
'(("h" "Daily habits" | |
((agenda "")) | |
((org-agenda-show-log t) | |
(org-agenda-ndays 7) | |
(org-agenda-log-mode-items '(state)) | |
(org-agenda-skip-function '(org-agenda-skip-entry-if 'notregexp ":DAILY:")))))) | |
#+end_src | |
** Babel | |
#+begin_src emacs-lisp | |
(org-babel-do-load-languages | |
'org-babel-load-languages | |
'((python . t))) | |
#+end_src | |
** Revealjs | |
#+begin_src emacs-lisp | |
(use-package ox-reveal | |
:ensure ox-reveal) | |
(setenv "PATH" (concat (getenv "PATH") ":/opt/texlive/2019/bin/x86_64-linux")) | |
(setq org-reveal-root "http://cdn.jsdelivr.net/reveal.js/4.1.2/") | |
(setq org-reveal-mathjax t) | |
(use-package htmlize | |
:ensure t) | |
#+end_src | |
** Markdown | |
#+begin_src emacs-lisp | |
(use-package markdown-mode | |
:ensure t | |
:mode (("README\\.md\\'" . gfm-mode) | |
("\\.md\\'" . markdown-mode) | |
("\\.markdown\\'" . markdown-mode)) | |
:init (setq markdown-command "multimarkdown")) | |
#+end_src | |
** htmlize | |
#+BEGIN_SRC emacs-lisp | |
(use-package htmlize) | |
(use-package epresent) | |
(defadvice htmlize-buffer-1 (around ome-htmlize-buffer-1 disable) | |
(rainbow-delimiters-mode -1) | |
ad-do-it | |
(rainbow-delimiters-mode t)) | |
(defun ome-htmlize-setup () | |
(if (el-get-read-package-status 'rainbow-delimiters) | |
(progn | |
(ad-enable-advice 'htmlize-buffer-1 'around 'ome-htmlize-buffer-1) | |
(ad-activate 'htmlize-buffer-1)))) | |
#+END_SRC | |
** Embedding youtube video | |
#+BEGIN_SRC emacs-lisp | |
(defvar yt-iframe-format | |
;; You may want to change your width and height. | |
(concat "<iframe width=\"440\"" | |
" height=\"335\"" | |
" src=\"https://www.youtube.com/embed/%s\"" | |
" frameborder=\"0\"" | |
" allowfullscreen>%s</iframe>")) | |
(org-add-link-type | |
"yt" | |
(lambda (handle) | |
(browse-url | |
(concat "https://www.youtube.com/embed/" | |
handle))) | |
(lambda (path desc backend) | |
(cl-case backend | |
(html (format yt-iframe-format | |
path (or desc ""))) | |
(latex (format "\href{%s}{%s}" | |
path (or desc "video")))))) | |
#+END_SRC | |
* Code and Syntax | |
** LSP | |
;; GO111MODULE=on go get golang.org/x/tools/gopls@latest or go install golang.org/x/tools/gopls@latest | |
#+begin_src emacs-lisp | |
(require 'lsp-mode) | |
(add-hook 'go-mode-hook #'lsp-deferred) | |
;; Set up before-save hooks to format buffer and add/delete imports. | |
;; Make sure you don't have other gofmt/goimports hooks enabled. | |
(defun lsp-go-install-save-hooks () | |
(add-hook 'before-save-hook #'lsp-format-buffer t t) | |
(add-hook 'before-save-hook #'lsp-organize-imports t t)) | |
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks) | |
#+end_src | |
** Tabnine | |
#+begin_src emacs-lisp | |
(use-package company-tabnine :ensure t) | |
(add-to-list 'company-backends #'company-tabnine) | |
#+end_src | |
** Company | |
#+begin_src emacs-lisp | |
(use-package company | |
:diminish company-mode | |
:defines | |
(company-dabbrev-ignore-case company-dabbrev-downcase) | |
:bind | |
(:map company-active-map | |
("C-n" . company-select-next) | |
("C-p" . company-select-previous) | |
("<tab>" . company-complete-common-or-cycle) | |
:map company-search-map | |
("C-p" . company-select-previous) | |
("C-n" . company-select-next)) | |
:custom | |
(company-idle-delay 0) | |
(company-echo-delay 0) | |
(company-minimum-prefix-length 1) | |
:hook | |
(after-init . global-company-mode) | |
(plantuml-mode . (lambda () (set (make-local-variable 'company-backends) | |
'((company-yasnippet | |
;; company-dabbrev | |
))))) | |
((go-mode | |
c++-mode | |
c-mode | |
objc-mode) . (lambda () (set (make-local-variable 'company-backends) | |
'((company-yasnippet | |
company-lsp | |
company-files | |
;; company-dabbrev-code | |
))))) | |
:config | |
;; using child frame | |
(use-package company-posframe | |
:hook (company-mode . company-posframe-mode)) | |
;; Show pretty icons | |
(use-package company-box | |
:diminish | |
:hook (company-mode . company-box-mode) | |
:init (setq company-box-icons-alist 'company-box-icons-all-the-icons) | |
:config | |
(setq company-box-backends-colors nil) | |
(setq company-box-show-single-candidate t) | |
(setq company-box-max-candidates 50) | |
(defun company-box-icons--elisp (candidate) | |
(when (derived-mode-p 'emacs-lisp-mode) | |
(let ((sym (intern candidate))) | |
(cond ((fboundp sym) 'Function) | |
((featurep sym) 'Module) | |
((facep sym) 'Color) | |
((boundp sym) 'Variable) | |
((symbolp sym) 'Text) | |
(t . nil))))) | |
(with-eval-after-load 'all-the-icons | |
(declare-function all-the-icons-faicon 'all-the-icons) | |
(declare-function all-the-icons-fileicon 'all-the-icons) | |
(declare-function all-the-icons-material 'all-the-icons) | |
(declare-function all-the-icons-octicon 'all-the-icons) | |
(setq company-box-icons-all-the-icons | |
`((Unknown . ,(all-the-icons-material "find_in_page" :height 0.7 :v-adjust -0.15)) | |
(Text . ,(all-the-icons-faicon "book" :height 0.68 :v-adjust -0.15)) | |
(Method . ,(all-the-icons-faicon "cube" :height 0.7 :v-adjust -0.05 :face 'font-lock-constant-face)) | |
(Function . ,(all-the-icons-faicon "cube" :height 0.7 :v-adjust -0.05 :face 'font-lock-constant-face)) | |
(Constructor . ,(all-the-icons-faicon "cube" :height 0.7 :v-adjust -0.05 :face 'font-lock-constant-face)) | |
(Field . ,(all-the-icons-faicon "tags" :height 0.65 :v-adjust -0.15 :face 'font-lock-warning-face)) | |
(Variable . ,(all-the-icons-faicon "tag" :height 0.7 :v-adjust -0.05 :face 'font-lock-warning-face)) | |
(Class . ,(all-the-icons-faicon "clone" :height 0.65 :v-adjust 0.01 :face 'font-lock-constant-face)) | |
(Interface . ,(all-the-icons-faicon "clone" :height 0.65 :v-adjust 0.01)) | |
(Module . ,(all-the-icons-octicon "package" :height 0.7 :v-adjust -0.15)) | |
(Property . ,(all-the-icons-octicon "package" :height 0.7 :v-adjust -0.05 :face 'font-lock-warning-face)) ;; Golang module | |
(Unit . ,(all-the-icons-material "settings_system_daydream" :height 0.7 :v-adjust -0.15)) | |
(Value . ,(all-the-icons-material "format_align_right" :height 0.7 :v-adjust -0.15 :face 'font-lock-constant-face)) | |
(Enum . ,(all-the-icons-material "storage" :height 0.7 :v-adjust -0.15 :face 'all-the-icons-orange)) | |
(Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.7 :v-adjust -0.15)) | |
(Snippet . ,(all-the-icons-faicon "code" :height 0.7 :v-adjust 0.02 :face 'font-lock-variable-name-face)) | |
(Color . ,(all-the-icons-material "palette" :height 0.7 :v-adjust -0.15)) | |
(File . ,(all-the-icons-faicon "file" :height 0.7 :v-adjust -0.05)) | |
(Reference . ,(all-the-icons-material "collections_bookmark" :height 0.7 :v-adjust -0.15)) | |
(Folder . ,(all-the-icons-octicon "file-directory" :height 0.7 :v-adjust -0.05)) | |
(EnumMember . ,(all-the-icons-material "format_align_right" :height 0.7 :v-adjust -0.15 :face 'all-the-icons-blueb)) | |
(Constant . ,(all-the-icons-faicon "tag" :height 0.7 :v-adjust -0.05)) | |
(Struct . ,(all-the-icons-faicon "clone" :height 0.65 :v-adjust 0.01 :face 'font-lock-constant-face)) | |
(Event . ,(all-the-icons-faicon "bolt" :height 0.7 :v-adjust -0.05 :face 'all-the-icons-orange)) | |
(Operator . ,(all-the-icons-fileicon "typedoc" :height 0.65 :v-adjust 0.05)) | |
(TypeParameter . ,(all-the-icons-faicon "hashtag" :height 0.65 :v-adjust 0.07 :face 'font-lock-const-face)) | |
(Template . ,(all-the-icons-faicon "code" :height 0.7 :v-adjust 0.02 :face 'font-lock-variable-name-face)))))) | |
;; Show quick tooltip | |
(use-package company-quickhelp | |
:defines company-quickhelp-delay | |
:bind (:map company-active-map | |
("M-h" . company-quickhelp-manual-begin)) | |
:hook (global-company-mode . company-quickhelp-mode) | |
:custom (company-quickhelp-delay 0.8))) | |
#+end_src | |
#+RESULTS: | |
: company-select-next | |
** Common | |
#+begin_src emacs-lisp | |
(use-package exec-path-from-shell | |
:custom | |
(exec-path-from-shell-check-startup-files nil) | |
(exec-path-from-shell-variables '("PATH" "GOPATH")) | |
:config | |
(when (memq window-system '(mac ns x)) | |
(exec-path-from-shell-initialize))) | |
#+end_src | |
** Flycheck | |
#+begin_src emacs-lisp | |
(use-package flycheck | |
:ensure t | |
:init | |
(global-flycheck-mode t)) | |
#+end_src | |
** Yasnipet | |
YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates include: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from TextMate's syntax, you can even import most TextMate templates to YASnippet. | |
#+begin_src emacs-lisp | |
(use-package yasnippet | |
:ensure t | |
:init | |
(yas-global-mode 1)) | |
#+end_src | |
** Python | |
*** Elpy | |
#+begin_src emacs-lisp | |
(use-package elpy | |
:ensure t | |
:config | |
(elpy-enable)) | |
#+end_src | |
** Emmet | |
#+begin_src emacs-lisp | |
(use-package emmet-mode | |
:ensure t | |
:config | |
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes | |
(add-hook 'css-mode-hook 'emmet-mode) ;; enable Emmet's css abbreviation. | |
) | |
(use-package ac-emmet | |
:ensure t | |
:config | |
(add-hook 'sgml-mode-hook 'ac-emmet-html-setup) | |
(add-hook 'css-mode-hook 'ac-emmet-css-setup) | |
) | |
#+end_src | |
** Yang | |
#+begin_src emacs-lisp | |
(autoload 'yang-mode "yang-mode" "Major mode for editing YANG modules." t) | |
(add-to-list 'auto-mode-alist '("\\.yang$" . yang-mode)) | |
#+end_src | |
** Rest Client | |
#+begin_src emacs-lisp | |
(use-package restclient | |
:ensure t) | |
#+end_src | |
** html/css/js | |
#+begin_src emacs-lisp | |
(use-package js2-mode | |
:mode ("\\.js\\'" . js2-mode)) | |
#+end_src | |
** Protobuff | |
#+begin_src emacs-lisp | |
(use-package protobuf-mode | |
:mode "\\.proto$") | |
#+end_src | |
** Log view | |
#+begin_src emacs-lisp | |
(use-package logview :defer t) | |
#+end_src | |
** Yaml | |
#+begin_src emacs-lisp | |
(use-package yaml-mode | |
:mode ("\\.yaml\\'" "\\.yml\\'") | |
:custom-face | |
(font-lock-variable-name-face ((t (:foreground "violet"))))) | |
#+end_src | |
** Bazel test software | |
#+begin_src emacs-lisp | |
(use-package bazel :defer t) | |
#+end_src | |
** Docker & Dockerfile | |
#+begin_src emacs-lisp | |
(use-package dockerfile-mode | |
:mode "\\Dockerfile\\'") | |
#+end_src | |
** Terraform | |
#+begin_src emacs-lisp | |
(use-package terraform-mode | |
:mode "\\.tf\\'" "'\\.tfvars\\'") | |
(custom-set-variables | |
'(terraform-indent-level 4)) | |
(require 'company-terraform) | |
(company-terraform-init) | |
(lsp-register-client | |
(make-lsp-client :new-connection (lsp-stdio-connection '("/usr/bin/terraform-ls" "serve")) | |
:major-modes '(terraform-mode) | |
:server-id 'terraform-ls)) | |
(add-hook 'terraform-mode-hook #'lsp) | |
#+end_src | |
** Golang | |
#+begin_src emacs-lisp | |
(lsp-register-custom-settings | |
'(("gopls.completeUnimported" t t) | |
("gopls.staticcheck" t t))) | |
#+end_src | |
** Python | |
#+begin_src emacs-lisp | |
(use-package lsp-python-ms | |
:ensure t | |
:init (setq lsp-python-ms-auto-install-server t) | |
:hook (python-mode . (lambda () | |
(require 'lsp-python-ms) | |
(lsp)))) ; or lsp-deferred | |
#+end_src | |
** JS | |
#+begin_src emacs-lisp | |
(use-package lsp-mode | |
:defer t | |
:diminish lsp-mode | |
:hook (((js2-mode rjsx-mode) . lsp)) | |
:commands lsp | |
:config | |
(setq lsp-auto-configure t | |
lsp-auto-guess-root t | |
;; don't set flymake or lsp-ui so the default linter doesn't get trampled | |
lsp-diagnostic-package :none)) | |
;;; keybinds after | |
;;(evil-leader/set-key | |
;; "jd" #'lsp-goto-type-definition ; (j)ump to (d)efinition | |
;; "jb" #'xref-pop-marker-stack)) ; (j)ump (b)ack to marker | |
#+end_src | |
* Binding | |
#+BEGIN_SRC emacs-lisp | |
(defun toggle-term () | |
"Toggles between terminal and current buffer (creates terminal, if none exists)" | |
(interactive) | |
(if (string= (buffer-name) "*ansi-term*") | |
(switch-to-buffer (other-buffer (current-buffer))) | |
(if (get-buffer "*ansi-term*") | |
(switch-to-buffer "*ansi-term*") | |
(progn | |
(ansi-term (getenv "SHELL")) | |
(setq show-trailing-whitespace nil))))) | |
(global-set-key (kbd "C-`") 'toggle-term) | |
(require 'bind-key) | |
(global-set-key (kbd "M-q") (kbd "\C-a\C- \C-e")) | |
(global-set-key (kbd "M-g") 'magit-status) | |
(global-set-key (kbd "C-M-l") 'replace-regexp) | |
(global-set-key (kbd "M-y") 'helm-find-files) | |
(global-set-key (kbd "M-e") (kbd "C-y")) | |
(global-set-key (kbd "M-l") (kbd "C-x SPC")) | |
(global-set-key (kbd "M-n") 'generate-scratch-buffer) | |
(global-set-key (kbd "M-=") 'text-scale-increase) | |
(global-set-key (kbd "M--") 'text-scale-decrease) | |
(bind-key (kbd "M-<up>") 'windmove-up) | |
(bind-key (kbd "M-<down>") 'windmove-down) | |
(bind-key (kbd "M-<left>") 'windmove-left) | |
(bind-key (kbd "M-<right>") 'windmove-right) | |
(global-set-key (kbd "C-;") 'duplicate-line) | |
(global-set-key (kbd "M-;") 'string-rectangle) | |
(global-set-key (kbd "C-c f") (lambda() (interactive) (find-file "~/workspace/"))) | |
; (global-set-key [(meta shift K)] 'move-text-up) | |
; (global-set-key [(meta shift M)] 'move-text-down) | |
(global-set-key (kbd "M-<S-backspace>") 'kill-whole-line) | |
(global-set-key (kbd "C-w") 'kill-region) | |
;; (global-set-key ("C-o") 'move-line-up) | |
;; (global-set-key ("C-p") 'move-line-down) | |
(xterm-mouse-mode t) | |
(global-set-key [mouse-4] '(lambda () (interactive) (scroll-down 1))) | |
(global-set-key [mouse-5] '(lambda () (interactive) (scroll-up 1))) | |
(put 'kill-sentence 'disabled t) | |
(global-set-key (kbd "<backtab>") 'un-indent-by-removing-2-spaces) | |
(defun un-indent-by-removing-2-spaces () | |
"remove 4 spaces from beginning of of line" | |
(interactive) | |
(save-excursion | |
(save-match-data | |
(beginning-of-line) | |
;; get rid of tabs at beginning of line | |
(when (looking-at "^\\s-+") | |
(untabify (match-beginning 0) (match-end 0))) | |
(when (looking-at "^ ") | |
(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC | |
π terraform/apricot-legacy/prod SGSRE-94-refact-to-module ✗ ❯ >.... | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC(replace-match ""))))) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
#+END_SRC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment