Skip to content

Latest commit

 

History

History
2287 lines (2069 loc) · 70.4 KB

dots3.org

File metadata and controls

2287 lines (2069 loc) · 70.4 KB

Emacs

Better defaults

Set better default for a better emacs start up

(setq default-directory user-emacs-directory
      gc-cons-percentage .6
      gc-cons-threshold most-positive-fixnum
      read-process-output-max (* 1024 1024))
;; 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)))

Start server

(server-start)

Suppress native-comp Warnings buffer

(setq native-comp-async-report-warnings-errors nil)

Hide menu, tool-bar, scroll-bar

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1)

Default utf-8 encoding

(set-default-coding-systems 'utf-8)

Start in a blank page

This allow to start emacs in a blank page

(setq inhibit-startup-message t)
(setq initial-scratch-message "")

Disable custom file

I choose to lay out my configurations and customizations in this very Org document for better visibility and maintainability through time and various upgrades. Albeit useful, the customize-* routines go against that strategy by writing directly at the end of the user-init-file or into a dedicated file when set accordingly.

To fight the littering I’ve decided to completely disable this feature and redirect the writing to /dev/null.

(setq-default custom-file null-device)

Set font

(set-face-attribute 'default nil :family "ttf-iosevka" :height 110)
;; (add-to-list 'default-frame-alist
;;            '(font . "IBM Plex Mono 12"))
;; (set-frame-font "IBM Plex Mono-12" nil t)
;; (set-frame-font "SF Mono-12" nil t)
;; (set-frame-font "Go Mono-12" nil t)
;; (set-frame-font "Noto Sans Mono SemiCondensed-12" nil t)
;; (set-frame-font "Cascadia Mono-12" nil t)
;; (set-face-attribute 'default nil
;;                     :family "IBM Plex Mono"
;;                     :height 130
;;                     :weight 'normal
;;                     :width 'normal)

Better scrolling

(setq scroll-margin 3
      scroll-conservatively 101
      scroll-up-aggressively 0.01
      scroll-down-aggressively 0.01
      scroll-preserve-screen-position t
      auto-window-vscroll nil)

Open buffer vertically (help buffer, pdf, etc)

(setq split-height-threshold nil)
(setq split-width-threshold 0)

Stop emacs from asking me if I want to load a large file

(setq large-file-warning-threshold nil)

Hide tabs

(setq tab-bar-show nil)

Convert tabs to white spaces

(setq-default indent-tabs-mode nil)

Make tabs to be 2 whitespaces width

(setq-default tab-width 2)

Delete trailing whitespace

This always creates unnecessary diffs in git. Just delete it upon saving.

(add-hook 'before-save-hook #'delete-trailing-whitespace)
(add-hook 'before-save-hook 'whitespace-cleanup)

Show trailing white spaces and empty lines

(setq-default show-trailing-whitespace nil)
(setq-default indicate-empty-lines t)

Configure compile command

;; use make as default command when M-x compile
(setq compile-command "make")
;; don't ask for confirmation to run make command
;; just run it
(setq compilation-read-command nil)

Preserve contents of system clipboard

Say you copied a link from your web browser, then switched to Emacs to paste it somewhere. Before you do that, you notice something you want to kill. Doing that will place the last kill to the clipboard, thus overriding the thing you copied earlier. We can have a kill ring solution to this with the following:

(setq save-interprogram-paste-before-kill t)

Now the contents of the clipboard are stored in the kill ring and can be retrieved from there (e.g. with M-y).

Update file whenever the file change

This mode ensures that the buffer is updated whenever the file changes. A change can happen externally or by some other tool inside of Emacs (e.g. kill a Magit diff).

(setq auto-revert-verbose t)
(add-hook 'after-init-hook 'global-auto-revert-mode)

Does anyone type yes anymore?

(fset 'yes-or-no-p 'y-or-n-p)

Do not display buffers with the name *Async Shell Command*

It is annoying when exactracting files with the UI program.

(add-to-list 'display-buffer-alist
             (cons "\\*Async Shell Command\\*.*" (cons #'display-buffer-no-window nil)))

Stop blinking cursor

Turn off the blinking cursor

(blink-cursor-mode -1)

Show-paren-mode

Highlight the the matching (){}[]

(show-paren-mode t)

Highlight current line

;; (global-hl-line-mode t)
;; (add-hook 'prog-mode-hook #'hl-line-mode)
(add-hook 'org-mode-hook #'hl-line-mode)

Stop asking to kill the process when exit emacs

(setq confirm-kill-processes nil)

Open help buffers in the current window

(add-to-list 'display-buffer-alist
             '("*Help*" display-buffer-same-window))

Backups and autosaves

(setq backup-directory-alist
      '(("." . "~/.emacs.d/backup/")))
(setq backup-by-copying t)
(setq version-control t)
(setq delete-old-versions t)
(setq kept-new-versions 6)
(setq kept-old-versions 2)
(setq create-lockfiles nil)
;; (setq make-backup-files nil)
(setq auto-save-default nil)
(setq auto-save-list-file-prefix nil)

Position register

(defadvice jump-to-register (around jump-to-buffer-maybe
                                    (register &optional delete)
                                    activate compile)
  (let ((r (get-register register)))
    (cond ((markerp r) (switch-to-buffer (marker-buffer r)))
          ((functionp r) (funcall r))
          ((and (cdr r) (atom (cdr r))) (find-file (cdr r) )))))

(setq register-alist
      `((?s . ,(with-current-buffer "*scratch*" (point-marker)))
        (?m . ,(with-current-buffer "*Messages*" (point-marker)))
        (?c . ,'consult-dir)
        (?b . ,'consult-buffer)
        (?q . ,'mode-line-other-buffer)
        (?d . ,'dired-jump)
        (?n . ,'org-roam-node-find)
        (?r file . "~/.emacs.d/notes")
        (100 file . "~/Projects/dots/dots.org")))

Prettify Symbols

(global-prettify-symbols-mode 1)
(defun add-pretty-lambda ()
  "Make some word or string show as pretty Unicode symbols.  See https://unicodelookup.com for more."
  (setq prettify-symbols-alist
        '(
          ("lambda" . 955)
          ("delta" . 120517)
          ("epsilon" . 120518)
          ("->" . 8594)
          ("<=" . 8804)
          (">=" . 8805))))
(add-hook 'prog-mode-hook 'add-pretty-lambda)
(add-hook 'org-mode-hook 'add-pretty-lambda)

Enable recursive minibuffers

(setq enable-recursive-minibuffers t)

Do not allow the cursor in the minibuffer prompt

(setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

Packages

straight.el

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)

use-package

(straight-use-package 'use-package)
;; (setq use-package-verbose t)

exec-path-from-shell

(use-package exec-path-from-shell
  :config
  (when (daemonp)
  (exec-path-from-shell-copy-env "LD_LIBRARY_PATH")
  (exec-path-from-shell-initialize)))

all-the-icons

(use-package all-the-icons)

general.el

(use-package general
  :config
  (general-evil-setup))

evil

(use-package evil
  :hook (after-init . evil-mode)
  <<evil-variables>>
  <<evil-config>>
  <<evil-bindings>>)

evil variables

:custom
(evil-undo-system 'undo-fu)
;; change the color of the cursor
(evil-normal-state-cursor '("gray" box))
(evil-visual-state-cursor '("orange" box))
(evil-insert-state-cursor '("dodger blue" bar))
(evil-replace-state-cursor '("red" bar))
;; use emacs bindings in insert-mode
(evil-disable-insert-state-bindings t)
(evil-want-keybinding nil)

evil config

:config
(evil-set-initial-state 'dired-mode 'normal)
(evil-set-initial-state 'wdired-mode 'normal)
(evil-set-initial-state 'org-mode 'normal)
(evil-set-initial-state 'vterm-mode 'insert)
(evil-set-initial-state 'prog-mode 'normal)
(evil-set-initial-state 'ebib-index-mode 'emacs)
(evil-set-initial-state 'org-fc-dashboard-mode 'emacs)
(evil-set-initial-state 'org-fc-flip-mode 'emacs)
(evil-set-initial-state 'org-fc-rate-mode 'emacs)
(evil-set-initial-state 'Info-mode 'emacs)
(evil-set-initial-state 'org-fc-review-rate-mode 'emacs)
(evil-set-initial-state 'org-fc-review-flip 'emacs)
(evil-set-initial-state 'calibredb-search-mode 'emacs)
(evil-set-initial-state 'exwm-mode 'emacs)
(evil-set-initial-state 'rg-mode 'emacs)
;; (evil-set-initial-state 'nov-mode 'emacs)
(evil-set-initial-state 'image-mode 'emacs)
(evil-set-initial-state 'eshell-mode 'normal)
(evil-set-initial-state 'pdf-view-mode 'emacs)
(evil-set-initial-state 'pdf-annot-list-mode 'emacs)
(evil-set-initial-state 'pdf-outline-buffer-mode 'emacs)

evil bindings

:general
(:states '(emacs normal motion insert visual)
         "C-c c r k" '(lambda () (interactive) (kill-line 0))
         "C-c c v u" 'evil-scroll-up
         "C-c c v d" 'evil-scroll-down
         "C-c c e ," 'mode-line-other-buffer
         "C-c c e t" 'ram/switch-recent-tab
         "C-c c d d" '(lambda() (interactive) (dired default-directory))
         "C-c c e d" 'kill-whole-line
         "C-c c e o" 'ram/insert-line-below
         "C-c c x p" 'ram/insert-line-above
         )
(:states '(insert)
        "C-e" 'end-of-line
        "C-a" 'beginning-of-line-text
        "C-k" 'kill-line
        "C-c c u r" 'undo-fu-only-redo
        "C-c c e p" 'ram/paste
        "C-c c e y" 'evil-yank
         )
(:states '(normal motion)
         "C-a" 'evil-first-non-blank
         "C-e" 'evil-last-non-blank
         "C-p" 'previous-line
         "C-n" 'next-line
         "C-f" 'forward-char
         "C-b" 'backward-char
         "j" 'evil-next-visual-line
         "k" 'evil-previous-visual-line
         "m" 'point-to-register
         "'" 'jump-to-register
         "gp" 'ram/evil-select-pasted)
(:states 'normal
         :keymaps 'messages-buffer-mode-map
         "q" 'quit-window)

doom-modeline

(use-package doom-modeline
  :hook (after-init . doom-modeline-mode)
  :custom
  (doom-modeline-modal-icon nil)
  (doom-modeline-lsp t)
  (doom-modeline-buffer-state-icon t)
  (doom-modeline-major-mode-icon nil)
  (doom-modeline-buffer-file-name-style 'file-name)
  ;; Whether display buffer encoding.
  (doom-modeline-buffer-encoding nil)
  (doom-modeline-icon (display-graphic-p)))

doom themes

(use-package doom-themes
  :custom
  (doom-themes-enable-bold t)    ; if nil, bold is universally disabled
  (doom-themes-enable-italic t)  ; if nil, italics is universally disabled
  (doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
  :config
  ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
  ;; may have their own settings.
  (load-theme 'doom-one t)
  ;; (load-theme 'doom-old-hope t)

  ;; Enable flashing mode-line on errors
  (doom-themes-visual-bell-config)

  ;; or for treemacs users
  (doom-themes-treemacs-config)

  ;; Corrects (and improves) org-mode's native fontification.
  (doom-themes-org-config))

windmove

(use-package windmove
  :straight (:type built-in)
  :config
  (general-define-key
   :states '(normal insert motion emacs)
   "s-l" 'windmove-right
   "s-h" 'windmove-left
   "s-k" 'windmove-up
   "s-j" 'windmove-down)

  (general-define-key
   :states 'normal
   :prefix "C-c"
   "r l" 'windmove-delete-right
   "r h" 'windmove-delete-left
   "r j" 'windmove-delete-down
   "r k" 'windmove-delete-up))

winner-mode

(use-package winner
  :straight (:type built-in)
  :hook
  (after-init . winner-mode)
  :general
  (:states '(normal insert motion emacs)
           "C-c c w u" 'winner-undo
           "C-c c w r" 'winner-redo))

org

(use-package org
  :custom
  (org-startup-folded t)
  ;; (org-hide-emphasis-markers t)
  (org-agenda-files '("~/org/tasks.org"))
  ;; to be able to use #+attr_org: :width
  (org-image-actual-width nil)
  (org-startup-with-inline-images t)
  (org-display-remote-inline-images 'download)
  ;; inline latex like $y=mx+c$ will appear in a different colour in
  ;; an org-mode file to help it stand out
  (org-highlight-latex-and-related '(latex))
  (org-ellipsis "")
  ;; syntax highlight
  (org-src-fontify-natively t)
  (org-src-tab-acts-natively t)
  (org-src-window-setup 'current-window)
  (org-edit-src-content-indentation 0)
  (org-src-preserve-indentation nil)
  (org-imenu-depth 7)
  ;; Don't ask for confirm when evaluating a source block
  (org-confirm-babel-evaluate nil)
  ;; RETURN will follow links in org-mode files
  (org-return-follows-link  t)
  (org-export-backends '(ascii beamer html latex md))
  ;; (org-image-actual-width '(300))
  :config
  ;; To Github Flavored Markdown
  (eval-after-load "org"
    '(require 'ox-gfm nil t))

  ;; The defaults use an old MathJax version
  (setf org-html-mathjax-options
        '((path "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML")
          (scale "100")
          (align "center")
          (indent "2em")
          (mathml nil)))
  (setf org-html-mathjax-template
        "<script type=\"text/javascript\" src=\"%PATH\"></script>")

  ;; Font size control of LateX previews in Org files
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))

  ;; https://emacs.stackexchange.com/questions/29902/more-detailed-description-of-how-to-set-up-org-file-apps-for-orgmode-9-0
  ;; how to open attach files in an org file
  (setq org-file-apps
        '(("\\.docx\\'" . default)
          ("\\.mm\\'" . default)
          ("\\.pdf::\\([0-9]+\\)?\\'" . "zathura %s -P %1")
          ("\\.x?html?\\'" . default)
          ("\\.pdf\\'" . "zathura \"%s\"")
          (auto-mode . emacs)))
  ;; open org-links with a specific program.
  ;; in this case open pdf files with zathura
  ;; (add-hook 'org-mode-hook
  ;;           '(lambda ()
  ;;              (setq org-file-apps
  ;;                    '((auto-mode . emacs)
  ;;                      ("\\.pdf::\\([0-9]+\\)?\\'" . "zathura %s -P %1")
  ;;                      ("\\.pdf\\'" . "zathura %s")
  ;;                      (directory . emacs)))))

  (add-hook 'org-mode-hook (lambda () (setq fill-column 80)))
  ;; This break the line but only when editing
  (add-hook 'org-mode-hook 'auto-fill-mode)
  ;; Visualy break the line of the frame size
  (add-hook 'org-mode-hook 'visual-line-mode)

  ;; puts the cursor in the right position
  ;; when hitting enter
  (add-hook 'org-mode-hook 'org-indent-mode)
  (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((dot . t)
     (js . t)
     (latex . t)
     (calc . t)
     (shell . t)
     (scheme . t)
     (sql . t)
     (lisp . t)
     (C . t)
     (python . t)
     (emacs-lisp . t)))
  :general
  (:states '(normal)
           :keymaps 'org-mode-map
           "<tab>" 'org-cycle
           "C-c c o n" 'org-toggle-narrow-to-subtree
           "C-c c o t" 'ram/org-set-tags
           "h" 'left-char)
  (:states 'insert
           :keymaps 'org-mode-map
           "C-c c o i" 'indent-relative
           "<tab>" 'org-cycle))

org-roam

https://github.com/org-roam/org-roam#configuration

(use-package org-roam
  :straight (org-roam
             :type git
             :host github
             :repo "org-roam/org-roam")
  :init
  (setq org-roam-directory "~/Documents/org/roams")
  :config
  ;; If you're using a vertical completion framework, you might want a more informative completion interface
  (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
  (org-roam-db-autosync-mode)
  :general
  (:prefix "C-c c"
           :states '(normal motion insert emacs)
           "r n" 'org-roam-node-find
           "r l" 'org-roam-buffer-toggle
           "r i" 'org-roam-node-insert
           "r d" 'org-id-get-create
           "r t" 'org-roam-tag-add
           "r a" 'org-roam-alias-add))

evil-org

(use-package evil-org
  :after org
  :hook (org-mode . evil-org-mode)
  :config
  (evil-org-set-key-theme '(navigation insert textobjects additional calendar)))

dired

(use-package dired
  :straight (:type built-in)
  :hook ((dired-mode . hl-line-mode)
         (dired-mode . dired-hide-details-mode))
  <<dired-variables>>
  <<dired-config>>
  <<dired-functions>>
  <<dired-bindings>>)

dired variables

:custom
(dired-recursive-copies 'always)
(dired-recursive-deletes 'always)
(dired-dwim-target t) ;;use to copy to the next buffer visible
;; Auto refresh Dired, but be quiet about it
(global-auto-revert-non-file-buffers t)
(dired-free-space nil)
(auto-revert-verbose nil)
(image-dired-external-viewer (executable-find "sxiv"))

dired config

:config
;; Enable global auto-revert
(global-auto-revert-mode t)
;; Reuse same dired buffer, to prevent numerous buffers while navigating in dired
(put 'dired-find-alternate-file 'disabled nil)

(setq dired-listing-switches "-Bhl --group-directories-first -v")
(set-face-attribute 'dired-header nil
                    :foreground "#282c34"
                    :weight 'bold)

(defcustom list-of-dired-switches
  '(("-Bhl --group-directories-first -v" . "")
    ("-ahl -v --group-directories-first -v" . "everything")
    ;; ("-BhlAL --group-directories-first -v" . "no . & ..")
    )
"List of ls switches (together with a name to display in the mode-line) for dired to cycle among.")

(advice-add 'dired-delete-file :before 'ram/dired-kill-before-delete)

dired functions

cycle-dired-switches
(defun cycle-dired-switches ()
  "Cycle through the list `list-of-dired-switches' of switches for ls"
  (interactive)
  (setq list-of-dired-switches
        (append (cdr list-of-dired-switches)
                (list (car list-of-dired-switches))))
  (dired-sort-other (caar list-of-dired-switches))
  (setq mode-name (concat "Dired " (cdar list-of-dired-switches)))
  (force-mode-line-update))

;; remove buffers before delete the file
(defun ram/dired-kill-before-delete (file &rest rest)
  (when-let ((buf (get-file-buffer file)))
    (kill-buffer buf)))
remove buffers before delete the file
(defun ram/dired-kill-before-delete (file &rest rest)
  (when-let ((buf (get-file-buffer file)))
    (kill-buffer buf)))
make l to behave as expected in dired
(defun ram/dired-open()
  (interactive)
  (cond
   ;; use dired-find-file if it is a directory
   ((file-directory-p (dired-get-file-for-visit))
    (dired-find-file))
   ;; use dired-find-file if the mime type of the file is emacs.desktop
   ((string= "emacs.desktop" (string-trim-right (shell-command-to-string
                                                 (format "xdg-mime query filetype %s | xargs xdg-mime query default"
                                                         (shell-quote-argument (dired-get-file-for-visit))))))
    (dired-find-file))
   (t
    ;; use xdg-open for everything else
    ;; start-process quote the arguments so you do not need the sell-quote-argument function
    ;; (start-process "ram-dired-open" nil "xdg-open" (dired-get-file-for-visit)))))
    (call-process "xdg-open" nil nil nil (dired-get-file-for-visit)))))

dired bindings

:general
(:states 'normal
         :keymaps 'dired-mode-map
         "j" 'dired-next-line
         "k" 'dired-previous-line
         "l" 'ram/dired-open
         "h" 'dired-up-directory
         "yy" 'dired-do-copy
         "yn" 'dired-copy-filename-as-kill
         "yp" (lambda() (interactive) (dired-copy-filename-as-kill 0))
         "gk" (lambda() (interactive) (dired "~/Documents"))
         "gn" (lambda() (interactive) (dired "~/Documents/notes"))
         "gd" (lambda() (interactive) (dired "~/Downloads"))
         "gp" (lambda() (interactive) (dired "~/Projects"))
         "gk" (lambda() (interactive) (dired "~/Projects/katas"))
         "ge" (lambda() (interactive) (dired "~/.emacs.d"))
         "gc" (lambda() (interactive) (dired "~/.config"))
         "gs" (lambda() (interactive) (dired "~/bin/scripts"))
         "gy" (lambda() (interactive) (dired "~/Projects/playground"))
         "gb" (lambda() (interactive) (dired "~/bin"))
         "gm" (lambda() (interactive) (dired "/media"))
         "gh" (lambda() (interactive) (dired "~"))
         "m" 'dired-mark
         "u" 'dired-unmark
         "t" 'dired-toggle-marks
         "cw" 'dired-do-rename
         "r" 'revert-buffer
         "nd" 'dired-create-directory
         "nf" 'dired-create-empty-file
         "np" 'ram/create-project
         "nk" 'ram/create-kata
         "s" 'dired-do-async-shell-command
         "q" 'quit-window
         "w" 'dired-toggle-read-only
         "W" 'wdired-finish-edit
         "x" 'dired-do-compress
         "za" 'cycle-dired-switches
         "zd" 'dired-hide-details-mode
         "M" 'point-to-register
         "'" 'jump-to-register
         "fz" 'dired-narrow-fuzzy
         "fe" 'dired-filter-by-extension
         "fc" 'dired-filter-pop-all
         "ff" 'dired-narrow-regexp
         "d" 'dired-hide-details-mode
         "i" 'image-dired-show-all-from-dir
         "I" (lambda() (interactive) (find-file (dired-get-filename)))
         "D" 'dired-do-delete)
(:states 'normal
         :keymaps 'image-dired-thumbnail-mode-map
         "l" 'image-dired-forward-image
         "h" 'image-dired-backward-image
         "k" 'image-dired-previous-line
         "j" 'image-dired-next-line
         "m" 'image-dired-toggle-mark-thumb-original-file
         "s" 'image-dired-display-thumbnail-original-image
         "q" 'quit-window
         "SPC" 'image-dired-thumbnail-display-external)
(:states 'normal
         :keymaps 'image-dired-display-image-mode-map
         "q" 'quit-window)

dired-hacks-utils

(use-package dired-hacks-utils
  :after dired)

dired-narrow

(use-package dired-narrow
  :after dired)

dired-filter

(use-package dired-filter
  :after dired)

dired-avfs

(use-package dired-avfs
  :after dired)

vertico

(use-package vertico
  :init
  (vertico-mode)
  (icomplete-mode -1))

savehist

Persist history over Emacs restarts. Vertico sorts by history position.

(use-package savehist
  :init
  (savehist-mode))

orderless

(use-package orderless
  :config
  (setq read-file-name-completion-ignore-case t
        read-buffer-completion-ignore-case t
        completion-ignore-case t)
  (setq completion-styles '(substring orderless)
        completion-category-defaults nil
        completion-category-overrides '((file (styles basic partial-completion)))))
;; completion-category-overrides '((file (styles . (partial-completion))))

consult

(use-package consult
  :straight (consult :type git
                     :host github
                     :repo "minad/consult")
  :config
  ;; PATCH: a temporary workarund for `consult-org-heading' with new `org-fold'.
  (defun consult--invisible-open-permanently () 
    "Open overlays which hide the current line. 
 See `isearch-open-necessary-overlays' and `isearch-open-overlay-temporary'." 
    (dolist (ov (let ((inhibit-field-text-motion t)) 
                  (overlays-in (line-beginning-position) (line-end-position)))) 
      (when-let (fun (overlay-get ov 'isearch-open-invisible)) 
        (when (invisible-p (overlay-get ov 'invisible)) 
          (funcall fun ov))))
    (if (featurep 'org-fold) (org-fold-show-set-visibility 'local)))

  (defun consult--invisible-open-temporarily () 
    "Temporarily open overlays which hide the current line. 
 See `isearch-open-necessary-overlays' and `isearch-open-overlay-temporary'." 
    (let (restore) 
      (dolist (ov (let ((inhibit-field-text-motion t)) 
                    (overlays-in (line-beginning-position) (line-end-position)))) 
        (let ((inv (overlay-get ov 'invisible))) 
          (when (and (invisible-p inv) (overlay-get ov 'isearch-open-invisible)) 
            (push (if-let (fun (overlay-get ov 'isearch-open-invisible-temporary)) 
                      (progn 
                        (funcall fun ov nil) 
                        (lambda () (funcall fun ov t))) 
                    (overlay-put ov 'invisible nil) 
                    (lambda () (overlay-put ov 'invisible inv))) 
                  restore)))) 
      restore)
    (if (featurep 'org-fold)
        (save-excursion
          (org-fold-save-outline-visibility nil
            (org-fold-show-set-visibility 'local)))))
  :general
  (:states '(normal insert emacs)
           "M-y" 'consult-yank-pop
           "C-x b" 'consult-buffer
           "C-c c c r" 'consult-ripgrep
           "C-c c c l" 'consult-line
           "C-c c n o" 'consult-outline))

corfu

(use-package corfu
  :init
  (global-corfu-mode)
  :custom
  (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
  :general
  (:states 'insert
           :keymaps 'corfu-mode-map
           "C-n" 'corfu-next)
  (:states 'insert
           "C-." 'completion-at-point))

cape

(use-package cape
:init
  ;; Add `completion-at-point-functions', used by `completion-at-point'.
  (add-to-list 'completion-at-point-functions #'cape-abbrev)
  (add-to-list 'completion-at-point-functions #'cape-symbol)
  (add-to-list 'completion-at-point-functions #'cape-file)
  ;;(add-to-list 'completion-at-point-functions #'cape-history)
  ;;(add-to-list 'completion-at-point-functions #'cape-keyword)
  ;;(add-to-list 'completion-at-point-functions #'cape-tex)
  ;;(add-to-list 'completion-at-point-functions #'cape-sgml)
  ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
  ;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
  ;;(add-to-list 'completion-at-point-functions #'cape-ispell)
  ;;(add-to-list 'completion-at-point-functions #'cape-dict)
  ;;(add-to-list 'completion-at-point-functions #'cape-symbol)
  ;;(add-to-list 'completion-at-point-functions #'cape-line)
)

embark

(use-package embark
  :general
  (:states '(normal insert)
           "C-c c k d" 'embark-dwim
           )
 (:keymaps 'vertico-map
   "<escape>" 'minibuffer-keyboard-quit
   "C-c c k d" 'embark-dwim
   "C-c c k a" 'embark-act)
)

marginalia

;; Enable richer annotations using the Marginalia package
(use-package marginalia
  :after consult
  :bind (:map minibuffer-local-map
              ("C-M-a" . marginalia-cycle)
              ;; When using the Embark package, you can bind `marginalia-cycle' as an Embark action!
              ;;:map embark-general-map
              ;;     ("A" . marginalia-cycle)
              )

  ;; The :init configuration is always executed (Not lazy!)
  :init

  ;; Must be in the :init section of use-package such that the mode gets
  ;; enabled right away. Note that this forces loading the package.
  (marginalia-mode)

  ;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations.
;;  (advice-add #'marginalia-cycle :after
;;              (lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit))))

  ;; Prefer richer, more heavy, annotations over the lighter default variant.
  ;; E.g. M-x will show the documentation string additional to the keybinding.
  ;; By default only the keybinding is shown as annotation.
  ;; Note that there is the command `marginalia-cycle' to
  ;; switch between the annotators.
  (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)))

consult-dir

(use-package consult-dir
  :general
  (:states '(normal insert emacs)
           "C-c c c d" 'consult-dir)
  :config
  (setq consult-dir-sources '(consult-dir--source-default
                              consult-dir--source-recentf
                              consult-dir--source-project
                              consult-dir--source-tramp-local
                              consult-dir--source-bookmark)))

Undo Fu

(use-package undo-fu
  :general
  (:states '(normal)
           "u" 'undo-fu-only-undo
           "C-r" 'undo-fu-only-redo)
  (:states '(insert emacs)
           "C-/" 'undo-fu-only-undo))

magit

(use-package magit
  :commands magit-status
  :custom
  ;; When maintaining a number of projects, it sometimes is necessary
  ;; to produce a full list of them with their corresponding Magit
  ;; status. That way you can determine very quickly which repositories
  ;; need to be examined further. (magit-list-repositories)
  (magit-repository-directories
   '(("~/Projects" . 1))))

evil-magit

(use-package evil-magit
  :after (magit))

projectile

(use-package projectile
  :custom
  (projectile-completion-system 'default)
  (projectile-create-missing-test-files t)
  :config
  ;; (setq projectile-project-search-path '("~/Projects/"))
  (setq projectile-switch-project-action #'projectile-dired)

  (projectile-mode +1)
  (add-to-list 'projectile-project-root-files-bottom-up "pubspec.yaml")
  (add-to-list 'projectile-project-root-files-bottom-up "pyproject.toml")
  (add-to-list 'projectile-project-root-files-bottom-up "package.json")
  (add-to-list 'projectile-project-root-files-bottom-up "Makefile")
  (add-to-list 'projectile-project-root-files-bottom-up "Eldev")
  (add-to-list 'projectile-project-root-files-bottom-up "lisp.org")
  (add-to-list 'projectile-project-root-files-bottom-up "dev_deps.ts")

  (projectile-register-project-type 'lisp '("lisp.org" "README.markdown")
                                    :src-dir "src/"
                                    :related-files-fn (list
                                                       (projectile-related-files-fn-groups
                                                        :test
                                                        '(("src/main.lisp"
                                                           "test/main.lisp"))))

                                    :test (format "sbcl --noinform --non-interactive --eval '(ql:quickload \"%s/tests\")' --eval '(asdf:test-system :%s)'" (projectile-project-name) (projectile-project-name))
                                    :test-dir "tests/"
                                    :test-suffix "")

  (projectile-register-project-type 'dart '("pubspec.yaml")
                                    :test "dart run test"
                                    :configure "dart pub get"
                                    :run "webdev serve"
                                    :test-dir "test/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'deno '("dev_deps.ts")
                                    :run "deno run"
                                    :test "deno test test/"
                                    :test-dir "test/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'python '("pyproject.toml")
                                    :project-file "pyproject.toml"
                                    :test "poetry run pytest"
                                    :test-dir "tests/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'npm '("package.json")
                                    :project-file "package.json"
                                    :configure "npm install"
                                    :test "npm test"
                                    :run "npm start"
                                    :test-dir "__tests__"
                                    :test-suffix ".test")

  (projectile-register-project-type 'cpp '("Makefile")
                                    :project-file "Makefile"
                                    :compile "make"
                                    :run "make run"
                                    :test "make test"
                                    :test-dir "tests/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'elisp '("Eldev")
                                    :project-file "Eldev"
                                    :test "eldev test"
                                    :test-dir "tests/"
                                    :test-suffix "-test")

  :general
  (:states '(normal insert emacs motion)
           "<f7>" 'projectile-configure-project)
  (:states 'normal
           :prefix ","
           "t" 'projectile-toggle-between-implementation-and-test)

  (:prefix "C-c p"
           :states '(normal insert emacs motion)
           "f" 'projectile-find-file
           "d" 'projectile-dired
           "r" 'projectile-run-project
           "c" 'projectile-compile-project
           "t" 'projectile-test-project
           "g" 'projectile-ripgrep
           "p" 'projectile-switch-project
           "b" 'projectile-switch-to-buffer
           "v" 'projectile-run-vterm))

ansi-color

This fix the problem with the compilation buffer. The poblem was that when doing projectile-test-project the compilation buffer add many characters making it difficult to read.

(use-package ansi-color
  :init
  ;; (defun my-colorize-compilation-buffer ()
  ;;   (when (eq major-mode 'compilation-mode)
  ;;     (ansi-color-apply-on-region compilation-filter-start (point))))
  (defun my-colorize-compilation-buffer ()
    (toggle-read-only)
    (ansi-color-apply-on-region (point-min) (point-max))
    (toggle-read-only))
  ;; (defun my-colorize-compilation-buffer ()
  ;;   (when (eq major-mode 'compilation-mode)
  ;;     (ansi-color-apply-on-region compilation-filter-start (point-max))))
  :hook (compilation-filter . my-colorize-compilation-buffer)
  :config
  (add-hook 'compilation-filter-hook 'ansi-color-for-comint-mode-on))

yaml-mode

(use-package yaml-mode
  :mode ("\\.yaml\\'")
  :hook (yaml-mode . lsp-deferred))

prog-mode

(use-package prog-mode
  :straight (:type built-in)
  :general
  (:states 'normal
           :keymaps 'prog-mode-map
           "<f6>" 'async-shell-command
           "gc" 'evil-commentary
           "gb" 'evil-jump-backward))

c-mode and c++-mode

(use-package cc-mode
  :straight (:type built-in)
  :init
  (add-to-list 'auto-mode-alist '("\\.cppm\\'" . c++-mode))
  (add-to-list 'auto-mode-alist '("\\.cxx\\'" . c++-mode))
  (add-to-list 'auto-mode-alist '("\\.mxx\\'" . c++-mode))
  (defun remove-electric-indent-mode ()
    (electric-indent-local-mode -1))
  :hook
  (c++-mode . remove-electric-indent-mode)
  (c-mode . remove-electric-indent-mode)
  :general
  (:states '(emacs normal insert visual)
           :keymaps '(c++-mode-map c-mode-map)
           "C-;" 'ram/insertSemicolon))

make-mode

(use-package make-mode
  :straight (:type built-in)
  :config
  (add-hook 'makefile-mode-hook
            (lambda ()
              (setq indent-tabs-mode t)
              (setq-default indent-tabs-mode t)
              (setq tab-width 8))))

js-mode

The actual problem is that you passed the wrong library name to use-package. You used js-mode, but there is no js-mode.el on the load-path. The filename is js.el, thus you should pass js to use-package. This is independent of straight.el.

(use-package js
  :config
  (add-hook 'js-mode-hook (lambda () (setq js-indent-level 2
                                           tab-width 2)))
  (general-define-key
   :states '(emacs normal insert visual)
   :keymaps 'js-mode-map
   "<f5>" (lambda()
            (interactive)
            (async-shell-command
             (concat "node " (buffer-file-name)) "*javascript output*"))
   "C-;" 'ram/insertSemicolon))

python-mode

;; The package is "python" but the mode is "python-mode":
(use-package python
  :straight (:type built-in)
  :mode ("\\.py\\'" . python-mode)
  :interpreter ("python" . python-mode)
  :config
  (general-define-key
   :states 'normal
   :keymaps 'python-mode-map
   "<f5>" (lambda()
            (interactive)
            (async-shell-command
             (concat "python " (buffer-file-name)) "*python output*"))))

pyvenv

(use-package pyenv-mode
  :defer 5
  :init
  (add-to-list 'exec-path "~/bin/pyenv/shims")
  (setq pyenv-installation-dir "~/bin/pyenv/bin")
  :config
  (pyenv-mode))

lisp-interaction-mode

(use-package elisp-mode
  :straight nil
  :general
  (:states 'normal
           :keymaps 'lisp-interaction-mode-map
           "gr" 'eval-defun))

go-mode

(use-package go-mode
  :mode "\\.go\\'"
  :general
  (:states 'normal
           :keymaps 'go-mode-map
           "<f5>" (lambda()
                    (interactive)
                    (async-shell-command
                     (concat "go run " (buffer-file-name)) "*go output*"))))

json-mode

(use-package json-mode
  :mode "\\.json\\'")

dart-mode

(use-package dart-mode
  :general
  (:states '(emacs normal insert visual)
           :keymaps 'dart-mode-map
           "<f5>" (lambda()
                    (interactive)
                    (async-shell-command
                     (concat "dart --enable-experiment=non-nullable " (buffer-file-name)) "*dart output*"))
           "C-;" 'ram/insertSemicolon))

haskell-mode

(use-package haskell-mode
  :mode ("\\.hs\\'")
  :general
  (:states '(emacs normal insert visual)
           :keymaps 'haskell-mode-map
           "<f5>" (lambda()
                    (interactive)
                    (async-shell-command
                     (concat "ghc -e main " (buffer-name)) "*haskell output*"))))

typescript-mode

(use-package typescript-mode
  :mode ("\\.ts\\'"))

sly (common-lisp)

(use-package sly
  :straight (sly :type git :host github :repo "joaotavora/sly")
  :custom (inferior-lisp-program "~/bin/sbcl/bin/sbcl --noinform")
  :commands sly
  :init
  ;; Activate common lisp highlight syntax to SBCL configuration file
  (add-to-list 'auto-mode-alist '("\\.sbclrc\\'" . lisp-mode))
  ;; Activate common lisp highlight syntax to Stumpwm configuration file
  (add-to-list 'auto-mode-alist '("\\.stumpwmrc\\'" . lisp-mode))
  :general
  (:states 'normal
           :keymaps 'sly-mode-map
           "K" 'sly-documentation-lookup
           "g i" 'sly-autodoc-manually
           "g d" 'sly-edit-definition))

geiser (guile, racket)

(use-package geiser
  :straight (geiser :type git :host gitlab :repo "emacs-geiser/geiser")
  :commands geiser
  :general
  (:states '(normal insert)
           :keymaps 'geiser-repl-mode-map
           "C-l" 'geiser-repl-clear-buffer)
  (:states 'normal
           :keymaps 'geiser-debug-mode-map
           "q" 'View-quit)
  :init
  (add-hook 'scheme-mode-hook 'geiser-mode)
  (setq geiser-default-implementation 'guile)
  (setq geiser-active-implementations '(guile))
  (setq geiser-guile-binary (executable-find "guile"))
  ;; the value matches comments starting with three semicolons and opening parens on the first column
  (add-hook 'scheme-mode-hook
            (lambda ()
              (outline-minor-mode 1)
              (set (make-local-variable 'outline-regexp) ";;\\(?:;[^#]\\|\\*+\\)\\|(define")
              (outline-hide-body))))

(use-package geiser-guile
  :straight (geiser-guile :type git :host gitlab :repo "emacs-geiser/guile")
  :after geiser)

lsp-mode

(use-package lsp-mode
  :straight (lsp-mode :type git :host github :repo "emacs-lsp/lsp-mode")
  :hook
  ((lsp-completion-mode . ram/lsp-mode-setup-completion)
   (go-mode . lsp-deferred)
   (python-mode . lsp-deferred)
   (js-mode . lsp-deferred)
   (c++-mode . lsp-deferred)
   (c-mode . lsp-deferred)
   (before-save . lsp-format-buffer)
   (before-save . lsp-organize-imports))
  :custom
  (lsp-completion-provider :none) ;; we use Corfu!
  (lsp-clients-clangd-executable (concat (getenv "HOME") "/bin/clang/bin/clangd"))
  (lsp-clients-clangd-args '("--header-insertion-decorators=0" "-j=4" "--suggest-missing-includes" "-background-index" "-log=error" "--clang-tidy"))
  :init
  (setq lsp-use-plists t)
  (defun ram/lsp-mode-setup-completion ()
    (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
          '(orderless))) ;; Configure orderless
  )

lsp-ui

(use-package lsp-ui
  :hook (lsp-mode . lsp-ui-mode)
  :custom
  ;; (lsp-ui-doc-header t)
  (lsp-ui-doc-include-signature t)
  (lsp-ui-doc-position 'bottom) ;; top, bottom, or at-point
  ;; (lsp-ui-doc-max-width 120)
  ;; (lsp-ui-doc-max-height 30)
  ;; (lsp-ui-doc-use-childframe t)
  ;; (lsp-ui-doc-use-webkit t)
  ;; (lsp-ui-doc-enable t)
  (lsp-ui-sideline-enable nil)
  (lsp-ui-sideline-show-code-actions nil)
  (lsp-ui-sideline-show-symbol t)
  (lsp-ui-sideline-show-hover t)
  (lsp-ui-sideline-show-diagnostics nil)
  ;; lsp-ui-imenu
  (lsp-ui-imenu-enable t)
  (lsp-ui-imenu-kind-position 'top))

lsp-dart

(use-package lsp-dart
  :straight (lsp-dart :type git :host github :repo "emacs-lsp/lsp-dart")
  :custom
  (lsp-dart-sdk-dir "~/bin/flutter/bin/cache/dart-sdk")
  :hook (dart-mode . lsp-deferred))

lsp-pyright

(use-package lsp-pyright
  :after lsp
  :straight (lsp-pyright :type git :host github :repo "emacs-lsp/lsp-pyright")
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         (lsp))))  ; or lsp-deferred

treemacs

(use-package treemacs
  :defer 3)

lsp-treemacs

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

consult-lsp

(use-package consult-lsp
  :straight (consult-lsp :type git :host github :repo "gagbo/consult-lsp")
  :after (consult lsp-mode))

dap-mode

(use-package dap-mode
  :config
  (setq dap-auto-configure-features '(sessions locals controls tooltip))
  (require 'dap-cpptools)
  (require 'dap-gdb-lldb)
  (require 'dap-lldb)
  (require 'dap-python)
  (require 'dap-chrome)
  (setq dap-print-io t)
  :bind
  (:map dap-mode-map
        (("<f12>" . dap-debug)
         ("<f8>" . dap-continue)
         ("<f9>" . dap-next)
         ("<M-f11>" . dap-step-in)
         ("C-M-<f11>" . dap-step-out)
         ("<f7>" . dap-breakpoint-toggle))))

flycheck

(use-package flycheck
  :hook
  ((go-mode . flycheck-mode)
   (python-mode . flycheck-mode)
   (dart-mode . flycheck-mode)
   (js-mode . flycheck-mode))
  :custom
  (lsp-prefer-flymake nil))

aggressive-indent

(use-package aggressive-indent
  :hook
  ((web-mode . aggressive-indent-mode)
   (json-mode . aggressive-indent-mode)
   (lisp-mode . aggressive-indent-mode)
   (scheme-mode . aggressive-indent-mode)
   (emacs-lisp-mode . aggressive-indent-mode)))

avy

Search for character

(use-package avy
  :general
  (:states '(normal emacs insert motion)
           "C-c c a f" 'avy-goto-char-timer
           ;; goto "("
           "C-c c a p" (lambda() (interactive) (avy-goto-char 40))))

smartparens

(use-package smartparens
  :hook
  ((js-mode . smartparens-mode)
   (c++-mode . smartparens-mode)
   (dart-mode . smartparens-mode)
   (go-mode . smartparens-mode)
   (sly-mrepl-mode . smartparens-mode)
   (geiser-repl-mode . smartparens-mode))
  :config
  (require 'smartparens-config)

  (with-eval-after-load 'smartparens
    (sp-with-modes
        '(c++-mode dart-mode go-mode js-mode)
      (sp-local-pair "{" nil :post-handlers '(:add ("||\n[i]" "RET")))))

  (with-eval-after-load 'smartparens
    (sp-with-modes
        '(c++-mode dart-mode go-mode js-mode)
      (sp-local-pair "(" nil :post-handlers '(:add ("||\n[i]" "RET")))))

  (sp-local-pair '(sly-mrepl-mode) "'" "'" :actions nil)
  ;; (add-hook 'js-mode-hook #'smartparens-mode)
  ;; (add-hook 'c++-mode-hook #'smartparens-mode)
  ;; (add-hook 'dart-mode-hook #'smartparens-mode)
  ;; (add-hook 'go-mode-hook #'smartparens-mode)
  ;; Activate smartparens in minibuffer
  (add-hook 'eval-expression-minibuffer-setup-hook #'smartparens-mode)

  ;; (smartparens-global-mode t)
  )

whitespace

(use-package whitespace
  :straight (:type built-in)
  :hook
  (prog-mode . whitespace-mode)
  (text-mode . whitespace-mode)
  :custom
  (whitespace-style '(face empty indentation::space tab trailing)))

ctrlf

(use-package ctrlf
  :straight (ctrlf :host github :repo "raxod502/ctrlf")
  :bind ("C-s" . ctrlf-forward-literal)
  :config
  (ctrlf-mode +1))

expand-region

(use-package expand-region
  :general
  (:states '(normal motion)
           "SPC" 'er/expand-region))

lispy

(use-package lispy
  :hook ((common-lisp-mode . lispy-mode)
         (emacs-lisp-mode . lispy-mode)
         (lisp-mode . lispy-mode)
         (scheme-mode . lispy-mode)
         (racket-mode . lispy-mode)
         (hy-mode . lispy-mode)
         (lfe-mode . lispy-mode)
         (clojure-mode . lispy-mode))
  :general
  (:states '(emacs insert)
           :keymaps 'lispy-mode-map
           "C-c p w" 'lispy-wrap-round
           "C-c p k" 'lispy-delete
           "C-c p m" 'lispy-multiline
           "C-c p o" 'lispy-oneline
           ))

lispyville

(use-package lispyville
  :after lispy
  :hook ((lispy-mode . lispyville-mode))
  ;; :init
  ;; (general-add-hook '(lisp-interaction-mode-hook emacs-lisp-mode-hook lisp-mode-hook) #'lispyville-mode)
  :config
  (lispyville-set-key-theme '(operators
                              additional-insert
                              c-w additional
                              text-objects
                              atom-motions
                              additional-motions
                              wrap
                              slurp/barf-lispy)))

yasnippet

(use-package yasnippet
  :bind
  (:map yas-minor-mode-map
        ("TAB" . nil)
        ([tab] . nil))
  :hook
  (prog-mode . yas-minor-mode)
  (text-mode . yas-minor-mode)
  :custom
  (yas-snippet-dirs
   '("~/Documents/dots/snips/yasnippet"))
  :config
  (yas-reload-all)
  :general
  (:states 'visual
           :prefix ","
           "y" 'yas-insert-snippet)
  (:states 'insert
           "C-c c y i" 'yas-expand)
  (:states 'insert
           :keymaps 'yas-minor-mode-map
           "M-l" 'yas-next-field
           "M-h" 'yas-prev-field))

web-mode

(use-package web-mode
  :mode "\\.html\\'"
  :custom
  (web-mode-enable-auto-expanding t)
  (web-mode-markup-indent-offset 2)
  (web-mode-css-indent-offset 2)
  (web-mode-code-indent-offset 2)
  (web-mode-enable-auto-pairing t)
  (web-mode-enable-css-colorization t)
  (web-mode-enable-current-element-highlight t)
  :config
  (set-face-background 'web-mode-current-element-highlight-face "#ff6c6b")
  (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
  (add-to-list 'auto-mode-alist '("\\.css?\\'" . web-mode)))

lorem-ipsum

(use-package lorem-ipsum)

org-cliplink

(use-package org-cliplink
  :commands org-cliplink)

sudo-edit

(use-package sudo-edit
  :commands sudo-edit)

skeletor

(use-package skeletor
  :commands (skeletor-create-project skeletor-create-project-at ram/create-kata ram/create-project)
  :custom
  (skeletor-user-directory "~/Projects/dots/project-skeletons")
  :init
  (skeletor-define-template "c-make-munit"
    :no-license? t
    :no-git? t
    :title "C Make Munit Kata")

  (skeletor-define-template "cpp-hello-world"
    :no-license? t
    :no-git? t
    :title "Cpp Hellow World")

  (skeletor-define-template "cpp-make-fmt-ut-as-headers"
    :no-license? t
    :no-git? t
    :title "Cpp Make Fmt Ut Kata")

  (skeletor-define-template "elisp"
    :no-git? t
    :no-license? t
    :title "Elisp Kata")

  (skeletor-define-template "lisp-fiveam"
    :no-git? t
    :no-license? t
    :title "Lisp Fiveam Kata")

  (skeletor-define-template "lisp"
    :no-git? t
    :no-license? t
    :title "Lisp Kata"
    :after-creation
    (lambda (dir)
      (skeletor-async-shell-command (format "ln -s %s ~/Projects/lisp/katas" dir))))

  (skeletor-define-template "js"
    :no-git? t
    :no-license? t
    :title "Javascript Kata"
    :after-creation
    (lambda (dir)
      (skeletor-async-shell-command "npm install")))

  (skeletor-define-template "typescript"
    :no-git? t
    :no-license? t
    :title "Typescript Kata")

  (skeletor-define-constructor "Dart Project"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "dart create -t %s %s" (ram/get-dart-template) (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Dart Kata"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "dart create -t package-simple %s" (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Dcli Script"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "dcli create %s" (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Flutter Project"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "flutter create -t %s %s" (ram/get-flutter-template) (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Python Project"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "poetry new %s" (shell-quote-argument .project-name))
         .project-dir)))
    :after-creation
    (lambda (dir)
      (skeletor-async-shell-command "poetry install")))

  (skeletor-define-constructor "Python Kata"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "poetry new %s" (shell-quote-argument .project-name))
         .project-dir)))))

helpful

(use-package helpful
  :general
  (:states '(normal visual emacs motion)
           :prefix "C-h"
           "v" 'helpful-variable
           "f" 'helpful-callable
           "k" 'helpful-key)
  (:states 'normal
           :keymaps 'helpful-mode-map
           "q" 'helpful-kill-buffers))

ace-window

(use-package ace-window
  :general
  (:states 'normal
           "M-o" 'ace-window))

buttercup (tdd)

(use-package buttercup)

vterm

(use-package vterm
:general
(:states '(insert)
         :keymaps 'vterm-mode-map
        "C-c c e p" 'vterm-yank
         )
(:states '(normal motion)
         :keymaps 'vterm-mode-map
         "p" 'vterm-yank)
)

vterm-toggle

(use-package vterm-toggle
  :init
  :general
  (:states '(emacs normal insert visual)
           "C-c c v v" '(lambda () (interactive)
                          (if (string-equal (buffer-name) "*vterm*")
                              (vterm-toggle-cd)
                            ;; open vterm in full-screen
                            ;; 4 -> C-u
                            (vterm-toggle-cd 4)))))

rainbow-delimiters

(use-package rainbow-delimiters
  :config
  (add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'scheme-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'lisp-interaction-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'geiser-repl-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'sly-mrepl-mode-hook 'rainbow-delimiters-mode)

  (custom-set-faces
   '(rainbow-delimiters-depth-1-face ((t (:foreground "white"))))
   '(rainbow-delimiters-depth-2-face ((t (:foreground "cyan"))))
   '(rainbow-delimiters-depth-3-face ((t (:foreground "yellow"))))
   '(rainbow-delimiters-depth-4-face ((t (:foreground "green"))))
   '(rainbow-delimiters-depth-5-face ((t (:foreground "orange"))))
   '(rainbow-delimiters-depth-6-face ((t (:foreground "purple"))))
   '(rainbow-delimiters-depth-7-face ((t (:foreground "white"))))
   '(rainbow-delimiters-depth-8-face ((t (:foreground "cyan"))))
   '(rainbow-delimiters-depth-9-face ((t (:foreground "yellow"))))
   '(rainbow-delimiters-unmatched-face ((t (:foreground "red"))))))

dabbrev

(setq company-dabbrev-ignore-case 'keep-case
      company-dabbrev-downcase nil) ;; Keep dabbrev suggestions as-is, no downcasing

vundo

(use-package vundo
  :commands (vundo)
  :straight (vundo :type git :host github :repo "casouri/vundo")
  :config
  (setq vundo-compact-display t)
  (custom-set-faces
   '(vundo-node ((t (:foreground "#808080"))))
   '(vundo-stem ((t (:foreground "#808080"))))
   '(vundo-highlight ((t (:foreground "#FFFF00"))))))

s.el

String manipulation library

(use-package s)

f.el

Modern API for working with files and directories

(use-package f)

dash.el

A modern list API

(use-package dash)

ht.el

The missing hash table library for Emacs

(use-package ht)

let-alist

(use-package let-alist)

Functions

Change the default file application to emacs (mime)

(defun ram/change-mime-emacs ()
  (interactive)
  (message "The old default app was %s\n" (shell-command-to-string
                                           (format "xdg-mime query filetype %s | xargs xdg-mime query default"
                                                   (shell-quote-argument (dired-get-file-for-visit)))))

  (shell-command (format "xdg-mime query filetype %s | xargs xdg-mime default emacs.desktop"
                         (shell-quote-argument (dired-get-file-for-visit))))

  (message "The new default app is %s" (shell-command-to-string
                                        (format "xdg-mime query filetype %s | xargs xdg-mime query default"
                                                (shell-quote-argument (dired-get-file-for-visit))))))

Open book

(defun ram/open-book ()
  (interactive)
  (let* ((books-directory (expand-file-name "~/Documents/books"))
         (book-paths (directory-files-recursively books-directory "\\(pdf\\|epub\\|djvu\\|mobi\\)$"))
         (book-list (mapcar 'file-name-nondirectory book-paths))
         (chosen-book (completing-read "Books " book-list))
         (chosen-book-path (car (directory-files-recursively books-directory chosen-book))))
    (call-process "xdg-open" nil nil nil chosen-book-path)))

switch-recent-tab

(defun ram/switch-recent-tab ()
  (interactive)
  (when (tab-bar-switch-to-recent-tab)
    (tab-new)))

ram/paste

(defun ram/paste ()
  (interactive)
  (save-excursion (evil-paste-before 1)))

ram/insert-line

(defun ram/insert-line-below ()
  (interactive)
  (end-of-line)
  (newline-and-indent))

(defun ram/insert-line-above ()
  (interactive)
  (beginning-of-line)
  (newline-and-indent)
  (previous-line))

Emacs daemon

It is not needed to add systemctl start --user emacs.service to ~.profile. If systemctl enable --user emacs.service is run. https://www.youtube.com/watch?v=fg_jTo9SK9I

[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=forking
ExecStart=/home/last/bin/emacs/bin/emacs --daemon
ExecStop=/home/last/bin/emacs/bin/emacsclient --eval "(kill-emacs)"
Restart=no

[Install]
WantedBy=default.target

Kmonad

Copy-out the following template to quickly create a layer

#| --------------------------------------------------------------------------

(deflayer base
  _         _    _    _    _    _    _    _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _    _    _    _    _   _   _   _              _
  _         _    _    _    _    _    _    _    _    _    _   _   _   _              _
  _         _    _    _    _    _    _    _    _    _    _   _   _                  _
  _    _    _    _    _    _    _    _    _    _    _    _   _       _              _
  _         _    _         _         _    _    _                 _   _   _
  )

-------------------------------------------------------------------------- |#

Basic system config

The name given as the first argument to uinput-sink will be the name given to the virtual keyboard that KMonad creates.

input is the build-in notebook keyboard. If a keyboard is plug, the value has to be changed.

fallthrough just means that if a key is not define in the current layer, it will take the key value of the base layer.

(defcfg
  input  (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
  output (uinput-sink "KMonad kbd")
  allow-cmd true)

Aliases

Layout aliases

(defalias
  def (layer-switch default)
  han (layer-next handler)
  qsy (layer-toggle qsy)
  edt (layer-toggle editing)
  sym (layer-next sym)
  sym2 (layer-next sym2)
  sym3 (layer-next sym3)
  nav (layer-next nav)
  eWin (layer-toggle eWin)
  emcs (layer-next emacs)
)

Handler aliases

(defalias
  ;; completion-at-point
  c. #(C-.)
  ;; beggining of line
  ca #(C-a)
  ;; end of line
  ce #(C-e)
  ;; scroll half page up
  cccvu #(C-c c v u)
  ;; scroll half page down
  cccvd #(C-c c v d)
  ;; paste
  cccep #(C-c c e p)
  ;; yank
  cccey #(C-c c e y)
  ;; embark
  cccka #(C-c c k a)
  ;; embark dwim
  ccckd #(C-c c k d)
)

Nav aliases

(defalias
  ;; other-window
  cxo #(C-x o)
  ;; previous buffer
  ccce, #(C-c c e ,)
  ;; previous tab
  cccet #(C-c c e t)
  ;; avy-goto-char-timer
  cccaf #(C-c c a f)
  ;; consult-line
  ccccl #(C-c c c l)
  ;; open dired
  cccdd #(C-c c d d)
  ;; open roam
  cccrn #(C-c c r n)
  ;; consult-dir
  ccccd #(C-c c c d)
  ;; buffer
  cxb #(C-x b)
  ;; outline
  cccno #(C-c c n o)
  )

Emacs windows aliases

(defalias
  ;; winner undo
  cccwu #(C-c c w u)
  ;; winner redo
  cccwr #(C-c c w r)
  ;; delete-window
  cx0 #(C-x 0)
  ;; delete-other-window
  cx1 #(C-x 1)
  ;; split window horizontal
  cxh #(C-x 2)
  ;; split window vertical
  cxv #(C-x 3)
  )

Emacs aliases

(defalias
  ;; M-x
  mx #(A-x)
  ;; eval-expression
  as: #(A-S-:)
  ;; save
  cxcs #(C-x C-s)
  ;; cancel
  cg #(C-g)
  ;; magit-status
  cxg #(C-x g)
  ;; tangle
  cccvt #(C-c C-v t)
  ;; yas-expand
  cccyi #(C-c c y i)
  ;; vterm
  cccvv #(C-c c v v)
  )

Editing aliases

(defalias
  ;; redo
  cccur #(C-c c u r)
  ;; delete until begining line
  c0ck #(C-0 C-k)
  ;; delete line
  ccced #(C-c c e d)
  ;; insert line under cursor
  ccceo #(C-c c e o)
  ;; insert line above cursor
  cccxp #(C-c c x p)
  )

Quick symbols

(defalias
  op #(\()
  cp #(\))
  )

Symbols aliases

(defalias
  at #(@)
  us #(\_)
  )

Source layer

First up is the source (base) layer; this is used to set the default keys that will be overwritten later. It is `not’ a layer that will be used in the actual layout.

(defsrc
  esc         f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11   f12    pause  prnt  ins  del
  `           1    2    3    4    5    6    7    8    9    0    -     =      bspc              home
  tab         q    w    e    r    t    y    u    i    o    p    [     ]      ret               pgup
  caps        a    s    d    f    g    h    j    k    l    ;    '     \                        pgdn
  lsft   102d z    x    c    v    b    n    m    ,    .    /    rsft         up                end
  lctl        lmet lalt      spc       ralt cmps rctl                 left   down   rght
  )

Layers

Default layer

Since this is the first layer, it’s the layout KMonad starts in.

(deflayer default
  esc         f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11   f12    pause  prnt  ins  del
  `           1    2    3    4    5    6    7    8    9    0    -     =      bspc              home
  tab         q    w    e    r    t    y    u    i    o    p    [     ]      ret               pgup
  caps        a    s    d    f    g    h    j    k    l    @han '     \                        pgdn
  lsft   102d z    x    c    v    b    n    m    @nav @sym /    rsft         up                end
  lctl        lmet lalt      spc       ralt cmps rctl                 left   down   rght
  )

Nav layer

(deflayer nav
  _         _      _      _       _      _     _       _       _       _       _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _       _       _   _   _              _
  _         @cccet @eWin  _       _      _     _       _       _       @cccno  _       _   _   _              _
  _         @cxb   @cccaf @cccdd  @ccccl _     _       _       _       _       _       _   _                  _
  _    _    _      _      _       _      _     @cccrn  @ccccd  @ccce,  @cxo    _       _       _              _
  _         _      _              _            _       _       _                           _   _   _
  )

Editing layer

(deflayer editing
  _         _      _      _       _      _     _       _       _       _      _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _      _       _   _   _              _
  _         _      _      _       _      _     _       C-/     @cccur  @ccceo @cccxp  _   _   _              _
  _         _      _      _       _      _     A-del   bspc    del     A-d    @ccced  _   _                  _
  _    _    _      _      _       _      _     @c0ck   C-k     _       _      _       _       _              _
  _         _      _              _            _       _       _                          _   _   _
  )

eWin layer

(deflayer eWin
  _         _      _      _       _      _     _       _       _       _     _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     @cxh    @cxv    _       _     _       _   _   _              _
  _         _      _      _       _      _     _       @cx0    @cx1    _     _       _   _                  _
  _    _    _      _      _       _      _     @cccwu  @cccwr  _       _     _       _       _              _
  _         _      _              _            _       _       _                         _   _   _
  )

Emacs layer

(deflayer emacs
  _         _      _      _       _      _       _       _       _       _       _       _   _   _   _     _    _
  _         _      _      _       _      _       _       _       _       _       _       _   _   _              _
  _         _      @cxcs  _       _      @cccvt  _       _       @cccyi  _       _       _   _   _              _
  _         _      @mx    @cccdd  _      @cg     _       _       _       _       @as:    _   _                  _
  _    _    _      _      _       _      @cxb    @cccrn  @cxg    _       _       _       _       _              _
  _         _      _              _              _       _       _                           _   _   _
  )

Handler layer

(deflayer handler
  esc         f1     f2    f3     f4     f5   f6     f7     f8      f9   f10    f11   f12    pause  prnt  ins  del
  `           1      2     3      4      5    6      7      8       9    0      -     =      bspc              home
  tab         esc    w     @cccka @ccckd t    y      A->    A-<     o    @cccep [     ]      ret               pgup
  caps        @c.    @emcs @cccvv @edt   C-g  left   down   up      rght ;      '     \                        pgdn
  lsft  102d  z      x     @cccey v      b    @ca    @ce    ,       .    /      rsft         up                end
  lctl        lmet   lalt         C-spc       ralt   cmps   rctl                      left   down   rght
  )

qsy layer

(deflayer qsy
  _         _      _      _       _      _     _       _       _       _     _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     _       <       >       _     _       _   _   _              _
  _         _      _      _       _      _     _       @op     @cp     {     }       _   _                  _
  _    _    _      _      _       _      _     [       ]       ,       .     _       _       _              _
  _         _      _              _            _       _       _                         _   _   _
  )

sym layer

(deflayer sym
  _         _      _      _       _      _     _       _       _       _     _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         @sym2  @sym3  :       @qsy   _     _       =       +       "     ;       _   _                  _
  _    _    _      _      _       _      _     @us     -       #       .     _       _       _              _
  _         _      _              _            _       _       _                         _   _   _
  )

sym2 layer

(deflayer sym2
  _         _      _      _       _      _     _       _       _       _     _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     _       /       *       ^     ?       _   _                  _
  _    _    _      _      _       _      _     @at     &       $       %     _       _       _              _
  _         _      _              _            _       _       _                         _   _   _
  )

sym3 layer

(deflayer sym3
  _         _      _      _       _      _     _       _       _       _     _       _   _   _   _     _    _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     _       _       _       _     _       _   _   _              _
  _         _      _      _       _      _     _       \       ~       |     `       _   _                  _
  _    _    _      _      _       _      _     _       _       _       _     _       _       _              _
  _         _      _              _            _       _       _                         _   _   _
  )