Go to file
Bob Slacker 5fe453e4f7 0.1 2022-12-10 17:17:07 +01:00
README.org 0.1 2022-12-10 17:17:07 +01:00
config.org 0.1 2022-12-10 17:17:07 +01:00
init.el 0.1 2022-12-10 17:17:07 +01:00


Emacs Configuration

I've been using emacs for a while now and dicided that it is time to convert my configs to org mode.

This configuration uses the use-package package from John Wiegley, which is a fantastic way to manage package configurations.

Personal Information

(setq user-full-name "b2r1s8"
      user-mail-address "")

Sane defaults

The default emacs config is ugly and not efficient.

Startup Performance

Make startup faster by reducing the frequency of garbage collection and then use a hook to measure Emacs startup time.

;; The default is 800 kilobytes.  Measured in bytes.
(setq gc-cons-threshold (* 50 1000 1000))

;; Profile emacs startup
(add-hook 'emacs-startup-hook
          (lambda ()
            (message "*** Emacs loaded in %s with %d garbage collections."
                     (format "%.2f seconds"
                              (time-subtract after-init-time before-init-time)))

Customizing emacs

;; Fist things first
(setq inhibit-startup-message t)
(tool-bar-mode -1)    ;;  Remove tool bar C-x u undo | C-w cut | M-w copy | C-y paste
(menu-bar-mode -1) ;; Remove menus
(scroll-bar-mode -1) ;; Remove scroll bar
(global-hl-line-mode t) ;; Show current line
(global-prettify-symbols-mode t) ;; Prettify symbols mode
(set-face-attribute 'default nil :height 105) ;; Font size
(show-paren-mode 1) ;; Show parent parentesis
(setq visible-bell t) ;; Visible bell
;;(setq-default header-line-format mode-line-format)
(setq-default mode-line-format nil)
(setq-default header-line-format nil)

;; Tabbar
(require 'tabbar)
(defun tabbar-buffer-groups-by-dir ()
        "Put all files in the same directory into the same tab bar"
        (with-current-buffer (current-buffer)
          (let ((dir (expand-file-name default-directory)))
            (cond ;; assign group name until one clause succeeds, so the order is important
             ((eq major-mode 'dired-mode)
              (list "Dired"))
             ((memq major-mode
                    '(help-mode apropos-mode Info-mode Man-mode))
              (list "Help"))
             ((string-match-p "\*.*\*" (buffer-name))
              (list "Misc"))
             (t (list dir))))))

(defun tabbar-switch-grouping-method (&optional arg)
  "Changes grouping method of tabbar to grouping by dir.
With a prefix arg, changes to grouping by major mode."
  (interactive "P")
    (if arg
        (setq tabbar-buffer-groups-function 'tabbar-buffer-groups) ;; the default setting
      (setq tabbar-buffer-groups-function 'tabbar-buffer-groups-by-dir))))
(tab-bar-mode 1) ;; Additing tabs

;; Show time and date on the mode line
(setq display-time-day-and-date t)
(setq display-time-format "%a %b %F %R")
(display-time-mode 1)

;; Frame tansparency
(set-frame-parameter (selected-frame) 'alpha '(90 . 90))
(add-to-list 'default-frame-alist '(alpha . (90 . 90)))
(set-frame-parameter (selected-frame) 'fullscreen 'maximized)
(add-to-list 'default-frame-alist '(fullscreen . maximized))

;; Line numbers
(global-linum-mode t)
(column-number-mode 1) ;; Colummns numeration
(setq linum-format "%2d \u2502")
(dolist (mode '(org-mode-hook
  (add-hook mode (lambda () (display-line-numbers-mode 0))))

;; Border
(setq frame-resize-pixelwise t)
(set-frame-parameter nil 'fullscreen 'fullboth)

;; Keep all backup and auto-save files in one directory
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))

;; UTF-8 please
(setq locale-coding-system 'utf-8) ; pretty
(set-terminal-coding-system 'utf-8) ; pretty
(set-keyboard-coding-system 'utf-8) ; pretty
(set-selection-coding-system 'utf-8) ; please
(prefer-coding-system 'utf-8) ; with sugar on top

;; Identation:
(setq-default tab-width 2)
(setq-default standard-indent 2)
(setq c-basic-offset tab-width)
(setq-default electric-indent-inhibit t)
(setq-default indent-tabs-mode nil)
(setq backward-delete-char-untabify-method 'nil)

;; Enable bracket pair-matching
(setq electric-pair-pairs '(
							(?\{ . ?\})
							(?\( . ?\))
							(?\[ . ?\])
							(?\" . ?\")
(electric-pair-mode t)

;; Terminal-here
(require 'terminal-here)
(setq terminal-here-linux-terminal-command 'alacritty)

Changing how focus work

This fuction change the focus to the new window

;;; Mude o foco p/ novas janelas
(defun split-and-follow-horizontally ()
  (other-window 1))

(defun split-and-follow-vertically ()
  (other-window 1))


Some alias that make my life easier

;; Alias
(defalias 'yes-or-no-p 'y-or-n-p)
(defalias 'open 'find-file-other-window)
(defalias 'clean 'eshell/clear-scrollback)
(defalias 'list-buffers 'ibuffer)

Key binds

Some key binds to make my life easier

(global-unset-key (kbd "C-z")) ;; Unbind C-z
(global-unset-key (kbd "C-Z")) ;; Unbind C-Z
(global-set-key (kbd "M-<up>") 'shrink-window)
(global-set-key (kbd "M-<down>") 'enlarge-window)
(global-set-key (kbd "M-<right>") 'shrink-window-horizontally)
(global-set-key (kbd "M-<left>") 'enlarge-window-horizontally)
(global-set-key (kbd "s-<up>") 'windmove-up)
(global-set-key (kbd "s-<down>") 'windmove-down)
(global-set-key (kbd "s-<right>") 'windmove-right)
(global-set-key (kbd "s-<left>") 'windmove-left)
(global-set-key (kbd "C-<tab>") 'other-window)
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)	
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
(global-set-key (kbd "C-<f5>") #'terminal-here-launch)
(global-set-key (kbd "C-<f6>") #'terminal-here-project-launch)
(global-set-key (kbd "C-S-p") 'tabbar-backward-group)
(global-set-key (kbd "C-S-n") 'tabbar-forward-group)
(global-set-key (kbd "C-<") 'tabbar-backward)
(global-set-key (kbd "C->") 'tabbar-forward) ;; tabbar.el, put all the buffers on the tabs.


Some Functions that I use.


;; Open new tab on the dashboard
(defun new-tab ()
  (switch-to-buffer (get-buffer-create "*dashboard*")))
(global-set-key (kbd "s-x") 'new-tab)
(global-set-key (kbd "s-X") 'tab-close)

Midnight + cleanbuffer-list

;; Configuring desktop
;;(require 'desktop)
;;  (desktop-save-mode 1)
;;  (defun my-desktop-save ()
;;    (interactive)
;;    ;; Don't call desktop-save-in-desktop-dir, as it prints a message.
;;    (if (eq (desktop-owner) (emacs-pid))
;;        (desktop-save desktop-dirname)))
;;  (add-hook 'auto-save-hook 'my-desktop-save)
;;(setq clean-buffer-list-delay-general 1)
;;;; Configuring midnight
;;(require 'midnight)
;;(midnight-delay-set 'midnight-delay "6:30am")


Some packages that I use.


A beatiful and usefull dashboard.

(use-package dashboard
  :defer nil
  (defun init-edit ()
	"Edit initialization file."
	(find-file "~/.emacs.d/init.el"))
  (defun conf-edit ()
	"Edit configuration file."
	(find-file "~/.emacs.d/config.org"))
  (defun create-scratch-buffer ()
	"Create a scratch buffer."
	(switch-to-buffer (get-buffer-create "*scratch*"))
  (setq dashboard-items '((recents . 25)))
  (setq dashboard-banner-logo-title "Welcome to Emacs!")
  (setq dashboard-startup-banner "~/.emacs.d/img/emacs.png")
  (setq dashboard-center-content t)
  (setq dashboard-show-shortcuts nil)
  (setq dashboard-set-init-info t)
  (setq dashboard-init-info (format "%d packages loaded in %s"
									(length package-activated-list) (emacs-init-time)))
  (setq dashboard-set-footer nil)
  (setq dashboard-set-navigator t)
  (setq dashboard-navigator-buttons
			"Open init.el file."
			"Open Emacs initialization file for easy editing."
			(lambda (&rest _) (init-edit))
			"Open config.org file."
			"Open Emacs configuration file for easy editing."
			(lambda (&rest _) (conf-edit))
			"Open scratch buffer."
			"Switch to the scratch buffer."
			(lambda (&rest _) (create-scratch-buffer))


;;  ;;Helper functions
;;  (defun exwm/run-in-background (command)
;;    (let ((command-parts (split-string command "[ ]+")))
;;      (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
;;  (defun exwm/bind-function (key invocation &rest bindings)
;;    "Bind KEYs to FUNCTIONs globally"
;;    (while key
;;      (exwm-input-set-key (kbd key)
;;			  `(lambda ()
;;			     (interactive)
;;			     (funcall ',invocation)))
;;      (setq key (pop bindings)
;;	    invocation (pop bindings))))
;;  (defun exwm/bind-command (key command &rest bindings)
;;    "Bind KEYs to COMMANDs globally"
;;    (while key
;;      (exwm-input-set-key (kbd key)
;;			  `(lambda ()
;;			     (interactive)
;;			     (exwm/run-in-background ,command)))
;;      (setq key (pop bindings)
;;	    command (pop bindings))))
;;  (defun exwm/exwm-update-class ()
;;    (exwm-workspace-rename-buffer exwm-class-name))
;;  (defun exwm/exwm-update-title ()
;;    (pcase exwm-class-name
;;      ("Firefox" (exwm-workspace-rename-buffer (format "Firefox: %s" exwm-title)))))
;;  (defun exwm/configure-window-by-class ()
;;    (interactive)
;;    (pcase exwm-class-name
;;      ("TelegramDesktop" (exwm-workspace-move-window 9))
;;      ("mpv" (exwm-floating-toggle-floating)
;;       (exwm-layout-toggle-mode-line))))
;;  (use-package exwm
;;    :config
;;    ;; Set the default number of workspaces
;;    (setq exwm-workspace-number 5)
;;    ;; When window "class" updates, use it to set the buffer name
;;    (add-hook 'exwm-update-class-hook #'exwm/exwm-update-class)
;;    ;; When window title updates, use it to set the buffer name
;;    (add-hook 'exwm-update-title-hook #'exwm/exwm-update-title)
;;    ;; Configure windows as they're created
;;    (add-hook 'exwm-init-hook #'exwm/configure-window-by-class)
;;    ;; Automatically move EXWM buffer to current worspace when selected
;;    (setq exwm-layout-show-all-buffers t)
;;    ;; Display all EXWM buffers in every workspace buffer list
;;    (setq exwm-workspace-show-all-buffers t)
;;    ;; Detach the minibuffer
;;    (setq exwm-workspace-minibuffer-position 'top)
;;    ;; Set the screen resolution (update this to be the correct resolution for your screen!)
;;    (require 'exwm-randr)
;;    (exwm-randr-enable)
;;    (start-process-shell-command "xrandr" nil "xrandr --output HDMI-A-3 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DVI-D-0 --mode 1920x1080 --pos 1920x0 --rotate normal")
;;    (setq exwm-randr-workspace-monitor-plist '(0 "DVI-D-0" 9 "DVI-D-0"))
;;    ;; Initialazing apps
;;    (exwm/run-in-background "nitrogen --restore")
;;    (exwm/run-in-background "nm-applet")
;;    (exwm/run-in-background "radeon-profile")
;;    (exwm/run-in-background "pulseaudio --kill")
;;    (exwm/run-in-background "pulseaudio --start")
;;    (exwm/run-in-background "ipfs daemon")
;;    (exwm/run-in-background "xsetoff")
;;    ;; Load the system tray before exwm-init
;;    (require 'exwm-systemtray)
;;    (setq exwm-systemtray-height 20)
;;    (exwm-systemtray-enable)
;;    ;; Keybinds
;;    ;; Volume
;;    (defun exwm/volup ()
;;      (exwm/run-in-background "pactl set-sink-volume @DEFAULT_SINK@ +5%"))
;;    (defun exwm/voldown ()
;;      (exwm/run-in-background "pactl set-sink-volume @DEFAULT_SINK@ -5%"))
;;    (exwm/bind-function
;;     "s-=" 'exwm/volup
;;     "s--" 'exwm/voldown)
;;    ;; These keys should always pass through to Emacs
;;    (setq exwm-input-prefix-keys
;;	  '(?\C-x
;;	    ?\C-u
;;	    ?\C-h
;;	    ?\M-x
;;	    ?\M-`
;;	    ?\M-&
;;	    ?\M-:
;;	    ?\C-\M-j  ;; Buffer list
;;	    ?\C-\ ))  ;; File-tree
;;    ;; Ctrl+Q will enable the next key to be sent directly
;;    (define-key exwm-mode-map [?\C-ç] 'exwm-input-send-next-key)
;;    ;; Set up global key bindings.  These always work, no matter the input state!
;;    ;; Keep in mind that changing this list after EXWM initializes has no effect.
;;    (setq exwm-input-global-keys
;;	  `(
;;	    ;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)
;;	    ([?\s-r] . exwm-reset)
;;	    ;; Dmenu-like app launcher
;;	    ([s-menu] . counsel-linux-app)
;;	    ;; Move between windows
;;	    ([s-left] . windmove-left)
;;	    ([s-right] . windmove-right)
;;	    ([s-up] . windmove-up)
;;	    ([s-down] . windmove-down)
;;	    ;; Launch applications via shell command
;;	    ([?\s-&] . (lambda (command)
;;			 (interactive (list (read-shell-command "$ ")))
;;			 (start-process-shell-command command nil command)))
;;	    ;; Switch workspace
;;	    ([?\s-w] . exwm-workspace-switch)
;;	    ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0)))
;;	    ;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
;;	    ,@(mapcar (lambda (i)
;;			`(,(kbd (format "s-%d" i)) .
;;			  (lambda ()
;;			    (interactive)
;;			    (exwm-workspace-switch-create ,i))))
;;		      (number-sequence 0 9))))
;;    (exwm-enable))


;; term
(use-package term
  (setq explicit-shell-file-name "zsh"))
  ;;(setq explicit-zsh-args '())

(use-package eterm-256color
  :hook (term-mode . eterm-256color-mode))

;; vterm
(use-package vterm
  :commands vterm
  (setq vterm-max-scrollback 10000))


(use-package doom-themes)
(use-package green-is-the-new-black-theme)


Change viewdoc to pdfview with pdftools

(use-package pdf-tools
  :defer t
  :commands (pdf-view-mode pdf-tools-install)
  :mode ("\\.[pP][dD][fF]\\'" . pdf-view-mode)
  :load-path "site-lisp/pdf-tools/lisp"
  :magic ("%PDF" . pdf-view-mode)
  (define-pdf-cache-function pagelabels)
  :hook ((pdf-view-mode-hook . (lambda () (display-line-numbers-mode -1)))
		     (pdf-view-mode-hook . pdf-tools-enable-minor-modes)))
(use-package pdf-view-restore
  :after pdf-tools
  (add-hook 'pdf-view-mode-hook 'pdf-view-restore-mode))

(add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1)))

ORG Mode

Org mode configurantion.

;; Org init
(use-package org
  (add-hook 'org-mode-hook
			      '(lambda ()
			         (visual-line-mode 1)))
  (setq org-display-inline-images t)
  (setq org-redisplay-inline-images t)
  (setq org-startup-with-inline-images "inlineimages")
  (setq org-directory "~/.emacs.d/org")
  (setq org-agenda-files (list "inbox.org"))
  (global-set-key (kbd "C-<f1>") (lambda()
;;(use-package org-bullets
;;  :config
;;  (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))

(require 'org-superstar)
(add-hook 'org-mode-hook (lambda () (org-superstar-mode 1)))

(use-package htmlize
  :ensure t)

;; src exec
(org-babel-do-load-languages 'org-babel-load-languages
							                 (shell . t)

(setq org-src-fontify-natively t
      org-src-window-setup 'current-window
      org-src-strip-leading-and-trailing-blank-lines t
      org-src-preserve-indentation t
      org-src-tab-acts-natively t)

(require 'org-tempo)

;; And that'll allow you to type "<sh", "<el", "<py", "<conf" followed by tab to create src blocks for those languages, and you can add as many others as you want.
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(add-to-list 'org-structure-template-alist '("conf" . "src conf"))

(setq org-agenda-start-with-log-mode t)
(setq org-log-done 'time)
(setq org-log-into-drawer t)

(setq org-agenda-files

(use-package org-roam)
(add-to-list 'exec-path "/usr/bin/sqlite3")
(setq org-roam-directory "~/projects/code/org-mode/org-roam")
(add-hook 'after-init-hook 'org-roam-mode)

;; Disabling linum-mode
(add-hook 'org-mode-hook (lambda () (linum-mode 0)))

;; Hiding markup elements
(setq org-hide-emphasis-markers t)

Company mode

Company Mode provides a nicer in-buffer completion interface than completion-at-point which is more reminiscent of what you would expect from an IDE. We add a simple configuration to make the keybindings a little more useful (TAB now completes the selection and initiates completion at the current location if needed).

We also use company-box to further enhance the look of the completions with icons and better overall presentation.

  (use-package company
    :after lsp-mode
    :hook (lsp-mode . company-mode)
    :bind (:map company-active-map
           ("<tab>" . company-complete-selection))
          (:map lsp-mode-map
           ("<tab>" . company-indent-or-complete-common))
    (company-minimum-prefix-length 1)
    (company-idle-delay 0.0))

  (use-package company-box
    :hook (company-mode . company-box-mode))


(use-package projectile
  :diminish projectile-mode
  :config (projectile-mode)
  :custom ((projectile-completion-system 'ivy))
  ("C-c p" . projectile-command-map)
  ;; NOTE: Set this to the folder where you keep your Git repos!
  (when (file-directory-p "~/projects/code")
    (setq projectile-project-search-path '("~/projects/code")))
  (setq projectile-switch-project-action #'projectile-dired))


Magit is the best Git interface I've ever used. Common Git operations are easy to execute quickly using Magit's command panel system.

(use-package magit
  (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))

;; NOTE: Make sure to configure a GitHub token before using this package!
;; - https://magit.vc/manual/forge/Token-Creation.html#Token-Creation
;; - https://magit.vc/manual/ghub/Getting-Started.html#Getting-Started
;;(use-package forge)


Default Doom-modeline.

(use-package all-the-icons)

(use-package doom-modeline
  :ensure t
  :init (doom-modeline-mode 1))
(setq doom-modeline-height 5)

;; Hide mode-line when is not usefull
(setq doom-hide-modeline-mode nil)

;; The limit of the window width.
;; If `window-width' is smaller than the limit, some information won't be displayed.
(setq doom-modeline-window-width-limit fill-column)

;; Whether display the icon for `major-mode'. It respects `doom-modeline-icon'.
(setq doom-modeline-major-mode-icon t)

;; Whether display the colorful icon for `major-mode'.
;; It respects `all-the-icons-color-icons'.
(setq doom-modeline-major-mode-color-icon t)

;; Whether display the icon for the buffer state. It respects `doom-modeline-icon'.
(setq doom-modeline-buffer-state-icon t)

;; Whether display the modification icon for the buffer.
;; It respects `doom-modeline-icon' and `doom-modeline-buffer-state-icon'.
(setq doom-modeline-buffer-modification-icon t)

;; Whether display the buffer encoding.
(setq doom-modeline-buffer-encoding t)

;; If non-nil, only display one number for checker information if applicable.
(setq doom-modeline-checker-simple-format t)

;; Whether display the workspace name. Non-nil to display in the mode-line.
(setq doom-modeline-workspace-name t)

;; Whether display the environment version.
(setq doom-modeline-env-version t)

Ace window

This packages make easy to move around windows.

  • x -> delete window
  • m -> swap windows
  • M -> move window
  • c -> copy window
  • j -> select buffer
  • n -> select the previous window
  • u -> select buffer in the other window
  • c -> split window fairly, either vertically or horizontally
  • v -> split window vertically
  • b -> split window horizontally
  • o -> maximize current window
  • ? -> show these command bindings
(use-package ace-window
  :ensure t
  :bind (("C-o" . ace-window)))


(use-package rainbow-delimiters
  :hook (prog-mode . rainbow-delimiters-mode))

IDE Features with lsp-mode


We use the excellent lsp-mode to enable IDE-like functionality for many different programming languages via "language servers" that speak the Language Server Protocol. Before trying to set up lsp-mode for a particular language, check out the documentation for your language so that you can learn which language servers are available and how to install them.

The lsp-keymap-prefix setting enables you to define a prefix for where lsp-mode's default keybindings will be added. I highly recommend using the prefix to find out what you can do with lsp-mode in a buffer.

The which-key integration adds helpful descriptions of the various keys so you should be able to learn a lot just by pressing C-c l in a lsp-mode buffer and trying different things that you find there.

(defun efs/lsp-mode-setup ()
  (setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols))

(use-package lsp-mode
  :commands (lsp lsp-deferred)
  :hook (lsp-mode . efs/lsp-mode-setup)
  (setq lsp-keymap-prefix "C-c l")  ;; Or 'C-l', 's-l'
  (lsp-enable-which-key-integration t))


lsp-ui is a set of UI enhancements built on top of lsp-mode which make Emacs feel even more like an IDE. Check out the screenshots on the lsp-ui homepage (linked at the beginning of this paragraph) to see examples of what it can do.

  (use-package lsp-ui
    :hook (lsp-mode . lsp-ui-mode)
    (lsp-ui-doc-position 'bottom)
    (lsp-ui-sideline-show-diagnostics t)
    (lsp-ui-sideline-show-hover t)
    (lsp-ui-sideline-show-code-actions t)
    (lsp-ui-sideline-update-mode t)
    (lsp-ui-doc-enable t)
    (lsp-ui-doc-show-with-cursor t)
    (lsp-ui-doc-show-with-mouse t))


lsp-treemacs provides nice tree views for different aspects of your code like symbols in a file, references of a symbol, or diagnostic messages (errors and warnings) that are found in your code.

Try these commands with M-x:

  • lsp-treemacs-symbols - Show a tree view of the symbols in the current file
  • lsp-treemacs-references - Show a tree view for the references of the symbol under the cursor
  • lsp-treemacs-error-list - Show a tree view for the diagnostic messages in the project

This package is built on the treemacs package which might be of some interest to you if you like to have a file browser at the left side of your screen in your editor.

  (use-package lsp-treemacs
    :after lsp
    (lsp-treemacs-sync-mode 1))


lsp-ivy integrates Ivy with lsp-mode to make it easy to search for things by name in your code. When you run these commands, a prompt will appear in the minibuffer allowing you to type part of the name of a symbol in your code. Results will be populated in the minibuffer so that you can find what you're looking for and jump to that location in the code upon selecting the result.

Try these commands with M-x:

  • lsp-ivy-workspace-symbol - Search for a symbol name in the current project workspace
  • lsp-ivy-global-workspace-symbol - Search for a symbol name in all active project workspaces
  (use-package lsp-ivy)


npm i -g bash-language-server


npm install -g vscode-html-languageserver-bin


Perl config


Rust config.


Common lisp setup

(use-package slime
  :ensure t
  :defer 10
  (setq inferior-lisp-program "sbcl")
  (setq slime-contribs '(slime-fancy)))


(use-package which-key
  :ensure t
  :init (which-key-mode)
  :diminish which-key-mode
  (setq which-key-idle-delay 0.3))

Simplify Leader Bindings (general.el)

general.el is a fantastic library for defining prefixed keybindings, especially in conjunction with Evil modes.

(use-package general
  (general-evil-setup nil)

  (general-create-definer dw/leader-key-def
    :keymaps '(normal insert visual emacs)
    :prefix "SPC"
    :global-prefix "C-SPC")

  (general-create-definer dw/ctrl-c-keys
    :prefix "C-c"))


(use-package swiper
  :ensure t
  :bind ("s-s" . 'swiper))


(use-package beacon
  :ensure t
  :diminish beacon-mode
  (beacon-mode 1))


(use-package async
  :ensure t
  (dired-async-mode 1))


(use-package page-break-lines
  :ensure t
  :diminish (page-break-lines-mode visual-line-mode))


(use-package undo-tree
  :ensure t
  :diminish undo-tree-mode)


(use-package saveplace
  :defer nil


(use-package eldoc
  :diminish eldoc-mode)


(use-package try
  :ensure t)


(use-package auto-complete
  :ensure t
	(global-auto-complete-mode t)))


(use-package neotree
  :ensure t
  :bind (("C-\\" . 'neotree-toggle))) ;; Ativa a tree


(use-package color-theme-modern
  :ensure t)


(use-package flycheck
  :ensure t
  :init (global-flycheck-mode t))


(use-package recentf
  (recentf-mode t)
  (setq recentf-max-saved-items 500))

Expand region

(use-package expand-region
  :ensure t
  :bind ("C-@" . er/expand-region))


This makes it so C-n-ing and C-p-ing won't make the buffer jump around so much.

(use-package smooth-scrolling
  :ensure t


(use-package web-mode
  :ensure t)


According to their website, "Emmet — the essential toolkit for web-developers."

(use-package emmet-mode
  :ensure t
  :commands emmet-mode
  (add-hook 'html-mode-hook 'emmet-mode)
  (add-hook 'css-mode-hookg 'emmet-mode))

Scratch major mode

Convenient package to create *scratch* buffers that are based on the current buffer's major mode. This is more convienent than manually creating a buffer to do some scratch work or reusing the initial *scratch* buffer.

(use-package scratch
  :ensure t
  :commands scratch)

Shell pop

(use-package shell-pop
  :ensure t
  :bind ("M-<f12>" . shell-pop))


(use-package quickrun
  :defer 10
  :ensure t
  :bind ("C-c r" . quickrun))


(use-package terminal-here
  :ensure t
  :bind (("C-c o t" . terminal-here-launch)
		     ("C-c o p" . terminal-here-project-launch)))


(use-package whitespace)
(require 'whitespace)
(setq whitespace-line-column 80) ;; limit line length
(setq whitespace-style '(face lines-tail))

;; Automatically clean whitespace
(use-package ws-butler
  :hook ((text-mode . ws-butler-mode)
         (prog-mode . ws-butler-mode)))


I currently use Ivy, Counsel, and Swiper to navigate around files, buffers, and projects super quickly. Here are some workflow notes on how to best use Ivy:

  • While in an Ivy minibuffer, you can search within the current results by using S-Space.
  • To quickly jump to an item in the minibuffer, use C-' to get Avy line jump keys.
  • To see actions for the selected minibuffer item, use M-o and then press the action's key.
  • Super useful: Use C-c C-o to open ivy-occur to open the search results in a separate buffer. From there you can click any item to perform the ivy action.
(use-package ivy
  :bind (("C-s" . swiper)
         :map ivy-minibuffer-map
         ("TAB" . ivy-alt-done)
         ("C-f" . ivy-alt-done)
         ("C-l" . ivy-alt-done)
         ("C-j" . ivy-next-line)
         ("C-k" . ivy-previous-line)
         :map ivy-switch-buffer-map
         ("C-k" . ivy-previous-line)
         ("C-l" . ivy-done)
         ("C-d" . ivy-switch-buffer-kill)
         :map ivy-reverse-i-search-map
         ("C-k" . ivy-previous-line)
         ("C-d" . ivy-reverse-i-search-kill))
  (ivy-mode 1)
  (setq ivy-use-virtual-buffers t)
  (setq ivy-wrap t)
  (setq ivy-count-format "(%d/%d) ")
  (setq enable-recursive-minibuffers t)

  ;; Use different regex strategies per completion command
  (push '(completion-at-point . ivy--regex-fuzzy) ivy-re-builders-alist) ;; This doesn't seem to work...
  (push '(swiper . ivy--regex-ignore-order) ivy-re-builders-alist)
  (push '(counsel-M-x . ivy--regex-ignore-order) ivy-re-builders-alist)

  ;; Set minibuffer height for different commands
  (setf (alist-get 'counsel-projectile-ag ivy-height-alist) 15)
  (setf (alist-get 'counsel-projectile-rg ivy-height-alist) 15)
  (setf (alist-get 'swiper ivy-height-alist) 15)
  (setf (alist-get 'counsel-switch-buffer ivy-height-alist) 7))

(use-package ivy-hydra
  :defer t
  :after hydra)

(use-package ivy-rich
  (ivy-rich-mode 1)
  :after counsel
  (setq ivy-format-function #'ivy-format-function-line)
  (setq ivy-rich-display-transformers-list
        (plist-put ivy-rich-display-transformers-list
                     ((ivy-rich-candidate (:width 40))
                      (ivy-rich-switch-buffer-indicators (:width 4 :face error :align right)); return the buffer indicators
                      (ivy-rich-switch-buffer-major-mode (:width 12 :face warning))          ; return the major mode info
                      (ivy-rich-switch-buffer-project (:width 15 :face success))             ; return project name using `projectile'
                      (ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))  ; return file path relative to project root or `default-directory' if project is nil
                     (lambda (cand)
                       (if-let ((buffer (get-buffer cand)))
                           ;; Don't mess with EXWM buffers
                           (with-current-buffer buffer
                             (not (derived-mode-p 'exwm-mode)))))))))

(use-package counsel
  :after ivy
  :bind (("M-x" . counsel-M-x)
         ("C-x b" . counsel-ibuffer)
         ("C-x C-f" . counsel-find-file)
         ("C-M-j" . counsel-switch-buffer)
         ("C-M-l" . counsel-imenu)
         :map minibuffer-local-map
         ("C-r" . 'counsel-minibuffer-history))
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  (setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^

(use-package flx  ;; Improves sorting for fuzzy-matched results
  :after ivy
  :defer t
  (setq ivy-flx-limit 10000))

(use-package wgrep)

(use-package ivy-posframe
  (ivy-posframe-width      115)
  (ivy-posframe-min-width  115)
  (ivy-posframe-height     10)
  (ivy-posframe-min-height 10)
  (setq ivy-posframe-display-functions-alist '((t . ivy-posframe-display-at-frame-center)))
  (setq ivy-posframe-parameters '((parent-frame . nil)
                                  (left-fringe . 8)
                                  (right-fringe . 8)))
  (ivy-posframe-mode 1))

(use-package prescient
  :after counsel
  (prescient-persist-mode 1))

(use-package ivy-prescient
  :after prescient
  (ivy-prescient-mode 1))

  "r"   '(ivy-resume :which-key "ivy resume")
  "f"   '(:ignore t :which-key "files")
  "ff"  '(counsel-find-file :which-key "open file")
  "C-f" 'counsel-find-file
  "fr"  '(counsel-recentf :which-key "recent files")
  "fR"  '(revert-buffer :which-key "revert file")
  "fj"  '(counsel-file-jump :which-key "jump to file"))

(use-package counsel-projectile
  :config (counsel-projectile-mode))


(use-package helpful
  :commands (helpful-callable helpful-variable helpful-command helpful-key)
  (counsel-describe-function-function #'helpful-callable)
  (counsel-describe-variable-function #'helpful-variable)
  ([remap describe-function] . counsel-describe-function)
  ([remap describe-command] . helpful-command)
  ([remap describe-variable] . counsel-describe-variable)
  ([remap describe-key] . helpful-key))

Packages config

Configuration for packages

;; Dired
(require 'dired-x)
(setq dired-omit-files "^\\...+$")
(add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
(add-hook 'dired-mode-hook 'auto-revert-mode)
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)

;; Elpher
(advice-add 'eww-browse-url :around 'elpher:eww-browse-url)

;; eww
(defun elpher:eww-browse-url (original url &optional new-window)
  "Handle gemini links."
  (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url)
		     (require 'elpher)
		     (elpher-go url))
		    (t (funcall original url new-window))))

;;; Eshell
(defun efs/configure-eshell ()
  ;; Save command history when commands are entered
  (add-hook 'eshell-pre-command-hook 'eshell-save-some-history)

  ;; Truncate buffer for performance
  (add-to-list 'eshell-output-filter-functions 'eshell-truncate-buffer)

  ;; Bind some useful keys for evil-mode
  (evil-define-key '(normal insert visual) eshell-mode-map (kbd "C-r") 'counsel-esh-history)
  (evil-define-key '(normal insert visual) eshell-mode-map (kbd "<home>") 'eshell-bol)

  (setq eshell-history-size         10000
        eshell-buffer-maximum-lines 10000
        eshell-hist-ignoredups t
        eshell-scroll-to-bottom-on-input t)

  (setq eshell-prompt-function
  	    (lambda nil
  		     (if (string= (eshell/pwd) (getenv "HOME"))
  			       (propertize "~" 'face `(:foreground "#99CCFF"))
  			      (getenv "HOME")
  			      (propertize "~" 'face `(:foreground "#99CCFF"))
  			      (propertize (eshell/pwd) 'face `(:foreground "#99CCFF"))))
  		     (if (= (user-uid) 0)
  			       (propertize " α " 'face `(:foreground "#FF6666"))
  		       (propertize " λ " 'face `(:foreground "#A6E22E"))))))

  (setq eshell-highlight-prompt nil))

(use-package eshell-git-prompt)

(use-package eshell
  :hook (eshell-first-time-mode . efs/configure-eshell)

  (with-eval-after-load 'esh-opt
    (setq eshell-destroy-buffer-when-process-dies t)
    (setq eshell-visual-commands '("htop" "zsh" "glances")))
  (eshell-git-prompt-use-theme 'robbyrussell))

;; emms
(require 'emms-setup)
(setq emms-source-file-default-directory "~/songs/")
(setq emms-info-asynchronously nil)
(setq emms-playlist-buffer-name "*Music*")

;; ERC
;;(erc :server "irc.freenode.net" :port 6667 :nick "b2r1s8")
;;(setq erc-autojoin-channels-alist
;;      '(("freenode.net" "#gentoo" "#gentoo-chat" "#ratpoison" "#perl" "#monero" "#emacs" "#emacs-beginners" "#emacs-offtopic" "#org-mode")))