Treesit is a native Emacs tree-sitteropen in new window implementation which provides a very fast and flexible way of performing code-highlighting in Emacs. It is built-in in Emacs 29 and newer, and I just need to tweak a couple of variables to install grammars for different languages.

(use-package treesit
  :defer t
  :straight (:type built-in)
  :hook ((bash-ts-mode c-ts-mode c++-ts-mode
          html-ts-mode js-ts-mode typescript-ts-mode
          json-ts-mode rust-ts-mode tsx-ts-mode python-ts-mode
          css-ts-mode yaml-ts-mode) . lsp-deferred)
  (setq treesit-language-source-alist
   '((bash "")
     (c "")
     (cmake "")
     (common-lisp "")
     (cpp "")
     (css "")
     (csharp "")
     (elisp "")
     (go "")
     (go-mod "")
     (html "")
     (js . ("" "master" "src"))
     (json "")
     (lua "")
     (make "")
     (markdown "")
     (python "")
     (r "")
     (rust "")
     (toml "")
     (tsx . ("" "master" "tsx/src"))
     (typescript . ("" "master" "typescript/src"))
     (yaml ""))))


Appwriteopen in new window is an open-source and self-hostable alternative to Firebase. I am currently working on a server SDK for Appwrite in Emacs, so here it is.

(use-package appwrite
  :defer t
  :straight (appwrite :build t
                      :type git
                      :host github
                      :repo "Phundrak/appwrite.el")
  (csetq appwrite-endpoint ""
         appwrite-devel t))


A really cool tool in Emacs for manipulating databases is emacsql. It’s able to manipulate SQLite databases by default, but it’s also possible to manipulate MariaDB and PostgreSQL databases by installing additional packages. For now, I just need SQLite and PostgreSQL interfaces, so let’s install the relevant packages.

(use-package emacsql-psql
  :defer t
  :after (emacsql)
  :straight (:build t))

(with-eval-after-load 'emacsql
    :keymaps 'emacs-lisp-mode-map
    :packages '(emacsql)
    "E" #'emacsql-fix-vector-indentation))


(use-package flycheck
  :straight (:build t)
  :defer t
  (setq flycheck-emacs-lisp-load-path 'inherit)

  ;; Rerunning checks on every newline is a mote excessive.
  (delq 'new-line flycheck-check-syntax-automatically)
  ;; And don’t recheck on idle as often
  (setq flycheck-idle-change-delay 2.0)

  ;; For the above functionality, check syntax in a buffer that you
  ;; switched to on briefly. This allows “refreshing” the syntax check
  ;; state for several buffers quickly after e.g. changing a config
  ;; file.
  (setq flycheck-buffer-switch-check-intermediate-buffers t)

  ;; Display errors a little quicker (default is 0.9s)
  (setq flycheck-display-errors-delay 0.2))

(use-package flycheck-popup-tip
  :straight (:build t)
  :after (flycheck evil)
  :hook (flycheck-mode . flycheck-popup-tip-mode)
  (setq flycheck-popup-tip-error-prefix "X ")
  (with-eval-after-load 'evil
    (add-hook 'evil-insert-state-entry-hook
    (add-hook 'evil-replace-state-entry-hook


(use-package ispell
  :if (executable-find "aspell")
  :defer t
  :straight (:type built-in)
  (add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:"))
  (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
  (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE"))
  (setq ispell-program-name "aspell"
        ispell-extra-args   '("--sug-mode=ultra" "--run-together")
        ispell-aspell-dict-dir (ispell-get-aspell-config-value "dict-dir")
        ispell-aspell-data-dir (ispell-get-aspell-config-value "data-dir")
        ispell-personal-dictionary (expand-file-name (concat "ispell/" ispell-dictionary ".pws")
(use-package flyspell
  :defer t
  :straight (:type built-in)
  :ghook 'org-mode 'markdown-mode 'TeX-mode
  (defhydra flyspell-hydra ()
Spell Commands^^           Add To Dictionary^^              Other
--------------^^---------- -----------------^^------------- -----^^---------------------------
[_b_] check whole buffer   [_B_] add word to dict (buffer)  [_t_] toggle spell check
[_r_] check region         [_G_] add word to dict (global)  [_q_] exit
[_d_] change dictionary    [_S_] add word to dict (session) [_Q_] exit and disable spell check
[_n_] next error
[_c_] correct before point
[_s_] correct at point
    ("B" nil)
    ("b" flyspell-buffer)
    ("r" flyspell-region)
    ("d" ispell-change-dictionary)
    ("G" nil)
    ("n" flyspell-goto-next-error)
    ("c" flyspell-correct-wrapper)
    ("Q" flyspell-mode :exit t)
    ("q" nil :exit t)
    ("S" nil)
    ("s" flyspell-correct-at-point)
    ("t" nil))
  (provide 'ispell) ;; force loading ispell
  (setq flyspell-issue-welcome-flag nil
        flyspell-issue-message-flag nil))
(use-package flyspell-correct
  :defer t
  :straight (:build t)
  :general ([remap ispell-word] #'flyspell-correct-at-point)
  (require 'flyspell-correct-ivy nil t))

(use-package flyspell-correct-ivy
  :defer t
  :straight (:build t)
  :after flyspell-correct)
(use-package flyspell-lazy
  :defer t
  :straight (:build t)
  :after flyspell
  (setq flyspell-lazy-idle-seconds 1
        flyspell-lazy-window-idle-seconds 3)
  (flyspell-lazy-mode +1))


lsp-modeopen in new window is a mode for Emacs which implements the Language Server Protocolopen in new window and offers Emacs an IDE-like experience. In short, it’s awesome!

(use-package lsp-mode
  :defer t
  :straight (:build t)
  (setq lsp-keymap-prefix "C-c l"
        read-process-output-max (* 3 1024 1024))
  :hook ((c-mode          . lsp-deferred)
         (c++-mode        . lsp-deferred)
         (html-mode       . lsp-deferred)
         (sh-mode         . lsp-deferred)
         (lsp-mode        . lsp-enable-which-key-integration)
         (lsp-mode        . lsp-ui-mode))
  :commands (lsp lsp-deferred)
  (lsp-rust-analyzer-cargo-watch-command "clippy")
  (lsp-eldoc-render-all t)
  (lsp-idle-delay 0.6)
  (lsp-rust-analyzer-server-display-inlay-hints t)
  (lsp-use-plist t)
   (make-lsp-client :new-connection (lsp-tramp-connection "shellcheck")
                    :major-modes '(sh-mode)
                    :remote? t
                    :server-id 'shellcheck-remote)))

I also want all the visual enhancements LSP can provide.

(use-package lsp-ui
  :after lsp
  :defer t
  :straight (:build t)
  :commands lsp-ui-mode
  (require 'lsp-ui-flycheck)
  (require 'lsp-ui-sideline)
  (setq lsp-ui-peek-always-show t
        lsp-ui-doc-enable t
        lsp-ui-sideline-show-diagnostics t
        lsp-ui-sideline-show-code-action t)
    :keymaps 'lsp-ui-peek-mode-map
    :packages 'lsp-ui
    "c" #'lsp-ui-pook--select-prev-file
    "t" #'lsp-ui-pook--select-next
    "s" #'lsp-ui-pook--select-prev
    "r" #'lsp-ui-pook--select-next-file))

And let’s enable some integration with ivy.

(use-package lsp-ivy
  :straight (:build t)
  :defer t
  :after lsp
  :commands lsp-ivy-workspace-symbol)
(use-package lsp-treemacs
  :defer t
  :straight (:build t))

You can find the keybinds of Treemacs here.

(use-package exec-path-from-shell
  :defer t
  :straight (:build t)
  :init (exec-path-from-shell-initialize))
(use-package consult-lsp
  :defer t
  :after lsp
  :straight (:build t)
    :keymaps 'lsp-mode-map
    [remap xref-find-apropos] #'consult-lsp-symbols))

dap-mode is an advanced debugging mode that works through LSP. Note that currently, dap-firefox and dap-chrome don’t work correctly due to this issueopen in new window. A workaround can be found in this commentopen in new window though.

(use-package dap-mode
  :after lsp
  :defer t
  :straight (:build t)
  (dap-ui-controls-mode 1)
  (add-hook 'dap-stopped-hook
            (lambda (arg) (call-interactively #'dap-hydra)))
  ;; JS/TS
  (with-eval-after-load 'web-mode
    (require 'dap-firefox)
    (require 'dap-chrome)
    (require 'dap-node))

  ;; Rust
  (with-eval-after-load 'rustic-mode
    (require 'dap-lldb)
    (require 'dap-gdb-lldb)
     "Rust::LLDB Run Configuration"
     (list :type "lldb"
           :request "launch"
           :name "LLDB::Run"
           :gdbpath "rust-lldb"
           :target nil
           :cwd nil))))


LanguageTool is a great tool for catching typos and grammatical errors in quite a few languages.

(use-package langtool
  :defer t
  :straight (:build t)
  :commands (langtool-check
  (langtool-default-language "en-US")
  (langtool-mother-tongue "fr")
  (setq langtool-java-classpath (string-join '("/usr/share/languagetool"

Finally, writegood-mode detects some simple general rules when writing in English and can also calculate the Flesh-Kincaid levels of a document.

(use-package writegood-mode
  :defer t
  :straight (:build t)
  :hook org-mode latex-mode
    :keymaps 'writegood-mode-map
    "g" #'writegood-grade-level
    "r" #'writegood-reading-ease))


DSLs, or Domain Specific Languages, are languages dedicated to some very tasks, such as configuration languages or non-general programming such as SQL.


(defun my/local-tab-indent ()
  (setq-local indent-tabs-mode 1))

(add-hook 'makefile-mode-hook #'my/local-tab-indent)


Caddyopen in new window (or Caddyserver) is a web server akin to Nginx or Apache which I find much easier to configure that the latter two, plus it has built-in support for automatically generating SSL certificates with Letsencrypt! Automatic HTTPS, what more do you want?

All that is nice and all, but Emacs doesn’t support the syntax of Caddy files natively, so let’s install caddyfile-mode:

(use-package caddyfile-mode
  :defer t
  :straight (:build t)
  :mode (("Caddyfile\\'" . caddyfile-mode)
         ("caddy\\.conf\\'" . caddyfile-mode)))


CMake is one of the standard tools for indicating how a project should be built. It is not as standard as some other tools such as automake, autoconfig, and the likes, but still pretty standard. CMake however doesn’t have a major mode available by default, so let’s provide one.

(use-package cmake-mode
  :defer t
  :straight (:build t))

Let’s enable first some autocompletion for it.

(use-package company-cmake
  :straight (company-cmake :build t
                           :type git
                           :host github
                           :repo "purcell/company-cmake")
  :after cmake-mode
  :defer t)

And let’s also enable a more advanced CMake fontlock.

(use-package cmake-font-lock
  :defer t
  :after cmake-mode
  :straight (:build t))

And finally, let’s enable some Eldoc integration for CMake.

(use-package eldoc-cmake
  :straight (:build t)
  :defer t
  :after cmake-mode)


(use-package csv-mode
  :straight (:build t)
  :defer t
    :keymaps 'csv-mode-map
    "a"  #'csv-align-fields
    "d"  #'csv-kill-fields
    "h"  #'csv-header-line
    "i"  #'csv-toggle-invisibility
    "n"  #'csv-forward-field
    "p"  #'csv-backward-field
    "r"  #'csv-reverse-region
    "s"  '(:ignore t :wk "sort")
    "sf" #'csv-sort-fields
    "sn" #'csv-sort-numeric-fields
    "so" #'csv-toggle-descending
    "t"  #'csv-transpose
    "u"  #'csv-unalign-fields
    "y"  '(:ignore t :wk yank)
    "yf" #'csv-yank-fields
    "yt" #'csv-yank-as-new-table))


It is not rare to encounter a dotenv file, that is, a file with either the .env extension or simply called .env. They contain environment variables for projects which might rely on values you do not want to upload to a public git repository and such. While their syntax is similar to shell files, they’re not exactly shell files either since there’s rarely any script inside running. So, let’s install a simple package which will dumb down a lot sh-mode for these dotenv files.

(use-package dotenv-mode
  :defer t
  :straight (:build t))


This package is a front-end and major mode for the programming language Gnuplotopen in new window. Let’s make some beautiful graphs, shall we?

(use-package gnuplot
  :straight (:build t)
  :defer t)


Graphvizopen in new window, often known with dot, allows to programmatically create visual graphs and networks.

(use-package graphviz-dot-mode
  :defer t
  :straight (:build t)
  :after org
  :mode (("\\.diag\\'"      . graphviz-dot-mode)
         ("\\.blockdiag\\'" . graphviz-dot-mode)
         ("\\.nwdiag\\'"    . graphviz-dot-mode)
         ("\\.rackdiag\\'"  . graphviz-dot-mode)
         ("\\.dot\\'"       . graphviz-dot-mode)
         ("\\.gv\\'"        . graphviz-dot-mode))
  (setq graphviz-dot-indent-width tab-width)
  (with-eval-after-load 'org
      (defalias 'org-babel-execute:graphviz-dot #'org-babel-execute:dot)
      (add-to-list 'org-babel-load-languages '(dot . t))
      (require 'ob-dot)
      (setq org-src-lang-modes
            (append '(("dot" . graphviz-dot))
                    (delete '("dot" . fundamental) org-src-lang-modes))))

    :keymaps 'graphviz-dot-mode-map
    "=" #'graphviz-dot-indent-graph
    "c" #'compile)
  (setq graphviz-dot-indent-width 4))


Yes, I love org-mode and I largely prefer to use it instead of Markdown due to its far superior power and abilities. But still, sometimes I need to use Markdown because not everyone uses org-mode, unfortunately.

(use-package markdown-mode
  :defer t
  :straight t
  (("\\.mkd\\'" . markdown-mode)
   ("\\.mdk\\'" . markdown-mode)
   ("\\.mdx\\'" . markdown-mode))
  :hook (markdown-mode . orgtbl-mode)
  :hook (markdown-mode . visual-line-mode)
    :keymaps 'markdown-mode-map
    :packages '(markdown-mode evil)
    "M-RET" #'markdown-insert-list-item
    "M-c"   #'markdown-promote
    "M-t"   #'markdown-move-down
    "M-s"   #'markdown-move-up
    "M-r"   #'markdown-demote
    "t"     #'evil-next-visual-line
    "s"     #'evil-previous-visual-line)
    :keymaps 'markdown-mode-map
    :packages 'markdown-mode
    "{"   #'markdown-backward-paragraph
    "}"   #'markdown-forward-paragraph
    "]"   #'markdown-complete
    ">"   #'markdown-indent-region
    "»"   #'markdown-indent-region
    "<"   #'markdown-outdent-region
    "«"   #'markdown-outdent-region
    "n"   #'markdown-next-link
    "p"   #'markdown-previous-link
    "f"   #'markdown-follow-thing-at-point
    "k"   #'markdown-kill-thing-at-point
    "c"   '(:ignore t :which-key "command")
    "c]"  #'markdown-complete-buffer
    "cc"  #'markdown-check-refs
    "ce"  #'markdown-export
    "cm"  #'markdown-other-window
    "cn"  #'markdown-cleanup-list-numbers
    "co"  #'markdown-open
    "cp"  #'markdown-preview
    "cv"  #'markdown-export-and-preview
    "cw"  #'markdown-kill-ring-save
    "h"   '(:ignore t :which-key "headings")
    "hi"  #'markdown-insert-header-dwim
    "hI"  #'markdown-insert-header-setext-dwim
    "h1"  #'markdown-insert-header-atx-1
    "h2"  #'markdown-insert-header-atx-2
    "h3"  #'markdown-insert-header-atx-3
    "h4"  #'markdown-insert-header-atx-4
    "h5"  #'markdown-insert-header-atx-5
    "h6"  #'markdown-insert-header-atx-6
    "h!"  #'markdown-insert-header-setext-1
    "h@"  #'markdown-insert-header-setext-2
    "i"   '(:ignore t :which-key "insert")
    "i-"  #'markdown-insert-hr
    "if"  #'markdown-insert-footnote
    "ii"  #'markdown-insert-image
    "il"  #'markdown-insert-link
    "it"  #'markdown-insert-table
    "iw"  #'markdown-insert-wiki-link
    "l"   '(:ignore t :which-key "lists")
    "li"  #'markdown-insert-list-item
    "T"   '(:ignore t :which-key "toggle")
    "Ti"  #'markdown-toggle-inline-images
    "Tu"  #'markdown-toggle-url-hiding
    "Tm"  #'markdown-toggle-markup-hiding
    "Tt"  #'markdown-toggle-gfm-checkbox
    "Tw"  #'markdown-toggle-wiki-links
    "t"   '(:ignore t :which-key "table")
    "tc"  #'markdown-table-move-column-left
    "tt"  #'markdown-table-move-row-down
    "ts"  #'markdown-table-move-row-up
    "tr"  #'markdown-table-move-column-right
    "ts"  #'markdown-table-sort-lines
    "tC"  #'markdown-table-convert-region
    "tt"  #'markdown-table-transpose
    "td"  '(:ignore t :which-key "delete")
    "tdc" #'markdown-table-delete-column
    "tdr" #'markdown-table-delete-row
    "ti"  '(:ignore t :which-key "insert")
    "tic" #'markdown-table-insert-column
    "tir" #'markdown-table-insert-row
    "x"   '(:ignore t :which-key "text")
    "xb"  #'markdown-insert-bold
    "xB"  #'markdown-insert-gfm-checkbox
    "xc"  #'markdown-insert-code
    "xC"  #'markdown-insert-gfm-code-block
    "xi"  #'markdown-insert-italic
    "xk"  #'markdown-insert-kbd
    "xp"  #'markdown-insert-pre
    "xP"  #'markdown-pre-region
    "xs"  #'markdown-insert-strike-through
    "xq"  #'markdown-blockquote-region)
  (setq markdown-fontify-code-blocks-natively t))

Since most of my Markdown files are related to GitHub, I’d like to be able to render Markdown through its API.

(use-package gh-md
  :defer t
  :after markdown-mode
  :straight (:build t)
    :packages 'gh-md
    :keymaps 'markdown-mode-map
    "cr" #'gh-md-render-buffer))

Sometimes, I have to work with GitHub’s markdown flavour, but I’m not really a huge fan of writing it by hand. So instead, I’ll write it in org-mode and then export it with ox-gfm.

(use-package ox-gfm
  :straight (:build t)
  :defer t
  :after (org ox))

Tables of content are always nice to have for large files, just like with the toc-org package for org-mode.

(use-package markdown-toc
  :defer t
  :after markdown-mode
  :straight (:build t)
    :packages 'markdown-toc
    :keymaps 'markdown-mode-map
    "iT" #'markdown-toc-generate-toc))

Lastly, edit-indirect is a package that allows to edit code blocks as in org-mode but with other major modes, such as code blocks in Markdown.

(use-package edit-indirect
  :straight (:build t)
  :defer t)


(use-package nix-mode
  :straight (:build t)
  :defer t)


Nginx is another webserver, older and more mature than Caddy. A couple of packages are required in order to be able to properly work with Nginx configuration files. First, we need the correct mode for editing Nginx configuration files.

(use-package nginx-mode
  :straight (:build t)
  :defer t)

We then also have an autocompletion package that adds to company the Nginx syntax.

(use-package company-nginx
  :straight (company-nginx :build t
                           :type git
                           :host github
                           :repo "emacsmirror/company-nginx")
  :defer t
  (add-hook 'nginx-mode-hook (lambda ()
                               (add-to-list 'company-backends #'company-nginx))))


As I am an ArchLinux user, I sometimes have to interact with PKGBUILD files, both from the AUR when I want to install something from there or some I write myself.

(use-package pkgbuild-mode
  :straight (:build t)
  :defer t
  (pkgbuild-update-sums-on-save nil)
  (pkgbuild-ask-about-save nil)
    :keymaps 'pkgbuild-mode-map
    "c"  #'pkgbuild-syntax-check
    "i"  #'pkgbuild-initialize
    "I"  #'pkgbuild-increase-release-tag
    "m"  #'pkgbuild-makepkg
    "u"  '(:ignore :wk "update")
    "us" #'pkgbuild-update-sums-line
    "uS" #'pkgbuild-update-srcinfo))


(use-package plantuml-mode
  :defer t
  :straight (:build t)
  :mode ("\\.\\(pum\\|puml\\)\\'" . plantuml-mode)
  :after ob
  (add-to-list 'org-babel-load-languages '(plantuml . t))
   :keymaps 'plantuml-mode-map
   :packages 'plantuml-mode
   "c"  '(:ignore t :which-key "compile")
   "cc" #'plantuml-preview
   "co" #'plantuml-set-output-type)
  (setq plantuml-default-exec-mode 'jar
        plantuml-jar-path "~/.local/bin/plantuml.jar"
        org-plantuml-jar-path "~/.local/bin/plantuml.jar"))


Aside from Eshell, my main shell on my machine is fish (see my fish config), therefore I need a mode for it.

(use-package fish-mode
  :straight (:build t)
  :defer t)

When editing some scripts though, I need to use the built-in shell-mode.

(use-package shell
  :defer t
  :straight (:type built-in)
  :hook (shell-mode . tree-sitter-hl-mode))

SSH Config files

(use-package ssh-config-mode
  :defer t
  :straight (:build t))


(use-package systemd
  :defer t
  :straight (:build t)
    :keymaps '(systemd-mode-map)
    "d" '(systemd-doc-directives :which-key "directives manpage")
    "o" 'systemd-doc-open))

Tmux config

(use-package tmux-mode
  :defer t
  :straight (tmux-mode :type git :host github :repo "nverno/tmux-mode")
  :mode (("tmux\\.conf\\'" . tmux-mode)))


(use-package toml-mode
  :straight (:build t)
  :defer t
  :mode "/\\(Cargo.lock\\|\\.cargo/config\\)\\'")


(use-package yaml-mode
  :defer t
  :straight (:build t)
  :mode "\\.yml\\'"
  :mode "\\.yaml\\'")


This is one of the two file formats used by ewwopen in new window’s configuration, a Lisp-like language. Therefore, it will also use parinfer to manage its parenthesis.

(use-package yuck-mode
  :straight (:build t)
  :defer t
  :hook ((yuck-mode . parinfer-rust-mode)))

General Programming Languages


I know, I know, C and C++ no longer are closely related languages, each one of them went their own way and learning C won’t make you a good C++ programmer, neither will the other way around. But, They are still somewhat related, and Emacs thinks so too.

(use-package cc-mode
  :straight (:type built-in)
  :defer t
  (put 'c-c++-backend 'safe-local-variable 'symbolp)
  (add-hook 'c-mode-hook #'tree-sitter-hl-mode)
  (add-hook 'c++-mode-hook #'tree-sitter-hl-mode)
  (require 'compile)
    :keymaps '(c-mode-map c++-mode-map)
    ";" nil)
   :keymaps '(c-mode-map c++-mode-map)
   "l"  '(:keymap lsp-command-map :which-key "lsp" :package lsp-mode))
   :keymaps '(c-mode-map c++-mode-map)
   "ga" #'projectile-find-other-file
   "gA" #'projectile-find-other-file-other-window))

Something that is also important when working with these languages is respecting the .clang-format file that may be provided by a project.

(use-package clang-format+
  :straight (:build t)
  :defer t
  (add-hook 'c-mode-common-hook #'clang-format+-mode))

However, Emacs’ notion of C++ is somewhat outdated, so we need to update its fontlock.

(use-package modern-cpp-font-lock
  :straight (:build t)
  :defer t
  :hook (c++-mode . modern-c++-font-lock-mode))


In Lisp buffers, let’s enable parinfer-rust-mode.

(use-package lisp-mode
  :straight (:type built-in)
  :defer t
  :after parinfer-rust-mode
  :hook (lisp-mode . parinfer-rust-mode)
  (put 'defcommand 'lisp-indent-function 'defun)
  (setq inferior-lisp-program "/usr/bin/sbcl --noinform"))

My current window manager is StumpWM, inspired by Emacs and written in CommonLisp. stumpwm-mode offers some integration between Emacs and StumpWM that makes the user able to evaluate CommonLisp code and see its effects in StumpWM immediately. Since my only use for CommonLisp is for my StumpWM configuration, it should be automatically enabled when entering lisp-mode.

(use-package stumpwm-mode
  :straight (:build t)
  :defer t
  :hook lisp-mode
   :keymaps 'stumpwm-mode-map
   :packages 'stumpwm-mode
   "e"  '(:ignore t :which-key "eval")
   "ee" #'stumpwm-eval-last-sexp
   "ed" #'stumpwm-eval-defun
   "er" #'stumpwm-eval-region))

Sly enables some deep interactivity between Emacs and a CommonLisp application running the Slynk backend. For an example, see my Sly configuration for StumpWM.

(use-package sly
  :defer t
  :straight (:build t))


(use-package dart-mode
  :straight (:build t)
  :defer t
  :hook (dart-mode . lsp-deferred)
  :mode "\\.dart\\'")
(use-package lsp-dart
  :straight (:build t)
  :defer t
   :keymaps 'dart-mode-map
   :packages '(lsp-mode lsp-dart)
   "l"  '(:keymap lsp-command-map :which-key "lsp")))


This package displays the function’s arglist or variable’s docstring in the echo area at the bottom of the frame. Quite useful indeed.

(use-package eldoc
  :defer t
  :after company
  (eldoc-add-command 'company-complete-selection
(use-package elisp-mode
  :straight (:type built-in)
  :requires smartparens
  (add-hook 'emacs-lisp-mode-hook (lambda () (smartparens-mode -1))))

Still on the topic of documentation, I sometimes find it lacks examples on how to use Elisp functions. elisp-demos got you covered!

(use-package elisp-demos
  :defer t
  :straight (:build t)
  (advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update))
(use-package epdh
  :straight (epdh :type git
                  :host github
                  :repo "alphapapa/emacs-package-dev-handbook"
                  :build t)
  :defer t)

Let’s also declare some Elisp-dedicated keybindings, prefixed by a comma.

 :keymaps 'emacs-lisp-mode-map
 "'"   #'ielm
 "c"   '(emacs-lisp-byte-compile :which-key "Byte compile")
 "C"   '(:ignore t :which-key "checkdoc")
 "Cc"  #'checkdoc
 "Cs"  #'checkdoc-start
 "e"   '(:ignore t :which-key "eval")
 "eb"  #'eval-buffer
 "ed"  #'eval-defun
 "ee"  #'eval-last-sexp
 "er"  #'eval-region

 "h"   '(:ignore t :which-key "help")
 "hh"  #'helpful-at-point

 "t"   '(:ignore t :wk "toggle")
 "tP"  '(:ignore t :wk "parinfer")
 "tPs" #'parinfer-rust-switch-mode
 "tPd" #'parinfer-rust-mode-disable
 "tPp" #'parinfer-rust-toggle-paren-mode)

Package linting is important when you want to publish your packages to the world.

(use-package package-lint
  :defer t
  :straight (:build t)
    :keymaps 'emacs-lisp-mode-map
    :packages 'package-lint
    "l" #'package-lint-current-buffer))

If I need to run CI on a package, Caskopen in new window manages its dependencies.

(use-package cask-mode
  :defer t
  :straight (:build t))

However, I recently began using Easkopen in new window more and more, I find it nicer to work with, and it has a lot more features than Cask.

;; (use-package eask-api
;;  :defer t
;;  :straight (eask-api :type git
;;                      :host github
;;                      :repo "emacs-eask/eask-api"))
;;(use-package eask-mode
;;  :defer t
;;  :straight (eask-mode :type git
;;                       :host github
;;                       :repo "emacs-eask/eask-mode"))


Emacs has built-in support for Java, but it still lacks some features. The main one is being able to replace an IDE, so let’s install its LSP package.

(use-package lsp-java
  :requires lsp
  :straight (:build t)
  :after lsp
  :hook (java-mode . lsp-deferred))


First, we need to set up the main Python mode. With this, we’ll also add Python to the list of LSP languages and to the list of languages org-babel supports.

(use-package python
  :defer t
  :straight (:build t)
  :after ob
  :mode (("SConstruct\\'" . python-mode)
         ("SConscript\\'" . python-mode)
         ("[./]flake8\\'" . conf-mode)
         ("/Pipfile\\'"   . conf-mode))
  (setq python-indent-guess-indent-offset-verbose nil)
  (add-hook 'python-mode-local-vars-hook #'lsp)
  (setq python-indent-guess-indent-offset-verbose nil)
  (when (and (executable-find "python3")
           (string= python-shell-interpreter "python"))
    (setq python-shell-interpreter "python3"))
   :keymaps 'python-mode-map
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp")))

Now let’s add a package for pytestopen in new window.

(use-package pytest
  :defer t
  :straight (:build t)
  :commands (pytest-one
  (add-to-list 'pytest-project-root-files "setup.cfg")
   :keymaps 'python-mode-map
   :infix "t"
   :packages 'pytest
   ""  '(:ignore t :which-key "test")
   "a" #'python-pytest
   "f" #'python-pytest-file-dwim
   "F" #'python-pytest-file
   "t" #'python-pytest-function-dwim
   "T" #'python-pytest-function
   "r" #'python-pytest-repeat
   "p" #'python-pytest-dispatch))

Poetry is a nice tool with which we can manage our Python runtime version as well as our dependencies.

(use-package poetry
  :defer t
  :straight (:build t)
  :commands (poetry-venv-toggle
  (setq poetry-tracking-strategy 'switch-buffer)
  (add-hook 'python-mode-hook #'poetry-tracking-mode))

This package will bring a new major mode for editing pip requirements.

(use-package pip-requirements
  :defer t
  :straight (:build t))

Why use the command line to interact with pip when we can do it with an Emacs frontend?

(use-package pippel
  :defer t
  :straight (:build t)
   :keymaps 'python-mode-map
   :packages 'pippel
   "P" #'pippel-list-packages))

This is a pipenvopen in new window porcelain

(use-package pipenv
  :defer t
  :straight (:build t)
  :commands (pipenv-activate
  :hook (python-mode . pipenv-mode)
  :init (setq pipenv-with-projectile nil)
   :keymaps 'python-mode-map
   :packages 'pipenv
   :infix "e"
   ""  '(:ignore t :which-key "pipenv")
   "a" #'pipenv-activate
   "d" #'pipenv-deactivate
   "i" #'pipenv-install
   "l" #'pipenv-lock
   "o" #'pipenv-open
   "r" #'pipenv-run
   "s" #'pipenv-shell
   "u" #'pipenv-uninstall))

This integrates pyenv into python-mode.

(use-package pyenv
  :defer t
  :straight (:build t)
  (add-hook 'python-mode-hook #'pyenv-track-virtualenv)
  (add-to-list 'global-mode-string
               '(pyenv-virtual-env-name (" venv:" pyenv-virtual-env-name " "))

Let’s also add a mode for pyenv:

(use-package pyenv-mode
  :defer t
  :after python
  :straight (:build t)
  :if (executable-find "pyenv")
  :commands (pyenv-mode-versions)
    :packages 'pyenv-mode
    :keymaps 'python-mode-map
    :infix "v"
    "u" #'pyenv-mode-unset
    "s" #'pyenv-mode-set))

This package automatically imports packages we forgot to import.

(use-package pyimport
  :defer t
  :straight (:build t)
    :packages 'pyimport
    :keymaps 'python-mode-map
    :infix "i"
    ""  '(:ignore t :which-key "imports")
    "i" #'pyimport-insert-missing
    "r" #'pyimport-remove-unused))

On the other hand, this one sorts our imports to make them more readable.

(use-package py-isort
  :defer t
  :straight (:build t)
   :keymaps 'python-mode-map
   :packages 'py-isort
   :infix "i"
   ""  '(:ignore t :which-key "imports")
   "s" #'py-isort-buffer
   "R" #'py-isort-region))

Access pydoc through counsel.

(use-package counsel-pydoc
  :defer t
  :straight (:build t))

This generates Python documentation that is meant to be compatible with Sphinx, a documentation generation for Python.

(use-package sphinx-doc
  :defer t
  :straight (:build t)
  (add-hook 'python-mode-hook #'sphinx-doc-mode)
   :keymaps 'python-mode-map
   :packages 'sphinx-doc
   :infix "S"
   ""  '(:ignore t :which-key "sphinx-doc")
   "e" #'sphinx-doc-mode
   "d" #'sphinx-doc))

Cython is a Python to C compiler. It also introduces the extended Cython programming language which makes writing C for Python easier. This package is a major mode for the Cython programming language.

(use-package cython-mode
  :defer t
  :straight (:build t)
  :mode "\\.p\\(yx\\|x[di]\\)\\'"
  (setq cython-default-compile-format "cython -a %s")
   :keymaps 'cython-mode-map
   :packages 'cython-mode
   :infix "c"
   ""  '(:ignore t :which-key "cython")
   "c" #'cython-compile))

Flycheck can also be enabled for Cython:

(use-package flycheck-cython
  :defer t
  :straight (:build t)
  :after cython-mode)

Blacken uses the black formatter backend to format Python buffers.

(use-package blacken
  :defer t
  :straight (:build t)
  (add-hook 'python-mode-hook #'blacken-mode))

Finally, I’m using Pyrightopen in new window as my LSP backend for Python.

(use-package lsp-pyright
  :after lsp-mode
  :defer t
  :straight (:buidl t))


Rust is a general programming language, akin to C++ in some ways, but much more oriented towards safe code, and much better suited for web development. First, let’s install the most important package, rustic.

(use-package rustic
  :defer t
  :straight (:build t)
  :mode ("\\.rs\\'" . rustic-mode)
  :hook (rustic-mode-local-vars . rustic-setup-lsp)
  :hook (rustic-mode . lsp-deferred)
  (with-eval-after-load 'org
    (defalias 'org-babel-execute:rust #'org-babel-execute:rustic)
    (add-to-list 'org-src-lang-modes '("rust" . rustic)))
  (setq rustic-lsp-client 'lsp-mode)
  (add-hook 'rustic-mode-hook #'tree-sitter-hl-mode)
   :keymaps 'rustic-mode-map
   :packages 'lsp
   "M-t" #'lsp-ui-imenu
   "M-?" #'lsp-find-references)
   :keymaps 'rustic-mode-map
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp"))
   :keymaps 'rustic-mode-map
   :packages 'rustic
   "b"  '(:ignore t :which-key "build")
   "bb" #'rustic-cargo-build
   "bB" #'rustic-cargo-bench
   "bc" #'rustic-cargo-check
   "bC" #'rustic-cargo-clippy
   "bd" #'rustic-cargo-doc
   "bf" #'rustic-cargo-fmt
   "bn" #'rustic-cargo-new
   "bo" #'rustic-cargo-outdated
   "br" #'rustic-cargo-run
   "t"  '(:ignore t :which-key "cargo test")
   "ta" #'rustic-cargo-test
   "tt" #'rustic-cargo-current-test)
  (setq rustic-indent-method-chain    t
        rustic-babel-format-src-block nil
        rustic-format-trigger         nil)
  (remove-hook 'rustic-mode-hook #'flycheck-mode)
  (remove-hook 'rustic-mode-hook #'flymake-mode-off)
  (remove-hook 'rustic-mode-hook #'rustic-setup-lsp))


(use-package uiua-ts-mode
  :mode "\\.ua\\'"
  :straight (:build t))

Web programming

Emmetopen in new window is a powerful templating engine that can generate through simple CSS-like expression some HTML to avoid the user writing everything by hand.

(use-package emmet-mode
  :straight (:build t)
  :defer t
  :hook ((css-mode  . emmet-mode)
         (html-mode . emmet-mode)
         (web-mode  . emmet-mode)
         (sass-mode . emmet-mode)
         (scss-mode . emmet-mode)
         (web-mode  . emmet-mode))
   :keymaps 'emmet-mode-keymap
   "M-RET" #'emmet-expand-yas)
    :keymaps 'web-mode-map
    :packages '(web-mode emmet-mode)
    "e" '(:ignore t :which-key "emmet")
    "ee" #'emmet-expand-line
    "ep" #'emmet-preview
    "eP" #'emmet-preview-mode
    "ew" #'emmet-wrap-with-markup))

Impatient mode serves web buffers live over HTTP, including your live modifications.

(use-package impatient-mode
  :straight (:build t)
  :defer t)

Web mode is a sort of hybrid major mode that allows editing several languages in the same buffer, mainly HTML, CSS, and JavaScript.

(use-package web-mode
  :defer t
  :straight (:build t)
  :hook html-mode
  :hook (web-mode . prettier-js-mode)
  :hook (web-mode . lsp-deferred)
  :mode (("\\.phtml\\'"      . web-mode)
         ("\\.tpl\\.php\\'"  . web-mode)
         ("\\.twig\\'"       . web-mode)
         ("\\.xml\\'"        . web-mode)
         ("\\.html\\'"       . web-mode)
         ("\\.htm\\'"        . web-mode)
         ("\\.[gj]sp\\'"     . web-mode)
         ("\\.as[cp]x?\\'"   . web-mode)
         ("\\.eex\\'"        . web-mode)
         ("\\.erb\\'"        . web-mode)
         ("\\.mustache\\'"   . web-mode)
         ("\\.handlebars\\'" . web-mode)
         ("\\.hbs\\'"        . web-mode)
         ("\\.eco\\'"        . web-mode)
         ("\\.ejs\\'"        . web-mode)
         ("\\.svelte\\'"     . web-mode)
         ("\\.ctp\\'"        . web-mode)
         ("\\.djhtml\\'"     . web-mode)
         ("\\.vue\\'"        . web-mode))
  (csetq web-mode-markup-indent-offset 2
         web-mode-code-indent-offset   2
         web-mode-css-indent-offset    2
         web-mode-style-padding        0
         web-mode-script-padding       0)
   :keymaps 'web-mode-map
   :packages 'web-mode
   "="  '(:ignore t :which-key "format")
   "E"  '(:ignore t :which-key "errors")
   "El" #'web-mode-dom-errors-show
   "gb" #'web-mode-element-beginning
   "g"  '(:ignore t :which-key "goto")
   "gc" #'web-mode-element-child
   "gp" #'web-mode-element-parent
   "gs" #'web-mode-element-sibling-next
   "h"  '(:ignore t :which-key "dom")
   "hp" #'web-mode-dom-xpath
   "r"  '(:ignore t :which-key "refactor")
   "rc" #'web-mode-element-clone
   "rd" #'web-mode-element-vanish
   "rk" #'web-mode-element-kill
   "rr" #'web-mode-element-rename
   "rw" #'web-mode-element-wrap
   "z"  #'web-mode-fold-or-unfold)
    :keymaps 'web-mode-map
    :packages '(lsp-mode web-mode)
    "l" '(:keymap lsp-command-map :which-key "lsp")))

Auto-completion for emmet-mode, html-mode, and web-mode.

(use-package company-web
  :defer t
  :straight (:build t)
  :after (emmet-mode web-mode))


Let’s customize a bit the built-in CSS mode.

(use-package css-mode
  :defer t
  :straight (:type built-in)
  :hook (css-mode . smartparens-mode)
  :hook (css-mode . lsp-deferred)
  :hook (scss-mode . prettier-js-mode)
  (put 'css-indent-offset 'safe-local-variable #'integerp)
   :keymaps 'css-mode-map
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp"))
    :keymaps 'css-mode-map
    :packages 'css-mode
    "=" '(:ignore :wk "format")
    "g" '(:ignore :wk "goto")))

SCSS is much nicer to use than pure CSS in my opinion, so let’s add a mode for that.

(use-package scss-mode
  :straight (:build t)
  :hook (scss-mode . smartparens-mode)
  :hook (scss-mode . lsp-deferred)
  :hook (scss-mode . prettier-js-mode)
  :defer t
  :mode "\\.scss\\'")

And let’s add some autocompletion for CSS.

(use-package counsel-css
  :straight (:build t)
  :defer t
  (cl-loop for (mode-map . mode-hook) in '((css-mode-map  . css-mode-hook)
                                           (scss-mode-map . scss-mode-hook))
           do (add-hook mode-hook #'counsel-css-imenu-setup)
            :keymaps mode-map
            "gh" #'counsel-css)))

For some reason, although it is built-in, less-css-mode does not activate when I open .less files by default. Let’s fix that.

(use-package less-css-mode
  :straight  (:type built-in)
  :defer t
  :mode "\\.less\\'"
  :hook (less-css-mode . smartparens-mode)
  :hook (less-css-mode . lsp-deferred)
  :hook (less-css-mode . prettier-js-mode)
   :keymaps 'less-css-mode-map
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp")))


javascript-mode is meh at best, while rjsx-mode (Real JSX) is much better: it supports both JavaScript and .jsx files for React and Next.JS.

(use-package rjsx-mode
  :defer t
  :straight (:build t)
  :after compile
  :mode "\\.[mc]?jsx?\\'"
  :mode "\\.es6\\'"
  :mode "\\.pac\\'"
  :interpreter "node"
  :hook (rjsx-mode . rainbow-delimiters-mode)
  :hook (rjsx-mode . lsp-deferred)
  (add-to-list 'compilation-error-regexp-alist 'node)
  (add-to-list 'compilation-error-regexp-alist-alist
               '(node "^[[:blank:]]*at \\(.*(\\|\\)\\(.+?\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\)"
                      2 3 4))
   :keymaps 'rjsx-mode-map
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp"))
  (setq js-chain-indent                  t
        js2-basic-offset                 2
        ;; ignore shebangs
        js2-skip-preprocessor-directives t
        ;; Flycheck handles this already
        js2-mode-show-parse-errors       nil
        js2-mode-show-strict-warnings    nil
        ;; conflicting with eslint, Flycheck already handles this
        js2-strict-missing-semi-warning  nil
        js2-highlight-level              3
        js2-idle-timer-delay             0.15))

js2-refactor is an amazing tool for refactoring JavaScript code. I mean, look at thisopen in new window! And the video is only from 2013, and it still receives some commits!

(use-package js2-refactor
  :defer t
  :straight (:build t)
  :after (js2-mode rjsx-mode)
  :hook (js2-mode . js2-refactor-mode)
  :hook (rjsx-mode . js2-refactor-mode))

Is there any Emacser who prefers the command line over Emacs itself? I don’t. Let’s interact with NPM through Emacs then.

(use-package npm-transient
  :defer t
  :straight (npm-transient :build t
                           :type git
                           :host github
                           :repo "Phundrak/npm-transient"))
  ;; :general
  ;; (phundrak/major-leader-key
  ;;   :packages '(npm-transient rjsx-mode web-mode)
  ;;   :keymaps '(rjsx-mode-map web-mode-map)
  ;;   "n" #'npm-transient))

And finally, here is a formatter for JavaScript.

(use-package prettier-js
  :defer t
  :straight (:build t)
  :after (rjsx-mode web-mode typescript-mode)
  :hook ((rjsx-mode typescript-mode) . prettier-js-mode)
  (setq prettier-js-args '("--single-quote" "--jsx-single-quote")))


Typescript is a safer alternative to JavaScript. Let’s install its major mode then.

(use-package typescript-mode
  :defer t
  :straight (:build t)
  :hook (typescript-mode     . rainbow-delimiters-mode)
  :hook (typescript-tsx-mode . rainbow-delimiters-mode)
  :hook (typescript-mode     . lsp-deferred)
  :hook (typescript-tsx-mode . lsp-deferred)
  :hook (typescript-mode     . prettier-js-mode)
  :hook (typescript-tsx-mode . prettier-js-mode)
  :commands typescript-tsx-mode
  :after flycheck
  (add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
   :keymaps '(typescript-mode-map typescript-tsx-mode-map)
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp"))
    :packages 'typescript-mode
    :keymaps '(typescript-mode-map typescript-tsx-mode-map)
    "n" '(:keymap npm-mode-command-keymap :which-key "npm"))
  (with-eval-after-load 'flycheck
    (flycheck-add-mode 'javascript-eslint 'web-mode)
    (flycheck-add-mode 'javascript-eslint 'typescript-mode)
    (flycheck-add-mode 'javascript-eslint 'typescript-tsx-mode)
    (flycheck-add-mode 'typescript-tslint 'typescript-tsx-mode))
  (when (fboundp 'web-mode)
    (define-derived-mode typescript-tsx-mode web-mode "TypeScript-TSX"))
  (autoload 'js2-line-break "js2-mode" nil t))

Tide enabled interactivity with Typescript.

(use-package tide
  :defer t
  :straight (:build t)
  :hook (tide-mode . tide-hl-identifier-mode)
  (setq tide-completion-detailed              t
        tide-always-show-documentation        t
        tide-server-may-response-length       524288
        tide-completion-setup-company-backend nil)

  (advice-add #'tide-setup :after #'eldoc-mode)

    :keymaps 'tide-mode-map
    "R"   #'tide-restart-server
    "f"   #'tide-format
    "rrs" #'tide-rename-symbol
    "roi" #'tide-organize-imports))


Zigopen in new window is to C kind of what Rust is to C++: a modern replacement without sacrificing performance. It is much safer than C while providing interop with it. Plus, its standard libraryopen in new window is pretty complete.

First, here is its major mode.

(use-package zig-mode
  :defer t
  :straight (:build t)
  :after flycheck
  :hook (zig-mode . lsp-deferred)
  ;; This is from DoomEmacs
  (flycheck-define-checker zig
    "A zig syntax checker using the zig-fmt interpreter."
    :command ("zig" "fmt" (eval (buffer-file-name)))
    ((error line-start (file-name) ":" line ":" column ": error: " (message) line-end))
    :modes zig-mode)
  (add-to-list 'flycheck-checkers 'zig)
   :keymaps 'zip-mode-map
   :packages 'lsp-mode
   "l"  '(:keymap lsp-command-map :which-key "lsp"))
    :packages 'zig-mode
    :keymaps 'zig-mode-map
    "c" #'zig-compile
    "f" #'zig-format-buffer
    "r" #'zig-run
    "t" #'zig-test-buffer))

For LSP to work, we need zls to be installed. In my case, as I am on Arch Linux, I can install it from the AUR, and my AUR helper is paru.

paru --skipreview --noconfirm -S zls-bin 2>&1