commit 5fe453e4f7f92262b95030c0bd1d89892c00a5d7 Author: Bob Slacker Date: Sat Dec 10 17:17:07 2022 +0100 0.1 diff --git a/README.org b/README.org new file mode 100644 index 0000000..29ce188 --- /dev/null +++ b/README.org @@ -0,0 +1,1364 @@ +#+title: Emacs Configuration +#+author: b2r1s8@gen2 +#+date: 2021-02-08 +#+startup: hidestars odd overview +#+options: num:nil + + 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 [[https://github.com/jwiegley/use-package][use-package]] package from John Wiegley, which is +a fantastic way to manage package configurations. + +* Personal Information + +#+begin_src emacs-lisp + +(setq user-full-name "b2r1s8" + user-mail-address "") + +#+end_src + +* 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. + +#+begin_src emacs-lisp + +;; 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" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done))) + +#+end_src + +** Customizing emacs + +#+begin_src emacs-lisp + +;; 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") + (ignore-errors + (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 + term-mode-hook + shell-mode-hook + treemacs-mode-hook + eshell-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) + +#+end_src + +** Changing how focus work + + This fuction change the focus to the new window + +#+begin_src emacs-lisp + +;;; Mude o foco p/ novas janelas +(defun split-and-follow-horizontally () + (interactive) + (split-window-below) + (balance-windows) + (other-window 1)) + +(defun split-and-follow-vertically () + (interactive) + (split-window-right) + (balance-windows) + (other-window 1)) + +#+end_src + +** Alias + + Some alias that make my life easier + +#+begin_src emacs-lisp + +;; 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) + +#+end_src + +** Key binds + + Some key binds to make my life easier + +#+begin_src emacs-lisp + +(global-unset-key (kbd "C-z")) ;; Unbind C-z +(global-unset-key (kbd "C-Z")) ;; Unbind C-Z +(global-set-key (kbd "M-") 'shrink-window) +(global-set-key (kbd "M-") 'enlarge-window) +(global-set-key (kbd "M-") 'shrink-window-horizontally) +(global-set-key (kbd "M-") 'enlarge-window-horizontally) +(global-set-key (kbd "s-") 'windmove-up) +(global-set-key (kbd "s-") 'windmove-down) +(global-set-key (kbd "s-") 'windmove-right) +(global-set-key (kbd "s-") 'windmove-left) +(global-set-key (kbd "C-") '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-") #'terminal-here-launch) +(global-set-key (kbd "C-") #'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. + +#+end_src + +** Functions + + Some Functions that I use. + +*** Dashboard + +#+begin_src emacs-lisp + +;; Open new tab on the dashboard +(defun new-tab () + (interactive) + (tab-new-to) + (switch-to-buffer (get-buffer-create "*dashboard*"))) +(global-set-key (kbd "s-x") 'new-tab) +(global-set-key (kbd "s-X") 'tab-close) + +#+end_src + +*** Midnight + cleanbuffer-list + +#+begin_src emacs-lisp + +;; 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") + +#+end_src + +* Packages + + Some packages that I use. + +** Dashboard + +A beatiful and usefull dashboard. + +#+begin_src emacs-lisp + +(use-package dashboard + :defer nil + :preface + (defun init-edit () + "Edit initialization file." + (interactive) + (find-file "~/.emacs.d/init.el")) + (defun conf-edit () + "Edit configuration file." + (interactive) + (find-file "~/.emacs.d/config.org")) + (defun create-scratch-buffer () + "Create a scratch buffer." + (interactive) + (switch-to-buffer (get-buffer-create "*scratch*")) + (lisp-interaction-mode)) + :config + (dashboard-setup-startup-hook) + (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 + `(((,nil + "Open init.el file." + "Open Emacs initialization file for easy editing." + (lambda (&rest _) (init-edit)) + 'default) + (nil + "Open config.org file." + "Open Emacs configuration file for easy editing." + (lambda (&rest _) (conf-edit)) + 'default) + (nil + "Open scratch buffer." + "Switch to the scratch buffer." + (lambda (&rest _) (create-scratch-buffer)) + 'default))))) + +#+end_src + +** EXWM + +#+begin_src emacs-lisp + +;; ;;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)) + +#+end_src + +** Term-mode + +#+begin_src emacs-lisp + +;; term +(use-package term + :config + (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 + :config + (setq vterm-max-scrollback 10000)) + +#+end_src + +** Themes + +#+begin_src emacs-lisp + +(use-package doom-themes) +(use-package green-is-the-new-black-theme) + +#+end_src + +** PDFTools + + Change viewdoc to pdfview with pdftools + +#+begin_src emacs-lisp + +(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) + :config + (pdf-tools-install) + (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 + :config + (add-hook 'pdf-view-mode-hook 'pdf-view-restore-mode)) + +(add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) + +#+end_src + +** ORG Mode + + Org mode configurantion. + +#+begin_src emacs-lisp + +;; Org init +(use-package org + :config + (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-") (lambda() + (interactive) + (outline-show-all)))) +;;(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 "" . company-complete-selection)) + (:map lsp-mode-map + ("" . company-indent-or-complete-common)) + :custom + (company-minimum-prefix-length 1) + (company-idle-delay 0.0)) + + (use-package company-box + :hook (company-mode . company-box-mode)) + +#+end_src + +** Projectile + +#+begin_src emacs-lisp + +(use-package projectile + :diminish projectile-mode + :config (projectile-mode) + :custom ((projectile-completion-system 'ivy)) + :bind-keymap + ("C-c p" . projectile-command-map) + :init + ;; 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)) + +#+end_src + +** Magit + +[[https://magit.vc/][Magit]] is the best Git interface I've ever used. Common Git operations are easy to execute quickly using Magit's command panel system. + +#+begin_src emacs-lisp + +(use-package magit + :custom + (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) + +#+end_src + +** Doom-modeline + + Default [[https://github.com/seagle0128/doom-modeline][Doom-modeline]]. + +#+begin_src emacs-lisp +(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) + +#+end_src + +** 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 + +#+begin_src emacs-lisp + +(use-package ace-window + :ensure t + :bind (("C-o" . ace-window))) + +#+end_src + +** Rainbow-delimiters + +#+begin_src emacs-lisp + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +#+end_src + +** IDE Features with lsp-mode + +*** lsp-mode + + We use the excellent [[https://emacs-lsp.github.io/lsp-mode/][lsp-mode]] to enable IDE-like functionality for many different programming languages via "language servers" that speak the [[https://microsoft.github.io/language-server-protocol/][Language Server Protocol]]. Before trying to set up =lsp-mode= for a particular language, check out the [[https://emacs-lsp.github.io/lsp-mode/page/languages/][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. + +#+begin_src emacs-lisp + +(defun efs/lsp-mode-setup () + (setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols)) + (lsp-headerline-breadcrumb-mode)) + +(use-package lsp-mode + :commands (lsp lsp-deferred) + :hook (lsp-mode . efs/lsp-mode-setup) + :init + (setq lsp-keymap-prefix "C-c l") ;; Or 'C-l', 's-l' + :config + (lsp-enable-which-key-integration t)) + +#+end_src + +*** lsp-ui + + [[https://emacs-lsp.github.io/lsp-ui/][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. + +#+begin_src emacs-lisp + + (use-package lsp-ui + :hook (lsp-mode . lsp-ui-mode) + :custom + (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)) + +#+end_src + +*** lsp-treemacs + +[[https://github.com/emacs-lsp/lsp-treemacs][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 [[https://github.com/Alexander-Miller/treemacs][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. + +#+begin_src emacs-lisp + + (use-package lsp-treemacs + :after lsp + :custom + (lsp-treemacs-sync-mode 1)) + +#+end_src + +*** lsp-ivy + +[[https://github.com/emacs-lsp/lsp-ivy][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 + +#+begin_src emacs-lisp + + (use-package lsp-ivy) + +#+end_src + +*** Bash + +#+begin_src shell + +npm i -g bash-language-server + +#+end_src + +*** HTML + +#+begin_src shell + +npm install -g vscode-html-languageserver-bin + +#+end_src + +*** Perl + +Perl config + +*** Rust + +Rust config. + +** CLISP + + Common lisp setup + +#+begin_src emacs-lisp + +(use-package slime + :ensure t + :defer 10 + :config + :init + (setq inferior-lisp-program "sbcl") + (setq slime-contribs '(slime-fancy))) + +#+end_src + +** Which-key + +#+begin_src emacs-lisp + +(use-package which-key + :ensure t + :init (which-key-mode) + :diminish which-key-mode + :config + (setq which-key-idle-delay 0.3)) + +#+end_src + +** Simplify Leader Bindings (general.el) + +[[https://github.com/noctuid/general.el][general.el]] is a fantastic library for defining prefixed keybindings, especially +in conjunction with Evil modes. + +#+begin_src emacs-lisp + +(use-package general + :config + (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")) + +#+end_src + +** Swiper + +#+begin_src emacs-lisp + +(use-package swiper + :ensure t + :bind ("s-s" . 'swiper)) + +#+end_src + +** Beacon + +#+begin_src emacs-lisp + +(use-package beacon + :ensure t + :diminish beacon-mode + :init + (beacon-mode 1)) + +#+end_src + +** Async + +#+begin_src emacs-lisp + +(use-package async + :ensure t + :init + (dired-async-mode 1)) + +#+end_src + +** Page-break-lines + +#+begin_src emacs-lisp + +(use-package page-break-lines + :ensure t + :diminish (page-break-lines-mode visual-line-mode)) + +#+end_src + +** Undoo-tree + +#+begin_src emacs-lisp + +(use-package undo-tree + :ensure t + :diminish undo-tree-mode) + +#+end_src + +** Saveplace + +#+begin_src emacs-lisp + +(use-package saveplace + :defer nil + :config + (save-place-mode)) + +#+end_src + +** Eldoc + +#+begin_src emacs-lisp + +(use-package eldoc + :diminish eldoc-mode) + +#+end_src + +** Try + +#+begin_src emacs-lisp + +(use-package try + :ensure t) + +#+end_src + +** Auto-complete + +#+begin_src emacs-lisp + +(use-package auto-complete + :ensure t + :init + (progn + (ac-config-default) + (global-auto-complete-mode t))) + +#+end_src + +** Neotree + +#+begin_src emacs-lisp + +(use-package neotree + :ensure t + :bind (("C-\\" . 'neotree-toggle))) ;; Ativa a tree + +#+end_src + +** Color-theme-modern + +#+begin_src emacs-lisp + +(use-package color-theme-modern + :ensure t) + +#+end_src + +** Flycheck + +#+begin_src emacs-lisp + +(use-package flycheck + :ensure t + :init (global-flycheck-mode t)) + +#+end_src + +** Recentf + +#+begin_src emacs-lisp + +(use-package recentf + :config + (recentf-mode t) + (setq recentf-max-saved-items 500)) + +#+end_src + +** Expand region + +#+begin_src emacs-lisp + +(use-package expand-region + :ensure t + :bind ("C-@" . er/expand-region)) + +#+end_src + +** Smoothscrolling + + This makes it so ~C-n~-ing and ~C-p~-ing won't make the buffer jump +around so much. + +#+begin_src emacs-lisp + +(use-package smooth-scrolling + :ensure t + :config + (smooth-scrolling-mode)) + +#+end_src + +** Webmode + +#+begin_src emacs-lisp :tangle no + +(use-package web-mode + :ensure t) + +#+end_src + +** Emmet + + According to [[http://emmet.io/][their website]], "Emmet — the essential toolkit for web-developers." + +#+begin_src emacs-lisp + +(use-package emmet-mode + :ensure t + :commands emmet-mode + :config + (add-hook 'html-mode-hook 'emmet-mode) + (add-hook 'css-mode-hookg 'emmet-mode)) + +#+end_src + +** 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. + +#+begin_src emacs-lisp + +(use-package scratch + :ensure t + :commands scratch) + +#+end_src + +** Shell pop + +#+BEGIN_SRC emacs-lisp + +(use-package shell-pop + :ensure t + :bind ("M-" . shell-pop)) + +#+END_SRC + +** Quickrun + +#+BEGIN_SRC emacs-lisp + +(use-package quickrun + :defer 10 + :ensure t + :bind ("C-c r" . quickrun)) + +#+END_SRC + +** terminal-here + +#+begin_src emacs-lisp + +(use-package terminal-here + :ensure t + :bind (("C-c o t" . terminal-here-launch) + ("C-c o p" . terminal-here-project-launch))) + +#+end_src + +** Whitespace + +#+begin_src emacs-lisp + +(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))) + +#+end_src + +** Ivy + + 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. + +#+begin_src emacs-lisp + +(use-package ivy + :diminish + :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)) + :init + (ivy-mode 1) + :config + (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 + :init + (ivy-rich-mode 1) + :after counsel + :config + (setq ivy-format-function #'ivy-format-function-line) + (setq ivy-rich-display-transformers-list + (plist-put ivy-rich-display-transformers-list + 'ivy-switch-buffer + '(:columns + ((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 + :predicate + (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)) + :custom + (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only) + :config + (setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^ + +(use-package flx ;; Improves sorting for fuzzy-matched results + :after ivy + :defer t + :init + (setq ivy-flx-limit 10000)) + +(use-package wgrep) + +(use-package ivy-posframe + :disabled + :custom + (ivy-posframe-width 115) + (ivy-posframe-min-width 115) + (ivy-posframe-height 10) + (ivy-posframe-min-height 10) + :config + (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 + :config + (prescient-persist-mode 1)) + +(use-package ivy-prescient + :after prescient + :config + (ivy-prescient-mode 1)) + +(dw/leader-key-def + "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)) + +#+end_src + +** Helpfull + +#+begin_src emacs-lisp + +(use-package helpful + :commands (helpful-callable helpful-variable helpful-command helpful-key) + :custom + (counsel-describe-function-function #'helpful-callable) + (counsel-describe-variable-function #'helpful-variable) + :bind + ([remap describe-function] . counsel-describe-function) + ([remap describe-command] . helpful-command) + ([remap describe-variable] . counsel-describe-variable) + ([remap describe-key] . helpful-key)) + +#+end_src + +** Packages config + + Configuration for packages + +#+begin_src emacs-lisp + +;; 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 "") 'eshell-bol) + (evil-normalize-keymaps) + + (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 + (concat + (if (string= (eshell/pwd) (getenv "HOME")) + (propertize "~" 'face `(:foreground "#99CCFF")) + (replace-regexp-in-string + (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) + :config + + (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) +(emms-all) +(emms-default-players) +(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"))) + +#+end_src diff --git a/config.org b/config.org new file mode 100644 index 0000000..9394ef4 --- /dev/null +++ b/config.org @@ -0,0 +1,1364 @@ +#+title: Emacs Configuration +#+author: beastie@FreeBaSeD-T430 +#+date: 2022-12-01 +#+startup: hidestars odd overview +#+options: num:nil + + 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 [[https://github.com/jwiegley/use-package][use-package]] package from John Wiegley, which is +a fantastic way to manage package configurations. + +* Personal Information + +#+begin_src emacs-lisp + +(setq user-full-name "beastie" + user-mail-address "") + +#+end_src + +* 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. + +#+begin_src emacs-lisp + +;; 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" + (float-time + (time-subtract after-init-time before-init-time))) + gcs-done))) + +#+end_src + +** Customizing emacs + +#+begin_src emacs-lisp + +;; 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 80) ;; 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") + (ignore-errors + (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 + term-mode-hook + shell-mode-hook + treemacs-mode-hook + eshell-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 'terminator) + +#+end_src + +** Changing how focus work + + This fuction change the focus to the new window + +#+begin_src emacs-lisp + +;;; Mude o foco p/ novas janelas +(defun split-and-follow-horizontally () + (interactive) + (split-window-below) + (balance-windows) + (other-window 1)) + +(defun split-and-follow-vertically () + (interactive) + (split-window-right) + (balance-windows) + (other-window 1)) + +#+end_src + +** Alias + + Some alias that make my life easier + +#+begin_src emacs-lisp + +;; 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) + +#+end_src + +** Key binds + + Some key binds to make my life easier + +#+begin_src emacs-lisp + +(global-unset-key (kbd "C-z")) ;; Unbind C-z +(global-unset-key (kbd "C-Z")) ;; Unbind C-Z +(global-set-key (kbd "M-") 'shrink-window) +(global-set-key (kbd "M-") 'enlarge-window) +(global-set-key (kbd "M-") 'shrink-window-horizontally) +(global-set-key (kbd "M-") 'enlarge-window-horizontally) +(global-set-key (kbd "s-") 'windmove-up) +(global-set-key (kbd "s-") 'windmove-down) +(global-set-key (kbd "s-") 'windmove-right) +(global-set-key (kbd "s-") 'windmove-left) +(global-set-key (kbd "C-") '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-") #'terminal-here-launch) +(global-set-key (kbd "C-") #'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. + +#+end_src + +** Functions + + Some Functions that I use. + +*** Dashboard + +#+begin_src emacs-lisp + +;; Open new tab on the dashboard +(defun new-tab () + (interactive) + (tab-new-to) + (switch-to-buffer (get-buffer-create "*dashboard*"))) +(global-set-key (kbd "s-x") 'new-tab) +(global-set-key (kbd "s-X") 'tab-close) + +#+end_src + +*** Midnight + cleanbuffer-list + +#+begin_src emacs-lisp + +;; 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") + +#+end_src + +* Packages + + Some packages that I use. + +** Dashboard + +A beatiful and usefull dashboard. + +#+begin_src emacs-lisp + +(use-package dashboard + :defer nil + :preface + (defun init-edit () + "Edit initialization file." + (interactive) + (find-file "~/.emacs.d/init.el")) + (defun conf-edit () + "Edit configuration file." + (interactive) + (find-file "~/.emacs.d/config.org")) + (defun create-scratch-buffer () + "Create a scratch buffer." + (interactive) + (switch-to-buffer (get-buffer-create "*scratch*")) + (lisp-interaction-mode)) + :config + (dashboard-setup-startup-hook) + (setq dashboard-items '((recents . 25))) + (setq dashboard-banner-logo-title "Welcome to Emacs!") + (setq dashboard-startup-banner "~/.emacs.d/img/logo.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 + `(((,nil + "Open init.el file." + "Open Emacs initialization file for easy editing." + (lambda (&rest _) (init-edit)) + 'default) + (nil + "Open config.org file." + "Open Emacs configuration file for easy editing." + (lambda (&rest _) (conf-edit)) + 'default) + (nil + "Open scratch buffer." + "Switch to the scratch buffer." + (lambda (&rest _) (create-scratch-buffer)) + 'default))))) + +#+end_src + +** EXWM + +#+begin_src emacs-lisp + +;; ;;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)) + +#+end_src + +** Term-mode + +#+begin_src emacs-lisp + +;; term +(use-package term + :config + (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 + :config + (setq vterm-max-scrollback 10000)) + +#+end_src + +** Themes + +#+begin_src emacs-lisp + +(use-package doom-themes) +(use-package green-is-the-new-black-theme) + +#+end_src + +** PDFTools + + Change viewdoc to pdfview with pdftools + +#+begin_src emacs-lisp + +(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) + :config + (pdf-tools-install) + (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 + :config + (add-hook 'pdf-view-mode-hook 'pdf-view-restore-mode)) + +(add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1))) + +#+end_src + +** ORG Mode + + Org mode configurantion. + +#+begin_src emacs-lisp + +;; Org init +(use-package org + :config + (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-") (lambda() + (interactive) + (outline-show-all)))) +;;(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 "" . company-complete-selection)) + (:map lsp-mode-map + ("" . company-indent-or-complete-common)) + :custom + (company-minimum-prefix-length 1) + (company-idle-delay 0.0)) + + (use-package company-box + :hook (company-mode . company-box-mode)) + +#+end_src + +** Projectile + +#+begin_src emacs-lisp + +(use-package projectile + :diminish projectile-mode + :config (projectile-mode) + :custom ((projectile-completion-system 'ivy)) + :bind-keymap + ("C-c p" . projectile-command-map) + :init + ;; 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)) + +#+end_src + +** Magit + +[[https://magit.vc/][Magit]] is the best Git interface I've ever used. Common Git operations are easy to execute quickly using Magit's command panel system. + +#+begin_src emacs-lisp + +(use-package magit + :custom + (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) + +#+end_src + +** Doom-modeline + + Default [[https://github.com/seagle0128/doom-modeline][Doom-modeline]]. + +#+begin_src emacs-lisp +(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) + +#+end_src + +** 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 + +#+begin_src emacs-lisp + +(use-package ace-window + :ensure t + :bind (("C-o" . ace-window))) + +#+end_src + +** Rainbow-delimiters + +#+begin_src emacs-lisp + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +#+end_src + +** IDE Features with lsp-mode + +*** lsp-mode + + We use the excellent [[https://emacs-lsp.github.io/lsp-mode/][lsp-mode]] to enable IDE-like functionality for many different programming languages via "language servers" that speak the [[https://microsoft.github.io/language-server-protocol/][Language Server Protocol]]. Before trying to set up =lsp-mode= for a particular language, check out the [[https://emacs-lsp.github.io/lsp-mode/page/languages/][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. + +#+begin_src emacs-lisp + +(defun efs/lsp-mode-setup () + (setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols)) + (lsp-headerline-breadcrumb-mode)) + +(use-package lsp-mode + :commands (lsp lsp-deferred) + :hook (lsp-mode . efs/lsp-mode-setup) + :init + (setq lsp-keymap-prefix "C-c l") ;; Or 'C-l', 's-l' + :config + (lsp-enable-which-key-integration t)) + +#+end_src + +*** lsp-ui + + [[https://emacs-lsp.github.io/lsp-ui/][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. + +#+begin_src emacs-lisp + + (use-package lsp-ui + :hook (lsp-mode . lsp-ui-mode) + :custom + (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)) + +#+end_src + +*** lsp-treemacs + +[[https://github.com/emacs-lsp/lsp-treemacs][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 [[https://github.com/Alexander-Miller/treemacs][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. + +#+begin_src emacs-lisp + + (use-package lsp-treemacs + :after lsp + :custom + (lsp-treemacs-sync-mode 1)) + +#+end_src + +*** lsp-ivy + +[[https://github.com/emacs-lsp/lsp-ivy][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 + +#+begin_src emacs-lisp + + (use-package lsp-ivy) + +#+end_src + +*** Bash + +#+begin_src shell + +npm i -g bash-language-server + +#+end_src + +*** HTML + +#+begin_src shell + +npm install -g vscode-html-languageserver-bin + +#+end_src + +*** Perl + +Perl config + +*** Rust + +Rust config. + +** CLISP + + Common lisp setup + +#+begin_src emacs-lisp + +(use-package slime + :ensure t + :defer 10 + :config + :init + (setq inferior-lisp-program "sbcl") + (setq slime-contribs '(slime-fancy))) + +#+end_src + +** Which-key + +#+begin_src emacs-lisp + +(use-package which-key + :ensure t + :init (which-key-mode) + :diminish which-key-mode + :config + (setq which-key-idle-delay 0.3)) + +#+end_src + +** Simplify Leader Bindings (general.el) + +[[https://github.com/noctuid/general.el][general.el]] is a fantastic library for defining prefixed keybindings, especially +in conjunction with Evil modes. + +#+begin_src emacs-lisp + +(use-package general + :config + (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")) + +#+end_src + +** Swiper + +#+begin_src emacs-lisp + +(use-package swiper + :ensure t + :bind ("s-s" . 'swiper)) + +#+end_src + +** Beacon + +#+begin_src emacs-lisp + +(use-package beacon + :ensure t + :diminish beacon-mode + :init + (beacon-mode 1)) + +#+end_src + +** Async + +#+begin_src emacs-lisp + +(use-package async + :ensure t + :init + (dired-async-mode 1)) + +#+end_src + +** Page-break-lines + +#+begin_src emacs-lisp + +(use-package page-break-lines + :ensure t + :diminish (page-break-lines-mode visual-line-mode)) + +#+end_src + +** Undoo-tree + +#+begin_src emacs-lisp + +(use-package undo-tree + :ensure t + :diminish undo-tree-mode) + +#+end_src + +** Saveplace + +#+begin_src emacs-lisp + +(use-package saveplace + :defer nil + :config + (save-place-mode)) + +#+end_src + +** Eldoc + +#+begin_src emacs-lisp + +(use-package eldoc + :diminish eldoc-mode) + +#+end_src + +** Try + +#+begin_src emacs-lisp + +(use-package try + :ensure t) + +#+end_src + +** Auto-complete + +#+begin_src emacs-lisp + +(use-package auto-complete + :ensure t + :init + (progn + (ac-config-default) + (global-auto-complete-mode t))) + +#+end_src + +** Neotree + +#+begin_src emacs-lisp + +(use-package neotree + :ensure t + :bind (("C-\\" . 'neotree-toggle))) ;; Ativa a tree + +#+end_src + +** Color-theme-modern + +#+begin_src emacs-lisp + +(use-package color-theme-modern + :ensure t) + +#+end_src + +** Flycheck + +#+begin_src emacs-lisp + +(use-package flycheck + :ensure t + :init (global-flycheck-mode t)) + +#+end_src + +** Recentf + +#+begin_src emacs-lisp + +(use-package recentf + :config + (recentf-mode t) + (setq recentf-max-saved-items 500)) + +#+end_src + +** Expand region + +#+begin_src emacs-lisp + +(use-package expand-region + :ensure t + :bind ("C-@" . er/expand-region)) + +#+end_src + +** Smoothscrolling + + This makes it so ~C-n~-ing and ~C-p~-ing won't make the buffer jump +around so much. + +#+begin_src emacs-lisp + +(use-package smooth-scrolling + :ensure t + :config + (smooth-scrolling-mode)) + +#+end_src + +** Webmode + +#+begin_src emacs-lisp :tangle no + +(use-package web-mode + :ensure t) + +#+end_src + +** Emmet + + According to [[http://emmet.io/][their website]], "Emmet — the essential toolkit for web-developers." + +#+begin_src emacs-lisp + +(use-package emmet-mode + :ensure t + :commands emmet-mode + :config + (add-hook 'html-mode-hook 'emmet-mode) + (add-hook 'css-mode-hookg 'emmet-mode)) + +#+end_src + +** 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. + +#+begin_src emacs-lisp + +(use-package scratch + :ensure t + :commands scratch) + +#+end_src + +** Shell pop + +#+BEGIN_SRC emacs-lisp + +(use-package shell-pop + :ensure t + :bind ("M-" . shell-pop)) + +#+END_SRC + +** Quickrun + +#+BEGIN_SRC emacs-lisp + +(use-package quickrun + :defer 10 + :ensure t + :bind ("C-c r" . quickrun)) + +#+END_SRC + +** terminal-here + +#+begin_src emacs-lisp + +(use-package terminal-here + :ensure t + :bind (("C-c o t" . terminal-here-launch) + ("C-c o p" . terminal-here-project-launch))) + +#+end_src + +** Whitespace + +#+begin_src emacs-lisp + +(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))) + +#+end_src + +** Ivy + + 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. + +#+begin_src emacs-lisp + +(use-package ivy + :diminish + :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)) + :init + (ivy-mode 1) + :config + (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 + :init + (ivy-rich-mode 1) + :after counsel + :config + (setq ivy-format-function #'ivy-format-function-line) + (setq ivy-rich-display-transformers-list + (plist-put ivy-rich-display-transformers-list + 'ivy-switch-buffer + '(:columns + ((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 + :predicate + (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)) + :custom + (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only) + :config + (setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^ + +(use-package flx ;; Improves sorting for fuzzy-matched results + :after ivy + :defer t + :init + (setq ivy-flx-limit 10000)) + +(use-package wgrep) + +(use-package ivy-posframe + :disabled + :custom + (ivy-posframe-width 115) + (ivy-posframe-min-width 115) + (ivy-posframe-height 10) + (ivy-posframe-min-height 10) + :config + (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 + :config + (prescient-persist-mode 1)) + +(use-package ivy-prescient + :after prescient + :config + (ivy-prescient-mode 1)) + +(dw/leader-key-def + "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)) + +#+end_src + +** Helpfull + +#+begin_src emacs-lisp + +(use-package helpful + :commands (helpful-callable helpful-variable helpful-command helpful-key) + :custom + (counsel-describe-function-function #'helpful-callable) + (counsel-describe-variable-function #'helpful-variable) + :bind + ([remap describe-function] . counsel-describe-function) + ([remap describe-command] . helpful-command) + ([remap describe-variable] . counsel-describe-variable) + ([remap describe-key] . helpful-key)) + +#+end_src + +** Packages config + + Configuration for packages + +#+begin_src emacs-lisp + +;; 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 "") 'eshell-bol) + (evil-normalize-keymaps) + + (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 + (concat + (if (string= (eshell/pwd) (getenv "HOME")) + (propertize "~" 'face `(:foreground "#99CCFF")) + (replace-regexp-in-string + (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) + :config + + (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) +(emms-all) +(emms-default-players) +(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"))) + +#+end_src diff --git a/init.el b/init.el new file mode 100644 index 0000000..f67568b --- /dev/null +++ b/init.el @@ -0,0 +1,152 @@ +;;; init.el --- Summary + +;;; Commentary: + +;;; Code: + +;; Paths +;; (add-to-list 'load-path "/home/beastie/.emacs.d/pde/") +;; (load "pde-load") + +;; Repos +(require 'package) +(setq package-enable-at-startup nil) +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("org" . "https://orgmode.org/elpa/") + ("elpa" . "https://elpa.gnu.org/packages/"))) +(package-initialize) + +;;; Bootstrap use-package +;; Install use-package if it's not already installed. +;; use-package is used to configure the rest of the packages. +(unless (or (package-installed-p 'use-package) + (package-installed-p 'diminish)) + (package-refresh-contents) + (package-install 'use-package) + (package-install 'diminish)) +(require 'use-package-ensure) +(setq use-package-always-ensure t) + +;; From use-package README +(eval-when-compile + (require 'use-package)) +(use-package diminish + :ensure t) ;; if you use :diminish +(use-package bind-key) + +;;; Load the config +(org-babel-load-file (concat user-emacs-directory "config.org")) + +;; Coisas do Melpa +(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. + '(ansi-color-faces-vector + [default default default italic underline success warning error]) + '(ansi-color-names-vector + ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"]) + '(custom-enabled-themes '(org-beautify euphoria retro-green)) + '(custom-safe-themes + '("c086fe46209696a2d01752c0216ed72fd6faeabaaaa40db9fc1518abebaf700d" "be9645aaa8c11f76a10bcf36aaf83f54f4587ced1b9b679b55639c87404e2499" "28eb6d962d45df4b2cf8d861a4b5610e5dece44972e61d0604c44c4aad1e8a9d" "e1ef2d5b8091f4953fe17b4ca3dd143d476c106e221d92ded38614266cea3c8b" "aaa4c36ce00e572784d424554dcc9641c82d1155370770e231e10c649b59a074" "c83c095dd01cde64b631fb0fe5980587deec3834dc55144a6e78ff91ebc80b19" "bffa9739ce0752a37d9b1eee78fc00ba159748f50dc328af4be661484848e476" "4bca89c1004e24981c840d3a32755bf859a6910c65b829d9441814000cf6c3d0" "d6603a129c32b716b3d3541fc0b6bfe83d0e07f1954ee64517aa62c9405a3441" "499c3dd62c262b0bbb3ea0f5c83e92db5eac4a2a58468b51900e0ca706a7ad12" "0ec7094cc0a201c1d6f7c37f2414595d6684403b89b6fd74dcc714b5d41cd338" "922f930fc5aeec220517dbf74af9cd2601d08f8250e4a15c385d509e22629cac" "b5cff93c3c6ed12d09ce827231b0f5d4925cfda018c9dcf93a2517ce3739e7f1" "09feeb867d1ca5c1a33050d857ad6a5d62ad888f4b9136ec42002d6cdf310235" "06e0662b31a2ae8da5c6b5e9a05b25fabd1dc8dd3c3661ac194201131cafb080" "7de92d9e450585f9f435f2d9b265f34218cb235541c3d0d42c154bbbfe44d4dd" "69ad4071c7b2d91543fddd9030816404ff22e46f7207549319ce484e23082dee" "cdc2a7ba4ecf0910f13ba207cce7080b58d9ed2234032113b8846a4e44597e41" "ff8be9ed2696bf7bc999423d909a603cb23a9525bb43135c0d256b0b9377c958" "1a094b79734450a146b0c43afb6c669045d7a8a5c28bc0210aba28d36f85d86f" "9dc64d345811d74b5cd0dac92e5717e1016573417b23811b2c37bb985da41da2" "0f302165235625ca5a827ac2f963c102a635f27879637d9021c04d845a32c568" "9685cefcb4efd32520b899a34925c476e7920725c8d1f660e7336f37d6d95764" "0615f6940c6c5e5638c9157644263889db755d43576c25f7b311806f4cfe2c3a" "be2c1a78f42783eab9ff068c3f09e81a7908a77a1d288ce8d704491165ef448b" "be0efbaebc85494f3c1c06e320fd13a24abf485d5f221a90fe811cea9a39ed85" "a0d9281cf41e8a226f0539a7f54e4812fdeaaec36c751b84671df97a54013465" "ded82bed6a96cb8fdc7a547ef148679e78287664a5236e9c694e917383b052d7" "dd7213b37f448685f41e28b83a497f78fdefeeef0d47531fc24e99f576a7a191" "b80d4f6dee7691fc5a437d760164c3eba202944b3f977d5b47bbb6b76cba0806" "660376e0336bb04fae2dcf73ab6a1fe946ccea82b25f6800d51977e3a16de1b9" default)) + '(erc-modules + '(autojoin button completion fill irccontrols keep-place list match menu move-to-prompt netsplit networks noncommands notifications readonly replace ring services smiley sound stamp spelling track)) + '(fci-rule-color "#444a73") + '(hl-todo-keyword-faces + '(("TODO" . "#dc752f") + ("NEXT" . "#dc752f") + ("THEM" . "#2d9574") + ("PROG" . "#4f97d7") + ("OKAY" . "#4f97d7") + ("DONT" . "#f2241f") + ("FAIL" . "#f2241f") + ("DONE" . "#86dc2f") + ("NOTE" . "#b1951d") + ("KLUDGE" . "#b1951d") + ("HACK" . "#b1951d") + ("TEMP" . "#b1951d") + ("FIXME" . "#dc752f") + ("XXX+" . "#dc752f") + ("\\?\\?\\?+" . "#dc752f"))) + '(jdee-db-active-breakpoint-face-colors (cons "#161a2a" "#82aaff")) + '(jdee-db-requested-breakpoint-face-colors (cons "#161a2a" "#c3e88d")) + '(jdee-db-spec-breakpoint-face-colors (cons "#161a2a" "#444a73")) + '(objed-cursor-color "#ff757f") + '(org-bullets-bullet-list '("◉" "○" "●" "○" "●" "○" "●") nil nil "Customized with use-package org-bullets") + '(package-selected-packages + '(terminal-here org-roam autothemer eshell-git-prompt vterm eterm-256color company-box company lsp-ivy lsp-treemacs lsp-ui markdown-mode lsp-mode counsel-projectile projectile green-is-the-new-black-theme spacemacs-themes spacemacs-theme doom-themes helpful rainbow-delimiters doom-modeline ws-butler counsel exwm emms pdf-tools elpher typit org-beautify-theme org-babel-eval-in-repl gnugo dark-mint-theme color-theme-modern ace-window all-the-icons neotree autocomplete use-package)) + '(pdf-view-display-size 'fit-page) + '(pdf-view-midnight-colors (cons "#c8d3f5" "#212337")) + '(rustic-ansi-faces + ["#212337" "#ff757f" "#c3e88d" "#ffc777" "#82aaff" "#c099ff" "#b4f9f8" "#c8d3f5"]) + '(typit-test-time 30) + '(vc-annotate-background "#212337") + '(vc-annotate-color-map + (list + (cons 20 "#c3e88d") + (cons 40 "#d7dd85") + (cons 60 "#ebd27e") + (cons 80 "#ffc777") + (cons 100 "#ffb76e") + (cons 120 "#ffa866") + (cons 140 "#ff995e") + (cons 160 "#ea9993") + (cons 180 "#d599c9") + (cons 200 "#c099ff") + (cons 220 "#d58dd4") + (cons 240 "#ea81a9") + (cons 260 "#ff757f") + (cons 280 "#d06a7c") + (cons 300 "#a15f79") + (cons 320 "#725476") + (cons 340 "#444a73") + (cons 360 "#444a73"))) + '(vc-annotate-very-old-color nil)) +(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. + '(ac-candidate-mouse-face ((t (:background "black" :foreground "green")))) + '(ac-selection-face ((t (:background "green" :foreground "black")))) + '(border ((t (:background "green" :width normal)))) + '(cursor ((t (:background "green")))) + '(isearch ((t (:background "green" :foreground "black")))) + '(isearch-fail ((t (:background "OrangeRed" :foreground "black")))) + '(ivy-current-match ((t (:extend t :background "green" :foreground "black")))) + '(ivy-minibuffer-match-highlight ((t (:background "green" :foreground "black")))) + '(mouse ((t (:background "green" :foreground "green")))) + '(org-block-begin-line ((t (:extend t :background "black" :foreground "pink")))) + '(org-block-end-line ((t (:extend t :background "black" :foreground "pink")))) + '(org-date ((t (:foreground "yellow")))) + '(org-document-title ((t (:inherit org-level-1 :foreground "purple" :box (:line-width 5 :color "black") :underline nil :height 1.5)))) + '(org-level-1 ((t (:inherit default :extend nil :foreground "orange" :box (:line-width 5 :color "black") :slant normal :weight normal :height 1.3 :width normal :foundry "MS " :family "Verdana")))) + '(org-level-2 ((t (:inherit default :extend nil :foreground "cyan" :slant normal :weight normal :height 1.15 :width normal :foundry "MS " :family "Verdana")))) + '(org-todo ((t (:foreground "dodger blue")))) + '(org-verbatim ((t (:foreground "gold1")))) + '(rainbow-delimiters-base-error-face ((t (:background "red" :foreground "black")))) + '(rainbow-delimiters-depth-1-face ((t (:foreground "yellow")))) + '(rainbow-delimiters-depth-2-face ((t (:foreground "red")))) + '(rainbow-delimiters-depth-3-face ((t (:foreground "cyan")))) + '(rainbow-delimiters-depth-4-face ((t (:foreground "purple")))) + '(rainbow-delimiters-depth-5-face ((t (:foreground "orange")))) + '(rainbow-delimiters-depth-7-face ((t (:foreground "dodger blue")))) + '(rainbow-delimiters-depth-8-face ((t (:foreground "pink")))) + '(rainbow-delimiters-mismatched-face ((t (:background "orange" :foreground "black")))) + '(rainbow-delimiters-unmatched-face ((t (:background "white" :foreground "black")))) + '(rectangle-preview ((t (:inherit region :background "green" :foreground "black")))) + '(region ((t (:extend t :background "green" :foreground "black")))) + '(scroll-bar ((t (:background "dim gray" :foreground "green")))) + '(secondary-selection ((t (:extend t :background "dim gray" :foreground "green")))) + '(tab-bar ((t nil))) + '(tab-bar-tab ((t (:background "green" :foreground "black")))) + '(tab-bar-tab-inactive ((t (:background "black" :foreground "green")))) + '(tabbar-default-face ((t (:inherit variable-pitch :background "green" :foreground "black" :height 0.8)))) + '(tabbar-selected-face ((t (:background "green" :foreground "black")))) + '(tabbar-unselected-face ((t (:background "black" :foreground "green")))) + '(typit-correct-char ((t (:inherit success :background "green" :foreground "black")))) + '(typit-value ((t (:inherit font-lock-constant-face :foreground "green")))) + '(typit-wrong-char ((t (:inherit error :foreground "red"))))) + +;;; init.el ends here