Skip to content

Instantly share code, notes, and snippets.

@rorra
Last active May 23, 2022 04:17
Show Gist options
  • Save rorra/ecf2bf001b9c292766e32b64655923d1 to your computer and use it in GitHub Desktop.
Save rorra/ecf2bf001b9c292766e32b64655923d1 to your computer and use it in GitHub Desktop.
.emacs
;; Install these packages
;; use-package
;; alchemist
;; all-the-icons
;; all-the-icons-dired
;; avy
;; dimmer
;; diminish
;; doom-themes
;; doom-modeline
;; edts
;; exec-path-from-shell
;; iedit
;; ivy-avy
;; magit
;; projectile
;; unicode-fonts
;; Garbage collector
(setq gc-cons-threshold 100000000)
(require 'package)
(add-to-list 'package-archives '("elpa" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("fe2539ccf78f28c519541e37dc77115c6c7c2efcec18b970b16e4a4d2cd9891d" "b186688fbec5e00ee8683b9f2588523abdf2db40562839b2c5458fcfb322c8a4" "d47f868fd34613bd1fc11721fe055f26fd163426a299d45ce69bef1f109e1e71" "01cf34eca93938925143f402c2e6141f03abb341f27d1c2dba3d50af9357ce70" default))
'(package-selected-packages
'(rainbow-delimiters all-the-icons-dired diminish ivy-avy dimmer doom-modeline exec-path-from-shell unicode-fonts projectile ov magit iedit doom-themes all-the-icons alchemist edts)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; Use package
(require 'use-package)
;; Access to path environment variable
(use-package exec-path-from-shell
:init (exec-path-from-shell-initialize))
;; Fix emacs default
(setq
;; No need to see GNU agitprop.
inhibit-startup-screen t
;; No need to remind me what a scratch buffer is.
initial-scratch-message nil
;; Double-spaces after periods is morally wrong.
sentence-end-double-space nil
;; Never ding at me, ever.
ring-bell-function 'ignore
;; Prompts should go in the minibuffer, not in a GUI.
use-dialog-box nil
;; Fix undo in commands affecting the mark.
mark-even-if-inactive nil
;; Let C-k delete the whole line.
kill-whole-line t
;; search should be case-sensitive by default
;; case-fold-search nil
;; no need to prompt for the read command _every_ time
compilation-read-command nil
;; always scroll
compilation-scroll-output t
;; my source directory
;; default-directory "~/src/"
c-basic-offset 2
;; idents 2 chars
tab-width 2
;; 2 char for tabs
ident-tabs-mode nil
;; force use of spaces
user-mail-address "[email protected]"
;; default email
)
;; utf-8
(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))
;; Show line number, column and delete selection
(delete-selection-mode t)
(global-display-line-numbers-mode t)
(column-number-mode)
;; Don't create a thousand files
(setq
make-backup-files nil
auto-save-default nil
create-lockfiles nil)
;; Exlude package files from recent files
(require 'recentf)
(add-to-list 'recentf-exclude "\\elpa")
;(unbind-key "C-x C-f") ;; find-file-read-only
;(unbind-key "C-x C-d") ;; list-directory
;(unbind-key "C-z") ;; suspend-frame
;(unbind-key "M-o") ;; facemenu-mode
;(unbind-key "<mouse-2>") ;; pasting with mouse-wheel click
;(unbind-key "<C-wheel-down>") ;; text scale adjust
;(unbind-key "<C-wheel-up>") ;; ditto
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(setq require-final-newline t)
;; Ignore news
(defalias 'view-emacs-news 'ignore)
(defalias 'describe-gnu-project 'ignore)
;; Better undo
(use-package undo-tree
:diminish
:bind (("C-c _" . undo-tree-visualize))
:config
(global-undo-tree-mode +1)
(unbind-key "M-_" undo-tree-map))
;; Visuals
;; Font
;; (ignore-errors (set-frame-font "Menlo-14"))
;; (set-frame-font "Iosevka-12" nil t)
(set-frame-font "Hack-18" nil t)
;; All the icons packages
(use-package all-the-icons)
(use-package all-the-icons-dired
:after all-the-icons
:hook (dired-mode . all-the-icons-dired-mode))
;; Window setup
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(when (window-system)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1))
;; UI Theme
(use-package doom-themes
:config
(let ((chosen-theme 'doom-tomorrow-day)) ; 'doom-laserwave))
(doom-themes-visual-bell-config)
(doom-themes-org-config)
(setq doom-challenger-deep-brighter-comments t
doom-challenger-deep-brighter-modeline t)
(load-theme chosen-theme)))
;; diminish
(use-package diminish
:config (diminish 'eldoc-mode))
;; doom modeline
(use-package doom-modeline
:config (doom-modeline-mode))
;; dimmer
(use-package dimmer
:custom (dimmer-fraction 0.1)
:config (dimmer-mode))
;; parenthesis display
(show-paren-mode)
(electric-pair-mode)
(use-package rainbow-delimiters
:hook ((prog-mode . rainbow-delimiters-mode)))
;; expand-region
(use-package expand-region
:bind (("C-c n" . er/expand-region)))
;; avy and ivi-avy
(use-package avy
:bind (("C-c l" . avy-goto-line)
("C-c j" . avy-goto-char)))
(use-package ivy-avy)
;; iedit
(use-package iedit)
;; kill this buffer for mac
(bind-key "s-w" #'kill-this-buffer)
;; Ibuffer command
(bind-key "C-c B" #'ibuffer)
;; buffers management
(defun kill-this-buffer ()
"Kill the current buffer."
(interactive)
(kill-buffer nil)
)
(bind-key "C-x k" #'kill-this-buffer)
(bind-key "C-x K" #'kill-buffer)
(defun kill-all-buffers ()
"Close all buffers."
(interactive)
;; (maybe-unset-buffer-modified)
(delete-other-windows)
(save-some-buffers)
(let ((kill-buffer-query-functions '()))
(mapc 'kill-buffer (buffer-list))))
;; buffer on directory open
(defun dired-up-directory-same-buffer ()
"Go up in the same buffer."
(find-alternate-file ".."))
(defun my-dired-mode-hook ()
(put 'dired-find-alternate-file 'disabled nil) ; Disables the warning.
(define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file)
(define-key dired-mode-map (kbd "^") 'dired-up-directory-same-buffer))
(add-hook 'dired-mode-hook #'my-dired-mode-hook)
(setq dired-use-ls-dired nil)
;; Magit
(use-package magit
:diminish magit-auto-revert-mode
:diminish auto-revert-mode
:bind (("C-c g" . #'magit-status))
:config
(add-to-list 'magit-no-confirm 'stage-all-changes))
;; edts and alchemist
(add-hook 'after-init-hook 'my-after-init-hook)
(defun my-after-init-hook ()
(require 'edts-start)
(require 'alchemist))
(add-hook 'elixir-mode-hook 'company-mode) ;; add company-mode when elixir mode is loaded
;; Projectile
(projectile-mode +1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment